REFACTOR: Move javascript tests inside discourse app

REFACTOR: Move javascript tests inside discourse app

This is where they should be as far as ember is concerned. Note this is a huge commit and we should be really careful everything continues to work properly.

diff --git a/.eslintignore b/.eslintignore
index f0d962b..516be76 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -10,8 +10,8 @@ lib/highlight_js/
 plugins/**/lib/javascripts/locale
 public/
 vendor/
-test/javascripts/test_helper.js
-test/javascripts/fixtures
-test/javascripts/helpers/assertions.js
+app/assets/javascripts/discourse/tests/test_helper.js
+app/assets/javascripts/discourse/tests/fixtures
+app/assets/javascripts/discourse/tests/helpers/assertions.js
 node_modules/
 dist/
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 90508e1..3c2b32e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -147,7 +147,7 @@ jobs:
 
       - name: ESLint (core)
         if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'CORE'
-        run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern app/assets/javascripts test/javascripts
+        run: yarn eslint --ext .js,.js.es6 --no-error-on-unmatched-pattern app/assets/javascripts 
 
       - name: ESLint (core plugins)
         if: env.BUILD_TYPE == 'LINT' && env.TARGET == 'CORE'
@@ -164,7 +164,6 @@ jobs:
           yarn prettier --list-different \
             "app/assets/stylesheets/**/*.scss" \
             "app/assets/javascripts/**/*.{js,es6}" \
-            "test/javascripts/**/*.{js,es6}" \
             "plugins/**/assets/stylesheets/**/*.scss" \
             "plugins/**/assets/javascripts/**/*.{js,es6}"
 
diff --git a/.prettierignore b/.prettierignore
index b97584a..0d02324 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -18,8 +18,8 @@ lib/highlight_js/
 plugins/**/lib/javascripts/locale
 public/
 vendor/
-test/javascripts/test_helper.js
-test/javascripts/fixtures
-test/javascripts/helpers/assertions.js
+app/assets/javascripts/discourse/tests/test_helper.js
+app/assets/javascripts/discourse/tests/fixtures
+app/assets/javascripts/discourse/tests/helpers/assertions.js
 node_modules/
 dist/
diff --git a/app/assets/javascripts/admin/tests/admin/integration/components/group-list-setting-test.js b/app/assets/javascripts/admin/tests/admin/integration/components/group-list-setting-test.js
new file mode 100644
index 0000000..19ab163
--- /dev/null
+++ b/app/assets/javascripts/admin/tests/admin/integration/components/group-list-setting-test.js
@@ -0,0 +1,59 @@
+import EmberObject from "@ember/object";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
+
+moduleForComponent("group-list", { integration: true });
+
+componentTest("default", {
+  template: "{{site-setting setting=setting}}",
+
+  beforeEach() {
+    this.site.groups = [
+      {
+        id: 1,
+        name: "Donuts",
+      },
+      {
+        id: 2,
+        name: "Cheese cake",
+      },
+    ];
+
+    this.set(
+      "setting",
+      EmberObject.create({
+        allowsNone: undefined,
+        category: "foo",
+        default: "",
+        description: "Choose groups",
+        overridden: false,
+        placeholder: null,
+        preview: null,
+        secret: false,
+        setting: "foo_bar",
+        type: "group_list",
+        validValues: undefined,
+        value: "1",
+      })
+    );
+  },
+
+  async test(assert) {
+    const subject = selectKit(".list-setting");
+
+    assert.equal(
+      subject.header().value(),
+      "1",
+      "it selects the setting's value"
+    );
+
+    await subject.expand();
+    await subject.selectRowByValue("2");
+
+    assert.equal(
+      subject.header().value(),
+      "1,2",
+      "it allows to select a setting from the list of choices"
+    );
+  },
+});
diff --git a/app/assets/javascripts/admin/tests/admin/integration/components/themes-list-item-test.js b/app/assets/javascripts/admin/tests/admin/integration/components/themes-list-item-test.js
new file mode 100644
index 0000000..05c52ac
--- /dev/null
+++ b/app/assets/javascripts/admin/tests/admin/integration/components/themes-list-item-test.js
@@ -0,0 +1,95 @@
+import I18n from "I18n";
+import componentTest from "discourse/tests/helpers/component-test";
+import Theme from "admin/models/theme";
+
+moduleForComponent("themes-list-item", { integration: true });
+
+componentTest("default theme", {
+  template: "{{themes-list-item theme=theme}}",
+  beforeEach() {
+    this.set("theme", Theme.create({ name: "Test", default: true }));
+  },
+
+  test(assert) {
+    assert.expect(1);
+    assert.equal(find(".d-icon-check").length, 1, "shows default theme icon");
+  },
+});
+
+componentTest("pending updates", {
+  template: "{{themes-list-item theme=theme}}",
+  beforeEach() {
+    this.set(
+      "theme",
+      Theme.create({ name: "Test", remote_theme: { commits_behind: 6 } })
+    );
+  },
+
+  test(assert) {
+    assert.expect(1);
+    assert.equal(find(".d-icon-sync").length, 1, "shows pending update icon");
+  },
+});
+
+componentTest("broken theme", {
+  template: "{{themes-list-item theme=theme}}",
+  beforeEach() {
+    this.set(
+      "theme",
+      Theme.create({
+        name: "Test",
+        theme_fields: [{ name: "scss", type_id: 1, error: "something" }],
+      })
+    );
+  },
+
+  test(assert) {
+    assert.expect(1);
+    assert.equal(
+      find(".d-icon-exclamation-circle").length,
+      1,
+      "shows broken theme icon"
+    );
+  },
+});
+
+componentTest("with children", {
+  template: "{{themes-list-item theme=theme}}",
+
+  beforeEach() {
+    this.childrenList = [1, 2, 3, 4, 5].map((num) =>
+      Theme.create({ name: `Child ${num}`, component: true })
+    );
+
+    this.set(
+      "theme",
+      Theme.create({
+        name: "Test",
+        childThemes: this.childrenList,
+        default: true,
+      })
+    );
+  },
+
+  test(assert) {
+    assert.expect(2);
+    assert.deepEqual(
+      find(".components")
+        .text()
+        .trim()
+        .split(",")
+        .map((n) => n.trim())
+        .join(","),
+      this.childrenList
+        .splice(0, 4)
+        .map((theme) => theme.get("name"))
+        .join(","),
+      "lists the first 4 children"
+    );
+    assert.deepEqual(
+      find(".others-count").text().trim(),
+      I18n.t("admin.customize.theme.and_x_more", { count: 1 }),
+      "shows count of remaining children"
+    );
+  },
+});
diff --git a/app/assets/javascripts/admin/tests/admin/integration/components/themes-list-test.js b/app/assets/javascripts/admin/tests/admin/integration/components/themes-list-test.js
new file mode 100644
index 0000000..ed462ad
--- /dev/null
+++ b/app/assets/javascripts/admin/tests/admin/integration/components/themes-list-test.js
@@ -0,0 +1,144 @@
+import I18n from "I18n";
+import componentTest from "discourse/tests/helpers/component-test";
+import Theme, { THEMES, COMPONENTS } from "admin/models/theme";
+
+moduleForComponent("themes-list", { integration: true });
+
+componentTest("current tab is themes", {
+  template:
+    "{{themes-list themes=themes components=components currentTab=currentTab}}",
+  beforeEach() {
+    this.themes = [1, 2, 3, 4, 5].map((num) =>
+      Theme.create({ name: `Theme ${num}` })
+    );
+    this.components = [1, 2, 3, 4, 5].map((num) =>
+      Theme.create({
+        name: `Child ${num}`,
+        component: true,
+        parentThemes: [this.themes[num - 1]],
+        parent_themes: [1, 2, 3, 4, 5],
+      })
+    );
+    this.setProperties({
+      themes: this.themes,
+      components: this.components,
+      currentTab: THEMES,
+    });
+  },
+
+  test(assert) {
+    assert.equal(
+      find(".themes-tab").hasClass("active"),
+      true,
+      "themes tab is active"
+    );
+    assert.equal(
+      find(".components-tab").hasClass("active"),
+      false,
+      "components tab is not active"
+    );
+
+    assert.equal(
+      find(".inactive-indicator").index(),
+      -1,
+      "there is no inactive themes separator when all themes are inactive"
+    );
+    assert.equal(find(".themes-list-item").length, 5, "displays all themes");
+

[... diff too long, it was truncated ...]

GitHub sha: 23f24bfb

This commit appears in #10798 which was approved by CvX. It was merged by eviltrout.