DEV: De-arrowify tests (#11068)

DEV: De-arrowify tests (#11068)

Using arrow functions changes this context, which is undesired in tests, e.g. it makes it impossible to setup things like pretender (this.server) in beforeEach hooks.

Ember guides always use classic functions in examples (e.g. https://guides.emberjs.com/release/testing/test-types/), and that’s what it uses in its own test suite, as do various addons and ember apps.

It was also already used in Discourse where this was required. Moving forward, it will be needed in more places as we migrate toward ember-cli.

(I might later add a custom rule to eslint-discourse-ember to enforce this)

diff --git a/app/assets/javascripts/discourse/tests/acceptance/about-test.js b/app/assets/javascripts/discourse/tests/acceptance/about-test.js
index 9f0afe8..f16b599 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/about-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/about-test.js
@@ -4,7 +4,7 @@ import { test } from "qunit";
 import { acceptance } from "discourse/tests/helpers/qunit-helpers";
 
 acceptance("About", function () {
-  test("viewing", async (assert) => {
+  test("viewing", async function (assert) {
     await visit("/about");
 
     assert.ok($("body.about-page").length, "has body class");
diff --git a/app/assets/javascripts/discourse/tests/acceptance/account-created-test.js b/app/assets/javascripts/discourse/tests/acceptance/account-created-test.js
index a7111dd..2931a39 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/account-created-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/account-created-test.js
@@ -6,7 +6,7 @@ import { acceptance } from "discourse/tests/helpers/qunit-helpers";
 import PreloadStore from "discourse/lib/preload-store";
 
 acceptance("Account Created", function () {
-  test("account created - message", async (assert) => {
+  test("account created - message", async function (assert) {
     PreloadStore.store("accountCreated", {
       message: "Hello World",
     });
@@ -21,7 +21,7 @@ acceptance("Account Created", function () {
     assert.notOk(exists(".activation-controls"));
   });
 
-  test("account created - resend email", async (assert) => {
+  test("account created - resend email", async function (assert) {
     PreloadStore.store("accountCreated", {
       message: "Hello World",
       username: "eviltrout",
@@ -45,7 +45,7 @@ acceptance("Account Created", function () {
     assert.equal(email, "eviltrout@example.com");
   });
 
-  test("account created - update email - cancel", async (assert) => {
+  test("account created - update email - cancel", async function (assert) {
     PreloadStore.store("accountCreated", {
       message: "Hello World",
       username: "eviltrout",
@@ -65,7 +65,7 @@ acceptance("Account Created", function () {
     assert.equal(currentPath(), "account-created.index");
   });
 
-  test("account created - update email - submit", async (assert) => {
+  test("account created - update email - submit", async function (assert) {
     PreloadStore.store("accountCreated", {
       message: "Hello World",
       username: "eviltrout",
diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-emails-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-emails-test.js
index 871a229..30c3c1b 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/admin-emails-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-emails-test.js
@@ -28,7 +28,7 @@ acceptance("Admin - Emails", function (needs) {
     });
   });
 
-  test("shows selected and elided text", async (assert) => {
+  test("shows selected and elided text", async function (assert) {
     await visit("/admin/email/advanced-test");
     await fillIn("textarea.email-body", EMAIL.trim());
     await click(".email-advanced-test button");
diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-search-log-term-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-search-log-term-test.js
index 654e6d0..723534e 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/admin-search-log-term-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-search-log-term-test.js
@@ -6,7 +6,7 @@ import { acceptance } from "discourse/tests/helpers/qunit-helpers";
 acceptance("Admin - Search Log Term", function (needs) {
   needs.user();
 
-  test("show search log term details", async (assert) => {
+  test("show search log term details", async function (assert) {
     await visit("/admin/logs/search_logs/term?term=ruby");
 
     assert.ok($("div.search-logs-filter").length, "has the search type filter");
diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-search-logs-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-search-logs-test.js
index 5760595..c5bb95d 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/admin-search-logs-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-search-logs-test.js
@@ -6,7 +6,7 @@ import { acceptance } from "discourse/tests/helpers/qunit-helpers";
 acceptance("Admin - Search Logs", function (needs) {
   needs.user();
 
-  test("show search logs", async (assert) => {
+  test("show search logs", async function (assert) {
     await visit("/admin/logs/search_logs");
 
     assert.ok($("table.search-logs-list.grid").length, "has the div class");
diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js
index a0ea84d..411abac 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js
@@ -30,7 +30,7 @@ acceptance("Admin - Site Settings", function (needs) {
     updatedTitle = null;
   });
 
-  test("upload site setting", async (assert) => {
+  test("upload site setting", async function (assert) {
     await visit("/admin/site_settings");
 
     assert.ok(
@@ -41,7 +41,7 @@ acceptance("Admin - Site Settings", function (needs) {
     assert.ok(exists(".row.setting.upload .undo"), "undo button is present");
   });
 
-  test("changing value updates dirty state", async (assert) => {
+  test("changing value updates dirty state", async function (assert) {
     await visit("/admin/site_settings");
     await fillIn("#setting-filter", " title ");
     assert.equal(count(".row.setting"), 1, "filter returns 1 site setting");
@@ -88,7 +88,7 @@ acceptance("Admin - Site Settings", function (needs) {
     );
   });
 
-  test("always shows filtered site settings if a filter is set", async (assert) => {
+  test("always shows filtered site settings if a filter is set", async function (assert) {
     await visit("/admin/site_settings");
     await fillIn("#setting-filter", "title");
     assert.equal(count(".row.setting"), 1);
@@ -102,7 +102,7 @@ acceptance("Admin - Site Settings", function (needs) {
     assert.equal(count(".row.setting"), 1);
   });
 
-  test("filter settings by plugin name", async (assert) => {
+  test("filter settings by plugin name", async function (assert) {
     await visit("/admin/site_settings");
 
     await fillIn("#setting-filter", "plugin:discourse-logo");
@@ -113,7 +113,7 @@ acceptance("Admin - Site Settings", function (needs) {
     assert.equal(count(".row.setting"), 0);
   });
 
-  test("category name is preserved", async (assert) => {
+  test("category name is preserved", async function (assert) {
     await visit("admin/site_settings/category/basic?filter=menu");
     assert.equal(
       currentURL(),
@@ -121,7 +121,7 @@ acceptance("Admin - Site Settings", function (needs) {
     );
   });
 
-  test("shows all_results if current category has none", async (assert) => {
+  test("shows all_results if current category has none", async function (assert) {
     await visit("admin/site_settings");
 
     await click(".admin-nav .basic a");
diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-site-text-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-site-text-test.js
index cf9d843..4b92cd0 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/admin-site-text-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-site-text-test.js
@@ -7,7 +7,7 @@ import { acceptance } from "discourse/tests/helpers/qunit-helpers";
 acceptance("Admin - Site Texts", function (needs) {
   needs.user();
 
-  test("search for a key", async (assert) => {
+  test("search for a key", async function (assert) {

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

GitHub sha: a17d54d0

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