mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
DEV: allows fabricators to use faker (#26555)
The complexity of the situation is that we don't want to load faker into production by default but fabricators and styleguide are available on production. This is made possible through app/assets/javascripts/discourse/app/lib/load-faker.js which contains a function to ensure faker is loaded asynchronously (loadFaker) and another function to access the loaded faker (getLoadedFaker). Note 1: this commit also refactors fabricators to have access to context and use faker where possible Note 2: this commit moves automation to admin bundle --------- Co-authored-by: David Taylor <david@taylorhq.com>
This commit is contained in:
@ -0,0 +1,51 @@
|
||||
/*
|
||||
Fabricators are used to create fake data for testing purposes.
|
||||
The following fabricators are available in lib folder to allow
|
||||
styleguide to use them, and eventually to generate dummy data
|
||||
in a placeholder component. It should not be used for any other case.
|
||||
*/
|
||||
|
||||
import { setOwner } from "@ember/application";
|
||||
import ApplicationInstance from "@ember/application/instance";
|
||||
import { incrementSequence } from "discourse/lib/fabricators";
|
||||
import Automation from "../models/discourse-automation-automation";
|
||||
import Field from "../models/discourse-automation-field";
|
||||
|
||||
export default class AutomationFabricators {
|
||||
constructor(owner) {
|
||||
if (owner && !(owner instanceof ApplicationInstance)) {
|
||||
throw new Error(
|
||||
"First argument of AutomationFabricators constructor must be the owning ApplicationInstance"
|
||||
);
|
||||
}
|
||||
setOwner(this, owner);
|
||||
}
|
||||
|
||||
field(args = {}) {
|
||||
const template = args.template || {};
|
||||
template.accepts_placeholders = args.accepts_placeholders ?? true;
|
||||
template.accepted_contexts = args.accepted_contexts ?? [];
|
||||
template.name = args.name ?? "name";
|
||||
template.component = args.component ?? "boolean";
|
||||
template.value = args.value ?? false;
|
||||
template.is_required = args.is_required ?? false;
|
||||
template.extra = args.extra ?? {};
|
||||
return Field.create(template, {
|
||||
type: args.target ?? "script",
|
||||
name: "script_name",
|
||||
});
|
||||
}
|
||||
|
||||
automation(args = {}) {
|
||||
const automation = new Automation();
|
||||
automation.id = args.id || incrementSequence();
|
||||
automation.trigger = {
|
||||
id: incrementSequence().toString(),
|
||||
};
|
||||
automation.script = {
|
||||
id: incrementSequence().toString(),
|
||||
};
|
||||
|
||||
return automation;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ import { action } from "@ember/object";
|
||||
import { hash } from "rsvp";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import Field from "../admin/models/discourse-automation-field";
|
||||
import Field from "../models/discourse-automation-field";
|
||||
|
||||
export default class AutomationEdit extends DiscourseRoute {
|
||||
controllerName = "admin-plugins-discourse-automation-edit";
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
Fabricators are used to create fake data for testing purposes.
|
||||
The following fabricators are available in lib folder to allow
|
||||
styleguide to use them, and eventually to generate dummy data
|
||||
in a placeholder component. It should not be used for any other case.
|
||||
*/
|
||||
|
||||
import Automation from "../admin/models/discourse-automation-automation";
|
||||
import Field from "../admin/models/discourse-automation-field";
|
||||
|
||||
let sequence = 0;
|
||||
|
||||
function fieldFabricator(args = {}) {
|
||||
const template = args.template || {};
|
||||
template.accepts_placeholders = args.accepts_placeholders ?? true;
|
||||
template.accepted_contexts = args.accepted_contexts ?? [];
|
||||
template.name = args.name ?? "name";
|
||||
template.component = args.component ?? "boolean";
|
||||
template.value = args.value ?? false;
|
||||
template.is_required = args.is_required ?? false;
|
||||
template.extra = args.extra ?? {};
|
||||
return Field.create(template, {
|
||||
type: args.target ?? "script",
|
||||
name: "script_name",
|
||||
});
|
||||
}
|
||||
|
||||
function automationFabricator(args = {}) {
|
||||
const automation = new Automation();
|
||||
automation.id = args.id || sequence++;
|
||||
automation.trigger = {
|
||||
id: (sequence++).toString(),
|
||||
};
|
||||
automation.script = {
|
||||
id: (sequence++).toString(),
|
||||
};
|
||||
|
||||
return automation;
|
||||
}
|
||||
|
||||
export default {
|
||||
field: fieldFabricator,
|
||||
automation: automationFabricator,
|
||||
};
|
@ -1,18 +1,19 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { click, render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-boolean-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
});
|
||||
|
||||
test("set value", async function (assert) {
|
||||
this.field = fabricators.field();
|
||||
this.field = new AutomationFabricators(getOwner(this)).field();
|
||||
|
||||
await render(
|
||||
hbs`<AutomationField @automation={{this.automation}} @field={{this.field}} />`
|
||||
|
@ -1,19 +1,22 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-categories-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
});
|
||||
|
||||
test("sets values", async function (assert) {
|
||||
this.field = fabricators.field({ component: "categories" });
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "categories",
|
||||
});
|
||||
|
||||
await render(
|
||||
hbs`<AutomationField @automation={{this.automation}} @field={{this.field}} />`
|
||||
|
@ -1,19 +1,22 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-category-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
});
|
||||
|
||||
test("set value", async function (assert) {
|
||||
this.field = fabricators.field({ component: "category" });
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "category",
|
||||
});
|
||||
|
||||
await render(
|
||||
hbs`<AutomationField @automation={{this.automation}} @field={{this.field}} />`
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module(
|
||||
"Integration | Component | da-category-notification-level-field",
|
||||
@ -11,11 +12,11 @@ module(
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
});
|
||||
|
||||
test("set value", async function (assert) {
|
||||
this.field = fabricators.field({
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "category_notification_level",
|
||||
});
|
||||
|
||||
|
@ -1,19 +1,20 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-choices-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
});
|
||||
|
||||
test("set value", async function (assert) {
|
||||
this.field = fabricators.field({
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "choices",
|
||||
extra: { content: [{ name: "One", id: 1 }] },
|
||||
});
|
||||
|
@ -1,16 +1,17 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-custom-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
|
||||
pretender.get("/admin/customize/user_fields", () => {
|
||||
return response({
|
||||
@ -33,7 +34,9 @@ module("Integration | Component | da-custom-field", function (hooks) {
|
||||
});
|
||||
|
||||
test("set value", async function (assert) {
|
||||
this.field = fabricators.field({ component: "custom_field" });
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "custom_field",
|
||||
});
|
||||
|
||||
await render(
|
||||
hbs`<AutomationField @automation={{this.automation}} @field={{this.field}} />`
|
||||
|
@ -1,18 +1,21 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { fillIn, render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-date-time-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
});
|
||||
|
||||
test("set value", async function (assert) {
|
||||
this.field = fabricators.field({ component: "date_time" });
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "date_time",
|
||||
});
|
||||
|
||||
await render(
|
||||
hbs`<AutomationField @automation={{this.automation}} @field={{this.field}} />`
|
||||
|
@ -1,16 +1,17 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-group-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
|
||||
pretender.get("/groups/search.json", () => {
|
||||
return response([
|
||||
@ -26,7 +27,9 @@ module("Integration | Component | da-group-field", function (hooks) {
|
||||
});
|
||||
|
||||
test("set value", async function (assert) {
|
||||
this.field = fabricators.field({ component: "group" });
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "group",
|
||||
});
|
||||
|
||||
await render(
|
||||
hbs`<AutomationField @automation={{this.automation}} @field={{this.field}} />`
|
||||
|
@ -1,18 +1,21 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { fillIn, render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-message-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
});
|
||||
|
||||
test("set value", async function (assert) {
|
||||
this.field = fabricators.field({ component: "message" });
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "message",
|
||||
});
|
||||
|
||||
await render(
|
||||
hbs`<AutomationField @automation={{this.automation}} @field={{this.field}} />`
|
||||
|
@ -1,18 +1,19 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { click, fillIn, render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-pms-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
});
|
||||
|
||||
test("set value", async function (assert) {
|
||||
this.field = fabricators.field({
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "pms",
|
||||
});
|
||||
|
||||
|
@ -1,18 +1,21 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { fillIn, render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-post-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
});
|
||||
|
||||
test("set value", async function (assert) {
|
||||
this.field = fabricators.field({ component: "post" });
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "post",
|
||||
});
|
||||
|
||||
await render(
|
||||
hbs`<AutomationField @automation={{this.automation}} @field={{this.field}} />`
|
||||
|
@ -1,19 +1,20 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-tags-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
});
|
||||
|
||||
test("set value", async function (assert) {
|
||||
this.field = fabricators.field({
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "tags",
|
||||
});
|
||||
|
||||
|
@ -1,18 +1,21 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { fillIn, render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-text-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
});
|
||||
|
||||
test("set value", async function (assert) {
|
||||
this.field = fabricators.field({ component: "text" });
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "text",
|
||||
});
|
||||
|
||||
await render(
|
||||
hbs`<AutomationField @automation={{this.automation}} @field={{this.field}} />`
|
||||
|
@ -1,19 +1,20 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-text-list-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
});
|
||||
|
||||
test("set value", async function (assert) {
|
||||
this.field = fabricators.field({
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "text_list",
|
||||
});
|
||||
|
||||
|
@ -1,19 +1,20 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-trust-levels-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
});
|
||||
|
||||
test("set value", async function (assert) {
|
||||
this.field = fabricators.field({
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "trust-levels",
|
||||
});
|
||||
|
||||
|
@ -1,16 +1,17 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-user-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
|
||||
pretender.get("/u/search/users", () =>
|
||||
response({
|
||||
@ -26,7 +27,7 @@ module("Integration | Component | da-user-field", function (hooks) {
|
||||
});
|
||||
|
||||
test("set value", async function (assert) {
|
||||
this.field = fabricators.field({
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "user",
|
||||
});
|
||||
|
||||
|
@ -1,16 +1,17 @@
|
||||
import { getOwner } from "@ember/application";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import fabricators from "discourse/plugins/automation/discourse/lib/fabricators";
|
||||
import AutomationFabricators from "discourse/plugins/automation/admin/lib/fabricators";
|
||||
|
||||
module("Integration | Component | da-users-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.automation = fabricators.automation();
|
||||
this.automation = new AutomationFabricators(getOwner(this)).automation();
|
||||
|
||||
pretender.get("/u/search/users", () =>
|
||||
response({
|
||||
@ -31,7 +32,7 @@ module("Integration | Component | da-users-field", function (hooks) {
|
||||
});
|
||||
|
||||
test("sets values", async function (assert) {
|
||||
this.field = fabricators.field({
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "users",
|
||||
});
|
||||
|
||||
@ -49,7 +50,7 @@ module("Integration | Component | da-users-field", function (hooks) {
|
||||
});
|
||||
|
||||
test("allows emails", async function (assert) {
|
||||
this.field = fabricators.field({
|
||||
this.field = new AutomationFabricators(getOwner(this)).field({
|
||||
component: "users",
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user