DEV: Support Node 15 with Ember CLI (#12679)

DEV: Support Node 15 with Ember CLI (#12679)

  • DEV: Support Node 15 with Ember CLI

  • FIX: Broken tests that needed to be updated in newer Ember CLI

diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js
index a0c9d2d..01a09f4 100644
--- a/app/assets/javascripts/discourse/app/components/d-editor.js
+++ b/app/assets/javascripts/discourse/app/components/d-editor.js
@@ -639,7 +639,7 @@ export default Component.extend({
   },
 
   _selectText(from, length) {
-    schedule("afterRender", () => {
+    next(() => {
       const textarea = this.element.querySelector("textarea.d-editor-input");
       const $textarea = $(textarea);
       const oldScrollPos = $textarea.scrollTop();
@@ -648,7 +648,7 @@ export default Component.extend({
       }
       textarea.selectionStart = from;
       textarea.selectionEnd = from + length;
-      next(() => $textarea.trigger("change"));
+      $textarea.trigger("change");
       $textarea.scrollTop(oldScrollPos);
     });
   },
diff --git a/app/assets/javascripts/discourse/package.json b/app/assets/javascripts/discourse/package.json
index 0d1233e..b35b0ed 100644
--- a/app/assets/javascripts/discourse/package.json
+++ b/app/assets/javascripts/discourse/package.json
@@ -17,6 +17,7 @@
   },
   "devDependencies": {
     "@ember/optional-features": "^1.1.0",
+    "@ember/test-helpers": "^2.2.0",
     "@glimmer/component": "^1.0.0",
     "@popperjs/core": "^2.4.4",
     "admin": "^1.0.0",
@@ -25,20 +26,20 @@
     "discourse-common": "^1.0.0",
     "discourse-hbr": "^1.0.0",
     "discourse-widget-hbs": "^1.0.0",
-    "ember-auto-import": "^1.5.3",
+    "ember-auto-import": "^1.10.1",
     "ember-buffered-proxy": "^2.0.0-beta.0",
-    "ember-cli": "~3.15.2",
-    "ember-cli-app-version": "^3.2.0",
-    "ember-cli-babel": "^7.13.0",
+    "ember-cli": "~3.25.3",
+    "ember-cli-app-version": "^4.0.0",
+    "ember-cli-babel": "^7.23.1",
     "ember-cli-dependency-checker": "^3.2.0",
     "ember-cli-htmlbars": "^4.2.0",
     "ember-cli-inject-live-reload": "^2.0.1",
     "ember-cli-sri": "^2.1.1",
-    "ember-cli-uglify": "^3.0.0",
+    "ember-cli-terser": "^4.0.1",
     "ember-export-application-global": "^2.0.1",
     "ember-load-initializers": "^2.1.1",
     "ember-maybe-import-regenerator": "^0.1.6",
-    "ember-qunit": "^4.6.0",
+    "ember-qunit": "^5.1.2",
     "ember-source": "~3.15.0",
     "html-entities": "^2.1.0",
     "js-yaml": "^4.0.0",
@@ -48,7 +49,8 @@
     "mousetrap-global-bind": "^1.1.0",
     "pretender": "^3.4.3",
     "pretty-text": "^1.0.0",
-    "qunit-dom": "^0.9.2",
+    "qunit": "^2.14.0",
+    "qunit-dom": "^1.6.0",
     "sass": "^1.32.8",
     "select-kit": "^1.0.0",
     "sinon": "^9.2.0",
@@ -64,8 +66,5 @@
     "paths": [
       "lib/bootstrap-json"
     ]
-  },
-  "dependencies": {
-    "sass": "^1.32.8"
   }
 }
diff --git a/app/assets/javascripts/discourse/tests/acceptance/category-banner-test.js b/app/assets/javascripts/discourse/tests/acceptance/category-banner-test.js
index 9a2264a..ad04cef 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/category-banner-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/category-banner-test.js
@@ -27,7 +27,7 @@ acceptance("Category Banners", function (needs) {
         id: 5,
         name: "test read only without banner",
         slug: "test-read-only-without-banner",
-        permission: null,
+        permission: 1,
       },
       {
         id: 6,
diff --git a/app/assets/javascripts/discourse/tests/acceptance/category-edit-test.js b/app/assets/javascripts/discourse/tests/acceptance/category-edit-test.js
index 7393d1d..d498531 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/category-edit-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/category-edit-test.js
@@ -27,7 +27,7 @@ acceptance("Category Edit", function (needs) {
     await fillIn("input.category-name", "testing");
     assert.equal(queryAll(".badge-category").text(), "testing");
 
-    await fillIn(".edit-text-color input", "#ff0000");
+    await fillIn(".edit-text-color input", "ff0000");
 
     await click(".edit-category-topic-template");
     await fillIn(".d-editor-input", "this is the new topic template");
diff --git a/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js b/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js
index 06cd772..a4ee8a6 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js
@@ -126,7 +126,7 @@ acceptance("User Preferences", function (needs) {
 
     await click(".preferences-nav .nav-interface a");
     await click(".control-group.other input[type=checkbox]:nth-of-type(1)");
-    savePreferences();
+    await savePreferences();
 
     assert.ok(
       !exists(".preferences-nav .nav-apps a"),
diff --git a/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js b/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js
index 33fe369..f088f40 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js
@@ -1,4 +1,4 @@
-import { click, fillIn } from "@ember/test-helpers";
+import { click, fillIn, settled } from "@ember/test-helpers";
 import componentTest, {
   setupRenderingTest,
 } from "discourse/tests/helpers/component-test";
@@ -57,7 +57,9 @@ discourseModule("Integration | Component | d-editor", function (hooks) {
         "<p>evil trout</p>"
       );
 
-      await this.set("value", "zogstrip");
+      this.set("value", "zogstrip");
+      await settled();
+
       assert.equal(
         queryAll(".d-editor-preview").html().trim(),
         "<p>zogstrip</p>"
@@ -704,10 +706,11 @@ third line`
     assert.equal(this.value, "red yellow blue");
   });
 
-  function paste(element, text) {
+  async function paste(element, text) {
     let e = new Event("paste");
     e.clipboardData = { getData: () => text };
     element.dispatchEvent(e);
+    await settled();
   }
 
   componentTest("paste table", {
@@ -721,9 +724,18 @@ third line`
       let element = queryAll(".d-editor")[0];
       await paste(element, "\ta\tb\n1\t2\t3");
       assert.equal(this.value, "||a|b|\n|---|---|---|\n|1|2|3|\n");
+    },
+  });
 
+  componentTest("paste a different table", {
+    template: hbs`{{d-editor value=value composerEvents=true}}`,
+    beforeEach() {
       this.set("value", "");
+      this.siteSettings.enable_rich_text_paste = true;
+    },
 
+    async test(assert) {
+      let element = queryAll(".d-editor")[0];
       await paste(element, '\ta\tb\n1\t"2\n2.5"\t3');
       assert.equal(this.value, "||a|b|\n|---|---|---|\n|1|2<br>2.5|3|\n");
     },
diff --git a/app/assets/javascripts/discourse/tests/integration/components/group-membership-button-test.js b/app/assets/javascripts/discourse/tests/integration/components/group-membership-button-test.js
new file mode 100644
index 0000000..69f9247
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/integration/components/group-membership-button-test.js
@@ -0,0 +1,89 @@
+import {
+  discourseModule,
+  queryAll,
+} from "discourse/tests/helpers/qunit-helpers";
+import componentTest, {
+  setupRenderingTest,
+} from "discourse/tests/helpers/component-test";
+import hbs from "htmlbars-inline-precompile";
+
+discourseModule(
+  "Integration | Component | group-membership-button",
+  function (hooks) {
+    setupRenderingTest(hooks);
+
+    componentTest("canJoinGroup", {
+      template: hbs`{{group-membership-button model=model}}`,
+
+      beforeEach() {
+        this.set("model", { public_admission: false, is_group_user: true });
+      },
+
+      async test(assert) {
+        assert.ok(
+          queryAll(".group-index-join").length === 0,
+          "can't join group if public_admission is false"
+        );
+
+        this.set("model.public_admission", true);
+        assert.ok(
+          queryAll(".group-index-join").length === 0,

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

GitHub sha: 0afcf9e1

This commit appears in #12679 which was approved by markvanlan and CvX. It was merged by eviltrout.