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:
Joffrey JAFFEUX
2024-04-08 21:00:09 +02:00
committed by GitHub
parent 1801e3d64c
commit 1060e4573a
121 changed files with 732 additions and 515 deletions

View File

@ -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}} />`