diff --git a/.eslintrc b/.eslintrc index 8f0efccbc7..c311011c4d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -2,5 +2,11 @@ "extends": "eslint-config-discourse", "rules": { "discourse-ember/global-ember": 2 + }, + "globals": { + "moduleFor": "off", + "moduleForComponent": "off", + "testStart": "off", + "testDone": "off" } } 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 index 19ab1635bd..4df70d2c89 100644 --- 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 @@ -1,3 +1,4 @@ +import { moduleForComponent } from "ember-qunit"; import EmberObject from "@ember/object"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import componentTest from "discourse/tests/helpers/component-test"; 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 index 05c52ac5e3..70bace09ad 100644 --- 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 @@ -1,3 +1,4 @@ +import { moduleForComponent } from "ember-qunit"; import I18n from "I18n"; import componentTest from "discourse/tests/helpers/component-test"; import Theme from "admin/models/theme"; 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 index ed462ada16..7dc377972f 100644 --- 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 @@ -1,3 +1,4 @@ +import { moduleForComponent } from "ember-qunit"; import I18n from "I18n"; import componentTest from "discourse/tests/helpers/component-test"; import Theme, { THEMES, COMPONENTS } from "admin/models/theme"; diff --git a/app/assets/javascripts/admin/tests/admin/unit/controllers/admin-customize-themes-show-test.js b/app/assets/javascripts/admin/tests/admin/unit/controllers/admin-customize-themes-show-test.js index b0e06a9734..318f55fdc0 100644 --- a/app/assets/javascripts/admin/tests/admin/unit/controllers/admin-customize-themes-show-test.js +++ b/app/assets/javascripts/admin/tests/admin/unit/controllers/admin-customize-themes-show-test.js @@ -1,3 +1,5 @@ +import { moduleFor } from "ember-qunit"; +import { test } from "qunit"; import { mapRoutes } from "discourse/mapping-router"; import Theme from "admin/models/theme"; @@ -8,7 +10,7 @@ moduleFor("controller:admin-customize-themes-show", { needs: ["controller:adminUser"], }); -QUnit.test("can display source url for remote themes", function (assert) { +test("can display source url for remote themes", function (assert) { const repoUrl = "https://github.com/discourse/discourse-brand-header.git"; const remoteTheme = Theme.create({ id: 2, @@ -29,9 +31,7 @@ QUnit.test("can display source url for remote themes", function (assert) { ); }); -QUnit.test("can display source url for remote theme branches", function ( - assert -) { +test("can display source url for remote theme branches", function (assert) { const remoteTheme = Theme.create({ id: 2, default: true, diff --git a/app/assets/javascripts/admin/tests/admin/unit/controllers/admin-customize-themes-test.js b/app/assets/javascripts/admin/tests/admin/unit/controllers/admin-customize-themes-test.js index bd21cafb49..06eec98328 100644 --- a/app/assets/javascripts/admin/tests/admin/unit/controllers/admin-customize-themes-test.js +++ b/app/assets/javascripts/admin/tests/admin/unit/controllers/admin-customize-themes-test.js @@ -1,3 +1,5 @@ +import { moduleFor } from "ember-qunit"; +import { test } from "qunit"; import { mapRoutes } from "discourse/mapping-router"; import Theme from "admin/models/theme"; @@ -8,7 +10,7 @@ moduleFor("controller:admin-customize-themes", { needs: ["controller:adminUser"], }); -QUnit.test("can list themes correctly", function (assert) { +test("can list themes correctly", function (assert) { const defaultTheme = Theme.create({ id: 2, default: true, name: "default" }); const userTheme = Theme.create({ id: 3, diff --git a/app/assets/javascripts/admin/tests/admin/unit/controllers/admin-user-badges-test.js b/app/assets/javascripts/admin/tests/admin/unit/controllers/admin-user-badges-test.js index 175d1f29af..b377f7f31d 100644 --- a/app/assets/javascripts/admin/tests/admin/unit/controllers/admin-user-badges-test.js +++ b/app/assets/javascripts/admin/tests/admin/unit/controllers/admin-user-badges-test.js @@ -1,3 +1,5 @@ +import { moduleFor } from "ember-qunit"; +import { test } from "qunit"; import Badge from "discourse/models/badge"; import { mapRoutes } from "discourse/mapping-router"; @@ -8,7 +10,7 @@ moduleFor("controller:admin-user-badges", { needs: ["controller:adminUser"], }); -QUnit.test("grantableBadges", function (assert) { +test("grantableBadges", function (assert) { const badgeFirst = Badge.create({ id: 3, name: "A Badge", diff --git a/app/assets/javascripts/admin/tests/admin/unit/models/theme-test.js b/app/assets/javascripts/admin/tests/admin/unit/models/theme-test.js index d05cc24439..05f4dea5c1 100644 --- a/app/assets/javascripts/admin/tests/admin/unit/models/theme-test.js +++ b/app/assets/javascripts/admin/tests/admin/unit/models/theme-test.js @@ -1,8 +1,9 @@ +import { test, module } from "qunit"; import Theme from "admin/models/theme"; -QUnit.module("model:theme"); +module("model:theme"); -QUnit.test("can add an upload correctly", function (assert) { +test("can add an upload correctly", function (assert) { let theme = Theme.create(); assert.equal( diff --git a/app/assets/javascripts/discourse-loader.js b/app/assets/javascripts/discourse-loader.js index 3586997981..f6aa32d9af 100644 --- a/app/assets/javascripts/discourse-loader.js +++ b/app/assets/javascripts/discourse-loader.js @@ -153,6 +153,19 @@ var define, requirejs; pretender: { default: window.Pretender, }, + "ember-qunit": { + moduleFor: window.moduleFor, + moduleForComponent: window.moduleForComponent, + }, + qunit: + typeof window.QUnit !== "undefined" + ? { + default: window.QUnit, + test: window.QUnit.test, + skip: window.QUnit.skip, + module: window.QUnit.module, + } + : undefined, }; } diff --git a/app/assets/javascripts/discourse/tests/acceptance/about-test.js b/app/assets/javascripts/discourse/tests/acceptance/about-test.js index 3b50422d1e..f58b5e4682 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/about-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/about-test.js @@ -1,7 +1,8 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("About"); -QUnit.test("viewing", async (assert) => { +test("viewing", async (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 3a93a2fe20..a03faf24bc 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/account-created-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/account-created-test.js @@ -1,9 +1,10 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import PreloadStore from "discourse/lib/preload-store"; acceptance("Account Created"); -QUnit.test("account created - message", async (assert) => { +test("account created - message", async (assert) => { PreloadStore.store("accountCreated", { message: "Hello World", }); @@ -18,7 +19,7 @@ QUnit.test("account created - message", async (assert) => { assert.notOk(exists(".activation-controls")); }); -QUnit.test("account created - resend email", async (assert) => { +test("account created - resend email", async (assert) => { PreloadStore.store("accountCreated", { message: "Hello World", username: "eviltrout", @@ -42,7 +43,7 @@ QUnit.test("account created - resend email", async (assert) => { assert.equal(email, "eviltrout@example.com"); }); -QUnit.test("account created - update email - cancel", async (assert) => { +test("account created - update email - cancel", async (assert) => { PreloadStore.store("accountCreated", { message: "Hello World", username: "eviltrout", @@ -62,7 +63,7 @@ QUnit.test("account created - update email - cancel", async (assert) => { assert.equal(currentPath(), "account-created.index"); }); -QUnit.test("account created - update email - submit", async (assert) => { +test("account created - update email - submit", async (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 8a43428172..33d5f161f4 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/admin-emails-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/admin-emails-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import pretender from "discourse/tests/helpers/create-pretender"; @@ -16,7 +17,7 @@ Hello, this is a test! This part should be elided.`.trim(); -QUnit.test("shows selected and elided text", async (assert) => { +test("shows selected and elided text", async (assert) => { pretender.post("/admin/email/advanced-test", () => { return [ 200, 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 10747801ee..b0b9a000c0 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 @@ -1,7 +1,8 @@ +import { skip } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Admin - Search Log Term", { loggedIn: true }); -QUnit.skip("show search log term details", async (assert) => { +skip("show search log term details", async (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 230921fc6c..e7808c4319 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 @@ -1,7 +1,8 @@ +import { skip } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Admin - Search Logs", { loggedIn: true }); -QUnit.skip("show search logs", async (assert) => { +skip("show search logs", async (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 d2201846f7..2b8d7241aa 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 @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import siteSettingFixture from "discourse/tests/fixtures/site-settings"; @@ -29,7 +30,7 @@ acceptance("Admin - Site Settings", { }, }); -QUnit.test("upload site setting", async (assert) => { +test("upload site setting", async (assert) => { await visit("/admin/site_settings"); assert.ok( @@ -40,7 +41,7 @@ QUnit.test("upload site setting", async (assert) => { assert.ok(exists(".row.setting.upload .undo"), "undo button is present"); }); -QUnit.test("changing value updates dirty state", async (assert) => { +test("changing value updates dirty state", async (assert) => { await visit("/admin/site_settings"); await fillIn("#setting-filter", " title "); assert.equal(count(".row.setting"), 1, "filter returns 1 site setting"); @@ -87,24 +88,21 @@ QUnit.test("changing value updates dirty state", async (assert) => { ); }); -QUnit.test( - "always shows filtered site settings if a filter is set", - async (assert) => { - await visit("/admin/site_settings"); - await fillIn("#setting-filter", "title"); - assert.equal(count(".row.setting"), 1); +test("always shows filtered site settings if a filter is set", async (assert) => { + await visit("/admin/site_settings"); + await fillIn("#setting-filter", "title"); + assert.equal(count(".row.setting"), 1); - // navigate away to the "Dashboard" page - await click(".nav.nav-pills li:nth-child(1) a"); - assert.equal(count(".row.setting"), 0); + // navigate away to the "Dashboard" page + await click(".nav.nav-pills li:nth-child(1) a"); + assert.equal(count(".row.setting"), 0); - // navigate back to the "Settings" page - await click(".nav.nav-pills li:nth-child(2) a"); - assert.equal(count(".row.setting"), 1); - } -); + // navigate back to the "Settings" page + await click(".nav.nav-pills li:nth-child(2) a"); + assert.equal(count(".row.setting"), 1); +}); -QUnit.test("filter settings by plugin name", async (assert) => { +test("filter settings by plugin name", async (assert) => { await visit("/admin/site_settings"); await fillIn("#setting-filter", "plugin:discourse-logo"); @@ -115,12 +113,12 @@ QUnit.test("filter settings by plugin name", async (assert) => { assert.equal(count(".row.setting"), 0); }); -QUnit.test("category name is preserved", async (assert) => { +test("category name is preserved", async (assert) => { await visit("admin/site_settings/category/basic?filter=menu"); assert.equal(currentURL(), "admin/site_settings/category/basic?filter=menu"); }); -QUnit.test("shows all_results if current category has none", async (assert) => { +test("shows all_results if current category has none", async (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 6132441f0a..83bb145a2e 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 @@ -1,8 +1,9 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Admin - Site Texts", { loggedIn: true }); -QUnit.test("search for a key", async (assert) => { +test("search for a key", async (assert) => { await visit("/admin/customize/site_texts"); await fillIn(".site-text-search", "Test"); @@ -23,7 +24,7 @@ QUnit.test("search for a key", async (assert) => { assert.ok(exists(".site-text.overridden")); }); -QUnit.test("edit and revert a site text by key", async (assert) => { +test("edit and revert a site text by key", async (assert) => { await visit("/admin/customize/site_texts/site.test"); assert.equal(find(".title h3").text(), "site.test"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-suspend-user-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-suspend-user-test.js index 1eba7ffc3e..577d6fc19c 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/admin-suspend-user-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/admin-suspend-user-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -23,7 +24,7 @@ acceptance("Admin - Suspend User", { }, }); -QUnit.test("suspend a user - cancel", async (assert) => { +test("suspend a user - cancel", async (assert) => { await visit("/admin/users/1234/regular"); await click(".suspend-user"); @@ -34,7 +35,7 @@ QUnit.test("suspend a user - cancel", async (assert) => { assert.equal(find(".suspend-user-modal:visible").length, 0); }); -QUnit.test("suspend a user - cancel with input", async (assert) => { +test("suspend a user - cancel with input", async (assert) => { await visit("/admin/users/1234/regular"); await click(".suspend-user"); @@ -61,7 +62,7 @@ QUnit.test("suspend a user - cancel with input", async (assert) => { assert.equal(find(".bootbox.modal:visible").length, 0); }); -QUnit.test("suspend, then unsuspend a user", async (assert) => { +test("suspend, then unsuspend a user", async (assert) => { const suspendUntilCombobox = selectKit(".suspend-until .combobox"); await visit("/admin/flags/active"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-user-badges-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-user-badges-test.js index 561f0f0996..0a0b07ee81 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/admin-user-badges-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/admin-user-badges-test.js @@ -1,8 +1,9 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Admin - Users Badges", { loggedIn: true }); -QUnit.test("lists badges", async (assert) => { +test("lists badges", async (assert) => { await visit("/admin/users/1/eviltrout/badges"); assert.ok(exists(`span[data-badge-name="Badge 8"]`)); diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-user-emails-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-user-emails-test.js index 2f931eb67a..618553fb6b 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/admin-user-emails-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/admin-user-emails-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import I18n from "I18n"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -31,13 +32,13 @@ const assertMultipleSecondary = (assert, firstEmail, secondEmail) => { ); }; -QUnit.test("viewing self without secondary emails", async (assert) => { +test("viewing self without secondary emails", async (assert) => { await visit("/admin/users/1/eviltrout"); assertNoSecondary(assert); }); -QUnit.test("viewing self with multiple secondary emails", async (assert) => { +test("viewing self with multiple secondary emails", async (assert) => { await visit("/admin/users/3/markvanlan"); assert.equal( @@ -53,14 +54,14 @@ QUnit.test("viewing self with multiple secondary emails", async (assert) => { ); }); -QUnit.test("viewing another user with no secondary email", async (assert) => { +test("viewing another user with no secondary email", async (assert) => { await visit("/admin/users/1234/regular"); await click(`.display-row.secondary-emails button`); assertNoSecondary(assert); }); -QUnit.test("viewing another account with secondary emails", async (assert) => { +test("viewing another account with secondary emails", async (assert) => { await visit("/admin/users/1235/regular1"); await click(`.display-row.secondary-emails button`); diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-user-index-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-user-index-test.js index bef0b7c824..2f509c05fc 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/admin-user-index-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/admin-user-index-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import pretender from "discourse/tests/helpers/create-pretender"; @@ -34,7 +35,7 @@ acceptance("Admin - User Index", { }, }); -QUnit.test("can edit username", async (assert) => { +test("can edit username", async (assert) => { pretender.put("/users/sam/preferences/username", () => [ 200, { @@ -60,7 +61,7 @@ QUnit.test("can edit username", async (assert) => { assert.equal(find(".display-row.username .value").text().trim(), "new-sam"); }); -QUnit.test("will clear unsaved groups when switching user", async (assert) => { +test("will clear unsaved groups when switching user", async (assert) => { await visit("/admin/users/2/sam"); assert.equal( diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-users-list-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-users-list-test.js index 6053f4d37e..b6e35e40bb 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/admin-users-list-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/admin-users-list-test.js @@ -1,16 +1,17 @@ +import { test } from "qunit"; import I18n from "I18n"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Admin - Users List", { loggedIn: true }); -QUnit.test("lists users", async (assert) => { +test("lists users", async (assert) => { await visit("/admin/users/list/active"); assert.ok(exists(".users-list .user")); assert.ok(!exists(".user:eq(0) .email small"), "escapes email"); }); -QUnit.test("sorts users", async (assert) => { +test("sorts users", async (assert) => { await visit("/admin/users/list/active"); assert.ok(exists(".users-list .user")); @@ -34,7 +35,7 @@ QUnit.test("sorts users", async (assert) => { ); }); -QUnit.test("toggles email visibility", async (assert) => { +test("toggles email visibility", async (assert) => { await visit("/admin/users/list/active"); assert.ok(exists(".users-list .user")); @@ -56,7 +57,7 @@ QUnit.test("toggles email visibility", async (assert) => { ); }); -QUnit.test("switching tabs", async (assert) => { +test("switching tabs", async (assert) => { const activeUser = "eviltrout"; const suspectUser = "sam"; const activeTitle = I18n.t("admin.users.titles.active"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-watched-words-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-watched-words-test.js index 3fcc308114..087bef8070 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/admin-watched-words-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/admin-watched-words-test.js @@ -1,7 +1,8 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Admin - Watched Words", { loggedIn: true }); -QUnit.test("list words in groups", async (assert) => { +test("list words in groups", async (assert) => { await visit("/admin/logs/watched_words/action/block"); assert.ok(exists(".watched-words-list")); @@ -38,7 +39,7 @@ QUnit.test("list words in groups", async (assert) => { assert.ok(!exists(".watched-words-list .watched-word"), "Empty word list."); }); -QUnit.test("add words", async (assert) => { +test("add words", async (assert) => { await visit("/admin/logs/watched_words/action/block"); click(".show-words-checkbox"); @@ -55,7 +56,7 @@ QUnit.test("add words", async (assert) => { assert.equal(found.length, 1); }); -QUnit.test("remove words", async (assert) => { +test("remove words", async (assert) => { await visit("/admin/logs/watched_words/action/block"); await click(".show-words-checkbox"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/auth-complete-test.js b/app/assets/javascripts/discourse/tests/acceptance/auth-complete-test.js index a52c027f59..9b3cb3a4f0 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/auth-complete-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/auth-complete-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Auth Complete", { beforeEach() { @@ -16,7 +17,7 @@ acceptance("Auth Complete", { }, }); -QUnit.test("when login not required", async (assert) => { +test("when login not required", async (assert) => { await visit("/"); assert.equal(currentPath(), "discovery.latest", "it stays on the homepage"); @@ -27,7 +28,7 @@ QUnit.test("when login not required", async (assert) => { ); }); -QUnit.test("when login required", async function (assert) { +test("when login required", async function (assert) { this.siteSettings.login_required = true; await visit("/"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/badges-test.js b/app/assets/javascripts/discourse/tests/acceptance/badges-test.js index 7e922571bf..26ba43123b 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/badges-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/badges-test.js @@ -1,9 +1,10 @@ +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Badges", { loggedIn: true }); -QUnit.test("Visit Badge Pages", async (assert) => { +test("Visit Badge Pages", async (assert) => { await visit("/badges"); assert.ok($("body.badges-page").length, "has body class"); @@ -16,7 +17,7 @@ QUnit.test("Visit Badge Pages", async (assert) => { assert.ok(!exists(".badge-card:eq(0) script")); }); -QUnit.test("shows correct badge titles to choose from", async (assert) => { +test("shows correct badge titles to choose from", async (assert) => { const availableBadgeTitles = selectKit(".select-kit"); await visit("/badges/50/custombadge"); await availableBadgeTitles.expand(); diff --git a/app/assets/javascripts/discourse/tests/acceptance/bookmarks-test.js b/app/assets/javascripts/discourse/tests/acceptance/bookmarks-test.js index 0b13db4b6a..44da9f79c0 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/bookmarks-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/bookmarks-test.js @@ -1,3 +1,5 @@ +import { skip } from "qunit"; +import { test } from "qunit"; import I18n from "I18n"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { @@ -236,25 +238,22 @@ acceptance("Bookmarking - Mobile", { }, }); -QUnit.skip( - "Editing a bookmark that has a Later Today reminder, and it is before 6pm today", - async (assert) => { - await acceptanceUseFakeClock("2020-05-04T13:00:00", async () => { - mockSuccessfulBookmarkPost(assert); - await visit("/t/internationalization-localization/280"); - await openBookmarkModal(); - await fillIn("input#bookmark-name", "Test name"); - await click("#tap_tile_later_today"); - await openEditBookmarkModal(); - assert.not( - exists("#bookmark-custom-date > input"), - "it does not show the custom date input" - ); - assert.ok( - exists("#tap_tile_later_today.active"), - "it preselects Later Today" - ); - assert.verifySteps(["later_today"]); - }); - } -); +skip("Editing a bookmark that has a Later Today reminder, and it is before 6pm today", async (assert) => { + await acceptanceUseFakeClock("2020-05-04T13:00:00", async () => { + mockSuccessfulBookmarkPost(assert); + await visit("/t/internationalization-localization/280"); + await openBookmarkModal(); + await fillIn("input#bookmark-name", "Test name"); + await click("#tap_tile_later_today"); + await openEditBookmarkModal(); + assert.not( + exists("#bookmark-custom-date > input"), + "it does not show the custom date input" + ); + assert.ok( + exists("#tap_tile_later_today.active"), + "it preselects Later Today" + ); + assert.verifySteps(["later_today"]); + }); +}); 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 57a4d5f029..d2569ce99b 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/category-banner-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/category-banner-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import DiscoveryFixtures from "discourse/tests/fixtures/discovery-fixtures"; @@ -35,7 +36,7 @@ acceptance("Category Banners", { }, }); -QUnit.test("Does not display category banners when not set", async (assert) => { +test("Does not display category banners when not set", async (assert) => { await visit("/c/test-read-only-without-banner"); await click("#create-topic"); @@ -46,7 +47,7 @@ QUnit.test("Does not display category banners when not set", async (assert) => { ); }); -QUnit.test("Displays category banners when set", async (assert) => { +test("Displays category banners when set", async (assert) => { await visit("/c/test-read-only-with-banner"); await click("#create-topic"); @@ -84,7 +85,7 @@ acceptance("Anonymous Category Banners", { }, }); -QUnit.test("Does not display category banners when set", async (assert) => { +test("Does not display category banners when set", async (assert) => { await visit("/c/test-read-only-with-banner"); assert.ok( !visible(".category-read-only-banner"), diff --git a/app/assets/javascripts/discourse/tests/acceptance/category-chooser-test.js b/app/assets/javascripts/discourse/tests/acceptance/category-chooser-test.js index 183d1c9082..f26060feaf 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/category-chooser-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/category-chooser-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -8,7 +9,7 @@ acceptance("CategoryChooser", { }, }); -QUnit.test("does not display uncategorized if not allowed", async (assert) => { +test("does not display uncategorized if not allowed", async (assert) => { const categoryChooser = selectKit(".category-chooser"); await visit("/"); @@ -19,13 +20,13 @@ QUnit.test("does not display uncategorized if not allowed", async (assert) => { assert.ok(categoryChooser.rowByIndex(0).name() !== "uncategorized"); }); -QUnit.test("prefill category when category_id is set", async (assert) => { +test("prefill category when category_id is set", async (assert) => { await visit("/new-topic?category_id=1"); assert.equal(selectKit(".category-chooser").header().value(), 1); }); -QUnit.test("filter is case insensitive", async (assert) => { +test("filter is case insensitive", async (assert) => { const categoryChooser = selectKit(".category-chooser"); await visit("/"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/category-edit-security-test.js b/app/assets/javascripts/discourse/tests/acceptance/category-edit-security-test.js index ece3a6417f..e5abbbda70 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/category-edit-security-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/category-edit-security-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -5,7 +6,7 @@ acceptance("Category Edit - security", { loggedIn: true, }); -QUnit.test("default", async (assert) => { +test("default", async (assert) => { await visit("/c/bug"); await click(".edit-category"); @@ -20,7 +21,7 @@ QUnit.test("default", async (assert) => { assert.equal(permission, "Create / Reply / See"); }); -QUnit.test("removing a permission", async (assert) => { +test("removing a permission", async (assert) => { const availableGroups = selectKit(".available-groups"); await visit("/c/bug"); @@ -46,7 +47,7 @@ QUnit.test("removing a permission", async (assert) => { ); }); -QUnit.test("adding a permission", async (assert) => { +test("adding a permission", async (assert) => { const availableGroups = selectKit(".available-groups"); const permissionSelector = selectKit(".permission-selector"); @@ -72,7 +73,7 @@ QUnit.test("adding a permission", async (assert) => { assert.equal(permission, "Reply / See"); }); -QUnit.test("adding a previously removed permission", async (assert) => { +test("adding a previously removed permission", async (assert) => { const availableGroups = selectKit(".available-groups"); await visit("/c/bug"); 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 854927d809..2025688a58 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/category-edit-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/category-edit-test.js @@ -1,3 +1,5 @@ +import { skip } from "qunit"; +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import DiscourseURL from "discourse/lib/url"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -7,7 +9,7 @@ acceptance("Category Edit", { settings: { email_in: true }, }); -QUnit.test("Can open the category modal", async (assert) => { +test("Can open the category modal", async (assert) => { await visit("/c/bug"); await click(".edit-category"); @@ -17,7 +19,7 @@ QUnit.test("Can open the category modal", async (assert) => { assert.ok(!visible(".d-modal"), "it closes the modal"); }); -QUnit.test("Editing the category", async (assert) => { +test("Editing the category", async (assert) => { await visit("/c/bug"); await click(".edit-category"); @@ -46,7 +48,7 @@ QUnit.test("Editing the category", async (assert) => { ); }); -QUnit.skip("Edit the description without loosing progress", async (assert) => { +skip("Edit the description without loosing progress", async (assert) => { let win = { focus: function () {} }; let windowOpen = sandbox.stub(window, "open").returns(win); sandbox.stub(win, "focus"); @@ -61,7 +63,7 @@ QUnit.skip("Edit the description without loosing progress", async (assert) => { ); }); -QUnit.test("Error Saving", async (assert) => { +test("Error Saving", async (assert) => { await visit("/c/bug"); await click(".edit-category"); @@ -72,7 +74,7 @@ QUnit.test("Error Saving", async (assert) => { assert.equal(find("#modal-alert").html(), "duplicate email"); }); -QUnit.test("Subcategory list settings", async (assert) => { +test("Subcategory list settings", async (assert) => { const categoryChooser = selectKit( ".edit-category-tab-general .category-chooser" ); diff --git a/app/assets/javascripts/discourse/tests/acceptance/click-track-test.js b/app/assets/javascripts/discourse/tests/acceptance/click-track-test.js index 579345e988..0ae883a975 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/click-track-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/click-track-test.js @@ -1,9 +1,10 @@ +import { test } from "qunit"; import pretender from "discourse/tests/helpers/create-pretender"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Click Track", {}); -QUnit.test("Do not track mentions", async (assert) => { +test("Do not track mentions", async (assert) => { pretender.post("/clicks/track", () => assert.ok(false)); await visit("/t/internationalization-localization/280"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js index 6c8d1512d5..d5aa28fc4c 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import I18n from "I18n"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { @@ -19,25 +20,22 @@ acceptance("Composer Actions", { }, }); -QUnit.test( - "creating new topic and then reply_as_private_message keeps attributes", - async (assert) => { - await visit("/"); - await click("button#create-topic"); +test("creating new topic and then reply_as_private_message keeps attributes", async (assert) => { + await visit("/"); + await click("button#create-topic"); - await fillIn("#reply-title", "this is the title"); - await fillIn(".d-editor-input", "this is the reply"); + await fillIn("#reply-title", "this is the title"); + await fillIn(".d-editor-input", "this is the reply"); - const composerActions = selectKit(".composer-actions"); - await composerActions.expand(); - await composerActions.selectRowByValue("reply_as_private_message"); + const composerActions = selectKit(".composer-actions"); + await composerActions.expand(); + await composerActions.selectRowByValue("reply_as_private_message"); - assert.ok(find("#reply-title").val(), "this is the title"); - assert.ok(find(".d-editor-input").val(), "this is the reply"); - } -); + assert.ok(find("#reply-title").val(), "this is the title"); + assert.ok(find(".d-editor-input").val(), "this is the reply"); +}); -QUnit.test("replying to post", async (assert) => { +test("replying to post", async (assert) => { const composerActions = selectKit(".composer-actions"); await visit("/t/internationalization-localization/280"); @@ -55,7 +53,7 @@ QUnit.test("replying to post", async (assert) => { assert.equal(composerActions.rowByIndex(5).value(), undefined); }); -QUnit.test("replying to post - reply_as_private_message", async (assert) => { +test("replying to post - reply_as_private_message", async (assert) => { const composerActions = selectKit(".composer-actions"); await visit("/t/internationalization-localization/280"); @@ -70,7 +68,7 @@ QUnit.test("replying to post - reply_as_private_message", async (assert) => { ); }); -QUnit.test("replying to post - reply_to_topic", async (assert) => { +test("replying to post - reply_to_topic", async (assert) => { const composerActions = selectKit(".composer-actions"); await visit("/t/internationalization-localization/280"); @@ -97,7 +95,7 @@ QUnit.test("replying to post - reply_to_topic", async (assert) => { ); }); -QUnit.test("replying to post - toggle_whisper", async (assert) => { +test("replying to post - toggle_whisper", async (assert) => { const composerActions = selectKit(".composer-actions"); await visit("/t/internationalization-localization/280"); @@ -115,7 +113,7 @@ QUnit.test("replying to post - toggle_whisper", async (assert) => { ); }); -QUnit.test("replying to post - reply_as_new_topic", async (assert) => { +test("replying to post - reply_as_new_topic", async (assert) => { sandbox .stub(Draft, "get") .returns(Promise.resolve({ draft: "", draft_sequence: 0 })); @@ -146,7 +144,7 @@ QUnit.test("replying to post - reply_as_new_topic", async (assert) => { sandbox.restore(); }); -QUnit.test("reply_as_new_topic without a new_topic draft", async (assert) => { +test("reply_as_new_topic without a new_topic draft", async (assert) => { await visit("/t/internationalization-localization/280"); await click(".create.reply"); const composerActions = selectKit(".composer-actions"); @@ -155,7 +153,7 @@ QUnit.test("reply_as_new_topic without a new_topic draft", async (assert) => { assert.equal(exists(find(".bootbox")), false); }); -QUnit.test("reply_as_new_group_message", async (assert) => { +test("reply_as_new_group_message", async (assert) => { // eslint-disable-next-line server.get("/t/130.json", () => { return [ @@ -408,7 +406,7 @@ QUnit.test("reply_as_new_group_message", async (assert) => { assert.deepEqual(items, ["foo", "foo_group"]); }); -QUnit.test("hide component if no content", async (assert) => { +test("hide component if no content", async (assert) => { await visit("/"); await click("button#create-topic"); @@ -424,7 +422,7 @@ QUnit.test("hide component if no content", async (assert) => { assert.equal(composerActions.rows().length, 2); }); -QUnit.test("interactions", async (assert) => { +test("interactions", async (assert) => { const composerActions = selectKit(".composer-actions"); const quote = "Life is like riding a bicycle."; @@ -501,7 +499,7 @@ QUnit.test("interactions", async (assert) => { assert.equal(composerActions.rows().length, 3); }); -QUnit.test("replying to post - toggle_topic_bump", async (assert) => { +test("replying to post - toggle_topic_bump", async (assert) => { const composerActions = selectKit(".composer-actions"); await visit("/t/internationalization-localization/280"); @@ -529,7 +527,7 @@ QUnit.test("replying to post - toggle_topic_bump", async (assert) => { ); }); -QUnit.test("replying to post as staff", async (assert) => { +test("replying to post as staff", async (assert) => { const composerActions = selectKit(".composer-actions"); updateCurrentUser({ admin: true }); @@ -541,7 +539,7 @@ QUnit.test("replying to post as staff", async (assert) => { assert.equal(composerActions.rowByIndex(4).value(), "toggle_topic_bump"); }); -QUnit.test("replying to post as TL3 user", async (assert) => { +test("replying to post as TL3 user", async (assert) => { const composerActions = selectKit(".composer-actions"); updateCurrentUser({ moderator: false, admin: false, trust_level: 3 }); @@ -559,7 +557,7 @@ QUnit.test("replying to post as TL3 user", async (assert) => { }); }); -QUnit.test("replying to post as TL4 user", async (assert) => { +test("replying to post as TL4 user", async (assert) => { const composerActions = selectKit(".composer-actions"); updateCurrentUser({ moderator: false, admin: false, trust_level: 4 }); @@ -571,25 +569,22 @@ QUnit.test("replying to post as TL4 user", async (assert) => { assert.equal(composerActions.rowByIndex(3).value(), "toggle_topic_bump"); }); -QUnit.test( - "replying to first post - reply_as_private_message", - async (assert) => { - const composerActions = selectKit(".composer-actions"); +test("replying to first post - reply_as_private_message", async (assert) => { + const composerActions = selectKit(".composer-actions"); - await visit("/t/internationalization-localization/280"); - await click("article#post_1 button.reply"); + await visit("/t/internationalization-localization/280"); + await click("article#post_1 button.reply"); - await composerActions.expand(); - await composerActions.selectRowByValue("reply_as_private_message"); + await composerActions.expand(); + await composerActions.selectRowByValue("reply_as_private_message"); - assert.equal(find(".users-input .item:eq(0)").text(), "uwe_keim"); - assert.ok( - find(".d-editor-input").val().indexOf("Continuing the discussion") >= 0 - ); - } -); + assert.equal(find(".users-input .item:eq(0)").text(), "uwe_keim"); + assert.ok( + find(".d-editor-input").val().indexOf("Continuing the discussion") >= 0 + ); +}); -QUnit.test("editing post", async (assert) => { +test("editing post", async (assert) => { const composerActions = selectKit(".composer-actions"); await visit("/t/internationalization-localization/280"); @@ -627,7 +622,7 @@ const stubDraftResponse = () => { ); }; -QUnit.test("shared draft", async (assert) => { +test("shared draft", async (assert) => { stubDraftResponse(); try { toggleCheckDraftPopup(true); @@ -669,7 +664,7 @@ QUnit.test("shared draft", async (assert) => { sandbox.restore(); }); -QUnit.test("reply_as_new_topic with new_topic draft", async (assert) => { +test("reply_as_new_topic with new_topic draft", async (assert) => { await visit("/t/internationalization-localization/280"); await click(".create.reply"); const composerActions = selectKit(".composer-actions"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-attachment-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-attachment-test.js index a558654b51..01e6b2b3da 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-attachment-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-attachment-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; function setupPretender(server, helper) { @@ -33,7 +34,7 @@ acceptance("Composer Attachment", { }, }); -QUnit.test("attachments are cooked properly", async (assert) => { +test("attachments are cooked properly", async (assert) => { await writeInComposer(assert); assert.equal( find(".d-editor-preview:visible").html().trim(), @@ -51,13 +52,10 @@ acceptance("Composer Attachment - Secure Media Enabled", { }, }); -QUnit.test( - "attachments are cooked properly when secure media is enabled", - async (assert) => { - await writeInComposer(assert); - assert.equal( - find(".d-editor-preview:visible").html().trim(), - '
' - ); - } -); +test("attachments are cooked properly when secure media is enabled", async (assert) => { + await writeInComposer(assert); + assert.equal( + find(".d-editor-preview:visible").html().trim(), + '' + ); +}); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-edit-conflict-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-edit-conflict-test.js index 7f91a20c7b..1984037be0 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-edit-conflict-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-edit-conflict-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import I18n from "I18n"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import pretender from "discourse/tests/helpers/create-pretender"; @@ -6,7 +7,7 @@ acceptance("Composer - Edit conflict", { loggedIn: true, }); -QUnit.test("Edit a post that causes an edit conflict", async (assert) => { +test("Edit a post that causes an edit conflict", async (assert) => { await visit("/t/internationalization-localization/280"); await click(".topic-post:eq(0) button.show-more-actions"); await click(".topic-post:eq(0) button.edit"); @@ -47,21 +48,18 @@ function handleDraftPretender(assert) { }); } -QUnit.test( - "Should not send originalText when posting a new reply", - async (assert) => { - handleDraftPretender(assert); +test("Should not send originalText when posting a new reply", async (assert) => { + handleDraftPretender(assert); - await visit("/t/internationalization-localization/280"); - await click(".topic-post:eq(0) button.reply"); - await fillIn( - ".d-editor-input", - "hello world hello world hello world hello world hello world" - ); - } -); + await visit("/t/internationalization-localization/280"); + await click(".topic-post:eq(0) button.reply"); + await fillIn( + ".d-editor-input", + "hello world hello world hello world hello world hello world" + ); +}); -QUnit.test("Should send originalText when editing a reply", async (assert) => { +test("Should send originalText when editing a reply", async (assert) => { handleDraftPretender(assert); await visit("/t/internationalization-localization/280"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.js index 817e933684..5c7c06af96 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.js @@ -1,10 +1,11 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Composer - Hyperlink", { loggedIn: true, }); -QUnit.test("add a hyperlink to a reply", async (assert) => { +test("add a hyperlink to a reply", async (assert) => { await visit("/t/internationalization-localization/280"); await click(".topic-post:first-child button.reply"); await fillIn(".d-editor-input", "This is a link to "); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-onebox-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-onebox-test.js index a214e56f25..98a3e960ed 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-onebox-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-onebox-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Composer - Onebox", { @@ -8,15 +9,13 @@ acceptance("Composer - Onebox", { }, }); -QUnit.test( - "Preview update should respect max_oneboxes_per_post site setting", - async (assert) => { - await visit("/t/internationalization-localization/280"); - await click("#topic-footer-buttons .btn.create"); +test("Preview update should respect max_oneboxes_per_post site setting", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .btn.create"); - await fillIn( - ".d-editor-input", - ` + await fillIn( + ".d-editor-input", + ` http://www.example.com/has-title.html This is another test http://www.example.com/has-title.html @@ -27,11 +26,11 @@ This is another test http://www.example.com/has-title.html http://www.example.com/has-title.html ` - ); + ); - assert.equal( - find(".d-editor-preview:visible").html().trim(), - ` + assert.equal( + find(".d-editor-preview:visible").html().trim(), + `
This is another test This is a great title
http://www.example.com/no-title.html
@@ -39,6 +38,5 @@ This is another test This is a great title `.trim() - ); - } -); + ); +}); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-tags-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-tags-test.js index df50610ad3..056cedb560 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-tags-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-tags-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import Category from "discourse/models/category"; import { acceptance, @@ -17,7 +18,7 @@ acceptance("Composer - Tags", { }, }); -QUnit.test("staff bypass tag validation rule", async (assert) => { +test("staff bypass tag validation rule", async (assert) => { await visit("/"); await click("#create-topic"); @@ -34,7 +35,7 @@ QUnit.test("staff bypass tag validation rule", async (assert) => { assert.notEqual(currentURL(), "/"); }); -QUnit.test("users do not bypass tag validation rule", async (assert) => { +test("users do not bypass tag validation rule", async (assert) => { await visit("/"); await click("#create-topic"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js index 1d1061225e..db064826e4 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js @@ -1,3 +1,5 @@ +import { skip } from "qunit"; +import { test } from "qunit"; import I18n from "I18n"; import { run } from "@ember/runloop"; import selectKit from "discourse/tests/helpers/select-kit-helper"; @@ -18,7 +20,7 @@ acceptance("Composer", { }, }); -QUnit.skip("Tests the Composer controls", async (assert) => { +skip("Tests the Composer controls", async (assert) => { await visit("/"); assert.ok(exists("#create-topic"), "the create button is visible"); @@ -96,7 +98,7 @@ QUnit.skip("Tests the Composer controls", async (assert) => { assert.ok(!exists(".bootbox.modal"), "the confirmation can be cancelled"); }); -QUnit.test("Composer upload placeholder", async (assert) => { +test("Composer upload placeholder", async (assert) => { await visit("/"); await click("#create-topic"); @@ -189,7 +191,7 @@ QUnit.test("Composer upload placeholder", async (assert) => { ); }); -QUnit.test("Create a topic with server side errors", async (assert) => { +test("Create a topic with server side errors", async (assert) => { await visit("/"); await click("#create-topic"); await fillIn("#reply-title", "this title triggers an error"); @@ -201,7 +203,7 @@ QUnit.test("Create a topic with server side errors", async (assert) => { assert.ok(exists(".d-editor-input"), "the composer input is visible"); }); -QUnit.test("Create a Topic", async (assert) => { +test("Create a Topic", async (assert) => { await visit("/"); await click("#create-topic"); await fillIn("#reply-title", "Internationalization Localization"); @@ -214,7 +216,7 @@ QUnit.test("Create a Topic", async (assert) => { ); }); -QUnit.test("Create an enqueued Topic", async (assert) => { +test("Create an enqueued Topic", async (assert) => { await visit("/"); await click("#create-topic"); await fillIn("#reply-title", "Internationalization Localization"); @@ -227,7 +229,7 @@ QUnit.test("Create an enqueued Topic", async (assert) => { assert.ok(invisible(".d-modal"), "the modal can be dismissed"); }); -QUnit.test("Can display a message and route to a URL", async (assert) => { +test("Can display a message and route to a URL", async (assert) => { await visit("/"); await click("#create-topic"); await fillIn("#reply-title", "This title doesn't matter"); @@ -247,7 +249,7 @@ QUnit.test("Can display a message and route to a URL", async (assert) => { ); }); -QUnit.test("Create a Reply", async (assert) => { +test("Create a Reply", async (assert) => { await visit("/t/internationalization-localization/280"); assert.ok( @@ -267,7 +269,7 @@ QUnit.test("Create a Reply", async (assert) => { ); }); -QUnit.test("Can edit a post after starting a reply", async (assert) => { +test("Can edit a post after starting a reply", async (assert) => { await visit("/t/internationalization-localization/280"); await click("#topic-footer-buttons .create"); @@ -285,7 +287,7 @@ QUnit.test("Can edit a post after starting a reply", async (assert) => { ); }); -QUnit.test("Posting on a different topic", async (assert) => { +test("Posting on a different topic", async (assert) => { await visit("/t/internationalization-localization/280"); await click("#topic-footer-buttons .btn.create"); await fillIn(".d-editor-input", "this is the content for a different topic"); @@ -302,7 +304,7 @@ QUnit.test("Posting on a different topic", async (assert) => { ); }); -QUnit.test("Create an enqueued Reply", async (assert) => { +test("Create an enqueued Reply", async (assert) => { await visit("/t/internationalization-localization/280"); assert.notOk(find(".pending-posts .reviewable-item").length); @@ -326,7 +328,7 @@ QUnit.test("Create an enqueued Reply", async (assert) => { assert.ok(find(".pending-posts .reviewable-item").length); }); -QUnit.test("Edit the first post", async (assert) => { +test("Edit the first post", async (assert) => { await visit("/t/internationalization-localization/280"); assert.ok( @@ -364,7 +366,7 @@ QUnit.test("Edit the first post", async (assert) => { ); }); -QUnit.test("Composer can switch between edits", async (assert) => { +test("Composer can switch between edits", async (assert) => { await visit("/t/this-is-a-test-topic/9"); await click(".topic-post:eq(0) button.edit"); @@ -381,26 +383,23 @@ QUnit.test("Composer can switch between edits", async (assert) => { ); }); -QUnit.test( - "Composer with dirty edit can toggle to another edit", - async (assert) => { - await visit("/t/this-is-a-test-topic/9"); +test("Composer with dirty edit can toggle to another edit", async (assert) => { + await visit("/t/this-is-a-test-topic/9"); - await click(".topic-post:eq(0) button.edit"); - await fillIn(".d-editor-input", "This is a dirty reply"); - await click(".topic-post:eq(1) button.edit"); - assert.ok(exists(".bootbox.modal"), "it pops up a confirmation dialog"); + await click(".topic-post:eq(0) button.edit"); + await fillIn(".d-editor-input", "This is a dirty reply"); + await click(".topic-post:eq(1) button.edit"); + assert.ok(exists(".bootbox.modal"), "it pops up a confirmation dialog"); - await click(".modal-footer a:eq(0)"); - assert.equal( - find(".d-editor-input").val().indexOf("This is the second post."), - 0, - "it populates the input with the post text" - ); - } -); + await click(".modal-footer a:eq(0)"); + assert.equal( + find(".d-editor-input").val().indexOf("This is the second post."), + 0, + "it populates the input with the post text" + ); +}); -QUnit.test("Composer can toggle between edit and reply", async (assert) => { +test("Composer can toggle between edit and reply", async (assert) => { await visit("/t/this-is-a-test-topic/9"); await click(".topic-post:eq(0) button.edit"); @@ -419,7 +418,7 @@ QUnit.test("Composer can toggle between edit and reply", async (assert) => { ); }); -QUnit.test("Composer can toggle whispers", async (assert) => { +test("Composer can toggle whispers", async (assert) => { const menu = selectKit(".toolbar-popup-menu-options"); await visit("/t/this-is-a-test-topic/9"); @@ -454,98 +453,91 @@ QUnit.test("Composer can toggle whispers", async (assert) => { ); }); -QUnit.test( - "Composer can toggle layouts (open, fullscreen and draft)", - async (assert) => { - await visit("/t/this-is-a-test-topic/9"); - await click(".topic-post:eq(0) button.reply"); +test("Composer can toggle layouts (open, fullscreen and draft)", async (assert) => { + await visit("/t/this-is-a-test-topic/9"); + await click(".topic-post:eq(0) button.reply"); - assert.ok( - find("#reply-control.open").length === 1, - "it starts in open state by default" - ); + assert.ok( + find("#reply-control.open").length === 1, + "it starts in open state by default" + ); - await click(".toggle-fullscreen"); + await click(".toggle-fullscreen"); - assert.ok( - find("#reply-control.fullscreen").length === 1, - "it expands composer to full screen" - ); + assert.ok( + find("#reply-control.fullscreen").length === 1, + "it expands composer to full screen" + ); - await click(".toggle-fullscreen"); + await click(".toggle-fullscreen"); - assert.ok( - find("#reply-control.open").length === 1, - "it collapses composer to regular size" - ); + assert.ok( + find("#reply-control.open").length === 1, + "it collapses composer to regular size" + ); - await fillIn(".d-editor-input", "This is a dirty reply"); - await click(".toggler"); + await fillIn(".d-editor-input", "This is a dirty reply"); + await click(".toggler"); - assert.ok( - find("#reply-control.draft").length === 1, - "it collapses composer to draft bar" - ); + assert.ok( + find("#reply-control.draft").length === 1, + "it collapses composer to draft bar" + ); - await click(".toggle-fullscreen"); + await click(".toggle-fullscreen"); - assert.ok( - find("#reply-control.open").length === 1, - "from draft, it expands composer back to open state" - ); - } -); + assert.ok( + find("#reply-control.open").length === 1, + "from draft, it expands composer back to open state" + ); +}); -QUnit.test( - "Composer can toggle between reply and createTopic", - async (assert) => { - await visit("/t/this-is-a-test-topic/9"); - await click(".topic-post:eq(0) button.reply"); +test("Composer can toggle between reply and createTopic", async (assert) => { + await visit("/t/this-is-a-test-topic/9"); + await click(".topic-post:eq(0) button.reply"); - await selectKit(".toolbar-popup-menu-options").expand(); - await selectKit(".toolbar-popup-menu-options").selectRowByValue( - "toggleWhisper" - ); + await selectKit(".toolbar-popup-menu-options").expand(); + await selectKit(".toolbar-popup-menu-options").selectRowByValue( + "toggleWhisper" + ); - assert.ok( - find(".composer-fields .whisper .d-icon-far-eye-slash").length === 1, - "it sets the post type to whisper" - ); + assert.ok( + find(".composer-fields .whisper .d-icon-far-eye-slash").length === 1, + "it sets the post type to whisper" + ); - await visit("/"); - assert.ok(exists("#create-topic"), "the create topic button is visible"); + await visit("/"); + assert.ok(exists("#create-topic"), "the create topic button is visible"); - await click("#create-topic"); - assert.ok( - find(".composer-fields .whisper .d-icon-far-eye-slash").length === 0, - "it should reset the state of the composer's model" - ); + await click("#create-topic"); + assert.ok( + find(".composer-fields .whisper .d-icon-far-eye-slash").length === 0, + "it should reset the state of the composer's model" + ); - await selectKit(".toolbar-popup-menu-options").expand(); - await selectKit(".toolbar-popup-menu-options").selectRowByValue( - "toggleInvisible" - ); + await selectKit(".toolbar-popup-menu-options").expand(); + await selectKit(".toolbar-popup-menu-options").selectRowByValue( + "toggleInvisible" + ); - assert.ok( - find(".composer-fields .unlist") - .text() - .indexOf(I18n.t("composer.unlist")) > 0, - "it sets the topic to unlisted" - ); + assert.ok( + find(".composer-fields .unlist").text().indexOf(I18n.t("composer.unlist")) > + 0, + "it sets the topic to unlisted" + ); - await visit("/t/this-is-a-test-topic/9"); + await visit("/t/this-is-a-test-topic/9"); - await click(".topic-post:eq(0) button.reply"); - assert.ok( - find(".composer-fields .whisper") - .text() - .indexOf(I18n.t("composer.unlist")) === -1, - "it should reset the state of the composer's model" - ); - } -); + await click(".topic-post:eq(0) button.reply"); + assert.ok( + find(".composer-fields .whisper") + .text() + .indexOf(I18n.t("composer.unlist")) === -1, + "it should reset the state of the composer's model" + ); +}); -QUnit.test("Composer with dirty reply can toggle to edit", async (assert) => { +test("Composer with dirty reply can toggle to edit", async (assert) => { await visit("/t/this-is-a-test-topic/9"); await click(".topic-post:eq(0) button.reply"); @@ -560,55 +552,49 @@ QUnit.test("Composer with dirty reply can toggle to edit", async (assert) => { ); }); -QUnit.test( - "Composer draft with dirty reply can toggle to edit", - async (assert) => { - await visit("/t/this-is-a-test-topic/9"); +test("Composer draft with dirty reply can toggle to edit", async (assert) => { + await visit("/t/this-is-a-test-topic/9"); - await click(".topic-post:eq(0) button.reply"); - await fillIn(".d-editor-input", "This is a dirty reply"); - await click(".toggler"); - await click(".topic-post:eq(1) button.edit"); - assert.ok(exists(".bootbox.modal"), "it pops up a confirmation dialog"); - assert.equal( - find(".modal-footer a:eq(1)").text(), - I18n.t("post.abandon.no_value") - ); - await click(".modal-footer a:eq(0)"); - assert.equal( - find(".d-editor-input").val().indexOf("This is the second post."), - 0, - "it populates the input with the post text" - ); - } -); + await click(".topic-post:eq(0) button.reply"); + await fillIn(".d-editor-input", "This is a dirty reply"); + await click(".toggler"); + await click(".topic-post:eq(1) button.edit"); + assert.ok(exists(".bootbox.modal"), "it pops up a confirmation dialog"); + assert.equal( + find(".modal-footer a:eq(1)").text(), + I18n.t("post.abandon.no_value") + ); + await click(".modal-footer a:eq(0)"); + assert.equal( + find(".d-editor-input").val().indexOf("This is the second post."), + 0, + "it populates the input with the post text" + ); +}); -QUnit.test( - "Composer draft can switch to draft in new context without destroying current draft", - async (assert) => { - await visit("/t/this-is-a-test-topic/9"); +test("Composer draft can switch to draft in new context without destroying current draft", async (assert) => { + await visit("/t/this-is-a-test-topic/9"); - await click(".topic-post:eq(0) button.reply"); - await fillIn(".d-editor-input", "This is a dirty reply"); + await click(".topic-post:eq(0) button.reply"); + await fillIn(".d-editor-input", "This is a dirty reply"); - await click("#site-logo"); - await click("#create-topic"); + await click("#site-logo"); + await click("#create-topic"); - assert.ok(exists(".bootbox.modal"), "it pops up a confirmation dialog"); - assert.equal( - find(".modal-footer a:eq(1)").text(), - I18n.t("post.abandon.no_save_draft") - ); - await click(".modal-footer a:eq(1)"); - assert.equal( - find(".d-editor-input").val(), - "", - "it populates the input with the post text" - ); - } -); + assert.ok(exists(".bootbox.modal"), "it pops up a confirmation dialog"); + assert.equal( + find(".modal-footer a:eq(1)").text(), + I18n.t("post.abandon.no_save_draft") + ); + await click(".modal-footer a:eq(1)"); + assert.equal( + find(".d-editor-input").val(), + "", + "it populates the input with the post text" + ); +}); -QUnit.test("Checks for existing draft", async (assert) => { +test("Checks for existing draft", async (assert) => { try { toggleCheckDraftPopup(true); @@ -625,7 +611,7 @@ QUnit.test("Checks for existing draft", async (assert) => { } }); -QUnit.test("Can switch states without abandon popup", async (assert) => { +test("Can switch states without abandon popup", async (assert) => { try { toggleCheckDraftPopup(true); @@ -673,7 +659,7 @@ QUnit.test("Can switch states without abandon popup", async (assert) => { sandbox.restore(); }); -QUnit.test("Loading draft also replaces the recipients", async (assert) => { +test("Loading draft also replaces the recipients", async (assert) => { try { toggleCheckDraftPopup(true); @@ -695,24 +681,21 @@ QUnit.test("Loading draft also replaces the recipients", async (assert) => { } }); -QUnit.test( - "Deleting the text content of the first post in a private message", - async (assert) => { - await visit("/t/34"); +test("Deleting the text content of the first post in a private message", async (assert) => { + await visit("/t/34"); - await click("#post_1 .d-icon-ellipsis-h"); + await click("#post_1 .d-icon-ellipsis-h"); - await click("#post_1 .d-icon-pencil-alt"); + await click("#post_1 .d-icon-pencil-alt"); - await fillIn(".d-editor-input", ""); + await fillIn(".d-editor-input", ""); - assert.equal( - find(".d-editor-container textarea").attr("placeholder"), - I18n.t("composer.reply_placeholder"), - "it should not block because of missing category" - ); - } -); + assert.equal( + find(".d-editor-container textarea").attr("placeholder"), + I18n.t("composer.reply_placeholder"), + "it should not block because of missing category" + ); +}); const assertImageResized = (assert, uploads) => { assert.equal( @@ -722,7 +705,7 @@ const assertImageResized = (assert, uploads) => { ); }; -QUnit.test("Image resizing buttons", async (assert) => { +test("Image resizing buttons", async (assert) => { await visit("/"); await click("#create-topic"); @@ -828,7 +811,7 @@ QUnit.test("Image resizing buttons", async (assert) => { ); }); -QUnit.test("can reply to a private message", async (assert) => { +test("can reply to a private message", async (assert) => { let submitted; /* global server */ diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js index 0fa875c283..f2eb648875 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance, updateCurrentUser, @@ -12,7 +13,7 @@ acceptance("Composer topic featured links", { }, }); -QUnit.test("onebox with title", async (assert) => { +test("onebox with title", async (assert) => { await visit("/"); await click("#create-topic"); await fillIn("#reply-title", "http://www.example.com/has-title.html"); @@ -31,7 +32,7 @@ QUnit.test("onebox with title", async (assert) => { ); }); -QUnit.test("onebox result doesn't include a title", async (assert) => { +test("onebox result doesn't include a title", async (assert) => { await visit("/"); await click("#create-topic"); await fillIn("#reply-title", "http://www.example.com/no-title.html"); @@ -50,7 +51,7 @@ QUnit.test("onebox result doesn't include a title", async (assert) => { ); }); -QUnit.test("no onebox result", async (assert) => { +test("no onebox result", async (assert) => { await visit("/"); await click("#create-topic"); await fillIn("#reply-title", "http://www.example.com/nope-onebox.html"); @@ -69,7 +70,7 @@ QUnit.test("no onebox result", async (assert) => { ); }); -QUnit.test("ignore internal links", async (assert) => { +test("ignore internal links", async (assert) => { await visit("/"); await click("#create-topic"); const title = "http://" + window.location.hostname + "/internal-page.html"; @@ -87,7 +88,7 @@ QUnit.test("ignore internal links", async (assert) => { assert.equal(find(".title-input input").val(), title, "title is unchanged"); }); -QUnit.test("link is longer than max title length", async (assert) => { +test("link is longer than max title length", async (assert) => { await visit("/"); await click("#create-topic"); await fillIn( @@ -109,29 +110,26 @@ QUnit.test("link is longer than max title length", async (assert) => { ); }); -QUnit.test( - "onebox with title but extra words in title field", - async (assert) => { - await visit("/"); - await click("#create-topic"); - await fillIn("#reply-title", "http://www.example.com/has-title.html test"); - assert.equal( - find(".d-editor-preview").html().trim().indexOf("onebox"), - -1, - "onebox preview doesn't show" - ); - assert.equal( - find(".d-editor-input").val().length, - 0, - "link isn't put into the post" - ); - assert.equal( - find(".title-input input").val(), - "http://www.example.com/has-title.html test", - "title is unchanged" - ); - } -); +test("onebox with title but extra words in title field", async (assert) => { + await visit("/"); + await click("#create-topic"); + await fillIn("#reply-title", "http://www.example.com/has-title.html test"); + assert.equal( + find(".d-editor-preview").html().trim().indexOf("onebox"), + -1, + "onebox preview doesn't show" + ); + assert.equal( + find(".d-editor-input").val().length, + 0, + "link isn't put into the post" + ); + assert.equal( + find(".title-input input").val(), + "http://www.example.com/has-title.html test", + "title is unchanged" + ); +}); acceptance("Composer topic featured links when uncategorized is not allowed", { loggedIn: true, @@ -143,7 +141,7 @@ acceptance("Composer topic featured links when uncategorized is not allowed", { }, }); -QUnit.test("Pasting a link enables the text input area", async (assert) => { +test("Pasting a link enables the text input area", async (assert) => { updateCurrentUser({ moderator: false, admin: false, trust_level: 1 }); await visit("/"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js index 54d91404bb..b908e034d2 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance, @@ -15,7 +16,7 @@ acceptance( } ); -QUnit.test("Disable body until category is selected", async (assert) => { +test("Disable body until category is selected", async (assert) => { updateCurrentUser({ moderator: false, admin: false, trust_level: 1 }); await visit("/"); @@ -86,36 +87,33 @@ acceptance( } ); -QUnit.test( - "Enable composer/body if no topic templates present", - async (assert) => { - updateCurrentUser({ moderator: false, admin: false, trust_level: 1 }); +test("Enable composer/body if no topic templates present", async (assert) => { + updateCurrentUser({ moderator: false, admin: false, trust_level: 1 }); - await visit("/"); - await click("#create-topic"); - assert.ok(exists(".d-editor-input"), "the composer input is visible"); - assert.ok( - exists(".category-input .popup-tip.bad.hide"), - "category errors are hidden by default" - ); - assert.ok( - find(".d-editor-textarea-wrapper.disabled").length === 0, - "textarea is enabled" - ); + await visit("/"); + await click("#create-topic"); + assert.ok(exists(".d-editor-input"), "the composer input is visible"); + assert.ok( + exists(".category-input .popup-tip.bad.hide"), + "category errors are hidden by default" + ); + assert.ok( + find(".d-editor-textarea-wrapper.disabled").length === 0, + "textarea is enabled" + ); - await click("#reply-control button.create"); - assert.ok( - exists(".category-input .popup-tip.bad"), - "it shows the choose a category error" - ); + await click("#reply-control button.create"); + assert.ok( + exists(".category-input .popup-tip.bad"), + "it shows the choose a category error" + ); - const categoryChooser = selectKit(".category-chooser"); - await categoryChooser.expand(); - await categoryChooser.selectRowByValue(1); + const categoryChooser = selectKit(".category-chooser"); + await categoryChooser.expand(); + await categoryChooser.selectRowByValue(1); - assert.ok( - !exists(".category-input .popup-tip.bad"), - "category error removed after selecting category" - ); - } -); + assert.ok( + !exists(".category-input .popup-tip.bad"), + "category error removed after selecting category" + ); +}); diff --git a/app/assets/javascripts/discourse/tests/acceptance/create-account-external-test.js b/app/assets/javascripts/discourse/tests/acceptance/create-account-external-test.js index e9f844fc6c..d9bdfef09f 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/create-account-external-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/create-account-external-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Create Account - external auth", { @@ -19,7 +20,7 @@ acceptance("Create Account - external auth", { }, }); -QUnit.test("when skip is disabled (default)", async (assert) => { +test("when skip is disabled (default)", async (assert) => { await visit("/"); assert.ok( @@ -30,7 +31,7 @@ QUnit.test("when skip is disabled (default)", async (assert) => { assert.ok(exists("#new-account-username"), "it shows the fields"); }); -QUnit.test("when skip is enabled", async function (assert) { +test("when skip is enabled", async function (assert) { this.siteSettings.external_auth_skip_create_confirm = true; await visit("/"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/create-account-user-fields-test.js b/app/assets/javascripts/discourse/tests/acceptance/create-account-user-fields-test.js index 138428a294..89c88c9d45 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/create-account-user-fields-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/create-account-user-fields-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Create Account - User Fields", { @@ -25,7 +26,7 @@ acceptance("Create Account - User Fields", { }, }); -QUnit.test("create account with user fields", async (assert) => { +test("create account with user fields", async (assert) => { await visit("/"); await click("header .sign-up-button"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/custom-html-set-test.js b/app/assets/javascripts/discourse/tests/acceptance/custom-html-set-test.js index 51fb329d5e..2a4277ab9f 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/custom-html-set-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/custom-html-set-test.js @@ -1,15 +1,16 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import { setCustomHTML } from "discourse/helpers/custom-html"; import PreloadStore from "discourse/lib/preload-store"; acceptance("CustomHTML set"); -QUnit.test("has no custom HTML in the top", async (assert) => { +test("has no custom HTML in the top", async (assert) => { await visit("/static/faq"); assert.ok(!exists("span.custom-html-test"), "it has no markup"); }); -QUnit.test("renders set HTML", async (assert) => { +test("renders set HTML", async (assert) => { setCustomHTML("top", 'HTML'); await visit("/static/faq"); @@ -20,7 +21,7 @@ QUnit.test("renders set HTML", async (assert) => { ); }); -QUnit.test("renders preloaded HTML", async (assert) => { +test("renders preloaded HTML", async (assert) => { PreloadStore.store("customHTML", { top: "", }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/custom-html-template-test.js b/app/assets/javascripts/discourse/tests/acceptance/custom-html-template-test.js index 25d2d64f2a..f74358a381 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/custom-html-template-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/custom-html-template-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("CustomHTML template", { @@ -12,7 +13,7 @@ acceptance("CustomHTML template", { }, }); -QUnit.test("renders custom template", async (assert) => { +test("renders custom template", async (assert) => { await visit("/static/faq"); assert.equal(find("span.top-span").text(), "TOP", "it inserted the template"); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js b/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js index 600f86a684..54f618476f 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -21,13 +22,13 @@ acceptance("Dashboard", { }, }); -QUnit.test("default", async (assert) => { +test("default", async (assert) => { await visit("/admin"); assert.ok(exists(".dashboard"), "has dashboard-next class"); }); -QUnit.test("tabs", async (assert) => { +test("tabs", async (assert) => { await visit("/admin"); assert.ok(exists(".dashboard .navigation-item.general"), "general tab"); @@ -36,7 +37,7 @@ QUnit.test("tabs", async (assert) => { assert.ok(exists(".dashboard .navigation-item.reports"), "reports tab"); }); -QUnit.test("general tab", async (assert) => { +test("general tab", async (assert) => { await visit("/admin"); assert.ok(exists(".admin-report.signups"), "signups report"); assert.ok(exists(".admin-report.posts"), "posts report"); @@ -59,7 +60,7 @@ QUnit.test("general tab", async (assert) => { ); }); -QUnit.test("activity metrics", async (assert) => { +test("activity metrics", async (assert) => { await visit("/admin"); assert.ok(exists(".admin-report.page-view-total-reqs .today-count")); @@ -68,7 +69,7 @@ QUnit.test("activity metrics", async (assert) => { assert.ok(exists(".admin-report.page-view-total-reqs .thirty-days-count")); }); -QUnit.test("reports tab", async (assert) => { +test("reports tab", async (assert) => { await visit("/admin"); await click(".dashboard .navigation-item.reports .navigation-link"); @@ -102,7 +103,7 @@ QUnit.test("reports tab", async (assert) => { ); }); -QUnit.test("reports filters", async (assert) => { +test("reports filters", async (assert) => { await visit( '/admin/reports/signups_with_groups?end_date=2018-07-16&filters=%7B"group"%3A88%7D&start_date=2018-06-16' ); @@ -123,7 +124,7 @@ acceptance("Dashboard: dashboard_visible_tabs", { }, }); -QUnit.test("visible tabs", async (assert) => { +test("visible tabs", async (assert) => { await visit("/admin"); assert.ok(exists(".dashboard .navigation-item.general"), "general tab"); @@ -143,7 +144,7 @@ acceptance("Dashboard: dashboard_hidden_reports", { }, }); -QUnit.test("hidden reports", async (assert) => { +test("hidden reports", async (assert) => { await visit("/admin"); assert.ok(exists(".admin-report.signups.is-visible"), "signups report"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/email-notice-test.js b/app/assets/javascripts/discourse/tests/acceptance/email-notice-test.js index dfc1a81cc3..5707aae706 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/email-notice-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/email-notice-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance, updateCurrentUser, @@ -7,7 +8,7 @@ acceptance("Email Disabled Banner", { loggedIn: true, }); -QUnit.test("when disabled", async function (assert) { +test("when disabled", async function (assert) { this.siteSettings.disable_emails = "no"; await visit("/"); assert.notOk( @@ -16,7 +17,7 @@ QUnit.test("when disabled", async function (assert) { ); }); -QUnit.test("when enabled", async function (assert) { +test("when enabled", async function (assert) { this.siteSettings.disable_emails = "yes"; await visit("/latest"); assert.ok( @@ -25,7 +26,7 @@ QUnit.test("when enabled", async function (assert) { ); }); -QUnit.test("when non-staff", async function (assert) { +test("when non-staff", async function (assert) { this.siteSettings.disable_emails = "non-staff"; await visit("/"); assert.ok( diff --git a/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js b/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js index ad0b3d37d7..f356963665 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("EmojiPicker", { @@ -11,7 +12,7 @@ acceptance("EmojiPicker", { }, }); -QUnit.test("emoji picker can be opened/closed", async (assert) => { +test("emoji picker can be opened/closed", async (assert) => { await visit("/t/internationalization-localization/280"); await click("#topic-footer-buttons .btn.create"); @@ -22,7 +23,7 @@ QUnit.test("emoji picker can be opened/closed", async (assert) => { assert.notOk(exists(".emoji-picker.opened"), "it closes the picker"); }); -QUnit.test("emoji picker triggers event when picking emoji", async (assert) => { +test("emoji picker triggers event when picking emoji", async (assert) => { await visit("/t/internationalization-localization/280"); await click("#topic-footer-buttons .btn.create"); await click("button.emoji.btn"); @@ -35,101 +36,92 @@ QUnit.test("emoji picker triggers event when picking emoji", async (assert) => { ); }); -QUnit.test( - "emoji picker adds leading whitespace before emoji", - async (assert) => { - await visit("/t/internationalization-localization/280"); - await click("#topic-footer-buttons .btn.create"); +test("emoji picker adds leading whitespace before emoji", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .btn.create"); - // Whitespace should be added on text - await fillIn(".d-editor-input", "This is a test input"); - await click("button.emoji.btn"); - await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); - assert.equal( - find(".d-editor-input").val(), - "This is a test input :grinning:", - "it adds the emoji code and a leading whitespace when there is text" - ); + // Whitespace should be added on text + await fillIn(".d-editor-input", "This is a test input"); + await click("button.emoji.btn"); + await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); + assert.equal( + find(".d-editor-input").val(), + "This is a test input :grinning:", + "it adds the emoji code and a leading whitespace when there is text" + ); - // Whitespace should not be added on whitespace - await fillIn(".d-editor-input", "This is a test input "); - await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); + // Whitespace should not be added on whitespace + await fillIn(".d-editor-input", "This is a test input "); + await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); - assert.equal( - find(".d-editor-input").val(), - "This is a test input :grinning:", - "it adds the emoji code and no leading whitespace when user already entered whitespace" - ); - } -); + assert.equal( + find(".d-editor-input").val(), + "This is a test input :grinning:", + "it adds the emoji code and no leading whitespace when user already entered whitespace" + ); +}); -QUnit.test( - "emoji picker has a list of recently used emojis", - async (assert) => { - await visit("/t/internationalization-localization/280"); - await click("#topic-footer-buttons .btn.create"); - await click("button.emoji.btn"); - await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); +test("emoji picker has a list of recently used emojis", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .btn.create"); + await click("button.emoji.btn"); + await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); - assert.ok( - exists( - ".emoji-picker .section.recent .section-group img.emoji[title='grinning']" - ), - "it shows recent selected emoji" - ); + assert.ok( + exists( + ".emoji-picker .section.recent .section-group img.emoji[title='grinning']" + ), + "it shows recent selected emoji" + ); - assert.ok( - exists('.emoji-picker .category-button[data-section="recent"]'), - "it shows recent category icon" - ); + assert.ok( + exists('.emoji-picker .category-button[data-section="recent"]'), + "it shows recent category icon" + ); - await click(".emoji-picker .trash-recent"); + await click(".emoji-picker .trash-recent"); - assert.notOk( - exists( - ".emoji-picker .section.recent .section-group img.emoji[title='grinning']" - ), - "it has cleared recent emojis" - ); + assert.notOk( + exists( + ".emoji-picker .section.recent .section-group img.emoji[title='grinning']" + ), + "it has cleared recent emojis" + ); - assert.notOk( - exists('.emoji-picker .section[data-section="recent"]'), - "it hides recent section" - ); + assert.notOk( + exists('.emoji-picker .section[data-section="recent"]'), + "it hides recent section" + ); - assert.notOk( - exists('.emoji-picker .category-button[data-section="recent"]'), - "it hides recent category icon" - ); - } -); + assert.notOk( + exists('.emoji-picker .category-button[data-section="recent"]'), + "it hides recent category icon" + ); +}); -QUnit.test( - "emoji picker correctly orders recently used emojis", - async (assert) => { - await visit("/t/internationalization-localization/280"); - await click("#topic-footer-buttons .btn.create"); - await click("button.emoji.btn"); - await click(".emoji-picker-emoji-area img.emoji[title='sunglasses']"); - await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); +test("emoji picker correctly orders recently used emojis", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-buttons .btn.create"); + await click("button.emoji.btn"); + await click(".emoji-picker-emoji-area img.emoji[title='sunglasses']"); + await click(".emoji-picker-emoji-area img.emoji[title='grinning']"); - assert.equal( - find('.section[data-section="recent"] .section-group img.emoji').length, - 2, - "it has multiple recent emojis" - ); + assert.equal( + find('.section[data-section="recent"] .section-group img.emoji').length, + 2, + "it has multiple recent emojis" + ); - assert.equal( - /grinning/.test( - find(".section.recent .section-group img.emoji").first().attr("src") - ), - true, - "it puts the last used emoji in first" - ); - } -); + assert.equal( + /grinning/.test( + find(".section.recent .section-group img.emoji").first().attr("src") + ), + true, + "it puts the last used emoji in first" + ); +}); -QUnit.test("emoji picker persists state", async (assert) => { +test("emoji picker persists state", async (assert) => { await visit("/t/internationalization-localization/280"); await click("#topic-footer-buttons .btn.create"); await click("button.emoji.btn"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js b/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js index f23d251d37..e3bcf210ad 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js @@ -1,9 +1,10 @@ +import { test } from "qunit"; import { IMAGE_VERSION as v } from "pretty-text/emoji/version"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Emoji", { loggedIn: true }); -QUnit.test("emoji is cooked properly", async (assert) => { +test("emoji is cooked properly", async (assert) => { await visit("/t/internationalization-localization/280"); await click("#topic-footer-buttons .btn.create"); @@ -14,7 +15,7 @@ QUnit.test("emoji is cooked properly", async (assert) => { ); }); -QUnit.test("skin toned emoji is cooked properly", async (assert) => { +test("skin toned emoji is cooked properly", async (assert) => { await visit("/t/internationalization-localization/280"); await click("#topic-footer-buttons .btn.create"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/encoded-category-test.js b/app/assets/javascripts/discourse/tests/acceptance/encoded-category-test.js index 51b686b312..f3e1a66f8b 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/encoded-category-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/encoded-category-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import DiscoveryFixtures from "discourse/tests/fixtures/discovery-fixtures"; @@ -41,7 +42,7 @@ acceptance("Encoded Sub Category Discovery", { }, }); -QUnit.test("Visit subcategory by slug", async (assert) => { +test("Visit subcategory by slug", async (assert) => { let bodySelector = "body.category-\\%E6\\%BC\\%A2\\%E5\\%AD\\%97-parent-\\%E6\\%BC\\%A2\\%E5\\%AD\\%97-subcategory"; await visit("/c/%E6%BC%A2%E5%AD%97-parent/%E6%BC%A2%E5%AD%97-subcategory"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/enforce-second-factor-test.js b/app/assets/javascripts/discourse/tests/acceptance/enforce-second-factor-test.js index d5249a3a30..945bad39a2 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/enforce-second-factor-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/enforce-second-factor-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance, updateCurrentUser, @@ -15,7 +16,7 @@ acceptance("Enforce Second Factor", { }, }); -QUnit.test("as an admin", async function (assert) { +test("as an admin", async function (assert) { await visit("/u/eviltrout/preferences/second-factor"); this.siteSettings.enforce_second_factor = "staff"; @@ -37,7 +38,7 @@ QUnit.test("as an admin", async function (assert) { ); }); -QUnit.test("as a user", async function (assert) { +test("as a user", async function (assert) { updateCurrentUser({ moderator: false, admin: false }); await visit("/u/eviltrout/preferences/second-factor"); @@ -61,7 +62,7 @@ QUnit.test("as a user", async function (assert) { ); }); -QUnit.test("as an anonymous user", async function (assert) { +test("as an anonymous user", async function (assert) { updateCurrentUser({ moderator: false, admin: false, is_anonymous: true }); await visit("/u/eviltrout/preferences/second-factor"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/forgot-password-test.js b/app/assets/javascripts/discourse/tests/acceptance/forgot-password-test.js index e7f7bc0ada..56b606eab8 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/forgot-password-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/forgot-password-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import I18n from "I18n"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -13,7 +14,7 @@ acceptance("Forgot password", { }, }); -QUnit.test("requesting password reset", async (assert) => { +test("requesting password reset", async (assert) => { await visit("/"); await click("header .login-button"); await click("#forgot-password-link"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-card-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-card-mobile-test.js index 106b7e00c0..0b90426056 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-card-mobile-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-card-mobile-test.js @@ -1,9 +1,10 @@ +import { skip } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import DiscourseURL from "discourse/lib/url"; acceptance("Group Card - Mobile", { mobileView: true }); -QUnit.skip("group card", async (assert) => { +skip("group card", async (assert) => { await visit("/t/-/301/1"); assert.ok( invisible(".group-card"), diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-card-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-card-test.js index 4cb5db2ba8..89113098af 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-card-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-card-test.js @@ -1,9 +1,10 @@ +import { skip } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import DiscourseURL from "discourse/lib/url"; acceptance("Group Card"); -QUnit.skip("group card", async (assert) => { +skip("group card", async (assert) => { await visit("/t/-/301/1"); assert.ok(invisible(".group-card"), "user card is invisible by default"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js index 0d8f437335..1abdcb3f43 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import I18n from "I18n"; import { acceptance, @@ -6,7 +7,7 @@ import { acceptance("Group Members"); -QUnit.test("Viewing Members as anon user", async (assert) => { +test("Viewing Members as anon user", async (assert) => { await visit("/g/discourse"); assert.ok( @@ -29,7 +30,7 @@ QUnit.test("Viewing Members as anon user", async (assert) => { acceptance("Group Members", { loggedIn: true }); -QUnit.test("Viewing Members as a group owner", async (assert) => { +test("Viewing Members as a group owner", async (assert) => { updateCurrentUser({ moderator: false, admin: false }); await visit("/g/discourse"); @@ -42,7 +43,7 @@ QUnit.test("Viewing Members as a group owner", async (assert) => { ); }); -QUnit.test("Viewing Members as an admin user", async (assert) => { +test("Viewing Members as an admin user", async (assert) => { await visit("/g/discourse"); assert.ok( diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-manage-categories-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-categories-test.js index 99f64a92e9..918970d03c 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-manage-categories-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-categories-test.js @@ -1,10 +1,11 @@ +import { test } from "qunit"; import { acceptance, updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; acceptance("Managing Group Category Notification Defaults"); -QUnit.test("As an anonymous user", async (assert) => { +test("As an anonymous user", async (assert) => { await visit("/g/discourse/manage/categories"); assert.ok( @@ -15,7 +16,7 @@ QUnit.test("As an anonymous user", async (assert) => { acceptance("Managing Group Category Notification Defaults", { loggedIn: true }); -QUnit.test("As an admin", async (assert) => { +test("As an admin", async (assert) => { await visit("/g/discourse/manage/categories"); assert.ok( @@ -24,7 +25,7 @@ QUnit.test("As an admin", async (assert) => { ); }); -QUnit.test("As a group owner", async (assert) => { +test("As a group owner", async (assert) => { updateCurrentUser({ moderator: false, admin: false }); await visit("/g/discourse/manage/categories"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-manage-interaction-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-interaction-test.js index 60c4aa35cd..5631f4f5ec 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-manage-interaction-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-interaction-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance, updateCurrentUser, @@ -10,7 +11,7 @@ acceptance("Managing Group Interaction Settings", { }, }); -QUnit.test("As an admin", async (assert) => { +test("As an admin", async (assert) => { updateCurrentUser({ moderator: false, admin: true, @@ -50,7 +51,7 @@ QUnit.test("As an admin", async (assert) => { ); }); -QUnit.test("As a group owner", async (assert) => { +test("As a group owner", async (assert) => { updateCurrentUser({ moderator: false, admin: false, diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-manage-logs-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-logs-test.js index d1fb001032..c666c2eb6b 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-manage-logs-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-logs-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Group logs", { @@ -92,7 +93,7 @@ acceptance("Group logs", { }, }); -QUnit.test("Browsing group logs", async (assert) => { +test("Browsing group logs", async (assert) => { await visit("/g/snorlax/manage/logs"); assert.ok( find("tr.group-manage-logs-row").length === 2, diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-manage-membership-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-membership-test.js index 2d9876c0a2..acb0e76072 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-manage-membership-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-membership-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance, updateCurrentUser, @@ -8,7 +9,7 @@ acceptance("Managing Group Membership", { loggedIn: true, }); -QUnit.test("As an admin", async (assert) => { +test("As an admin", async (assert) => { updateCurrentUser({ can_create_group: true }); await visit("/g/alternative-group/manage/membership"); @@ -75,7 +76,7 @@ QUnit.test("As an admin", async (assert) => { assert.equal(emailDomains.header().value(), "foo.com"); }); -QUnit.test("As a group owner", async (assert) => { +test("As a group owner", async (assert) => { updateCurrentUser({ moderator: false, admin: false }); await visit("/g/discourse/manage/membership"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-manage-profile-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-profile-test.js index 4c13bf3291..2d8b5de924 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-manage-profile-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-profile-test.js @@ -1,10 +1,11 @@ +import { test } from "qunit"; import { acceptance, updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; acceptance("Managing Group Profile"); -QUnit.test("As an anonymous user", async (assert) => { +test("As an anonymous user", async (assert) => { await visit("/g/discourse/manage/profile"); assert.ok( @@ -15,7 +16,7 @@ QUnit.test("As an anonymous user", async (assert) => { acceptance("Managing Group Profile", { loggedIn: true }); -QUnit.test("As an admin", async (assert) => { +test("As an admin", async (assert) => { await visit("/g/discourse/manage/profile"); assert.ok( @@ -36,7 +37,7 @@ QUnit.test("As an admin", async (assert) => { ); }); -QUnit.test("As a group owner", async (assert) => { +test("As a group owner", async (assert) => { updateCurrentUser({ moderator: false, admin: false, diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-manage-tags-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-tags-test.js index 71c1c6c7e1..d8cf22ed58 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-manage-tags-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-tags-test.js @@ -1,10 +1,11 @@ +import { test } from "qunit"; import { acceptance, updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; acceptance("Managing Group Tag Notification Defaults"); -QUnit.test("As an anonymous user", async (assert) => { +test("As an anonymous user", async (assert) => { await visit("/g/discourse/manage/tags"); assert.ok( @@ -15,7 +16,7 @@ QUnit.test("As an anonymous user", async (assert) => { acceptance("Managing Group Tag Notification Defaults", { loggedIn: true }); -QUnit.test("As an admin", async (assert) => { +test("As an admin", async (assert) => { await visit("/g/discourse/manage/tags"); assert.ok( @@ -24,7 +25,7 @@ QUnit.test("As an admin", async (assert) => { ); }); -QUnit.test("As a group owner", async (assert) => { +test("As a group owner", async (assert) => { updateCurrentUser({ moderator: false, admin: false }); await visit("/g/discourse/manage/tags"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-requests-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-requests-test.js index 952089e785..42bd1a6120 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-requests-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-requests-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import { parsePostData } from "discourse/tests/helpers/create-pretender"; @@ -80,7 +81,7 @@ acceptance("Group Requests", { }, }); -QUnit.test("Group Requests", async (assert) => { +test("Group Requests", async (assert) => { await visit("/g/Macdonald/requests"); assert.equal(find(".group-members tr").length, 2); diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-test.js index 169aae4391..4dba725f8f 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/group-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/group-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import I18n from "I18n"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -22,7 +23,7 @@ const response = (object) => { return [200, { "Content-Type": "application/json" }, object]; }; -QUnit.test("Anonymous Viewing Group", async function (assert) { +test("Anonymous Viewing Group", async function (assert) { await visit("/g/discourse"); assert.equal( @@ -77,7 +78,7 @@ QUnit.test("Anonymous Viewing Group", async function (assert) { ); }); -QUnit.test("Anonymous Viewing Automatic Group", async (assert) => { +test("Anonymous Viewing Automatic Group", async (assert) => { await visit("/g/moderators"); assert.equal( @@ -89,7 +90,7 @@ QUnit.test("Anonymous Viewing Automatic Group", async (assert) => { acceptance("Group", Object.assign({ loggedIn: true }, groupArgs)); -QUnit.test("User Viewing Group", async (assert) => { +test("User Viewing Group", async (assert) => { await visit("/g"); await click(".group-index-request"); @@ -122,28 +123,25 @@ QUnit.test("User Viewing Group", async (assert) => { ); }); -QUnit.test( - "Admin viewing group messages when there are no messages", - async (assert) => { - pretender.get( - "/topics/private-messages-group/eviltrout/discourse.json", - () => { - return response({ topic_list: { topics: [] } }); - } - ); +test("Admin viewing group messages when there are no messages", async (assert) => { + pretender.get( + "/topics/private-messages-group/eviltrout/discourse.json", + () => { + return response({ topic_list: { topics: [] } }); + } + ); - await visit("/g/discourse"); - await click(".nav-pills li a[title='Messages']"); + await visit("/g/discourse"); + await click(".nav-pills li a[title='Messages']"); - assert.equal( - find(".alert").text().trim(), - I18n.t("choose_topic.none_found"), - "it should display the right alert" - ); - } -); + assert.equal( + find(".alert").text().trim(), + I18n.t("choose_topic.none_found"), + "it should display the right alert" + ); +}); -QUnit.test("Admin viewing group messages", async (assert) => { +test("Admin viewing group messages", async (assert) => { pretender.get( "/topics/private-messages-group/eviltrout/discourse.json", () => { @@ -238,7 +236,7 @@ QUnit.test("Admin viewing group messages", async (assert) => { ); }); -QUnit.test("Admin Viewing Group", async (assert) => { +test("Admin Viewing Group", async (assert) => { await visit("/g/discourse"); assert.ok( diff --git a/app/assets/javascripts/discourse/tests/acceptance/groups-index-test.js b/app/assets/javascripts/discourse/tests/acceptance/groups-index-test.js index 96ff83d28e..48adf928b5 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/groups-index-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/groups-index-test.js @@ -1,8 +1,9 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Groups"); -QUnit.test("Browsing Groups", async (assert) => { +test("Browsing Groups", async (assert) => { await visit("/g?username=eviltrout"); assert.equal(count(".group-box"), 1, "it displays user's groups"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/groups-new-test.js b/app/assets/javascripts/discourse/tests/acceptance/groups-new-test.js index eb638e8890..b43f40b045 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/groups-new-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/groups-new-test.js @@ -1,9 +1,10 @@ +import { test } from "qunit"; import I18n from "I18n"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("New Group"); -QUnit.test("As an anon user", async (assert) => { +test("As an anon user", async (assert) => { await visit("/g"); assert.equal( @@ -15,7 +16,7 @@ QUnit.test("As an anon user", async (assert) => { acceptance("New Group", { loggedIn: true }); -QUnit.test("Creating a new group", async (assert) => { +test("Creating a new group", async (assert) => { await visit("/g"); await click(".groups-header-new"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/hamburger-menu-test.js b/app/assets/javascripts/discourse/tests/acceptance/hamburger-menu-test.js index 18b5bcee23..25b95d2805 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/hamburger-menu-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/hamburger-menu-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance, updateCurrentUser, @@ -10,7 +11,7 @@ acceptance("Opening the hamburger menu with some reviewables", { }, }); -QUnit.test("As a staff member", async (assert) => { +test("As a staff member", async (assert) => { updateCurrentUser({ moderator: true, admin: false }); await visit("/"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/hashtags-test.js b/app/assets/javascripts/discourse/tests/acceptance/hashtags-test.js index 833d0d4f8d..a5e99a0b54 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/hashtags-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/hashtags-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Category and Tag Hashtags", { @@ -16,7 +17,7 @@ acceptance("Category and Tag Hashtags", { }, }); -QUnit.test("hashtags are cooked properly", async (assert) => { +test("hashtags are cooked properly", async (assert) => { await visit("/t/internationalization-localization/280"); await click("#topic-footer-buttons .btn.create"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/invite-accept-test.js b/app/assets/javascripts/discourse/tests/acceptance/invite-accept-test.js index 397ae63a8d..3c24b3c21b 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/invite-accept-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/invite-accept-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import PreloadStore from "discourse/lib/preload-store"; @@ -7,7 +8,7 @@ acceptance("Invite Accept", { }, }); -QUnit.test("Invite Acceptance Page", async (assert) => { +test("Invite Acceptance Page", async (assert) => { PreloadStore.store("invite_info", { invited_by: { id: 123, diff --git a/app/assets/javascripts/discourse/tests/acceptance/invite-show-user-fields-test.js b/app/assets/javascripts/discourse/tests/acceptance/invite-show-user-fields-test.js index 83f21aac25..1883acf188 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/invite-show-user-fields-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/invite-show-user-fields-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import PreloadStore from "discourse/lib/preload-store"; @@ -26,7 +27,7 @@ acceptance("Accept Invite - User Fields", { }, }); -QUnit.test("accept invite with user fields", async (assert) => { +test("accept invite with user fields", async (assert) => { PreloadStore.store("invite_info", { invited_by: { id: 123, diff --git a/app/assets/javascripts/discourse/tests/acceptance/jump-to-test.js b/app/assets/javascripts/discourse/tests/acceptance/jump-to-test.js index 1adbaa7f1a..7bf47d2494 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/jump-to-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/jump-to-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Jump to", { @@ -20,7 +21,7 @@ acceptance("Jump to", { }, }); -QUnit.test("default", async (assert) => { +test("default", async (assert) => { await visit("/t/internationalization-localization/280"); await click("nav#topic-progress .nums"); await click("button.jump-to-post"); @@ -37,7 +38,7 @@ QUnit.test("default", async (assert) => { ); }); -QUnit.test("invalid date", async (assert) => { +test("invalid date", async (assert) => { await visit("/t/internationalization-localization/280"); await click("nav#topic-progress .nums"); await click("button.jump-to-post"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js b/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js index f93ec01a18..fc91ab988b 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import pretender from "discourse/tests/helpers/create-pretender"; diff --git a/app/assets/javascripts/discourse/tests/acceptance/login-redirect-test.js b/app/assets/javascripts/discourse/tests/acceptance/login-redirect-test.js index 6057fed199..b69449a8c0 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/login-redirect-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/login-redirect-test.js @@ -1,7 +1,8 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Login redirect"); -QUnit.test("redirects login to default homepage", async function (assert) { +test("redirects login to default homepage", async function (assert) { await visit("/login"); assert.equal( currentPath(), @@ -16,7 +17,7 @@ acceptance("Login redirect - categories default", { }, }); -QUnit.test("when site setting is categories", async function (assert) { +test("when site setting is categories", async function (assert) { await visit("/login"); assert.equal( currentPath(), diff --git a/app/assets/javascripts/discourse/tests/acceptance/login-required-test.js b/app/assets/javascripts/discourse/tests/acceptance/login-required-test.js index c5d210c278..f51993d737 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/login-required-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/login-required-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Login Required", { @@ -6,7 +7,7 @@ acceptance("Login Required", { }, }); -QUnit.test("redirect", async (assert) => { +test("redirect", async (assert) => { await visit("/latest"); assert.equal(currentPath(), "login", "it redirects them to login"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/login-with-email-and-hide-email-address-taken-test.js b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-and-hide-email-address-taken-test.js index f95242d6ed..be8c5f69ce 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/login-with-email-and-hide-email-address-taken-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-and-hide-email-address-taken-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import I18n from "I18n"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import pretender from "discourse/tests/helpers/create-pretender"; @@ -18,7 +19,7 @@ acceptance("Login with email - hide email address taken", { }, }); -QUnit.test("with hide_email_address_taken enabled", async (assert) => { +test("with hide_email_address_taken enabled", async (assert) => { await visit("/"); await click("header .login-button"); await fillIn("#login-account-name", "someuser@example.com"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/login-with-email-and-no-social-logins-test.js b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-and-no-social-logins-test.js index 7d002f7448..20be2900f8 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/login-with-email-and-no-social-logins-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-and-no-social-logins-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Login with email - no social logins", { @@ -9,14 +10,14 @@ acceptance("Login with email - no social logins", { }, }); -QUnit.test("with login with email enabled", async (assert) => { +test("with login with email enabled", async (assert) => { await visit("/"); await click("header .login-button"); assert.ok(exists(".login-with-email-button")); }); -QUnit.test("with login with email disabled", async (assert) => { +test("with login with email disabled", async (assert) => { await visit("/"); await click("header .login-button"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/login-with-email-disabled-test.js b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-disabled-test.js index 6361efe2d9..8512658ed5 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/login-with-email-disabled-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-disabled-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Login with email disabled", { @@ -7,7 +8,7 @@ acceptance("Login with email disabled", { }, }); -QUnit.test("with email button", async (assert) => { +test("with email button", async (assert) => { await visit("/"); await click("header .login-button"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/login-with-email-test.js b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-test.js index 9b959cf961..1005e33736 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/login-with-email-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import I18n from "I18n"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -15,7 +16,7 @@ acceptance("Login with email", { }, }); -QUnit.test("with email button", async (assert) => { +test("with email button", async (assert) => { await visit("/"); await click("header .login-button"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/mobile-discovery-test.js b/app/assets/javascripts/discourse/tests/acceptance/mobile-discovery-test.js index 281bf94bf9..8e5d3aa0f0 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/mobile-discovery-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/mobile-discovery-test.js @@ -1,7 +1,8 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Topic Discovery - Mobile", { mobileView: true }); -QUnit.test("Visit Discovery Pages", async (assert) => { +test("Visit Discovery Pages", async (assert) => { await visit("/"); assert.ok(exists(".topic-list"), "The list of topics was rendered"); assert.ok(exists(".topic-list .topic-list-item"), "has topics"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/mobile-sign-in-test.js b/app/assets/javascripts/discourse/tests/acceptance/mobile-sign-in-test.js index 452c8ae8a4..63f98611e4 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/mobile-sign-in-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/mobile-sign-in-test.js @@ -1,8 +1,9 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Signing In - Mobile", { mobileView: true }); -QUnit.test("sign in", async (assert) => { +test("sign in", async (assert) => { await visit("/"); await click("header .login-button"); assert.ok(exists("#login-form"), "it shows the login modal"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/mobile-users-test.js b/app/assets/javascripts/discourse/tests/acceptance/mobile-users-test.js index ad84a25745..bb636b60fc 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/mobile-users-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/mobile-users-test.js @@ -1,8 +1,9 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("User Directory - Mobile", { mobileView: true }); -QUnit.test("Visit Page", async (assert) => { +test("Visit Page", async (assert) => { await visit("/u"); assert.ok(exists(".directory .user"), "has a list of users"); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/modal-test.js b/app/assets/javascripts/discourse/tests/acceptance/modal-test.js index b829dd23a5..f6bde32267 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/modal-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/modal-test.js @@ -1,3 +1,5 @@ +import { skip } from "qunit"; +import { test } from "qunit"; import I18n from "I18n"; import { run } from "@ember/runloop"; import { @@ -24,7 +26,7 @@ acceptance("Modal", { }, }); -QUnit.skip("modal", async function (assert) { +skip("modal", async function (assert) { await visit("/"); assert.ok( @@ -74,7 +76,7 @@ QUnit.skip("modal", async function (assert) { ); }); -QUnit.test("rawTitle in modal panels", async function (assert) { +test("rawTitle in modal panels", async function (assert) { Ember.TEMPLATES["modal/test-raw-title-panels"] = Ember.HTMLBars.compile(""); const panels = [ { id: "test1", rawTitle: "Test 1" }, @@ -91,7 +93,7 @@ QUnit.test("rawTitle in modal panels", async function (assert) { ); }); -QUnit.test("modal title", async function (assert) { +test("modal title", async function (assert) { Ember.TEMPLATES["modal/test-title"] = Ember.HTMLBars.compile(""); Ember.TEMPLATES["modal/test-title-with-body"] = Ember.HTMLBars.compile( "{{#d-modal-body}}test{{/d-modal-body}}" @@ -126,7 +128,7 @@ QUnit.test("modal title", async function (assert) { acceptance("Modal Keyboard Events", { loggedIn: true }); -QUnit.test("modal-keyboard-events", async function (assert) { +test("modal-keyboard-events", async function (assert) { await visit("/t/internationalization-localization/280"); await click(".toggle-admin-menu"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js b/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js index fa8011b466..f264d2da25 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js @@ -1,8 +1,9 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("New Message"); -QUnit.test("accessing new-message route when logged out", async (assert) => { +test("accessing new-message route when logged out", async (assert) => { await visit( "/new-message?username=charlie&title=message%20title&body=message%20body" ); @@ -11,7 +12,7 @@ QUnit.test("accessing new-message route when logged out", async (assert) => { }); acceptance("New Message", { loggedIn: true }); -QUnit.test("accessing new-message route when logged in", async (assert) => { +test("accessing new-message route when logged in", async (assert) => { await visit( "/new-message?username=charlie&title=message%20title&body=message%20body" ); diff --git a/app/assets/javascripts/discourse/tests/acceptance/new-topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/new-topic-test.js index cbddf5f614..9cebe072a6 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/new-topic-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/new-topic-test.js @@ -1,16 +1,17 @@ +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("New Topic"); -QUnit.test("accessing new-topic route when logged out", async (assert) => { +test("accessing new-topic route when logged out", async (assert) => { await visit("/new-topic?title=topic%20title&body=topic%20body"); assert.ok(exists(".modal.login-modal"), "it shows the login modal"); }); acceptance("New Topic", { loggedIn: true }); -QUnit.test("accessing new-topic route when logged in", async (assert) => { +test("accessing new-topic route when logged in", async (assert) => { await visit("/new-topic?title=topic%20title&body=topic%20body&category=bug"); assert.ok(exists(".composer-fields"), "it opens composer"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/notifications-filter-test.js b/app/assets/javascripts/discourse/tests/acceptance/notifications-filter-test.js index 2068e2eafb..300dc4ec40 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/notifications-filter-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/notifications-filter-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; diff --git a/app/assets/javascripts/discourse/tests/acceptance/page-publishing-test.js b/app/assets/javascripts/discourse/tests/acceptance/page-publishing-test.js index 64acfe8aab..7ccfe91e54 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/page-publishing-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/page-publishing-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Page Publishing", { @@ -22,7 +23,7 @@ acceptance("Page Publishing", { }); }, }); -QUnit.test("can publish a page via modal", async (assert) => { +test("can publish a page via modal", async (assert) => { await visit("/t/internationalization-localization/280"); await click(".topic-post:eq(0) button.show-more-actions"); await click(".topic-post:eq(0) button.show-post-admin-menu"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js b/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js index e0ed6433c6..88e966d55d 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import I18n from "I18n"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import PreloadStore from "discourse/lib/preload-store"; @@ -54,7 +55,7 @@ acceptance("Password Reset", { }, }); -QUnit.test("Password Reset Page", async (assert) => { +test("Password Reset Page", async (assert) => { PreloadStore.store("password_reset", { is_developer: false }); await visit("/u/password-reset/myvalidtoken"); @@ -86,7 +87,7 @@ QUnit.test("Password Reset Page", async (assert) => { assert.ok(!exists(".password-reset form"), "form is gone"); }); -QUnit.test("Password Reset Page With Second Factor", async (assert) => { +test("Password Reset Page With Second Factor", async (assert) => { PreloadStore.store("password_reset", { is_developer: false, second_factor_required: true, diff --git a/app/assets/javascripts/discourse/tests/acceptance/personal-message-test.js b/app/assets/javascripts/discourse/tests/acceptance/personal-message-test.js index 1c84889cbf..0d0f58027d 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/personal-message-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/personal-message-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import I18n from "I18n"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -5,7 +6,7 @@ acceptance("Personal Message", { loggedIn: true, }); -QUnit.test("footer edit button", async (assert) => { +test("footer edit button", async (assert) => { await visit("/t/pm-for-testing/12"); assert.ok( @@ -14,7 +15,7 @@ QUnit.test("footer edit button", async (assert) => { ); }); -QUnit.test("suggested messages", async (assert) => { +test("suggested messages", async (assert) => { await visit("/t/pm-for-testing/12"); assert.equal( diff --git a/app/assets/javascripts/discourse/tests/acceptance/plugin-keyboard-shortcut-test.js b/app/assets/javascripts/discourse/tests/acceptance/plugin-keyboard-shortcut-test.js index f8f2b3c159..12717a15e3 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/plugin-keyboard-shortcut-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/plugin-keyboard-shortcut-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import { withPluginApi } from "discourse/lib/plugin-api"; import KeyboardShortcuts from "discourse/lib/keyboard-shortcuts"; diff --git a/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-connector-class-test.js b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-connector-class-test.js index 3d2628e0f1..d996bd8a04 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-connector-class-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-connector-class-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import { extraConnectorClass } from "discourse/lib/plugin-connectors"; import { action } from "@ember/object"; @@ -64,7 +65,7 @@ acceptance("Plugin Outlet - Connector Class", { }, }); -QUnit.test("Renders a template into the outlet", async (assert) => { +test("Renders a template into the outlet", async (assert) => { await visit("/u/eviltrout"); assert.ok( find(".user-profile-primary-outlet.hello").length === 1, diff --git a/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-decorator-test.js b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-decorator-test.js index c9612adfec..e295308115 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-decorator-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-decorator-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import { withPluginApi } from "discourse/lib/plugin-api"; @@ -38,24 +39,21 @@ acceptance("Plugin Outlet - Decorator", { }, }); -QUnit.test( - "Calls the plugin callback with the rendered outlet", - async (assert) => { - await visit("/"); +test("Calls the plugin callback with the rendered outlet", async (assert) => { + await visit("/"); - const fooConnector = find(".discovery-list-container-top-outlet.foo ")[0]; - const barConnector = find(".discovery-list-container-top-outlet.bar ")[0]; + const fooConnector = find(".discovery-list-container-top-outlet.foo ")[0]; + const barConnector = find(".discovery-list-container-top-outlet.bar ")[0]; - assert.ok(exists(fooConnector)); - assert.equal(fooConnector.style.backgroundColor, "yellow"); - assert.equal(barConnector.style.backgroundColor, ""); + assert.ok(exists(fooConnector)); + assert.equal(fooConnector.style.backgroundColor, "yellow"); + assert.equal(barConnector.style.backgroundColor, ""); - await visit("/c/bug"); + await visit("/c/bug"); - assert.ok(fooConnector.classList.contains("in-category")); + assert.ok(fooConnector.classList.contains("in-category")); - await visit("/"); + await visit("/"); - assert.notOk(fooConnector.classList.contains("in-category")); - } -); + assert.notOk(fooConnector.classList.contains("in-category")); +}); diff --git a/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-multi-template-test.js b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-multi-template-test.js index f806ab3453..6fedbb1505 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-multi-template-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-multi-template-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import { clearCache } from "discourse/lib/plugin-connectors"; @@ -23,7 +24,7 @@ acceptance("Plugin Outlet - Multi Template", { }, }); -QUnit.test("Renders a template into the outlet", async (assert) => { +test("Renders a template into the outlet", async (assert) => { await visit("/u/eviltrout"); assert.ok( find(".user-profile-primary-outlet.hello").length === 1, diff --git a/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-single-template-test.js b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-single-template-test.js index e98a67bade..68a30530a9 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-single-template-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-single-template-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; const CONNECTOR = @@ -14,7 +15,7 @@ acceptance("Plugin Outlet - Single Template", { }, }); -QUnit.test("Renders a template into the outlet", async (assert) => { +test("Renders a template into the outlet", async (assert) => { await visit("/u/eviltrout"); assert.ok( find(".user-profile-primary-outlet.hello").length === 1, diff --git a/app/assets/javascripts/discourse/tests/acceptance/post-admin-menu-test.js b/app/assets/javascripts/discourse/tests/acceptance/post-admin-menu-test.js index 81ed32c84b..bc80964a31 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/post-admin-menu-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/post-admin-menu-test.js @@ -1,8 +1,9 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Post - Admin Menu Anonymous Users", { loggedIn: false }); -QUnit.test("Enter as a anon user", async (assert) => { +test("Enter as a anon user", async (assert) => { await visit("/t/internationalization-localization/280"); await click(".show-more-actions"); @@ -19,17 +20,14 @@ QUnit.test("Enter as a anon user", async (assert) => { acceptance("Post - Admin Menu", { loggedIn: true }); -QUnit.test( - "Enter as a user with group moderator permissions", - async (assert) => { - await visit("/t/topic-for-group-moderators/2480"); - await click(".show-more-actions"); - await click(".show-post-admin-menu"); +test("Enter as a user with group moderator permissions", async (assert) => { + await visit("/t/topic-for-group-moderators/2480"); + await click(".show-more-actions"); + await click(".show-post-admin-menu"); - assert.ok( - exists("#post_1 .post-controls .edit"), - "The edit button was rendered" - ); - assert.ok(exists(".add-notice"), "The add notice button was rendered"); - } -); + assert.ok( + exists("#post_1 .post-controls .edit"), + "The edit button was rendered" + ); + assert.ok(exists(".add-notice"), "The add notice button was rendered"); +}); diff --git a/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js b/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js index 5dec56e8e4..82639e9f5e 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import I18n from "I18n"; import { acceptance, @@ -69,7 +70,7 @@ acceptance("User Preferences", { pretend: preferencesPretender, }); -QUnit.test("update some fields", async (assert) => { +test("update some fields", async (assert) => { await visit("/u/eviltrout/preferences"); assert.ok($("body.user-preferences-page").length, "has the body class"); @@ -124,12 +125,12 @@ QUnit.test("update some fields", async (assert) => { ); }); -QUnit.test("username", async (assert) => { +test("username", async (assert) => { await visit("/u/eviltrout/preferences/username"); assert.ok(exists("#change_username"), "it has the input element"); }); -QUnit.test("email", async (assert) => { +test("email", async (assert) => { await visit("/u/eviltrout/preferences/email"); assert.ok(exists("#change-email"), "it has the input element"); @@ -143,7 +144,7 @@ QUnit.test("email", async (assert) => { ); }); -QUnit.test("email field always shows up", async (assert) => { +test("email field always shows up", async (assert) => { await visit("/u/eviltrout/preferences/email"); assert.ok(exists("#change-email"), "it has the input element"); @@ -157,7 +158,7 @@ QUnit.test("email field always shows up", async (assert) => { assert.ok(exists("#change-email"), "it has the input element"); }); -QUnit.test("connected accounts", async (assert) => { +test("connected accounts", async (assert) => { await visit("/u/eviltrout/preferences/account"); assert.ok( @@ -178,7 +179,7 @@ QUnit.test("connected accounts", async (assert) => { .indexOf("Connect") > -1; }); -QUnit.test("second factor totp", async (assert) => { +test("second factor totp", async (assert) => { await visit("/u/eviltrout/preferences/second-factor"); assert.ok(exists("#password"), "it has a password input"); @@ -198,7 +199,7 @@ QUnit.test("second factor totp", async (assert) => { ); }); -QUnit.test("second factor security keys", async (assert) => { +test("second factor security keys", async (assert) => { await visit("/u/eviltrout/preferences/second-factor"); assert.ok(exists("#password"), "it has a password input"); @@ -224,7 +225,7 @@ QUnit.test("second factor security keys", async (assert) => { } }); -QUnit.test("default avatar selector", async (assert) => { +test("default avatar selector", async (assert) => { await visit("/u/eviltrout/preferences"); await click(".pref-avatar .btn"); @@ -260,7 +261,7 @@ acceptance("Second Factor Backups", { }); }, }); -QUnit.test("second factor backup", async (assert) => { +test("second factor backup", async (assert) => { updateCurrentUser({ second_factor_enabled: true }); await visit("/u/eviltrout/preferences/second-factor"); await click(".edit-2fa-backup"); @@ -287,7 +288,7 @@ acceptance("Avatar selector when selectable avatars is enabled", { }, }); -QUnit.test("selectable avatars", async (assert) => { +test("selectable avatars", async (assert) => { await visit("/u/eviltrout/preferences"); await click(".pref-avatar .btn"); @@ -301,7 +302,7 @@ acceptance("User Preferences when badges are disabled", { pretend: preferencesPretender, }); -QUnit.test("visit my preferences", async (assert) => { +test("visit my preferences", async (assert) => { await visit("/u/eviltrout/preferences"); assert.ok($("body.user-preferences-page").length, "has the body class"); assert.equal( @@ -312,7 +313,7 @@ QUnit.test("visit my preferences", async (assert) => { assert.ok(exists(".user-preferences"), "it shows the preferences"); }); -QUnit.test("recently connected devices", async (assert) => { +test("recently connected devices", async (assert) => { await visit("/u/eviltrout/preferences"); assert.equal( @@ -367,7 +368,7 @@ acceptance( } ); -QUnit.test("setting featured topic on profile", async (assert) => { +test("setting featured topic on profile", async (assert) => { await visit("/u/eviltrout/preferences/profile"); assert.ok( @@ -418,7 +419,7 @@ acceptance("Custom User Fields", { pretend: preferencesPretender, }); -QUnit.test("can select an option from a dropdown", async (assert) => { +test("can select an option from a dropdown", async (assert) => { await visit("/u/eviltrout/preferences/profile"); assert.ok(exists(".user-field"), "it has at least one user field"); await click(".user-field.dropdown"); @@ -441,22 +442,19 @@ acceptance( } ); -QUnit.test( - "selecting bookmarks as home directs home to bookmarks", - async (assert) => { - await visit("/u/eviltrout/preferences/interface"); - assert.ok(exists(".home .combo-box"), "it has a home selector combo-box"); +test("selecting bookmarks as home directs home to bookmarks", async (assert) => { + await visit("/u/eviltrout/preferences/interface"); + assert.ok(exists(".home .combo-box"), "it has a home selector combo-box"); - const field = selectKit(".home .combo-box"); - await field.expand(); - await field.selectRowByValue("6"); - await click(".save-changes"); - await visit("/"); - assert.ok(exists(".topic-list"), "The list of topics was rendered"); - assert.equal( - currentPath(), - "discovery.bookmarks", - "it navigates to bookmarks" - ); - } -); + const field = selectKit(".home .combo-box"); + await field.expand(); + await field.selectRowByValue("6"); + await click(".save-changes"); + await visit("/"); + assert.ok(exists(".topic-list"), "The list of topics was rendered"); + assert.equal( + currentPath(), + "discovery.bookmarks", + "it navigates to bookmarks" + ); +}); diff --git a/app/assets/javascripts/discourse/tests/acceptance/raw-plugin-outlet-test.js b/app/assets/javascripts/discourse/tests/acceptance/raw-plugin-outlet-test.js index 6c19832471..32705c3f77 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/raw-plugin-outlet-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/raw-plugin-outlet-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import compile from "handlebars-compiler"; import { @@ -21,7 +22,7 @@ acceptance("Raw Plugin Outlet", { }, }); -QUnit.test("Renders the raw plugin outlet", async (assert) => { +test("Renders the raw plugin outlet", async (assert) => { await visit("/"); assert.ok(find(".topic-lala").length > 0, "it renders the outlet"); assert.equal( diff --git a/app/assets/javascripts/discourse/tests/acceptance/redirect-to-top-test.js b/app/assets/javascripts/discourse/tests/acceptance/redirect-to-top-test.js index cd668878f6..17691af824 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/redirect-to-top-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/redirect-to-top-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance, updateCurrentUser, @@ -19,7 +20,7 @@ acceptance("Redirect to Top", { loggedIn: true, }); -QUnit.test("redirects categories to weekly top", async (assert) => { +test("redirects categories to weekly top", async (assert) => { updateCurrentUser({ should_be_redirected_to_top: true, redirected_to_top: { @@ -32,7 +33,7 @@ QUnit.test("redirects categories to weekly top", async (assert) => { assert.equal(currentPath(), "discovery.topWeekly", "it works for categories"); }); -QUnit.test("redirects latest to monthly top", async (assert) => { +test("redirects latest to monthly top", async (assert) => { updateCurrentUser({ should_be_redirected_to_top: true, redirected_to_top: { @@ -45,7 +46,7 @@ QUnit.test("redirects latest to monthly top", async (assert) => { assert.equal(currentPath(), "discovery.topMonthly", "it works for latest"); }); -QUnit.test("redirects root to All top", async (assert) => { +test("redirects root to All top", async (assert) => { updateCurrentUser({ should_be_redirected_to_top: true, redirected_to_top: { diff --git a/app/assets/javascripts/discourse/tests/acceptance/reports-test.js b/app/assets/javascripts/discourse/tests/acceptance/reports-test.js index 6d42d65240..7841043184 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/reports-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/reports-test.js @@ -1,10 +1,11 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Reports", { loggedIn: true, }); -QUnit.test("Visit reports page", async (assert) => { +test("Visit reports page", async (assert) => { await visit("/admin/reports"); assert.equal($(".reports-list .report").length, 1); @@ -19,7 +20,7 @@ QUnit.test("Visit reports page", async (assert) => { ); }); -QUnit.test("Visit report page", async (assert) => { +test("Visit report page", async (assert) => { await visit("/admin/reports/staff_logins"); assert.ok(exists(".export-csv-btn")); diff --git a/app/assets/javascripts/discourse/tests/acceptance/review-test.js b/app/assets/javascripts/discourse/tests/acceptance/review-test.js index 1821b2abdc..996dedcb22 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/review-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/review-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -7,7 +8,7 @@ acceptance("Review", { const user = ".reviewable-item[data-reviewable-id=1234]"; -QUnit.test("It returns a list of reviewable items", async (assert) => { +test("It returns a list of reviewable items", async (assert) => { await visit("/review"); assert.ok(find(".reviewable-item").length, "has a list of items"); @@ -26,7 +27,7 @@ QUnit.test("It returns a list of reviewable items", async (assert) => { ); }); -QUnit.test("Grouped by topic", async (assert) => { +test("Grouped by topic", async (assert) => { await visit("/review/topics"); assert.ok( find(".reviewable-topic").length, @@ -34,7 +35,7 @@ QUnit.test("Grouped by topic", async (assert) => { ); }); -QUnit.test("Settings", async (assert) => { +test("Settings", async (assert) => { await visit("/review/settings"); assert.ok(find(".reviewable-score-type").length, "has a list of bonuses"); @@ -47,7 +48,7 @@ QUnit.test("Settings", async (assert) => { assert.ok(find(".reviewable-settings .saved").length, "it saved"); }); -QUnit.test("Flag related", async (assert) => { +test("Flag related", async (assert) => { await visit("/review"); assert.ok( @@ -63,7 +64,7 @@ QUnit.test("Flag related", async (assert) => { assert.equal(find(".reviewable-flagged-post .reviewable-score").length, 2); }); -QUnit.test("Flag related", async (assert) => { +test("Flag related", async (assert) => { await visit("/review/1"); assert.ok( @@ -72,13 +73,13 @@ QUnit.test("Flag related", async (assert) => { ); }); -QUnit.test("Clicking the buttons triggers actions", async (assert) => { +test("Clicking the buttons triggers actions", async (assert) => { await visit("/review"); await click(`${user} .reviewable-action.approve`); assert.equal(find(user).length, 0, "it removes the reviewable on success"); }); -QUnit.test("Editing a reviewable", async (assert) => { +test("Editing a reviewable", async (assert) => { const topic = ".reviewable-item[data-reviewable-id=4321]"; await visit("/review"); assert.ok(find(`${topic} .reviewable-action.approve`).length); diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js index 717bd90b4c..00639c47d2 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js @@ -1,3 +1,5 @@ +import { skip } from "qunit"; +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { selectDate, @@ -87,7 +89,7 @@ acceptance("Search - Full Page", { }, }); -QUnit.test("perform various searches", async (assert) => { +test("perform various searches", async (assert) => { await visit("/search"); assert.ok($("body.search-page").length, "has body class"); @@ -107,7 +109,7 @@ QUnit.test("perform various searches", async (assert) => { assert.ok(find(".fps-topic").length === 1, "has one post"); }); -QUnit.test("escape search term", async (assert) => { +test("escape search term", async (assert) => { await visit("/search"); await fillIn(".search-query", "@gmail.com"); @@ -119,7 +121,7 @@ QUnit.test("escape search term", async (assert) => { ); }); -QUnit.skip("update username through advanced search ui", async (assert) => { +skip("update username through advanced search ui", async (assert) => { await visit("/search"); await fillIn(".search-query", "none"); await fillIn(".search-advanced-options .user-selector", "admin"); @@ -152,7 +154,7 @@ QUnit.skip("update username through advanced search ui", async (assert) => { }); }); -QUnit.test("update category through advanced search ui", async (assert) => { +test("update category through advanced search ui", async (assert) => { const categoryChooser = selectKit( ".search-advanced-options .category-chooser" ); @@ -176,106 +178,94 @@ QUnit.test("update category through advanced search ui", async (assert) => { ); }); -QUnit.test( - "update in:title filter through advanced search ui", - async (assert) => { - await visit("/search"); - await fillIn(".search-query", "none"); - await click(".search-advanced-options .in-title"); +test("update in:title filter through advanced search ui", async (assert) => { + await visit("/search"); + await fillIn(".search-query", "none"); + await click(".search-advanced-options .in-title"); - assert.ok( - exists(".search-advanced-options .in-title:checked"), - 'has "in title" populated' - ); - assert.equal( - find(".search-query").val(), - "none in:title", - 'has updated search term to "none in:title"' - ); + assert.ok( + exists(".search-advanced-options .in-title:checked"), + 'has "in title" populated' + ); + assert.equal( + find(".search-query").val(), + "none in:title", + 'has updated search term to "none in:title"' + ); - await fillIn(".search-query", "none in:titleasd"); + await fillIn(".search-query", "none in:titleasd"); - assert.not( - exists(".search-advanced-options .in-title:checked"), - "does not populate title only checkbox" - ); - } -); + assert.not( + exists(".search-advanced-options .in-title:checked"), + "does not populate title only checkbox" + ); +}); -QUnit.test( - "update in:likes filter through advanced search ui", - async (assert) => { - await visit("/search"); - await fillIn(".search-query", "none"); - await click(".search-advanced-options .in-likes"); +test("update in:likes filter through advanced search ui", async (assert) => { + await visit("/search"); + await fillIn(".search-query", "none"); + await click(".search-advanced-options .in-likes"); - assert.ok( - exists(".search-advanced-options .in-likes:checked"), - 'has "I liked" populated' - ); - assert.equal( - find(".search-query").val(), - "none in:likes", - 'has updated search term to "none in:likes"' - ); - } -); + assert.ok( + exists(".search-advanced-options .in-likes:checked"), + 'has "I liked" populated' + ); + assert.equal( + find(".search-query").val(), + "none in:likes", + 'has updated search term to "none in:likes"' + ); +}); -QUnit.test( - "update in:personal filter through advanced search ui", - async (assert) => { - await visit("/search"); - await fillIn(".search-query", "none"); - await click(".search-advanced-options .in-private"); +test("update in:personal filter through advanced search ui", async (assert) => { + await visit("/search"); + await fillIn(".search-query", "none"); + await click(".search-advanced-options .in-private"); - assert.ok( - exists(".search-advanced-options .in-private:checked"), - 'has "are in my messages" populated' - ); + assert.ok( + exists(".search-advanced-options .in-private:checked"), + 'has "are in my messages" populated' + ); - assert.equal( - find(".search-query").val(), - "none in:personal", - 'has updated search term to "none in:personal"' - ); + assert.equal( + find(".search-query").val(), + "none in:personal", + 'has updated search term to "none in:personal"' + ); - await fillIn(".search-query", "none in:personal-direct"); + await fillIn(".search-query", "none in:personal-direct"); - assert.not( - exists(".search-advanced-options .in-private:checked"), - "does not populate messages checkbox" - ); - } -); + assert.not( + exists(".search-advanced-options .in-private:checked"), + "does not populate messages checkbox" + ); +}); -QUnit.test( - "update in:seen filter through advanced search ui", - async (assert) => { - await visit("/search"); - await fillIn(".search-query", "none"); - await click(".search-advanced-options .in-seen"); +test("update in:seen filter through advanced search ui", async (assert) => { + await visit("/search"); + await fillIn(".search-query", "none"); + await click(".search-advanced-options .in-seen"); - assert.ok( - exists(".search-advanced-options .in-seen:checked"), - "it should check the right checkbox" - ); + assert.ok( + exists(".search-advanced-options .in-seen:checked"), + "it should check the right checkbox" + ); - assert.equal( - find(".search-query").val(), - "none in:seen", - "it should update the search term" - ); + assert.equal( + find(".search-query").val(), + "none in:seen", + "it should update the search term" + ); - await fillIn(".search-query", "none in:seenasdan"); + await fillIn(".search-query", "none in:seenasdan"); - assert.not( - exists(".search-advanced-options .in-seen:checked"), - "does not populate seen checkbox" - ); - } -); + assert.not( + exists(".search-advanced-options .in-seen:checked"), + "does not populate seen checkbox" + ); +}); -QUnit.test("update in filter through advanced search ui", async (assert) => { +test("update in filter through advanced search ui", async (assert) => { const inSelector = selectKit(".search-advanced-options .select-kit#in"); await visit("/search"); @@ -296,7 +286,7 @@ QUnit.test("update in filter through advanced search ui", async (assert) => { ); }); -QUnit.test("update status through advanced search ui", async (assert) => { +test("update status through advanced search ui", async (assert) => { const statusSelector = selectKit( ".search-advanced-options .select-kit#status" ); @@ -319,35 +309,29 @@ QUnit.test("update status through advanced search ui", async (assert) => { ); }); -QUnit.test( - "doesn't update status filter header if wrong value entered through searchbox", - async (assert) => { - const statusSelector = selectKit( - ".search-advanced-options .select-kit#status" - ); +test("doesn't update status filter header if wrong value entered through searchbox", async (assert) => { + const statusSelector = selectKit( + ".search-advanced-options .select-kit#status" + ); - await visit("/search"); + await visit("/search"); - await fillIn(".search-query", "status:none"); + await fillIn(".search-query", "status:none"); - assert.equal(statusSelector.header().label(), "any", 'has "any" populated'); - } -); + assert.equal(statusSelector.header().label(), "any", 'has "any" populated'); +}); -QUnit.test( - "doesn't update in filter header if wrong value entered through searchbox", - async (assert) => { - const inSelector = selectKit(".search-advanced-options .select-kit#in"); +test("doesn't update in filter header if wrong value entered through searchbox", async (assert) => { + const inSelector = selectKit(".search-advanced-options .select-kit#in"); - await visit("/search"); + await visit("/search"); - await fillIn(".search-query", "in:none"); + await fillIn(".search-query", "in:none"); - assert.equal(inSelector.header().label(), "any", 'has "any" populated'); - } -); + assert.equal(inSelector.header().label(), "any", 'has "any" populated'); +}); -QUnit.test("update post time through advanced search ui", async (assert) => { +test("update post time through advanced search ui", async (assert) => { await visit("/search?expanded=true&q=after:2018-08-22"); assert.equal( @@ -380,47 +364,41 @@ QUnit.test("update post time through advanced search ui", async (assert) => { ); }); -QUnit.test( - "update min post count through advanced search ui", - async (assert) => { - await visit("/search"); - await fillIn(".search-query", "none"); - await fillIn("#search-min-post-count", "5"); +test("update min post count through advanced search ui", async (assert) => { + await visit("/search"); + await fillIn(".search-query", "none"); + await fillIn("#search-min-post-count", "5"); - assert.equal( - find(".search-advanced-options #search-min-post-count").val(), - "5", - 'has "5" populated' - ); - assert.equal( - find(".search-query").val(), - "none min_posts:5", - 'has updated search term to "none min_posts:5"' - ); - } -); + assert.equal( + find(".search-advanced-options #search-min-post-count").val(), + "5", + 'has "5" populated' + ); + assert.equal( + find(".search-query").val(), + "none min_posts:5", + 'has updated search term to "none min_posts:5"' + ); +}); -QUnit.test( - "update max post count through advanced search ui", - async (assert) => { - await visit("/search"); - await fillIn(".search-query", "none"); - await fillIn("#search-max-post-count", "5"); +test("update max post count through advanced search ui", async (assert) => { + await visit("/search"); + await fillIn(".search-query", "none"); + await fillIn("#search-max-post-count", "5"); - assert.equal( - find(".search-advanced-options #search-max-post-count").val(), - "5", - 'has "5" populated' - ); - assert.equal( - find(".search-query").val(), - "none max_posts:5", - 'has updated search term to "none max_posts:5"' - ); - } -); + assert.equal( + find(".search-advanced-options #search-max-post-count").val(), + "5", + 'has "5" populated' + ); + assert.equal( + find(".search-query").val(), + "none max_posts:5", + 'has updated search term to "none max_posts:5"' + ); +}); -QUnit.test("validate advanced search when initially empty", async (assert) => { +test("validate advanced search when initially empty", async (assert) => { await visit("/search?expanded=true"); await click(".search-advanced-options .in-likes"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-mobile-test.js index f7e1e68d9d..e1d38800ae 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/search-mobile-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/search-mobile-test.js @@ -1,8 +1,9 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Search - Mobile", { mobileView: true }); -QUnit.test("search", async (assert) => { +test("search", async (assert) => { await visit("/"); await click("#search-button"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-test.js index 0f9cdc5a0f..6cfc09e267 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/search-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/search-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -17,7 +18,7 @@ let searchArgs = { acceptance("Search", searchArgs); -QUnit.test("search", async (assert) => { +test("search", async (assert) => { await visit("/"); await click("#search-button"); @@ -43,7 +44,7 @@ QUnit.test("search", async (assert) => { assert.ok(exists(".search-advanced-options"), "advanced search is expanded"); }); -QUnit.test("search for a tag", async (assert) => { +test("search for a tag", async (assert) => { await visit("/"); await click("#search-button"); @@ -53,7 +54,7 @@ QUnit.test("search for a tag", async (assert) => { assert.ok(exists(".search-menu .results ul li"), "it shows results"); }); -QUnit.test("search scope checkbox", async (assert) => { +test("search scope checkbox", async (assert) => { await visit("/tag/important"); await click("#search-button"); assert.ok( @@ -86,7 +87,7 @@ QUnit.test("search scope checkbox", async (assert) => { ); }); -QUnit.test("Search with context", async (assert) => { +test("Search with context", async (assert) => { await visit("/t/internationalization-localization/280/1"); await click("#search-button"); @@ -126,7 +127,7 @@ QUnit.test("Search with context", async (assert) => { assert.ok(!$(".search-context input[type=checkbox]").is(":checked")); }); -QUnit.test("Right filters are shown to anonymous users", async (assert) => { +test("Right filters are shown to anonymous users", async (assert) => { const inSelector = selectKit(".select-kit#in"); await visit("/search?expanded=true"); @@ -151,7 +152,7 @@ QUnit.test("Right filters are shown to anonymous users", async (assert) => { acceptance("Search", Object.assign({ loggedIn: true, searchArgs })); -QUnit.test("Right filters are shown to logged-in users", async (assert) => { +test("Right filters are shown to logged-in users", async (assert) => { const inSelector = selectKit(".select-kit#in"); await visit("/search?expanded=true"); @@ -183,7 +184,7 @@ acceptance( }) ); -QUnit.test("displays tags", async (assert) => { +test("displays tags", async (assert) => { await visit("/"); await click("#search-button"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/share-and-invite-desktop-test.js b/app/assets/javascripts/discourse/tests/acceptance/share-and-invite-desktop-test.js index 30a8881501..c2c12e5018 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/share-and-invite-desktop-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/share-and-invite-desktop-test.js @@ -1,10 +1,11 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Share and Invite modal - desktop", { loggedIn: true, }); -QUnit.test("Topic footer button", async (assert) => { +test("Topic footer button", async (assert) => { await visit("/t/internationalization-localization/280"); assert.ok( @@ -64,7 +65,7 @@ QUnit.test("Topic footer button", async (assert) => { ); }); -QUnit.test("Post date link", async (assert) => { +test("Post date link", async (assert) => { await visit("/t/internationalization-localization/280"); await click("#post_2 .post-info.post-date a"); @@ -78,17 +79,14 @@ acceptance("Share url with badges disabled - desktop", { }, }); -QUnit.test( - "topic footer button - badges disabled - desktop", - async (assert) => { - await visit("/t/internationalization-localization/280"); - await click("#topic-footer-button-share-and-invite"); +test("topic footer button - badges disabled - desktop", async (assert) => { + await visit("/t/internationalization-localization/280"); + await click("#topic-footer-button-share-and-invite"); - assert.notOk( - find(".share-and-invite.modal .modal-panel.share .topic-share-url") - .val() - .includes("?u=eviltrout"), - "it doesn't add the username param when badges are disabled" - ); - } -); + assert.notOk( + find(".share-and-invite.modal .modal-panel.share .topic-share-url") + .val() + .includes("?u=eviltrout"), + "it doesn't add the username param when badges are disabled" + ); +}); diff --git a/app/assets/javascripts/discourse/tests/acceptance/share-and-invite-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/share-and-invite-mobile-test.js index f8c180897f..f67a5203aa 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/share-and-invite-mobile-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/share-and-invite-mobile-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -6,7 +7,7 @@ acceptance("Share and Invite modal - mobile", { mobileView: true, }); -QUnit.test("Topic footer mobile button", async (assert) => { +test("Topic footer mobile button", async (assert) => { await visit("/t/internationalization-localization/280"); assert.ok( @@ -54,7 +55,7 @@ QUnit.test("Topic footer mobile button", async (assert) => { ); }); -QUnit.test("Post date link", async (assert) => { +test("Post date link", async (assert) => { await visit("/t/internationalization-localization/280"); await click("#post_2 .post-info.post-date a"); @@ -69,7 +70,7 @@ acceptance("Share url with badges disabled - mobile", { }, }); -QUnit.test("topic footer button - badges disabled - mobile", async (assert) => { +test("topic footer button - badges disabled - mobile", async (assert) => { await visit("/t/internationalization-localization/280"); const subject = selectKit(".topic-footer-mobile-dropdown"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/shared-drafts-test.js b/app/assets/javascripts/discourse/tests/acceptance/shared-drafts-test.js index 4bc854a636..caaceef158 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/shared-drafts-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/shared-drafts-test.js @@ -1,9 +1,10 @@ +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Shared Drafts", { loggedIn: true }); -QUnit.test("Viewing", async (assert) => { +test("Viewing", async (assert) => { await visit("/t/some-topic/9"); assert.ok(find(".shared-draft-controls").length === 1); let categoryChooser = selectKit(".shared-draft-controls .category-chooser"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/sign-in-test.js b/app/assets/javascripts/discourse/tests/acceptance/sign-in-test.js index 4ab6c6c43c..1f2e5adae5 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sign-in-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sign-in-test.js @@ -1,7 +1,9 @@ +import { skip } from "qunit"; +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Signing In"); -QUnit.test("sign in", async (assert) => { +test("sign in", async (assert) => { await visit("/"); await click("header .login-button"); assert.ok(exists(".login-modal"), "it shows the login modal"); @@ -25,7 +27,7 @@ QUnit.test("sign in", async (assert) => { ); }); -QUnit.test("sign in - not activated", async (assert) => { +test("sign in - not activated", async (assert) => { await visit("/"); await click("header .login-button"); assert.ok(exists(".login-modal"), "it shows the login modal"); @@ -47,7 +49,7 @@ QUnit.test("sign in - not activated", async (assert) => { assert.ok(!exists(".modal-body small"), "it escapes the email address"); }); -QUnit.test("sign in - not activated - edit email", async (assert) => { +test("sign in - not activated - edit email", async (assert) => { await visit("/"); await click("header .login-button"); assert.ok(exists(".login-modal"), "it shows the login modal"); @@ -68,7 +70,7 @@ QUnit.test("sign in - not activated - edit email", async (assert) => { assert.equal(find(".modal-body b").text(), "different@example.com"); }); -QUnit.skip("second factor", async (assert) => { +skip("second factor", async (assert) => { await visit("/"); await click("header .login-button"); @@ -101,7 +103,7 @@ QUnit.skip("second factor", async (assert) => { ); }); -QUnit.skip("security key", async (assert) => { +skip("security key", async (assert) => { await visit("/"); await click("header .login-button"); @@ -127,7 +129,7 @@ QUnit.skip("security key", async (assert) => { assert.not(exists("#login-button:visible"), "hides the login button"); }); -QUnit.test("create account", async (assert) => { +test("create account", async (assert) => { await visit("/"); await click("header .sign-up-button"); @@ -163,7 +165,7 @@ QUnit.test("create account", async (assert) => { ); }); -QUnit.test("second factor backup - valid token", async (assert) => { +test("second factor backup - valid token", async (assert) => { await visit("/"); await click("header .login-button"); await fillIn("#login-account-name", "eviltrout"); @@ -179,7 +181,7 @@ QUnit.test("second factor backup - valid token", async (assert) => { ); }); -QUnit.test("second factor backup - invalid token", async (assert) => { +test("second factor backup - invalid token", async (assert) => { await visit("/"); await click("header .login-button"); await fillIn("#login-account-name", "eviltrout"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/static-test.js b/app/assets/javascripts/discourse/tests/acceptance/static-test.js index 95fd895e6e..c201bc4c0f 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/static-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/static-test.js @@ -1,7 +1,8 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Static"); -QUnit.test("Static Pages", async (assert) => { +test("Static Pages", async (assert) => { await visit("/faq"); assert.ok($("body.static-faq").length, "has the body class"); assert.ok(exists(".body-page"), "The content is present"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/tag-groups-test.js b/app/assets/javascripts/discourse/tests/acceptance/tag-groups-test.js index 8dab630970..fe24a9bf5f 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/tag-groups-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/tag-groups-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -20,7 +21,7 @@ acceptance("Tag Groups", { }, }); -QUnit.test("tag groups can be saved and deleted", async (assert) => { +test("tag groups can be saved and deleted", async (assert) => { const tags = selectKit(".tag-chooser"); await visit("/tag_groups"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/tags-intersection-test.js b/app/assets/javascripts/discourse/tests/acceptance/tags-intersection-test.js index 5363beb8da..cf7f7a26b2 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/tags-intersection-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/tags-intersection-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Tags intersection", { @@ -28,7 +29,7 @@ acceptance("Tags intersection", { }, }); -QUnit.test("Populate tags when creating new topic", async (assert) => { +test("Populate tags when creating new topic", async (assert) => { await visit("/tags/intersection/first/second"); await click("#create-topic"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/tags-test.js b/app/assets/javascripts/discourse/tests/acceptance/tags-test.js index e1da1c0a29..81226a4730 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/tags-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/tags-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { updateCurrentUser, acceptance, @@ -6,7 +7,7 @@ import pretender from "discourse/tests/helpers/create-pretender"; acceptance("Tags", { loggedIn: true }); -QUnit.test("list the tags", async (assert) => { +test("list the tags", async (assert) => { await visit("/tags"); assert.ok($("body.tags-page").length, "has the body class"); @@ -23,7 +24,7 @@ acceptance("Tags listed by group", { }, }); -QUnit.test("list the tags in groups", async (assert) => { +test("list the tags in groups", async (assert) => { await visit("/tags"); assert.equal( $(".tag-list").length, diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-admin-menu-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-admin-menu-test.js index f6f25b7c9a..9cc2605aa3 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-admin-menu-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-admin-menu-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance, updateCurrentUser, @@ -5,7 +6,7 @@ import { acceptance("Topic - Admin Menu Anonymous Users", { loggedIn: false }); -QUnit.test("Enter as a regular user", async (assert) => { +test("Enter as a regular user", async (assert) => { await visit("/t/internationalization-localization/280"); assert.ok(exists("#topic"), "The topic was rendered"); assert.ok( @@ -16,46 +17,31 @@ QUnit.test("Enter as a regular user", async (assert) => { acceptance("Topic - Admin Menu", { loggedIn: true }); -QUnit.test( - "Enter as a user with group moderator permissions", - async (assert) => { - updateCurrentUser({ moderator: false, admin: false, trust_level: 1 }); +test("Enter as a user with group moderator permissions", async (assert) => { + updateCurrentUser({ moderator: false, admin: false, trust_level: 1 }); - await visit("/t/topic-for-group-moderators/2480"); - assert.ok(exists("#topic"), "The topic was rendered"); - assert.ok( - exists(".toggle-admin-menu"), - "The admin menu button was rendered" - ); - } -); + await visit("/t/topic-for-group-moderators/2480"); + assert.ok(exists("#topic"), "The topic was rendered"); + assert.ok(exists(".toggle-admin-menu"), "The admin menu button was rendered"); +}); -QUnit.test( - "Enter as a user with moderator and admin permissions", - async (assert) => { - updateCurrentUser({ moderator: true, admin: true, trust_level: 4 }); +test("Enter as a user with moderator and admin permissions", async (assert) => { + updateCurrentUser({ moderator: true, admin: true, trust_level: 4 }); - await visit("/t/internationalization-localization/280"); - assert.ok(exists("#topic"), "The topic was rendered"); - assert.ok( - exists(".toggle-admin-menu"), - "The admin menu button was rendered" - ); - } -); + await visit("/t/internationalization-localization/280"); + assert.ok(exists("#topic"), "The topic was rendered"); + assert.ok(exists(".toggle-admin-menu"), "The admin menu button was rendered"); +}); -QUnit.test( - "Toggle the menu as admin focuses the first item", - async (assert) => { - updateCurrentUser({ admin: true }); +test("Toggle the menu as admin focuses the first item", async (assert) => { + updateCurrentUser({ admin: true }); - await visit("/t/internationalization-localization/280"); - assert.ok(exists("#topic"), "The topic was rendered"); - await click(".toggle-admin-menu"); + await visit("/t/internationalization-localization/280"); + assert.ok(exists("#topic"), "The topic was rendered"); + await click(".toggle-admin-menu"); - assert.equal( - document.activeElement, - document.querySelector(".topic-admin-multi-select > button") - ); - } -); + assert.equal( + document.activeElement, + document.querySelector(".topic-admin-multi-select > button") + ); +}); diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-anonymous-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-anonymous-test.js index b989b10efc..477e2fe579 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-anonymous-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-anonymous-test.js @@ -1,7 +1,8 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Topic - Anonymous"); -QUnit.test("Enter a Topic", async (assert) => { +test("Enter a Topic", async (assert) => { await visit("/t/internationalization-localization/280/1"); assert.ok(exists("#topic"), "The topic was rendered"); assert.ok(exists("#topic .cooked"), "The topic has cooked posts"); @@ -11,24 +12,24 @@ QUnit.test("Enter a Topic", async (assert) => { ); }); -QUnit.test("Enter without an id", async (assert) => { +test("Enter without an id", async (assert) => { await visit("/t/internationalization-localization"); assert.ok(exists("#topic"), "The topic was rendered"); }); -QUnit.test("Enter a 404 topic", async (assert) => { +test("Enter a 404 topic", async (assert) => { await visit("/t/not-found/404"); assert.ok(!exists("#topic"), "The topic was not rendered"); assert.ok(exists(".topic-error"), "An error message is displayed"); }); -QUnit.test("Enter without access", async (assert) => { +test("Enter without access", async (assert) => { await visit("/t/i-dont-have-access/403"); assert.ok(!exists("#topic"), "The topic was not rendered"); assert.ok(exists(".topic-error"), "An error message is displayed"); }); -QUnit.test("Enter with 500 errors", async (assert) => { +test("Enter with 500 errors", async (assert) => { await visit("/t/throws-error/500"); assert.ok(!exists("#topic"), "The topic was not rendered"); assert.ok(exists(".topic-error"), "An error message is displayed"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-test.js index bd9a8c826b..5b2b32e529 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import DiscourseURL from "discourse/lib/url"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -9,7 +10,7 @@ acceptance("Topic Discovery", { }, }); -QUnit.test("Visit Discovery Pages", async (assert) => { +test("Visit Discovery Pages", async (assert) => { await visit("/"); assert.ok($("body.navigation-topics").length, "has the default navigation"); assert.ok(exists(".topic-list"), "The list of topics was rendered"); @@ -68,7 +69,7 @@ QUnit.test("Visit Discovery Pages", async (assert) => { ); }); -QUnit.test("Clearing state after leaving a category", async (assert) => { +test("Clearing state after leaving a category", async (assert) => { await visit("/c/dev"); assert.ok( exists(".topic-list-item[data-topic-id=11994] .topic-excerpt"), @@ -81,7 +82,7 @@ QUnit.test("Clearing state after leaving a category", async (assert) => { ); }); -QUnit.test("Live update unread state", async (assert) => { +test("Live update unread state", async (assert) => { await visit("/"); assert.ok( exists(".topic-list-item:not(.visited) a[data-topic-id='11995']"), @@ -110,21 +111,18 @@ QUnit.test("Live update unread state", async (assert) => { ); }); -QUnit.test( - "Using period chooser when query params are present", - async (assert) => { - await visit("/top?f=foo&d=bar"); +test("Using period chooser when query params are present", async (assert) => { + await visit("/top?f=foo&d=bar"); - sandbox.stub(DiscourseURL, "routeTo"); + sandbox.stub(DiscourseURL, "routeTo"); - const periodChooser = selectKit(".period-chooser"); + const periodChooser = selectKit(".period-chooser"); - await periodChooser.expand(); - await periodChooser.selectRowByValue("yearly"); + await periodChooser.expand(); + await periodChooser.selectRowByValue("yearly"); - assert.ok( - DiscourseURL.routeTo.calledWith("/top/yearly?f=foo&d=bar"), - "it keeps the query params" - ); - } -); + assert.ok( + DiscourseURL.routeTo.calledWith("/top/yearly?f=foo&d=bar"), + "it keeps the query params" + ); +}); diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-edit-timer-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-edit-timer-test.js index 20a3554cec..125fab78fa 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-edit-timer-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-edit-timer-test.js @@ -1,3 +1,5 @@ +import { skip } from "qunit"; +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance, @@ -22,7 +24,7 @@ acceptance("Topic - Edit timer", { }, }); -QUnit.test("default", async (assert) => { +test("default", async (assert) => { updateCurrentUser({ moderator: true }); const futureDateInputSelector = selectKit(".future-date-input-selector"); @@ -34,7 +36,7 @@ QUnit.test("default", async (assert) => { assert.equal(futureDateInputSelector.header().value(), null); }); -QUnit.test("autoclose - specific time", async (assert) => { +test("autoclose - specific time", async (assert) => { updateCurrentUser({ moderator: true }); const futureDateInputSelector = selectKit(".future-date-input-selector"); @@ -53,7 +55,7 @@ QUnit.test("autoclose - specific time", async (assert) => { assert.ok(regex.test(html)); }); -QUnit.skip("autoclose", async (assert) => { +skip("autoclose", async (assert) => { updateCurrentUser({ moderator: true }); const futureDateInputSelector = selectKit(".future-date-input-selector"); @@ -106,7 +108,7 @@ QUnit.skip("autoclose", async (assert) => { assert.ok(regex3.test(html3)); }); -QUnit.test("close temporarily", async (assert) => { +test("close temporarily", async (assert) => { updateCurrentUser({ moderator: true }); const timerType = selectKit(".select-kit.timer-type"); const futureDateInputSelector = selectKit(".future-date-input-selector"); @@ -144,7 +146,7 @@ QUnit.test("close temporarily", async (assert) => { assert.ok(regex2.test(html2)); }); -QUnit.test("schedule", async (assert) => { +test("schedule", async (assert) => { updateCurrentUser({ moderator: true }); const timerType = selectKit(".select-kit.timer-type"); const categoryChooser = selectKit(".modal-body .category-chooser"); @@ -177,7 +179,7 @@ QUnit.test("schedule", async (assert) => { assert.ok(regex.test(text)); }); -QUnit.test("TL4 can't auto-delete", async (assert) => { +test("TL4 can't auto-delete", async (assert) => { updateCurrentUser({ moderator: false, admin: false, trust_level: 4 }); await visit("/t/internationalization-localization"); @@ -191,7 +193,7 @@ QUnit.test("TL4 can't auto-delete", async (assert) => { assert.ok(!timerType.rowByValue("delete").exists()); }); -QUnit.test("auto delete", async (assert) => { +test("auto delete", async (assert) => { updateCurrentUser({ moderator: true }); const timerType = selectKit(".select-kit.timer-type"); const futureDateInputSelector = selectKit(".future-date-input-selector"); @@ -217,7 +219,7 @@ QUnit.test("auto delete", async (assert) => { assert.ok(regex.test(html)); }); -QUnit.test("Inline delete timer", async (assert) => { +test("Inline delete timer", async (assert) => { updateCurrentUser({ moderator: true }); const futureDateInputSelector = selectKit(".future-date-input-selector"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-footer-buttons-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-footer-buttons-mobile-test.js index 8e160e07e4..9f9c20b196 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-footer-buttons-mobile-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-footer-buttons-mobile-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import I18n from "I18n"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { withPluginApi } from "discourse/lib/plugin-api"; @@ -35,7 +36,7 @@ acceptance("Topic footer buttons mobile", { }, }); -QUnit.test("default", async (assert) => { +test("default", async (assert) => { await visit("/t/internationalization-localization/280"); assert.equal(_test, null); diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-list-tracker-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-list-tracker-test.js index 5ddb9860fd..c19784c9ce 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-list-tracker-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-list-tracker-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import { nextTopicUrl, @@ -6,7 +7,7 @@ import { } from "discourse/lib/topic-list-tracker"; acceptance("Topic list tracking"); -QUnit.test("Navigation", async (assert) => { +test("Navigation", async (assert) => { await visit("/"); let url = await nextTopicUrl(); assert.equal(url, "/t/error-after-upgrade-to-0-9-7-9/11557"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-move-posts-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-move-posts-test.js index ee0e48cc33..4c35d63b9e 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-move-posts-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-move-posts-test.js @@ -1,8 +1,9 @@ +import { test } from "qunit"; import I18n from "I18n"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Topic move posts", { loggedIn: true }); -QUnit.test("default", async (assert) => { +test("default", async (assert) => { await visit("/t/internationalization-localization"); await click(".toggle-admin-menu"); await click(".topic-admin-multi-select .btn"); @@ -45,7 +46,7 @@ QUnit.test("default", async (assert) => { ); }); -QUnit.test("moving all posts", async (assert) => { +test("moving all posts", async (assert) => { await visit("/t/internationalization-localization"); await click(".toggle-admin-menu"); await click(".topic-admin-multi-select .btn"); @@ -81,7 +82,7 @@ QUnit.test("moving all posts", async (assert) => { ); }); -QUnit.test("moving posts from personal message", async (assert) => { +test("moving posts from personal message", async (assert) => { await visit("/t/pm-for-testing/12"); await click(".toggle-admin-menu"); await click(".topic-admin-multi-select .btn"); @@ -117,7 +118,7 @@ QUnit.test("moving posts from personal message", async (assert) => { ); }); -QUnit.test("group moderator moving posts", async (assert) => { +test("group moderator moving posts", async (assert) => { await visit("/t/topic-for-group-moderators/2480"); await click(".toggle-admin-menu"); await click(".topic-admin-multi-select .btn"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-notifications-button-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-notifications-button-test.js index f77ecd1a30..0b91fe4ecb 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-notifications-button-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-notifications-button-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import selectKit from "discourse/tests/helpers/select-kit-helper"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -10,7 +11,7 @@ acceptance("Topic Notifications button", { }, }); -QUnit.test("Updating topic notification level", async (assert) => { +test("Updating topic notification level", async (assert) => { const notificationOptions = selectKit( "#topic-footer-buttons .topic-notifications-options" ); diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js index 4068e04bbe..fff821e3ae 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import I18n from "I18n"; import { acceptance } from "discourse/tests/helpers/qunit-helpers"; @@ -19,39 +20,33 @@ acceptance("Topic - Quote button - logged in", { }, }); -QUnit.test( - "Does not show the quote share buttons by default", - async (assert) => { - await visit("/t/internationalization-localization/280"); - selectText("#post_5 blockquote"); - assert.ok(exists(".insert-quote"), "it shows the quote button"); - assert.equal( - find(".quote-sharing").length, - 0, - "it does not show quote sharing" - ); - } -); +test("Does not show the quote share buttons by default", async (assert) => { + await visit("/t/internationalization-localization/280"); + selectText("#post_5 blockquote"); + assert.ok(exists(".insert-quote"), "it shows the quote button"); + assert.equal( + find(".quote-sharing").length, + 0, + "it does not show quote sharing" + ); +}); -QUnit.test( - "Shows quote share buttons with the right site settings", - async function (assert) { - this.siteSettings.share_quote_visibility = "all"; +test("Shows quote share buttons with the right site settings", async function (assert) { + this.siteSettings.share_quote_visibility = "all"; - await visit("/t/internationalization-localization/280"); - selectText("#post_5 blockquote"); + await visit("/t/internationalization-localization/280"); + selectText("#post_5 blockquote"); - assert.ok(exists(".quote-sharing"), "it shows the quote sharing options"); - assert.ok( - exists(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`), - "it includes the twitter share button" - ); - assert.ok( - exists(`.quote-sharing .btn[title='${I18n.t("share.email")}']`), - "it includes the email share button" - ); - } -); + assert.ok(exists(".quote-sharing"), "it shows the quote sharing options"); + assert.ok( + exists(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`), + "it includes the twitter share button" + ); + assert.ok( + exists(`.quote-sharing .btn[title='${I18n.t("share.email")}']`), + "it includes the email share button" + ); +}); acceptance("Topic - Quote button - anonymous", { loggedIn: false, @@ -61,53 +56,45 @@ acceptance("Topic - Quote button - anonymous", { }, }); -QUnit.test( - "Shows quote share buttons with the right site settings", - async function (assert) { - await visit("/t/internationalization-localization/280"); - selectText("#post_5 blockquote"); +test("Shows quote share buttons with the right site settings", async function (assert) { + await visit("/t/internationalization-localization/280"); + selectText("#post_5 blockquote"); - assert.ok(find(".quote-sharing"), "it shows the quote sharing options"); - assert.ok( - exists(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`), - "it includes the twitter share button" - ); - assert.ok( - exists(`.quote-sharing .btn[title='${I18n.t("share.email")}']`), - "it includes the email share button" - ); - assert.equal( - find(".insert-quote").length, - 0, - "it does not show the quote button" - ); - } -); + assert.ok(find(".quote-sharing"), "it shows the quote sharing options"); + assert.ok( + exists(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`), + "it includes the twitter share button" + ); + assert.ok( + exists(`.quote-sharing .btn[title='${I18n.t("share.email")}']`), + "it includes the email share button" + ); + assert.equal( + find(".insert-quote").length, + 0, + "it does not show the quote button" + ); +}); -QUnit.test( - "Shows single share button when site setting only has one item", - async function (assert) { - this.siteSettings.share_quote_buttons = "twitter"; +test("Shows single share button when site setting only has one item", async function (assert) { + this.siteSettings.share_quote_buttons = "twitter"; - await visit("/t/internationalization-localization/280"); - selectText("#post_5 blockquote"); + await visit("/t/internationalization-localization/280"); + selectText("#post_5 blockquote"); - assert.ok(exists(".quote-sharing"), "it shows the quote sharing options"); - assert.ok( - exists(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`), - "it includes the twitter share button" - ); - assert.equal( - find(".quote-share-label").length, - 0, - "it does not show the Share label" - ); - } -); + assert.ok(exists(".quote-sharing"), "it shows the quote sharing options"); + assert.ok( + exists(`.quote-sharing .btn[title='${I18n.t("share.twitter")}']`), + "it includes the twitter share button" + ); + assert.equal( + find(".quote-share-label").length, + 0, + "it does not show the Share label" + ); +}); -QUnit.test("Shows nothing when visibility is disabled", async function ( - assert -) { +test("Shows nothing when visibility is disabled", async function (assert) { this.siteSettings.share_quote_visibility = "none"; await visit("/t/internationalization-localization/280"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-test.js index 5d05288ee0..091e4564da 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-test.js @@ -1,3 +1,5 @@ +import { skip } from "qunit"; +import { test } from "qunit"; import I18n from "I18n"; import { withPluginApi } from "discourse/lib/plugin-api"; import selectKit from "discourse/tests/helpers/select-kit-helper"; @@ -13,7 +15,7 @@ acceptance("Topic", { }, }); -QUnit.test("Reply as new topic", async (assert) => { +test("Reply as new topic", async (assert) => { await visit("/t/internationalization-localization/280"); await click("button.share:eq(0)"); await click(".reply-as-new-topic a"); @@ -32,7 +34,7 @@ QUnit.test("Reply as new topic", async (assert) => { ); }); -QUnit.test("Reply as new message", async (assert) => { +test("Reply as new message", async (assert) => { await visit("/t/pm-for-testing/12"); await click("button.share:eq(0)"); await click(".reply-as-new-topic a"); @@ -66,14 +68,14 @@ QUnit.test("Reply as new message", async (assert) => { ); }); -QUnit.test("Share Modal", async (assert) => { +test("Share Modal", async (assert) => { await visit("/t/internationalization-localization/280"); await click(".topic-post:first-child button.share"); assert.ok(exists("#share-link"), "it shows the share modal"); }); -QUnit.test("Showing and hiding the edit controls", async (assert) => { +test("Showing and hiding the edit controls", async (assert) => { await visit("/t/internationalization-localization/280"); await click("#topic-title .d-icon-pencil-alt"); @@ -89,7 +91,7 @@ QUnit.test("Showing and hiding the edit controls", async (assert) => { assert.ok(!exists("#edit-title"), "it hides the editing controls"); }); -QUnit.test("Updating the topic title and category", async (assert) => { +test("Updating the topic title and category", async (assert) => { const categoryChooser = selectKit(".title-wrapper .category-chooser"); await visit("/t/internationalization-localization/280"); @@ -112,7 +114,7 @@ QUnit.test("Updating the topic title and category", async (assert) => { ); }); -QUnit.test("Marking a topic as wiki", async (assert) => { +test("Marking a topic as wiki", async (assert) => { await visit("/t/internationalization-localization/280"); assert.ok(find("a.wiki").length === 0, "it does not show the wiki icon"); @@ -124,7 +126,7 @@ QUnit.test("Marking a topic as wiki", async (assert) => { assert.ok(find("a.wiki").length === 1, "it shows the wiki icon"); }); -QUnit.test("Visit topic routes", async (assert) => { +test("Visit topic routes", async (assert) => { await visit("/t/12"); assert.equal( @@ -142,7 +144,7 @@ QUnit.test("Visit topic routes", async (assert) => { ); }); -QUnit.test("Updating the topic title with emojis", async (assert) => { +test("Updating the topic title with emojis", async (assert) => { await visit("/t/internationalization-localization/280"); await click("#topic-title .d-icon-pencil-alt"); @@ -157,7 +159,7 @@ QUnit.test("Updating the topic title with emojis", async (assert) => { ); }); -QUnit.test("Updating the topic title with unicode emojis", async (assert) => { +test("Updating the topic title with unicode emojis", async (assert) => { await visit("/t/internationalization-localization/280"); await click("#topic-title .d-icon-pencil-alt"); @@ -172,26 +174,23 @@ QUnit.test("Updating the topic title with unicode emojis", async (assert) => { ); }); -QUnit.test( - "Updating the topic title with unicode emojis without whitespaces", - async function (assert) { - this.siteSettings.enable_inline_emoji_translation = true; - await visit("/t/internationalization-localization/280"); - await click("#topic-title .d-icon-pencil-alt"); +test("Updating the topic title with unicode emojis without whitespaces", async function (assert) { + this.siteSettings.enable_inline_emoji_translation = true; + await visit("/t/internationalization-localization/280"); + await click("#topic-title .d-icon-pencil-alt"); - await fillIn("#edit-title", "Test🙂Title"); + await fillIn("#edit-title", "Test🙂Title"); - await click("#topic-title .submit-edit"); + await click("#topic-title .submit-edit"); - assert.equal( - find(".fancy-title").html().trim(), - `Test
Title`,
- "it displays the new title with escaped unicode emojis"
- );
- }
-);
+ assert.equal(
+ find(".fancy-title").html().trim(),
+ `Test
Title`,
+ "it displays the new title with escaped unicode emojis"
+ );
+});
-QUnit.test("Suggested topics", async (assert) => {
+test("Suggested topics", async (assert) => {
await visit("/t/internationalization-localization/280");
assert.equal(
@@ -200,7 +199,7 @@ QUnit.test("Suggested topics", async (assert) => {
);
});
-QUnit.skip("Deleting a topic", async (assert) => {
+skip("Deleting a topic", async (assert) => {
await visit("/t/internationalization-localization/280");
await click(".topic-post:eq(0) button.show-more-actions");
await click(".widget-button.delete");
@@ -208,7 +207,7 @@ QUnit.skip("Deleting a topic", async (assert) => {
assert.ok(exists(".widget-button.recover"), "it shows the recover button");
});
-QUnit.test("Group category moderator posts", async (assert) => {
+test("Group category moderator posts", async (assert) => {
await visit("/t/topic-for-group-moderators/2480");
assert.ok(exists(".category-moderator"), "it has a class applied");
@@ -223,7 +222,7 @@ acceptance("Topic featured links", {
},
});
-QUnit.skip("remove featured link", async (assert) => {
+skip("remove featured link", async (assert) => {
await visit("/t/-/299/1");
assert.ok(
exists(".title-wrapper .topic-featured-link"),
@@ -241,7 +240,7 @@ QUnit.skip("remove featured link", async (assert) => {
assert.ok(!exists(".title-wrapper .topic-featured-link"), "link is gone");
});
-QUnit.test("Converting to a public topic", async (assert) => {
+test("Converting to a public topic", async (assert) => {
await visit("/t/test-pm/34");
assert.ok(exists(".private_message"));
await click(".toggle-admin-menu");
@@ -255,7 +254,7 @@ QUnit.test("Converting to a public topic", async (assert) => {
assert.ok(!exists(".private_message"));
});
-QUnit.test("Unpinning unlisted topic", async (assert) => {
+test("Unpinning unlisted topic", async (assert) => {
await visit("/t/internationalization-localization/280");
await click(".toggle-admin-menu");
@@ -269,7 +268,7 @@ QUnit.test("Unpinning unlisted topic", async (assert) => {
assert.ok(exists(".topic-admin-pin"), "it should show the multi select menu");
});
-QUnit.test("selecting posts", async (assert) => {
+test("selecting posts", async (assert) => {
await visit("/t/internationalization-localization/280");
await click(".toggle-admin-menu");
await click(".topic-admin-multi-select .btn");
@@ -285,7 +284,7 @@ QUnit.test("selecting posts", async (assert) => {
);
});
-QUnit.test("select below", async (assert) => {
+test("select below", async (assert) => {
await visit("/t/internationalization-localization/280");
await click(".toggle-admin-menu");
await click(".topic-admin-multi-select .btn");
@@ -308,7 +307,7 @@ QUnit.test("select below", async (assert) => {
);
});
-QUnit.test("View Hidden Replies", async (assert) => {
+test("View Hidden Replies", async (assert) => {
await visit("/t/internationalization-localization/280");
await click(".gap");
@@ -325,7 +324,7 @@ function selectText(selector) {
selection.addRange(range);
}
-QUnit.test("Quoting a quote keeps the original poster name", async (assert) => {
+test("Quoting a quote keeps the original poster name", async (assert) => {
await visit("/t/internationalization-localization/280");
selectText("#post_5 blockquote");
await click(".quote-button .insert-quote");
@@ -337,68 +336,56 @@ QUnit.test("Quoting a quote keeps the original poster name", async (assert) => {
);
});
-QUnit.test(
- "Quoting a quote of a different topic keeps the original topic title",
- async (assert) => {
- await visit("/t/internationalization-localization/280");
- selectText("#post_9 blockquote");
- await click(".quote-button .insert-quote");
+test("Quoting a quote of a different topic keeps the original topic title", async (assert) => {
+ await visit("/t/internationalization-localization/280");
+ selectText("#post_9 blockquote");
+ await click(".quote-button .insert-quote");
- assert.ok(
- find(".d-editor-input")
- .val()
- .indexOf(
- 'quote="A new topic with a link to another topic, post:3, topic:62"'
- ) !== -1
- );
- }
-);
+ assert.ok(
+ find(".d-editor-input")
+ .val()
+ .indexOf(
+ 'quote="A new topic with a link to another topic, post:3, topic:62"'
+ ) !== -1
+ );
+});
-QUnit.test(
- "Quoting a quote with the Reply button keeps the original poster name",
- async (assert) => {
- await visit("/t/internationalization-localization/280");
- selectText("#post_5 blockquote");
- await click(".reply");
+test("Quoting a quote with the Reply button keeps the original poster name", async (assert) => {
+ await visit("/t/internationalization-localization/280");
+ selectText("#post_5 blockquote");
+ await click(".reply");
- assert.ok(
- find(".d-editor-input")
- .val()
- .indexOf('quote="codinghorror said, post:3, topic:280"') !== -1
- );
- }
-);
+ assert.ok(
+ find(".d-editor-input")
+ .val()
+ .indexOf('quote="codinghorror said, post:3, topic:280"') !== -1
+ );
+});
-QUnit.test(
- "Quoting a quote with replyAsNewTopic keeps the original poster name",
- async (assert) => {
- await visit("/t/internationalization-localization/280");
- selectText("#post_5 blockquote");
- await keyEvent(document, "keypress", "j".charCodeAt(0));
- await keyEvent(document, "keypress", "t".charCodeAt(0));
+test("Quoting a quote with replyAsNewTopic keeps the original poster name", async (assert) => {
+ await visit("/t/internationalization-localization/280");
+ selectText("#post_5 blockquote");
+ await keyEvent(document, "keypress", "j".charCodeAt(0));
+ await keyEvent(document, "keypress", "t".charCodeAt(0));
- assert.ok(
- find(".d-editor-input")
- .val()
- .indexOf('quote="codinghorror said, post:3, topic:280"') !== -1
- );
- }
-);
+ assert.ok(
+ find(".d-editor-input")
+ .val()
+ .indexOf('quote="codinghorror said, post:3, topic:280"') !== -1
+ );
+});
-QUnit.test(
- "Quoting by selecting text can mark the quote as full",
- async (assert) => {
- await visit("/t/internationalization-localization/280");
- selectText("#post_5 .cooked");
- await click(".quote-button .insert-quote");
+test("Quoting by selecting text can mark the quote as full", async (assert) => {
+ await visit("/t/internationalization-localization/280");
+ selectText("#post_5 .cooked");
+ await click(".quote-button .insert-quote");
- assert.ok(
- find(".d-editor-input")
- .val()
- .indexOf('quote="pekka, post:5, topic:280, full:true"') !== -1
- );
- }
-);
+ assert.ok(
+ find(".d-editor-input")
+ .val()
+ .indexOf('quote="pekka, post:5, topic:280, full:true"') !== -1
+ );
+});
acceptance("Topic with title decorated", {
loggedIn: true,
@@ -411,7 +398,7 @@ acceptance("Topic with title decorated", {
},
});
-QUnit.test("Decorate topic title", async (assert) => {
+test("Decorate topic title", async (assert) => {
await visit("/t/internationalization-localization/280");
assert.ok(
diff --git a/app/assets/javascripts/discourse/tests/acceptance/unknown-test.js b/app/assets/javascripts/discourse/tests/acceptance/unknown-test.js
index 107e8891f1..f762eb2851 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/unknown-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/unknown-test.js
@@ -1,13 +1,14 @@
+import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import pretender from "discourse/tests/helpers/create-pretender";
acceptance("Unknown");
-QUnit.test("Permalink Unknown URL", async (assert) => {
+test("Permalink Unknown URL", async (assert) => {
await visit("/url-that-doesn't-exist");
assert.ok(exists(".page-not-found"), "The not found content is present");
});
-QUnit.test("Permalink URL to a Topic", async (assert) => {
+test("Permalink URL to a Topic", async (assert) => {
pretender.get("/permalink-check.json", () => {
return [
200,
@@ -24,7 +25,7 @@ QUnit.test("Permalink URL to a Topic", async (assert) => {
assert.ok(exists(".topic-post"));
});
-QUnit.test("Permalink URL to a static page", async (assert) => {
+test("Permalink URL to a static page", async (assert) => {
pretender.get("/permalink-check.json", () => {
return [
200,
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-anonymous-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-anonymous-test.js
index e2b04d175d..91ff16297c 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-anonymous-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-anonymous-test.js
@@ -1,3 +1,4 @@
+import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("User Anonymous");
@@ -11,13 +12,13 @@ function hasTopicList(assert) {
assert.ok(count(".topic-list tr") > 0, "it has a topic list");
}
-QUnit.test("Root URL", async (assert) => {
+test("Root URL", async (assert) => {
await visit("/u/eviltrout");
assert.ok($("body.user-summary-page").length, "has the body class");
assert.equal(currentPath(), "user.summary", "it defaults to summary");
});
-QUnit.test("Filters", async (assert) => {
+test("Filters", async (assert) => {
await visit("/u/eviltrout/activity");
assert.ok($("body.user-activity-page").length, "has the body class");
hasStream(assert);
@@ -31,13 +32,13 @@ QUnit.test("Filters", async (assert) => {
assert.ok(exists(".user-stream.filter-5"), "stream has filter class");
});
-QUnit.test("Badges", async (assert) => {
+test("Badges", async (assert) => {
await visit("/u/eviltrout/badges");
assert.ok($("body.user-badges-page").length, "has the body class");
assert.ok(exists(".user-badges-list .badge-card"), "shows a badge");
});
-QUnit.test("Restricted Routes", async (assert) => {
+test("Restricted Routes", async (assert) => {
await visit("/u/eviltrout/preferences");
assert.equal(
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-bookmarks-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-bookmarks-test.js
index f034878f6b..7537c2f91f 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-bookmarks-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-bookmarks-test.js
@@ -1,3 +1,4 @@
+import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import pretender from "discourse/tests/helpers/create-pretender";
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-card-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-card-mobile-test.js
index be9b6d0af5..8cc4223147 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-card-mobile-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-card-mobile-test.js
@@ -1,9 +1,10 @@
+import { skip } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import DiscourseURL from "discourse/lib/url";
acceptance("User Card - Mobile", { mobileView: true });
-QUnit.skip("user card", async (assert) => {
+skip("user card", async (assert) => {
await visit("/t/internationalization-localization/280");
assert.ok(
invisible(".user-card"),
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-card-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-card-test.js
index 8a14c0513d..13bf3e5268 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-card-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-card-test.js
@@ -1,3 +1,5 @@
+import { skip } from "qunit";
+import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import DiscourseURL from "discourse/lib/url";
@@ -10,7 +12,7 @@ acceptance("User Card - Show Local Time", {
settings: { display_local_time_in_user_card: true },
});
-QUnit.skip("user card local time", async (assert) => {
+skip("user card local time", async (assert) => {
User.current().changeTimezone("Australia/Brisbane");
let cardResponse = Object.assign({}, userFixtures["/u/eviltrout/card.json"]);
cardResponse.user.timezone = "Australia/Perth";
@@ -60,32 +62,29 @@ QUnit.skip("user card local time", async (assert) => {
);
});
-QUnit.test(
- "user card local time - does not update timezone for another user",
- async (assert) => {
- User.current().changeTimezone("Australia/Brisbane");
- let cardResponse = Object.assign({}, userFixtures["/u/charlie/card.json"]);
- delete cardResponse.user.timezone;
+test("user card local time - does not update timezone for another user", async (assert) => {
+ User.current().changeTimezone("Australia/Brisbane");
+ let cardResponse = Object.assign({}, userFixtures["/u/charlie/card.json"]);
+ delete cardResponse.user.timezone;
- pretender.get("/u/charlie/card.json", () => [
- 200,
- { "Content-Type": "application/json" },
- cardResponse,
- ]);
+ pretender.get("/u/charlie/card.json", () => [
+ 200,
+ { "Content-Type": "application/json" },
+ cardResponse,
+ ]);
- await visit("/t/internationalization-localization/280");
- await click("a[data-user-card=charlie]:first");
+ await visit("/t/internationalization-localization/280");
+ await click("a[data-user-card=charlie]:first");
- assert.not(
- exists(".user-card .local-time"),
- "it does not show the local time if the user card returns a null/undefined timezone for another user"
- );
- }
-);
+ assert.not(
+ exists(".user-card .local-time"),
+ "it does not show the local time if the user card returns a null/undefined timezone for another user"
+ );
+});
acceptance("User Card", { loggedIn: true });
-QUnit.skip("user card", async (assert) => {
+skip("user card", async (assert) => {
await visit("/t/internationalization-localization/280");
assert.ok(invisible(".user-card"), "user card is invisible by default");
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js
index 22a56354e0..f5e4972cc1 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js
@@ -1,8 +1,9 @@
+import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("User Drafts", { loggedIn: true });
-QUnit.test("Stream", async (assert) => {
+test("Stream", async (assert) => {
await visit("/u/eviltrout/activity/drafts");
assert.ok(find(".user-stream-item").length === 3, "has drafts");
@@ -13,7 +14,7 @@ QUnit.test("Stream", async (assert) => {
);
});
-QUnit.test("Stream - resume draft", async (assert) => {
+test("Stream - resume draft", async (assert) => {
await visit("/u/eviltrout/activity/drafts");
assert.ok(find(".user-stream-item").length > 0, "has drafts");
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js
index df5b5a9539..f92eb1cc20 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js
@@ -1,3 +1,4 @@
+import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import Site from "discourse/models/site";
@@ -8,7 +9,7 @@ acceptance("User Preferences - Interface", {
loggedIn: true,
});
-QUnit.test("font size change", async (assert) => {
+test("font size change", async (assert) => {
removeCookie("text_size");
const savePreferences = async () => {
@@ -53,15 +54,12 @@ QUnit.test("font size change", async (assert) => {
removeCookie("text_size");
});
-QUnit.test(
- "does not show option to disable dark mode by default",
- async (assert) => {
- await visit("/u/eviltrout/preferences/interface");
- assert.equal($(".control-group.dark-mode").length, 0);
- }
-);
+test("does not show option to disable dark mode by default", async (assert) => {
+ await visit("/u/eviltrout/preferences/interface");
+ assert.equal($(".control-group.dark-mode").length, 0);
+});
-QUnit.test("shows light/dark color scheme pickers", async (assert) => {
+test("shows light/dark color scheme pickers", async (assert) => {
let site = Site.current();
site.set("user_color_schemes", [
{ id: 2, name: "Cool Breeze" },
@@ -87,7 +85,7 @@ acceptance("User Preferences Color Schemes (with default dark scheme)", {
pretend: interfacePretender,
});
-QUnit.test("show option to disable dark mode", async (assert) => {
+test("show option to disable dark mode", async (assert) => {
await visit("/u/eviltrout/preferences/interface");
assert.ok(
@@ -96,7 +94,7 @@ QUnit.test("show option to disable dark mode", async (assert) => {
);
});
-QUnit.test("no color scheme picker by default", async (assert) => {
+test("no color scheme picker by default", async (assert) => {
let site = Site.current();
site.set("user_color_schemes", []);
@@ -104,7 +102,7 @@ QUnit.test("no color scheme picker by default", async (assert) => {
assert.equal($(".control-group.color-scheme").length, 0);
});
-QUnit.test("light color scheme picker", async (assert) => {
+test("light color scheme picker", async (assert) => {
let site = Site.current();
site.set("user_color_schemes", [{ id: 2, name: "Cool Breeze" }]);
@@ -117,7 +115,7 @@ QUnit.test("light color scheme picker", async (assert) => {
);
});
-QUnit.test("light and dark color scheme pickers", async (assert) => {
+test("light and dark color scheme pickers", async (assert) => {
let site = Site.current();
let session = Session.current();
session.userDarkSchemeId = 1; // same as default set in site settings
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-test.js
index 06a73a3ab3..f170e731b2 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-test.js
@@ -1,3 +1,4 @@
+import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import pretender from "discourse/tests/helpers/create-pretender";
import Draft from "discourse/models/draft";
@@ -5,7 +6,7 @@ import { Promise } from "rsvp";
acceptance("User", { loggedIn: true });
-QUnit.test("Invalid usernames", async (assert) => {
+test("Invalid usernames", async (assert) => {
pretender.get("/u/eviltrout%2F..%2F..%2F.json", () => {
return [400, { "Content-Type": "application/json" }, {}];
});
@@ -15,23 +16,23 @@ QUnit.test("Invalid usernames", async (assert) => {
assert.equal(currentPath(), "exception-unknown");
});
-QUnit.test("Unicode usernames", async (assert) => {
+test("Unicode usernames", async (assert) => {
await visit("/u/%E3%83%A9%E3%82%A4%E3%82%AA%E3%83%B3/summary");
assert.equal(currentPath(), "user.summary");
});
-QUnit.test("Invites", async (assert) => {
+test("Invites", async (assert) => {
await visit("/u/eviltrout/invited/pending");
assert.ok($("body.user-invites-page").length, "has the body class");
});
-QUnit.test("Messages", async (assert) => {
+test("Messages", async (assert) => {
await visit("/u/eviltrout/messages");
assert.ok($("body.user-messages-page").length, "has the body class");
});
-QUnit.test("Notifications", async (assert) => {
+test("Notifications", async (assert) => {
await visit("/u/eviltrout/notifications");
assert.ok($("body.user-notifications-page").length, "has the body class");
@@ -44,7 +45,7 @@ QUnit.test("Notifications", async (assert) => {
);
});
-QUnit.test("Root URL - Viewing Self", async (assert) => {
+test("Root URL - Viewing Self", async (assert) => {
await visit("/u/eviltrout");
assert.ok($("body.user-activity-page").length, "has the body class");
assert.equal(
@@ -55,7 +56,7 @@ QUnit.test("Root URL - Viewing Self", async (assert) => {
assert.ok(exists(".container.viewing-self"), "has the viewing-self class");
});
-QUnit.test("Viewing Summary", async (assert) => {
+test("Viewing Summary", async (assert) => {
await visit("/u/eviltrout/summary");
assert.ok(exists(".replies-section li a"), "replies");
@@ -68,7 +69,7 @@ QUnit.test("Viewing Summary", async (assert) => {
assert.ok(exists(".top-categories-section .category-link"), "top categories");
});
-QUnit.test("Viewing Drafts", async (assert) => {
+test("Viewing Drafts", async (assert) => {
sandbox.stub(Draft, "get").returns(
Promise.resolve({
draft: null,
diff --git a/app/assets/javascripts/discourse/tests/acceptance/users-test.js b/app/assets/javascripts/discourse/tests/acceptance/users-test.js
index f8a6df352a..7147fd4cac 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/users-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/users-test.js
@@ -1,24 +1,25 @@
+import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("User Directory");
-QUnit.test("Visit Page", async (assert) => {
+test("Visit Page", async (assert) => {
await visit("/u");
assert.ok($("body.users-page").length, "has the body class");
assert.ok(exists(".directory table tr"), "has a list of users");
});
-QUnit.test("Visit All Time", async (assert) => {
+test("Visit All Time", async (assert) => {
await visit("/u?period=all");
assert.ok(exists(".time-read"), "has time read column");
});
-QUnit.test("Visit Without Usernames", async (assert) => {
+test("Visit Without Usernames", async (assert) => {
await visit("/u?exclude_usernames=system");
assert.ok($("body.users-page").length, "has the body class");
assert.ok(exists(".directory table tr"), "has a list of users");
});
-QUnit.test("Visit With Group Filter", async (assert) => {
+test("Visit With Group Filter", async (assert) => {
await visit("/u?group=trust_level_0");
assert.ok($("body.users-page").length, "has the body class");
assert.ok(exists(".directory table tr"), "has a list of users");
diff --git a/app/assets/javascripts/discourse/tests/helpers/component-test.js b/app/assets/javascripts/discourse/tests/helpers/component-test.js
index 813b72b703..5509343240 100644
--- a/app/assets/javascripts/discourse/tests/helpers/component-test.js
+++ b/app/assets/javascripts/discourse/tests/helpers/component-test.js
@@ -6,6 +6,7 @@ import User from "discourse/models/user";
import Site from "discourse/models/site";
import Session from "discourse/models/session";
import { currentSettings } from "discourse/tests/helpers/site-settings";
+import { test } from "qunit";
export default function (name, opts) {
opts = opts || {};
diff --git a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
index edb00c964b..be1c7d0ca7 100644
--- a/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
+++ b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
@@ -35,6 +35,7 @@ import { setTopicList } from "discourse/lib/topic-list-tracker";
import { setURLContainer } from "discourse/lib/url";
import { setDefaultOwner } from "discourse-common/lib/get-owner";
import bootbox from "bootbox";
+import { moduleFor } from "ember-qunit";
export function currentUser() {
return User.create(sessionFixtures["/session/current.json"].current_user);
@@ -134,7 +135,7 @@ export function controllerModule(name, args = {}) {
}
export function discourseModule(name, hooks) {
- QUnit.module(name, {
+ module(name, {
beforeEach() {
this.container = getOwner(this);
this.siteSettings = currentSettings();
@@ -157,7 +158,7 @@ export function acceptance(name, options) {
_pretenderCallbacks[name] = options.pretend;
}
- QUnit.module("Acceptance: " + name, {
+ module("Acceptance: " + name, {
beforeEach() {
resetMobile();
diff --git a/app/assets/javascripts/discourse/tests/helpers/select-kit-helper.js b/app/assets/javascripts/discourse/tests/helpers/select-kit-helper.js
index 63c45adc3e..8e5932e424 100644
--- a/app/assets/javascripts/discourse/tests/helpers/select-kit-helper.js
+++ b/app/assets/javascripts/discourse/tests/helpers/select-kit-helper.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import { isEmpty } from "@ember/utils";
function checkSelectKitIsNotExpanded(selector) {
diff --git a/app/assets/javascripts/discourse/tests/helpers/widget-test.js b/app/assets/javascripts/discourse/tests/helpers/widget-test.js
index 30f689552e..0a7e7d2780 100644
--- a/app/assets/javascripts/discourse/tests/helpers/widget-test.js
+++ b/app/assets/javascripts/discourse/tests/helpers/widget-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
export function moduleForWidget(name, options = {}) {
diff --git a/app/assets/javascripts/discourse/tests/integration/components/ace-editor-test.js b/app/assets/javascripts/discourse/tests/integration/components/ace-editor-test.js
index e6ece18dd3..44792a75e9 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/ace-editor-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/ace-editor-test.js
@@ -1,4 +1,5 @@
import componentTest from "discourse/tests/helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
moduleForComponent("ace-editor", { integration: true });
diff --git a/app/assets/javascripts/discourse/tests/integration/components/admin-report-test.js b/app/assets/javascripts/discourse/tests/integration/components/admin-report-test.js
index 756dbda3b8..d288b3deab 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/admin-report-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/admin-report-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
import pretender from "discourse/tests/helpers/create-pretender";
diff --git a/app/assets/javascripts/discourse/tests/integration/components/badge-title-test.js b/app/assets/javascripts/discourse/tests/integration/components/badge-title-test.js
index ad88301a70..4d9b0c9f26 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/badge-title-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/badge-title-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import componentTest from "discourse/tests/helpers/component-test";
import EmberObject from "@ember/object";
diff --git a/app/assets/javascripts/discourse/tests/integration/components/cook-text-test.js b/app/assets/javascripts/discourse/tests/integration/components/cook-text-test.js
index 25ef333677..b0e10f4b1f 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/cook-text-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/cook-text-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
import pretender from "discourse/tests/helpers/create-pretender";
import { resetCache } from "pretty-text/upload-short-url";
diff --git a/app/assets/javascripts/discourse/tests/integration/components/d-button-test.js b/app/assets/javascripts/discourse/tests/integration/components/d-button-test.js
index 5d66dd8e3d..759938d11e 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/d-button-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/d-button-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import I18n from "I18n";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("d-button", { integration: true });
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 f3ddb8e228..b207338bf0 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,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import I18n from "I18n";
import { next } from "@ember/runloop";
import { clearToolbarCallbacks } from "discourse/components/d-editor";
diff --git a/app/assets/javascripts/discourse/tests/integration/components/d-icon-test.js b/app/assets/javascripts/discourse/tests/integration/components/d-icon-test.js
index 737aa45d11..60db5afac9 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/d-icon-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/d-icon-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("d-icon", { integration: true });
diff --git a/app/assets/javascripts/discourse/tests/integration/components/date-input-test.js b/app/assets/javascripts/discourse/tests/integration/components/date-input-test.js
index bdaea1d2ca..96b7cbad0a 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/date-input-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/date-input-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("date-input", { integration: true });
diff --git a/app/assets/javascripts/discourse/tests/integration/components/date-time-input-range-test.js b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-range-test.js
index 24207d6074..9425e4feda 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/date-time-input-range-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-range-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("date-time-input-range", { integration: true });
diff --git a/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.js b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.js
index 5df768217e..37812fe4df 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("date-time-input", { integration: true });
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
index 2d17c0ed6d..331c3daffc 100644
--- 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
@@ -1,6 +1,9 @@
+import { test } from "qunit";
+import { moduleFor } from "ember-qunit";
+
moduleFor("component:group-membership-button");
-QUnit.test("canJoinGroup", function (assert) {
+test("canJoinGroup", function (assert) {
this.subject().setProperties({
model: { public_admission: false, is_group_user: true },
});
@@ -28,7 +31,7 @@ QUnit.test("canJoinGroup", function (assert) {
);
});
-QUnit.test("canLeaveGroup", function (assert) {
+test("canLeaveGroup", function (assert) {
this.subject().setProperties({
model: { public_exit: false, is_group_user: false },
});
@@ -56,7 +59,7 @@ QUnit.test("canLeaveGroup", function (assert) {
);
});
-QUnit.test("canRequestMembership", function (assert) {
+test("canRequestMembership", function (assert) {
this.subject().setProperties({
model: { allow_membership_requests: true, is_group_user: true },
});
@@ -76,7 +79,7 @@ QUnit.test("canRequestMembership", function (assert) {
);
});
-QUnit.test("userIsGroupUser", function (assert) {
+test("userIsGroupUser", function (assert) {
this.subject().setProperties({
model: { is_group_user: true },
});
diff --git a/app/assets/javascripts/discourse/tests/integration/components/highlighted-code-test.js b/app/assets/javascripts/discourse/tests/integration/components/highlighted-code-test.js
index f51b3531ac..c4a86900fc 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/highlighted-code-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/highlighted-code-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
const LONG_CODE_BLOCK = "puts a\n".repeat(15000);
diff --git a/app/assets/javascripts/discourse/tests/integration/components/html-safe-helper-test.js b/app/assets/javascripts/discourse/tests/integration/components/html-safe-helper-test.js
index 7170283c7c..28eba894a8 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/html-safe-helper-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/html-safe-helper-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("html-safe-helper", { integration: true });
diff --git a/app/assets/javascripts/discourse/tests/integration/components/iframed-html-test.js b/app/assets/javascripts/discourse/tests/integration/components/iframed-html-test.js
index 678d5fe2ac..ff1fcc4ce7 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/iframed-html-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/iframed-html-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("iframed-html", { integration: true });
diff --git a/app/assets/javascripts/discourse/tests/integration/components/image-uploader-test.js b/app/assets/javascripts/discourse/tests/integration/components/image-uploader-test.js
index 332274773e..5b714a3a44 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/image-uploader-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/image-uploader-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("image-uploader", { integration: true });
diff --git a/app/assets/javascripts/discourse/tests/integration/components/keyboard-shortcuts-test.js b/app/assets/javascripts/discourse/tests/integration/components/keyboard-shortcuts-test.js
index 19ccbe946f..4b88456758 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/keyboard-shortcuts-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/keyboard-shortcuts-test.js
@@ -1,9 +1,10 @@
+import { test, module } from "qunit";
import DiscourseURL from "discourse/lib/url";
var testMouseTrap;
import KeyboardShortcuts from "discourse/lib/keyboard-shortcuts";
-QUnit.module("lib:keyboard-shortcuts", {
+module("lib:keyboard-shortcuts", {
beforeEach() {
var _bindings = {};
@@ -115,21 +116,21 @@ Object.keys(functionBindings).forEach((func) => {
});
});
-QUnit.test("selectDown calls _moveSelection with 1", (assert) => {
+test("selectDown calls _moveSelection with 1", (assert) => {
var stub = sandbox.stub(KeyboardShortcuts, "_moveSelection");
KeyboardShortcuts.selectDown();
assert.ok(stub.calledWith(1), "_moveSelection is called with 1");
});
-QUnit.test("selectUp calls _moveSelection with -1", (assert) => {
+test("selectUp calls _moveSelection with -1", (assert) => {
var stub = sandbox.stub(KeyboardShortcuts, "_moveSelection");
KeyboardShortcuts.selectUp();
assert.ok(stub.calledWith(-1), "_moveSelection is called with -1");
});
-QUnit.test("goBack calls history.back", (assert) => {
+test("goBack calls history.back", (assert) => {
var called = false;
sandbox.stub(history, "back").callsFake(function () {
called = true;
@@ -139,14 +140,14 @@ QUnit.test("goBack calls history.back", (assert) => {
assert.ok(called, "history.back is called");
});
-QUnit.test("nextSection calls _changeSection with 1", (assert) => {
+test("nextSection calls _changeSection with 1", (assert) => {
var spy = sandbox.spy(KeyboardShortcuts, "_changeSection");
KeyboardShortcuts.nextSection();
assert.ok(spy.calledWith(1), "_changeSection is called with 1");
});
-QUnit.test("prevSection calls _changeSection with -1", (assert) => {
+test("prevSection calls _changeSection with -1", (assert) => {
var spy = sandbox.spy(KeyboardShortcuts, "_changeSection");
KeyboardShortcuts.prevSection();
diff --git a/app/assets/javascripts/discourse/tests/integration/components/load-more-test.js b/app/assets/javascripts/discourse/tests/integration/components/load-more-test.js
index 6d2fbcd1ac..d5a9310b3d 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/load-more-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/load-more-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import { configureEyeline } from "discourse/lib/eyeline";
import componentTest from "discourse/tests/helpers/component-test";
diff --git a/app/assets/javascripts/discourse/tests/integration/components/secret-value-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/secret-value-list-test.js
index a1dc8c6fc7..c07ab3a5d5 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/secret-value-list-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/secret-value-list-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import I18n from "I18n";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("secret-value-list", { integration: true });
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/combo-box-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/combo-box-test.js
index b945832cea..ccbd9f29b1 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/combo-box-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/combo-box-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import componentTest from "discourse/tests/helpers/component-test";
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/dropdown-select-box-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/dropdown-select-box-test.js
index cf44ea6011..817be1aadc 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/dropdown-select-box-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/dropdown-select-box-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import componentTest from "discourse/tests/helpers/component-test";
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/pinned-options-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/pinned-options-test.js
index 4199ff7d3b..32d24a0f6d 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/pinned-options-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/pinned-options-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import componentTest from "discourse/tests/helpers/component-test";
import Topic from "discourse/models/topic";
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/topic-notifications-button-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/topic-notifications-button-test.js
index 64cd90a738..6656bda882 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/topic-notifications-button-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/topic-notifications-button-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import I18n from "I18n";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import componentTest from "discourse/tests/helpers/component-test";
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/topic-notifications-options-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/topic-notifications-options-test.js
index 12bdc5f941..9a072ebaec 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/topic-notifications-options-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/topic-notifications-options-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import I18n from "I18n";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import componentTest from "discourse/tests/helpers/component-test";
diff --git a/app/assets/javascripts/discourse/tests/integration/components/share-button-test.js b/app/assets/javascripts/discourse/tests/integration/components/share-button-test.js
index 53d7564501..9a137ff183 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/share-button-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/share-button-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("share-button", { integration: true });
diff --git a/app/assets/javascripts/discourse/tests/integration/components/simple-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/simple-list-test.js
index 93d21a312d..c66c8d7c5c 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/simple-list-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/simple-list-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("simple-list", { integration: true });
diff --git a/app/assets/javascripts/discourse/tests/integration/components/text-field-test.js b/app/assets/javascripts/discourse/tests/integration/components/text-field-test.js
index e6b8d49549..21eb8d00c6 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/text-field-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/text-field-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import I18n from "I18n";
import componentTest from "discourse/tests/helpers/component-test";
diff --git a/app/assets/javascripts/discourse/tests/integration/components/time-input-test.js b/app/assets/javascripts/discourse/tests/integration/components/time-input-test.js
index e2d2a259fe..6773b1b8e8 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/time-input-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/time-input-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import componentTest from "discourse/tests/helpers/component-test";
diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-selector-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-selector-test.js
index ab070b4fc6..4e54429693 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/user-selector-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/user-selector-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("user-selector", { integration: true });
diff --git a/app/assets/javascripts/discourse/tests/integration/components/value-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/value-list-test.js
index 67ffa4b697..e1708c5865 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/value-list-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/value-list-test.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("value-list", { integration: true });
diff --git a/app/assets/javascripts/discourse/tests/unit/controllers/avatar-selector-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/avatar-selector-test.js
index c6e2301f4d..5988091251 100644
--- a/app/assets/javascripts/discourse/tests/unit/controllers/avatar-selector-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/avatar-selector-test.js
@@ -1,3 +1,5 @@
+import { moduleFor } from "ember-qunit";
+import { test } from "qunit";
import { mapRoutes } from "discourse/mapping-router";
moduleFor("controller:avatar-selector", "controller:avatar-selector", {
@@ -7,7 +9,7 @@ moduleFor("controller:avatar-selector", "controller:avatar-selector", {
needs: ["controller:modal"],
});
-QUnit.test("avatarTemplate", function (assert) {
+test("avatarTemplate", function (assert) {
const avatarSelectorController = this.subject();
avatarSelectorController.setProperties({
diff --git a/app/assets/javascripts/discourse/tests/unit/controllers/bookmark-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/bookmark-test.js
index 9d23fc1121..2c0ff30c0c 100644
--- a/app/assets/javascripts/discourse/tests/unit/controllers/bookmark-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/bookmark-test.js
@@ -1,3 +1,5 @@
+import { moduleFor } from "ember-qunit";
+import { test } from "qunit";
import { logIn } from "discourse/tests/helpers/qunit-helpers";
import User from "discourse/models/user";
import KeyboardShortcutInitializer from "discourse/initializers/keyboard-shortcuts";
@@ -26,39 +28,29 @@ function mockMomentTz(dateString) {
fakeTime(dateString, BookmarkController.userTimezone);
}
-QUnit.test("showLaterToday when later today is tomorrow do not show", function (
- assert
-) {
+test("showLaterToday when later today is tomorrow do not show", function (assert) {
mockMomentTz("2019-12-11T22:00:00");
assert.equal(BookmarkController.get("showLaterToday"), false);
});
-QUnit.test(
- "showLaterToday when later today is after 5pm but before 6pm",
- function (assert) {
- mockMomentTz("2019-12-11T15:00:00");
- assert.equal(BookmarkController.get("showLaterToday"), true);
- }
-);
+test("showLaterToday when later today is after 5pm but before 6pm", function (assert) {
+ mockMomentTz("2019-12-11T15:00:00");
+ assert.equal(BookmarkController.get("showLaterToday"), true);
+});
-QUnit.test("showLaterToday when now is after the cutoff time (5pm)", function (
- assert
-) {
+test("showLaterToday when now is after the cutoff time (5pm)", function (assert) {
mockMomentTz("2019-12-11T17:00:00");
assert.equal(BookmarkController.get("showLaterToday"), false);
});
-QUnit.test(
- "showLaterToday when later today is before the end of the day, show",
- function (assert) {
- mockMomentTz("2019-12-11T10:00:00");
+test("showLaterToday when later today is before the end of the day, show", function (assert) {
+ mockMomentTz("2019-12-11T10:00:00");
- assert.equal(BookmarkController.get("showLaterToday"), true);
- }
-);
+ assert.equal(BookmarkController.get("showLaterToday"), true);
+});
-QUnit.test("nextWeek gets next week correctly", function (assert) {
+test("nextWeek gets next week correctly", function (assert) {
mockMomentTz("2019-12-11T08:00:00");
assert.equal(
@@ -67,7 +59,7 @@ QUnit.test("nextWeek gets next week correctly", function (assert) {
);
});
-QUnit.test("nextMonth gets next month correctly", function (assert) {
+test("nextMonth gets next month correctly", function (assert) {
mockMomentTz("2019-12-11T08:00:00");
assert.equal(
@@ -76,7 +68,7 @@ QUnit.test("nextMonth gets next month correctly", function (assert) {
);
});
-QUnit.test("laterThisWeek gets 2 days from now", function (assert) {
+test("laterThisWeek gets 2 days from now", function (assert) {
mockMomentTz("2019-12-10T08:00:00");
assert.equal(
@@ -85,27 +77,24 @@ QUnit.test("laterThisWeek gets 2 days from now", function (assert) {
);
});
-QUnit.test(
- "laterThisWeek returns null if we are at Thursday already",
- function (assert) {
- mockMomentTz("2019-12-12T08:00:00");
+test("laterThisWeek returns null if we are at Thursday already", function (assert) {
+ mockMomentTz("2019-12-12T08:00:00");
- assert.equal(BookmarkController.laterThisWeek(), null);
- }
-);
+ assert.equal(BookmarkController.laterThisWeek(), null);
+});
-QUnit.test("showLaterThisWeek returns true if < Thursday", function (assert) {
+test("showLaterThisWeek returns true if < Thursday", function (assert) {
mockMomentTz("2019-12-10T08:00:00");
assert.equal(BookmarkController.showLaterThisWeek, true);
});
-QUnit.test("showLaterThisWeek returns false if > Thursday", function (assert) {
+test("showLaterThisWeek returns false if > Thursday", function (assert) {
mockMomentTz("2019-12-12T08:00:00");
assert.equal(BookmarkController.showLaterThisWeek, false);
});
-QUnit.test("tomorrow gets tomorrow correctly", function (assert) {
+test("tomorrow gets tomorrow correctly", function (assert) {
mockMomentTz("2019-12-11T08:00:00");
assert.equal(
@@ -114,146 +103,125 @@ QUnit.test("tomorrow gets tomorrow correctly", function (assert) {
);
});
-QUnit.test(
- "startOfDay changes the time of the provided date to 8:00am correctly",
- function (assert) {
- let dt = moment.tz(
- "2019-12-11T11:37:16",
- BookmarkController.currentUser.resolvedTimezone(
- BookmarkController.currentUser
- )
- );
+test("startOfDay changes the time of the provided date to 8:00am correctly", function (assert) {
+ let dt = moment.tz(
+ "2019-12-11T11:37:16",
+ BookmarkController.currentUser.resolvedTimezone(
+ BookmarkController.currentUser
+ )
+ );
- assert.equal(
- BookmarkController.startOfDay(dt).format("YYYY-MM-DD HH:mm:ss"),
- "2019-12-11 08:00:00"
- );
- }
-);
+ assert.equal(
+ BookmarkController.startOfDay(dt).format("YYYY-MM-DD HH:mm:ss"),
+ "2019-12-11 08:00:00"
+ );
+});
-QUnit.test(
- "laterToday gets 3 hours from now and if before half-past, it rounds down",
- function (assert) {
- mockMomentTz("2019-12-11T08:13:00");
+test("laterToday gets 3 hours from now and if before half-past, it rounds down", function (assert) {
+ mockMomentTz("2019-12-11T08:13:00");
- assert.equal(
- BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
- "2019-12-11 11:00:00"
- );
- }
-);
+ assert.equal(
+ BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
+ "2019-12-11 11:00:00"
+ );
+});
-QUnit.test(
- "laterToday gets 3 hours from now and if after half-past, it rounds up to the next hour",
- function (assert) {
- mockMomentTz("2019-12-11T08:43:00");
+test("laterToday gets 3 hours from now and if after half-past, it rounds up to the next hour", function (assert) {
+ mockMomentTz("2019-12-11T08:43:00");
- assert.equal(
- BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
- "2019-12-11 12:00:00"
- );
- }
-);
+ assert.equal(
+ BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
+ "2019-12-11 12:00:00"
+ );
+});
-QUnit.test(
- "laterToday is capped to 6pm. later today at 3pm = 6pm, 3:30pm = 6pm, 4pm = 6pm, 4:59pm = 6pm",
- function (assert) {
- mockMomentTz("2019-12-11T15:00:00");
+test("laterToday is capped to 6pm. later today at 3pm = 6pm, 3:30pm = 6pm, 4pm = 6pm, 4:59pm = 6pm", function (assert) {
+ mockMomentTz("2019-12-11T15:00:00");
- assert.equal(
- BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
- "2019-12-11 18:00:00",
- "3pm should max to 6pm"
- );
+ assert.equal(
+ BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
+ "2019-12-11 18:00:00",
+ "3pm should max to 6pm"
+ );
- mockMomentTz("2019-12-11T15:31:00");
+ mockMomentTz("2019-12-11T15:31:00");
- assert.equal(
- BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
- "2019-12-11 18:00:00",
- "3:30pm should max to 6pm"
- );
+ assert.equal(
+ BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
+ "2019-12-11 18:00:00",
+ "3:30pm should max to 6pm"
+ );
- mockMomentTz("2019-12-11T16:00:00");
+ mockMomentTz("2019-12-11T16:00:00");
- assert.equal(
- BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
- "2019-12-11 18:00:00",
- "4pm should max to 6pm"
- );
+ assert.equal(
+ BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
+ "2019-12-11 18:00:00",
+ "4pm should max to 6pm"
+ );
- mockMomentTz("2019-12-11T16:59:00");
+ mockMomentTz("2019-12-11T16:59:00");
- assert.equal(
- BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
- "2019-12-11 18:00:00",
- "4:59pm should max to 6pm"
- );
- }
-);
+ assert.equal(
+ BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
+ "2019-12-11 18:00:00",
+ "4:59pm should max to 6pm"
+ );
+});
-QUnit.test("showLaterToday returns false if >= 5PM", function (assert) {
+test("showLaterToday returns false if >= 5PM", function (assert) {
mockMomentTz("2019-12-11T17:00:01");
assert.equal(BookmarkController.showLaterToday, false);
});
-QUnit.test("showLaterToday returns false if >= 5PM", function (assert) {
+test("showLaterToday returns false if >= 5PM", function (assert) {
mockMomentTz("2019-12-11T17:00:01");
assert.equal(BookmarkController.showLaterToday, false);
});
-QUnit.test(
- "reminderAt - custom - defaults to 8:00am if the time is not selected",
- function (assert) {
- BookmarkController.customReminderDate = "2028-12-12";
- BookmarkController.selectedReminderType =
- BookmarkController.reminderTypes.CUSTOM;
- const reminderAt = BookmarkController._reminderAt();
- assert.equal(BookmarkController.customReminderTime, "08:00");
- assert.equal(
- reminderAt.toString(),
- moment
- .tz(
- "2028-12-12 08:00",
- BookmarkController.currentUser.resolvedTimezone(
- BookmarkController.currentUser
- )
+test("reminderAt - custom - defaults to 8:00am if the time is not selected", function (assert) {
+ BookmarkController.customReminderDate = "2028-12-12";
+ BookmarkController.selectedReminderType =
+ BookmarkController.reminderTypes.CUSTOM;
+ const reminderAt = BookmarkController._reminderAt();
+ assert.equal(BookmarkController.customReminderTime, "08:00");
+ assert.equal(
+ reminderAt.toString(),
+ moment
+ .tz(
+ "2028-12-12 08:00",
+ BookmarkController.currentUser.resolvedTimezone(
+ BookmarkController.currentUser
)
- .toString(),
- "the custom date and time are parsed correctly with default time"
- );
- }
-);
+ )
+ .toString(),
+ "the custom date and time are parsed correctly with default time"
+ );
+});
-QUnit.test(
- "loadLastUsedCustomReminderDatetime fills the custom reminder date + time if present in localStorage",
- function (assert) {
- mockMomentTz("2019-12-11T08:00:00");
- localStorage.lastCustomBookmarkReminderDate = "2019-12-12";
- localStorage.lastCustomBookmarkReminderTime = "08:00";
+test("loadLastUsedCustomReminderDatetime fills the custom reminder date + time if present in localStorage", function (assert) {
+ mockMomentTz("2019-12-11T08:00:00");
+ localStorage.lastCustomBookmarkReminderDate = "2019-12-12";
+ localStorage.lastCustomBookmarkReminderTime = "08:00";
- BookmarkController._loadLastUsedCustomReminderDatetime();
+ BookmarkController._loadLastUsedCustomReminderDatetime();
- assert.equal(BookmarkController.lastCustomReminderDate, "2019-12-12");
- assert.equal(BookmarkController.lastCustomReminderTime, "08:00");
- }
-);
+ assert.equal(BookmarkController.lastCustomReminderDate, "2019-12-12");
+ assert.equal(BookmarkController.lastCustomReminderTime, "08:00");
+});
-QUnit.test(
- "loadLastUsedCustomReminderDatetime does not fills the custom reminder date + time if the datetime in localStorage is < now",
- function (assert) {
- mockMomentTz("2019-12-11T08:00:00");
- localStorage.lastCustomBookmarkReminderDate = "2019-12-11";
- localStorage.lastCustomBookmarkReminderTime = "07:00";
+test("loadLastUsedCustomReminderDatetime does not fills the custom reminder date + time if the datetime in localStorage is < now", function (assert) {
+ mockMomentTz("2019-12-11T08:00:00");
+ localStorage.lastCustomBookmarkReminderDate = "2019-12-11";
+ localStorage.lastCustomBookmarkReminderTime = "07:00";
- BookmarkController._loadLastUsedCustomReminderDatetime();
+ BookmarkController._loadLastUsedCustomReminderDatetime();
- assert.equal(BookmarkController.lastCustomReminderDate, null);
- assert.equal(BookmarkController.lastCustomReminderTime, null);
- }
-);
+ assert.equal(BookmarkController.lastCustomReminderDate, null);
+ assert.equal(BookmarkController.lastCustomReminderTime, null);
+});
-QUnit.test("user timezone updates when the modal is shown", function (assert) {
+test("user timezone updates when the modal is shown", function (assert) {
User.current().changeTimezone(null);
let stub = sandbox.stub(moment.tz, "guess").returns("Europe/Moscow");
BookmarkController.onShow();
@@ -274,19 +242,13 @@ QUnit.test("user timezone updates when the modal is shown", function (assert) {
stub.restore();
});
-QUnit.test(
- "opening the modal with an existing bookmark with reminder at prefills the custom reminder type",
- function (assert) {
- let name = "test";
- let reminderAt = "2020-05-15T09:45:00";
- BookmarkController.model = { id: 1, name: name, reminderAt: reminderAt };
- BookmarkController.onShow();
- assert.equal(
- BookmarkController.selectedReminderType,
- REMINDER_TYPES.CUSTOM
- );
- assert.equal(BookmarkController.customReminderDate, "2020-05-15");
- assert.equal(BookmarkController.customReminderTime, "09:45");
- assert.equal(BookmarkController.model.name, name);
- }
-);
+test("opening the modal with an existing bookmark with reminder at prefills the custom reminder type", function (assert) {
+ let name = "test";
+ let reminderAt = "2020-05-15T09:45:00";
+ BookmarkController.model = { id: 1, name: name, reminderAt: reminderAt };
+ BookmarkController.onShow();
+ assert.equal(BookmarkController.selectedReminderType, REMINDER_TYPES.CUSTOM);
+ assert.equal(BookmarkController.customReminderDate, "2020-05-15");
+ assert.equal(BookmarkController.customReminderTime, "09:45");
+ assert.equal(BookmarkController.model.name, name);
+});
diff --git a/app/assets/javascripts/discourse/tests/unit/controllers/create-account-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/create-account-test.js
index fa66fb9318..45f66b4e63 100644
--- a/app/assets/javascripts/discourse/tests/unit/controllers/create-account-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/create-account-test.js
@@ -1,3 +1,4 @@
+import { test } from "qunit";
import I18n from "I18n";
import { controllerModule } from "discourse/tests/helpers/qunit-helpers";
diff --git a/app/assets/javascripts/discourse/tests/unit/controllers/history-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/history-test.js
index 20385f3638..5a04d41433 100644
--- a/app/assets/javascripts/discourse/tests/unit/controllers/history-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/history-test.js
@@ -1,6 +1,8 @@
+import { moduleFor } from "ember-qunit";
+import { test } from "qunit";
moduleFor("controller:history");
-QUnit.test("displayEdit", async function (assert) {
+test("displayEdit", async function (assert) {
const HistoryController = this.subject();
HistoryController.setProperties({
diff --git a/app/assets/javascripts/discourse/tests/unit/controllers/preferences-account-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/preferences-account-test.js
index e686c705e1..ce0b1016cd 100644
--- a/app/assets/javascripts/discourse/tests/unit/controllers/preferences-account-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/preferences-account-test.js
@@ -1,7 +1,9 @@
+import { moduleFor } from "ember-qunit";
+import { test } from "qunit";
import EmberObject from "@ember/object";
moduleFor("controller:preferences/account");
-QUnit.test("updating of associated accounts", function (assert) {
+test("updating of associated accounts", function (assert) {
const controller = this.subject({
siteSettings: {
enable_google_oauth2_logins: true,
diff --git a/app/assets/javascripts/discourse/tests/unit/controllers/preferences-second-factor-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/preferences-second-factor-test.js
index 5d6fd69c5b..53e249d3ac 100644
--- a/app/assets/javascripts/discourse/tests/unit/controllers/preferences-second-factor-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/preferences-second-factor-test.js
@@ -1,14 +1,13 @@
+import { moduleFor } from "ember-qunit";
+import { test } from "qunit";
moduleFor("controller:preferences/second-factor");
-QUnit.test(
- "displayOAuthWarning when OAuth login methods are enabled",
- function (assert) {
- const controller = this.subject({
- siteSettings: {
- enable_google_oauth2_logins: true,
- },
- });
+test("displayOAuthWarning when OAuth login methods are enabled", function (assert) {
+ const controller = this.subject({
+ siteSettings: {
+ enable_google_oauth2_logins: true,
+ },
+ });
- assert.equal(controller.get("displayOAuthWarning"), true);
- }
-);
+ assert.equal(controller.get("displayOAuthWarning"), true);
+});
diff --git a/app/assets/javascripts/discourse/tests/unit/controllers/reorder-categories-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/reorder-categories-test.js
index becd110326..2c3eaa32cc 100644
--- a/app/assets/javascripts/discourse/tests/unit/controllers/reorder-categories-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/reorder-categories-test.js
@@ -1,3 +1,5 @@
+import { moduleFor } from "ember-qunit";
+import { test } from "qunit";
import EmberObject from "@ember/object";
import { mapRoutes } from "discourse/mapping-router";
import createStore from "discourse/tests/helpers/create-store";
@@ -9,7 +11,7 @@ moduleFor("controller:reorder-categories", "controller:reorder-categories", {
needs: ["controller:modal"],
});
-QUnit.test("reorder set unique position number", function (assert) {
+test("reorder set unique position number", function (assert) {
const store = createStore();
const categories = [];
@@ -29,187 +31,175 @@ QUnit.test("reorder set unique position number", function (assert) {
});
});
-QUnit.test(
- "reorder places subcategories after their parent categories, while maintaining the relative order",
- function (assert) {
- const store = createStore();
+test("reorder places subcategories after their parent categories, while maintaining the relative order", function (assert) {
+ const store = createStore();
- const parent = store.createRecord("category", {
- id: 1,
- position: 1,
- slug: "parent",
- });
- const child1 = store.createRecord("category", {
- id: 2,
- position: 3,
- slug: "child1",
- parent_category_id: 1,
- });
- const child2 = store.createRecord("category", {
- id: 3,
- position: 0,
- slug: "child2",
- parent_category_id: 1,
- });
- const other = store.createRecord("category", {
- id: 4,
- position: 2,
- slug: "other",
- });
+ const parent = store.createRecord("category", {
+ id: 1,
+ position: 1,
+ slug: "parent",
+ });
+ const child1 = store.createRecord("category", {
+ id: 2,
+ position: 3,
+ slug: "child1",
+ parent_category_id: 1,
+ });
+ const child2 = store.createRecord("category", {
+ id: 3,
+ position: 0,
+ slug: "child2",
+ parent_category_id: 1,
+ });
+ const other = store.createRecord("category", {
+ id: 4,
+ position: 2,
+ slug: "other",
+ });
- const categories = [child2, parent, other, child1];
- const expectedOrderSlugs = ["parent", "child2", "child1", "other"];
+ const categories = [child2, parent, other, child1];
+ const expectedOrderSlugs = ["parent", "child2", "child1", "other"];
- const site = EmberObject.create({ categories: categories });
- const reorderCategoriesController = this.subject({ site });
+ const site = EmberObject.create({ categories: categories });
+ const reorderCategoriesController = this.subject({ site });
- reorderCategoriesController.reorder();
+ reorderCategoriesController.reorder();
- assert.deepEqual(
- reorderCategoriesController.get("categoriesOrdered").mapBy("slug"),
- expectedOrderSlugs
- );
- }
-);
+ assert.deepEqual(
+ reorderCategoriesController.get("categoriesOrdered").mapBy("slug"),
+ expectedOrderSlugs
+ );
+});
-QUnit.test(
- "changing the position number of a category should place it at given position",
- function (assert) {
- const store = createStore();
+test("changing the position number of a category should place it at given position", function (assert) {
+ const store = createStore();
- const elem1 = store.createRecord("category", {
- id: 1,
- position: 0,
- slug: "foo",
- });
+ const elem1 = store.createRecord("category", {
+ id: 1,
+ position: 0,
+ slug: "foo",
+ });
- const elem2 = store.createRecord("category", {
- id: 2,
- position: 1,
- slug: "bar",
- });
+ const elem2 = store.createRecord("category", {
+ id: 2,
+ position: 1,
+ slug: "bar",
+ });
- const elem3 = store.createRecord("category", {
- id: 3,
- position: 2,
- slug: "test",
- });
+ const elem3 = store.createRecord("category", {
+ id: 3,
+ position: 2,
+ slug: "test",
+ });
- const categories = [elem1, elem2, elem3];
- const site = EmberObject.create({ categories: categories });
- const reorderCategoriesController = this.subject({ site });
+ const categories = [elem1, elem2, elem3];
+ const site = EmberObject.create({ categories: categories });
+ const reorderCategoriesController = this.subject({ site });
- reorderCategoriesController.actions.change.call(
- reorderCategoriesController,
- elem1,
- { target: { value: "2" } }
- );
+ reorderCategoriesController.actions.change.call(
+ reorderCategoriesController,
+ elem1,
+ { target: { value: "2" } }
+ );
- assert.deepEqual(
- reorderCategoriesController.get("categoriesOrdered").mapBy("slug"),
- ["test", "bar", "foo"]
- );
- }
-);
+ assert.deepEqual(
+ reorderCategoriesController.get("categoriesOrdered").mapBy("slug"),
+ ["test", "bar", "foo"]
+ );
+});
-QUnit.test(
- "changing the position number of a category should place it at given position and respect children",
- function (assert) {
- const store = createStore();
+test("changing the position number of a category should place it at given position and respect children", function (assert) {
+ const store = createStore();
- const elem1 = store.createRecord("category", {
- id: 1,
- position: 0,
- slug: "foo",
- });
+ const elem1 = store.createRecord("category", {
+ id: 1,
+ position: 0,
+ slug: "foo",
+ });
- const child1 = store.createRecord("category", {
- id: 4,
- position: 1,
- slug: "foochild",
- parent_category_id: 1,
- });
+ const child1 = store.createRecord("category", {
+ id: 4,
+ position: 1,
+ slug: "foochild",
+ parent_category_id: 1,
+ });
- const elem2 = store.createRecord("category", {
- id: 2,
- position: 2,
- slug: "bar",
- });
+ const elem2 = store.createRecord("category", {
+ id: 2,
+ position: 2,
+ slug: "bar",
+ });
- const elem3 = store.createRecord("category", {
- id: 3,
- position: 3,
- slug: "test",
- });
+ const elem3 = store.createRecord("category", {
+ id: 3,
+ position: 3,
+ slug: "test",
+ });
- const categories = [elem1, child1, elem2, elem3];
- const site = EmberObject.create({ categories: categories });
- const reorderCategoriesController = this.subject({ site });
+ const categories = [elem1, child1, elem2, elem3];
+ const site = EmberObject.create({ categories: categories });
+ const reorderCategoriesController = this.subject({ site });
- reorderCategoriesController.actions.change.call(
- reorderCategoriesController,
- elem1,
- { target: { value: 3 } }
- );
+ reorderCategoriesController.actions.change.call(
+ reorderCategoriesController,
+ elem1,
+ { target: { value: 3 } }
+ );
- assert.deepEqual(
- reorderCategoriesController.get("categoriesOrdered").mapBy("slug"),
- ["test", "bar", "foo", "foochild"]
- );
- }
-);
+ assert.deepEqual(
+ reorderCategoriesController.get("categoriesOrdered").mapBy("slug"),
+ ["test", "bar", "foo", "foochild"]
+ );
+});
-QUnit.test(
- "changing the position through click on arrow of a category should place it at given position and respect children",
- function (assert) {
- const store = createStore();
+test("changing the position through click on arrow of a category should place it at given position and respect children", function (assert) {
+ const store = createStore();
- const elem1 = store.createRecord("category", {
- id: 1,
- position: 0,
- slug: "foo",
- });
+ const elem1 = store.createRecord("category", {
+ id: 1,
+ position: 0,
+ slug: "foo",
+ });
- const child1 = store.createRecord("category", {
- id: 4,
- position: 1,
- slug: "foochild",
- parent_category_id: 1,
- });
+ const child1 = store.createRecord("category", {
+ id: 4,
+ position: 1,
+ slug: "foochild",
+ parent_category_id: 1,
+ });
- const child2 = store.createRecord("category", {
- id: 5,
- position: 2,
- slug: "foochildchild",
- parent_category_id: 4,
- });
+ const child2 = store.createRecord("category", {
+ id: 5,
+ position: 2,
+ slug: "foochildchild",
+ parent_category_id: 4,
+ });
- const elem2 = store.createRecord("category", {
- id: 2,
- position: 3,
- slug: "bar",
- });
+ const elem2 = store.createRecord("category", {
+ id: 2,
+ position: 3,
+ slug: "bar",
+ });
- const elem3 = store.createRecord("category", {
- id: 3,
- position: 4,
- slug: "test",
- });
+ const elem3 = store.createRecord("category", {
+ id: 3,
+ position: 4,
+ slug: "test",
+ });
- const categories = [elem1, child1, child2, elem2, elem3];
- const site = EmberObject.create({ categories: categories });
- const reorderCategoriesController = this.subject({ site });
+ const categories = [elem1, child1, child2, elem2, elem3];
+ const site = EmberObject.create({ categories: categories });
+ const reorderCategoriesController = this.subject({ site });
- reorderCategoriesController.reorder();
+ reorderCategoriesController.reorder();
- reorderCategoriesController.actions.moveDown.call(
- reorderCategoriesController,
- elem1
- );
+ reorderCategoriesController.actions.moveDown.call(
+ reorderCategoriesController,
+ elem1
+ );
- assert.deepEqual(
- reorderCategoriesController.get("categoriesOrdered").mapBy("slug"),
- ["bar", "foo", "foochild", "foochildchild", "test"]
- );
- }
-);
+ assert.deepEqual(
+ reorderCategoriesController.get("categoriesOrdered").mapBy("slug"),
+ ["bar", "foo", "foochild", "foochildchild", "test"]
+ );
+});
diff --git a/app/assets/javascripts/discourse/tests/unit/controllers/topic-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/topic-test.js
index cefa233494..d552ef1f7b 100644
--- a/app/assets/javascripts/discourse/tests/unit/controllers/topic-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/topic-test.js
@@ -1,3 +1,5 @@
+import { moduleFor } from "ember-qunit";
+import { test } from "qunit";
import EmberObject from "@ember/object";
import { next } from "@ember/runloop";
import Topic from "discourse/models/topic";
@@ -25,7 +27,7 @@ function topicWithStream(streamDetails) {
return topic;
}
-QUnit.test("editTopic", function (assert) {
+test("editTopic", function (assert) {
const model = Topic.create();
const controller = this.subject({ model });
@@ -60,7 +62,7 @@ QUnit.test("editTopic", function (assert) {
);
});
-QUnit.test("toggleMultiSelect", function (assert) {
+test("toggleMultiSelect", function (assert) {
const model = Topic.create();
const controller = this.subject({ model });
@@ -100,7 +102,7 @@ QUnit.test("toggleMultiSelect", function (assert) {
);
});
-QUnit.test("selectedPosts", function (assert) {
+test("selectedPosts", function (assert) {
let model = topicWithStream({ posts: [{ id: 1 }, { id: 2 }, { id: 3 }] });
const controller = this.subject({ model });
@@ -117,7 +119,7 @@ QUnit.test("selectedPosts", function (assert) {
);
});
-QUnit.test("selectedAllPosts", function (assert) {
+test("selectedAllPosts", function (assert) {
let model = topicWithStream({ stream: [1, 2, 3] });
const controller = this.subject({ model });
@@ -147,7 +149,7 @@ QUnit.test("selectedAllPosts", function (assert) {
);
});
-QUnit.test("selectedPostsUsername", function (assert) {
+test("selectedPostsUsername", function (assert) {
let model = topicWithStream({
posts: [
{ id: 1, username: "gary" },
@@ -198,7 +200,7 @@ QUnit.test("selectedPostsUsername", function (assert) {
);
});
-QUnit.test("showSelectedPostsAtBottom", function (assert) {
+test("showSelectedPostsAtBottom", function (assert) {
const site = EmberObject.create({ mobileView: false });
const model = Topic.create({ posts_count: 3 });
const controller = this.subject({ model, site });
@@ -220,7 +222,7 @@ QUnit.test("showSelectedPostsAtBottom", function (assert) {
);
});
-QUnit.test("canDeleteSelected", function (assert) {
+test("canDeleteSelected", function (assert) {
const currentUser = User.create({ admin: false });
this.registry.register("current-user:main", currentUser, {
instantiate: false,
@@ -271,7 +273,7 @@ QUnit.test("canDeleteSelected", function (assert) {
);
});
-QUnit.test("Can split/merge topic", function (assert) {
+test("Can split/merge topic", function (assert) {
let model = topicWithStream({
posts: [
{ id: 1, post_number: 1, post_type: 1 },
@@ -316,7 +318,7 @@ QUnit.test("Can split/merge topic", function (assert) {
);
});
-QUnit.test("canChangeOwner", function (assert) {
+test("canChangeOwner", function (assert) {
const currentUser = User.create({ admin: false });
this.registry.register("current-user:main", currentUser, {
instantiate: false,
@@ -358,7 +360,7 @@ QUnit.test("canChangeOwner", function (assert) {
);
});
-QUnit.test("canMergePosts", function (assert) {
+test("canMergePosts", function (assert) {
let model = topicWithStream({
posts: [
{ id: 1, username: "gary", can_delete: true },
@@ -405,7 +407,7 @@ QUnit.test("canMergePosts", function (assert) {
);
});
-QUnit.test("Select/deselect all", function (assert) {
+test("Select/deselect all", function (assert) {
let model = topicWithStream({ stream: [1, 2, 3] });
const controller = this.subject({ model });
@@ -432,7 +434,7 @@ QUnit.test("Select/deselect all", function (assert) {
);
});
-QUnit.test("togglePostSelection", function (assert) {
+test("togglePostSelection", function (assert) {
const controller = this.subject();
const selectedPostIds = controller.get("selectedPostIds");
@@ -455,7 +457,7 @@ QUnit.test("togglePostSelection", function (assert) {
);
});
-// QUnit.test("selectReplies", function(assert) {
+// test("selectReplies", function(assert) {
// const controller = this.subject();
// const selectedPostIds = controller.get("selectedPostIds");
//
@@ -468,7 +470,7 @@ QUnit.test("togglePostSelection", function (assert) {
// assert.equal(selectedPostIds[2], 100, "selected post #100");
// });
-QUnit.test("selectBelow", function (assert) {
+test("selectBelow", function (assert) {
const site = EmberObject.create({
post_types: { small_action: 3, whisper: 4 },
});
@@ -493,7 +495,7 @@ QUnit.test("selectBelow", function (assert) {
assert.equal(selectedPostIds[3], 8, "also selected 3rd post below post #3");
});
-QUnit.test("topVisibleChanged", function (assert) {
+test("topVisibleChanged", function (assert) {
let model = topicWithStream({
posts: [{ id: 1 }],
});
@@ -509,38 +511,35 @@ QUnit.test("topVisibleChanged", function (assert) {
);
});
-QUnit.test(
- "deletePost - no modal is shown if post does not have replies",
- function (assert) {
- pretender.get("/posts/2/reply-ids.json", () => {
- return [200, { "Content-Type": "application/json" }, []];
- });
+test("deletePost - no modal is shown if post does not have replies", function (assert) {
+ pretender.get("/posts/2/reply-ids.json", () => {
+ return [200, { "Content-Type": "application/json" }, []];
+ });
- let destroyed;
- const post = EmberObject.create({
- id: 2,
- post_number: 2,
- can_delete: true,
- reply_count: 3,
- destroy: () => {
- destroyed = true;
- return Promise.resolve();
- },
- });
+ let destroyed;
+ const post = EmberObject.create({
+ id: 2,
+ post_number: 2,
+ can_delete: true,
+ reply_count: 3,
+ destroy: () => {
+ destroyed = true;
+ return Promise.resolve();
+ },
+ });
- const currentUser = EmberObject.create({ moderator: true });
- let model = topicWithStream({
- stream: [2, 3, 4],
- posts: [post, { id: 3 }, { id: 4 }],
- });
- const controller = this.subject({ model, currentUser });
+ const currentUser = EmberObject.create({ moderator: true });
+ let model = topicWithStream({
+ stream: [2, 3, 4],
+ posts: [post, { id: 3 }, { id: 4 }],
+ });
+ const controller = this.subject({ model, currentUser });
- const done = assert.async();
- controller.send("deletePost", post);
+ const done = assert.async();
+ controller.send("deletePost", post);
- next(() => {
- assert.ok(destroyed, "post was destroyed");
- done();
- });
- }
-);
+ next(() => {
+ assert.ok(destroyed, "post was destroyed");
+ done();
+ });
+});
diff --git a/app/assets/javascripts/discourse/tests/unit/ember/resolver-test.js b/app/assets/javascripts/discourse/tests/unit/ember/resolver-test.js
index 62877d4dcc..771a1594ac 100644
--- a/app/assets/javascripts/discourse/tests/unit/ember/resolver-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/ember/resolver-test.js
@@ -1,3 +1,4 @@
+import { test, module } from "qunit";
import { setResolverOption, buildResolver } from "discourse-common/resolver";
let originalTemplates;
@@ -17,7 +18,7 @@ function setTemplates(lookupTemplateStrings) {
const DiscourseResolver = buildResolver("discourse");
-QUnit.module("lib:resolver", {
+module("lib:resolver", {
beforeEach() {
originalTemplates = Ember.TEMPLATES;
Ember.TEMPLATES = {};
@@ -30,7 +31,7 @@ QUnit.module("lib:resolver", {
},
});
-QUnit.test("finds templates in top level dir", (assert) => {
+test("finds templates in top level dir", (assert) => {
setTemplates(["foobar", "fooBar", "foo_bar", "foo.bar"]);
lookupTemplate(assert, "template:foobar", "foobar", "by lowcased name");
@@ -39,7 +40,7 @@ QUnit.test("finds templates in top level dir", (assert) => {
lookupTemplate(assert, "template:foo.bar", "foo.bar", "by dotted name");
});
-QUnit.test("finds templates in first-level subdir", (assert) => {
+test("finds templates in first-level subdir", (assert) => {
setTemplates(["foo/bar_baz"]);
lookupTemplate(
@@ -68,33 +69,30 @@ QUnit.test("finds templates in first-level subdir", (assert) => {
);
});
-QUnit.test(
- "resolves precedence between overlapping top level dir and first level subdir templates",
- (assert) => {
- setTemplates(["fooBar", "foo_bar", "foo.bar", "foo/bar"]);
+test("resolves precedence between overlapping top level dir and first level subdir templates", (assert) => {
+ setTemplates(["fooBar", "foo_bar", "foo.bar", "foo/bar"]);
- lookupTemplate(
- assert,
- "template:foo.bar",
- "foo/bar",
- "preferring first level subdir for dotted name"
- );
- lookupTemplate(
- assert,
- "template:fooBar",
- "fooBar",
- "preferring top level dir for camel cased name"
- );
- lookupTemplate(
- assert,
- "template:foo_bar",
- "foo_bar",
- "preferring top level dir for underscored name"
- );
- }
-);
+ lookupTemplate(
+ assert,
+ "template:foo.bar",
+ "foo/bar",
+ "preferring first level subdir for dotted name"
+ );
+ lookupTemplate(
+ assert,
+ "template:fooBar",
+ "fooBar",
+ "preferring top level dir for camel cased name"
+ );
+ lookupTemplate(
+ assert,
+ "template:foo_bar",
+ "foo_bar",
+ "preferring top level dir for underscored name"
+ );
+});
-QUnit.test("finds templates in subdir deeper than one level", (assert) => {
+test("finds templates in subdir deeper than one level", (assert) => {
setTemplates(["foo/bar/baz/qux"]);
lookupTemplate(
@@ -148,7 +146,7 @@ QUnit.test("finds templates in subdir deeper than one level", (assert) => {
);
});
-QUnit.test("resolves mobile templates to 'mobile/' namespace", (assert) => {
+test("resolves mobile templates to 'mobile/' namespace", (assert) => {
setTemplates(["mobile/foo", "bar", "mobile/bar", "baz"]);
setResolverOption("mobileView", true);
@@ -173,94 +171,85 @@ QUnit.test("resolves mobile templates to 'mobile/' namespace", (assert) => {
);
});
-QUnit.test(
- "resolves plugin templates to 'javascripts/' namespace",
- (assert) => {
- setTemplates(["javascripts/foo", "bar", "javascripts/bar", "baz"]);
+test("resolves plugin templates to 'javascripts/' namespace", (assert) => {
+ setTemplates(["javascripts/foo", "bar", "javascripts/bar", "baz"]);
- lookupTemplate(
- assert,
- "template:foo",
- "javascripts/foo",
- "finding plugin version even if normal one is not present"
- );
- lookupTemplate(
- assert,
- "template:bar",
- "javascripts/bar",
- "preferring plugin version when both versions are present"
- );
- lookupTemplate(
- assert,
- "template:baz",
- "baz",
- "falling back to a normal version when plugin version is not present"
- );
- }
-);
+ lookupTemplate(
+ assert,
+ "template:foo",
+ "javascripts/foo",
+ "finding plugin version even if normal one is not present"
+ );
+ lookupTemplate(
+ assert,
+ "template:bar",
+ "javascripts/bar",
+ "preferring plugin version when both versions are present"
+ );
+ lookupTemplate(
+ assert,
+ "template:baz",
+ "baz",
+ "falling back to a normal version when plugin version is not present"
+ );
+});
-QUnit.test(
- "resolves templates with 'admin' prefix to 'admin/templates/' namespace",
- (assert) => {
- setTemplates([
- "admin/templates/foo",
- "adminBar",
- "admin_bar",
- "admin.bar",
- "admin/templates/bar",
- ]);
+test("resolves templates with 'admin' prefix to 'admin/templates/' namespace", (assert) => {
+ setTemplates([
+ "admin/templates/foo",
+ "adminBar",
+ "admin_bar",
+ "admin.bar",
+ "admin/templates/bar",
+ ]);
- lookupTemplate(
- assert,
- "template:adminFoo",
- "admin/templates/foo",
- "when prefix is separated by camel case"
- );
- lookupTemplate(
- assert,
- "template:admin_foo",
- "admin/templates/foo",
- "when prefix is separated by underscore"
- );
- lookupTemplate(
- assert,
- "template:admin.foo",
- "admin/templates/foo",
- "when prefix is separated by dot"
- );
+ lookupTemplate(
+ assert,
+ "template:adminFoo",
+ "admin/templates/foo",
+ "when prefix is separated by camel case"
+ );
+ lookupTemplate(
+ assert,
+ "template:admin_foo",
+ "admin/templates/foo",
+ "when prefix is separated by underscore"
+ );
+ lookupTemplate(
+ assert,
+ "template:admin.foo",
+ "admin/templates/foo",
+ "when prefix is separated by dot"
+ );
- lookupTemplate(
- assert,
- "template:adminfoo",
- undefined,
- "but not when prefix is not separated in any way"
- );
- lookupTemplate(
- assert,
- "template:adminBar",
- "adminBar",
- "but not when template with the exact camel cased name exists"
- );
- lookupTemplate(
- assert,
- "template:admin_bar",
- "admin_bar",
- "but not when template with the exact underscored name exists"
- );
- lookupTemplate(
- assert,
- "template:admin.bar",
- "admin.bar",
- "but not when template with the exact dotted name exists"
- );
- }
-);
+ lookupTemplate(
+ assert,
+ "template:adminfoo",
+ undefined,
+ "but not when prefix is not separated in any way"
+ );
+ lookupTemplate(
+ assert,
+ "template:adminBar",
+ "adminBar",
+ "but not when template with the exact camel cased name exists"
+ );
+ lookupTemplate(
+ assert,
+ "template:admin_bar",
+ "admin_bar",
+ "but not when template with the exact underscored name exists"
+ );
+ lookupTemplate(
+ assert,
+ "template:admin.bar",
+ "admin.bar",
+ "but not when template with the exact dotted name exists"
+ );
+});
-QUnit.test(
- "returns 'not_found' template when template name cannot be resolved",
- (assert) => {
- setTemplates(["not_found"]);
+test("returns 'not_found' template when template name cannot be resolved", (assert) => {
+ setTemplates(["not_found"]);
- lookupTemplate(assert, "template:foo/bar/baz", "not_found", "");
- }
-);
+ lookupTemplate(assert, "template:foo/bar/baz", "not_found", "");
+});
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/bbcode-test.js b/app/assets/javascripts/discourse/tests/unit/lib/bbcode-test.js
index f8b7225335..41530ac39c 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/bbcode-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/bbcode-test.js
@@ -1,8 +1,9 @@
+import { test, module } from "qunit";
import { parseBBCodeTag } from "pretty-text/engines/discourse-markdown/bbcode-block";
-QUnit.module("lib:pretty-text:bbcode");
+module("lib:pretty-text:bbcode");
-QUnit.test("block with multiple quoted attributes", (assert) => {
+test("block with multiple quoted attributes", (assert) => {
const parsed = parseBBCodeTag('[test one="foo" two="bar bar"]', 0, 30);
assert.equal(parsed.tag, "test");
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/bookmark-test.js b/app/assets/javascripts/discourse/tests/unit/lib/bookmark-test.js
index 16857a8b73..7f12fbcce9 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/bookmark-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/bookmark-test.js
@@ -1,7 +1,8 @@
+import { test, module } from "qunit";
import { formattedReminderTime } from "discourse/lib/bookmark";
import { fakeTime } from "discourse/tests/helpers/qunit-helpers";
-QUnit.module("lib:bookmark", {
+module("lib:bookmark", {
beforeEach() {
fakeTime("2020-04-11 08:00:00", "Australia/Brisbane");
},
@@ -11,44 +12,35 @@ QUnit.module("lib:bookmark", {
},
});
-QUnit.test(
- "formattedReminderTime works when the reminder time is tomorrow",
- (assert) => {
- let reminderAt = "2020-04-12 09:45:00";
- let reminderAtDate = moment
- .tz(reminderAt, "Australia/Brisbane")
- .format("H:mm a");
- assert.equal(
- formattedReminderTime(reminderAt, "Australia/Brisbane"),
- "tomorrow at " + reminderAtDate
- );
- }
-);
+test("formattedReminderTime works when the reminder time is tomorrow", (assert) => {
+ let reminderAt = "2020-04-12 09:45:00";
+ let reminderAtDate = moment
+ .tz(reminderAt, "Australia/Brisbane")
+ .format("H:mm a");
+ assert.equal(
+ formattedReminderTime(reminderAt, "Australia/Brisbane"),
+ "tomorrow at " + reminderAtDate
+ );
+});
-QUnit.test(
- "formattedReminderTime works when the reminder time is today",
- (assert) => {
- let reminderAt = "2020-04-11 09:45:00";
- let reminderAtDate = moment
- .tz(reminderAt, "Australia/Brisbane")
- .format("H:mm a");
- assert.equal(
- formattedReminderTime(reminderAt, "Australia/Brisbane"),
- "today at " + reminderAtDate
- );
- }
-);
+test("formattedReminderTime works when the reminder time is today", (assert) => {
+ let reminderAt = "2020-04-11 09:45:00";
+ let reminderAtDate = moment
+ .tz(reminderAt, "Australia/Brisbane")
+ .format("H:mm a");
+ assert.equal(
+ formattedReminderTime(reminderAt, "Australia/Brisbane"),
+ "today at " + reminderAtDate
+ );
+});
-QUnit.test(
- "formattedReminderTime works when the reminder time is in the future",
- (assert) => {
- let reminderAt = "2020-04-15 09:45:00";
- let reminderAtDate = moment
- .tz(reminderAt, "Australia/Brisbane")
- .format("H:mm a");
- assert.equal(
- formattedReminderTime(reminderAt, "Australia/Brisbane"),
- "at Apr 15, 2020 " + reminderAtDate
- );
- }
-);
+test("formattedReminderTime works when the reminder time is in the future", (assert) => {
+ let reminderAt = "2020-04-15 09:45:00";
+ let reminderAtDate = moment
+ .tz(reminderAt, "Australia/Brisbane")
+ .format("H:mm a");
+ assert.equal(
+ formattedReminderTime(reminderAt, "Australia/Brisbane"),
+ "at Apr 15, 2020 " + reminderAtDate
+ );
+});
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/break-string-test.js b/app/assets/javascripts/discourse/tests/unit/lib/break-string-test.js
index 32bd03fb28..1a711d6c7d 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/break-string-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/break-string-test.js
@@ -1,8 +1,9 @@
+import { test, module } from "qunit";
/* global BreakString:true */
-QUnit.module("lib:breakString", {});
+module("lib:breakString", {});
-QUnit.test("breakString", (assert) => {
+test("breakString", (assert) => {
var b = function (s, hint) {
return new BreakString(s).break(hint);
};
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js b/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js
index d767147c62..005d729e86 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js
@@ -1,3 +1,4 @@
+import { test } from "qunit";
import createStore from "discourse/tests/helpers/create-store";
import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
import Site from "discourse/models/site";
@@ -6,11 +7,11 @@ discourseModule("lib:category-link");
import { categoryBadgeHTML } from "discourse/helpers/category-link";
-QUnit.test("categoryBadge without a category", (assert) => {
+test("categoryBadge without a category", (assert) => {
assert.blank(categoryBadgeHTML(), "it returns no HTML");
});
-QUnit.test("Regular categoryBadge", (assert) => {
+test("Regular categoryBadge", (assert) => {
const store = createStore();
const category = store.createRecord("category", {
name: "hello",
@@ -37,7 +38,7 @@ QUnit.test("Regular categoryBadge", (assert) => {
);
});
-QUnit.test("undefined color", (assert) => {
+test("undefined color", (assert) => {
const store = createStore();
const noColor = store.createRecord("category", { name: "hello", id: 123 });
const tag = $.parseHTML(categoryBadgeHTML(noColor))[0];
@@ -48,7 +49,7 @@ QUnit.test("undefined color", (assert) => {
);
});
-QUnit.test("topic count", (assert) => {
+test("topic count", (assert) => {
const store = createStore();
const category = store.createRecord("category", { name: "hello", id: 123 });
@@ -63,7 +64,7 @@ QUnit.test("topic count", (assert) => {
);
});
-QUnit.test("allowUncategorized", (assert) => {
+test("allowUncategorized", (assert) => {
const store = createStore();
const uncategorized = store.createRecord("category", {
name: "uncategorized",
@@ -85,7 +86,7 @@ QUnit.test("allowUncategorized", (assert) => {
);
});
-QUnit.test("category names are wrapped in dir-spans", function (assert) {
+test("category names are wrapped in dir-spans", function (assert) {
this.siteSettings.support_mixed_text_direction = true;
const store = createStore();
const rtlCategory = store.createRecord("category", {
@@ -110,7 +111,7 @@ QUnit.test("category names are wrapped in dir-spans", function (assert) {
assert.equal(dirSpan.dir, "ltr");
});
-QUnit.test("recursive", function (assert) {
+test("recursive", function (assert) {
const store = createStore();
const foo = store.createRecord("category", {
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/click-track-edit-history-test.js b/app/assets/javascripts/discourse/tests/unit/lib/click-track-edit-history-test.js
index 713bcb3997..77610e1692 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/click-track-edit-history-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/click-track-edit-history-test.js
@@ -1,10 +1,11 @@
+import { skip } from "qunit";
import DiscourseURL from "discourse/lib/url";
import ClickTrack from "discourse/lib/click-track";
import { fixture, logIn } from "discourse/tests/helpers/qunit-helpers";
import User from "discourse/models/user";
import pretender from "discourse/tests/helpers/create-pretender";
-QUnit.module("lib:click-track-edit-history", {
+module("lib:click-track-edit-history", {
beforeEach() {
logIn();
@@ -58,7 +59,7 @@ function generateClickEventOn(selector) {
return $.Event("click", { currentTarget: fixture(selector).first() });
}
-QUnit.skip("tracks internal URLs", async (assert) => {
+skip("tracks internal URLs", async (assert) => {
assert.expect(2);
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
@@ -74,7 +75,7 @@ QUnit.skip("tracks internal URLs", async (assert) => {
assert.notOk(track(generateClickEventOn("#same-site")));
});
-QUnit.skip("tracks external URLs", async (assert) => {
+skip("tracks external URLs", async (assert) => {
assert.expect(2);
const done = assert.async();
@@ -89,22 +90,19 @@ QUnit.skip("tracks external URLs", async (assert) => {
assert.notOk(track(generateClickEventOn("a")));
});
-QUnit.skip(
- "tracks external URLs when opening in another window",
- async (assert) => {
- assert.expect(3);
- User.currentProp("external_links_in_new_tab", true);
+skip("tracks external URLs when opening in another window", async (assert) => {
+ assert.expect(3);
+ User.currentProp("external_links_in_new_tab", true);
- const done = assert.async();
- pretender.post("/clicks/track", (request) => {
- assert.equal(
- request.requestBody,
- "url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
- );
- done();
- });
+ const done = assert.async();
+ pretender.post("/clicks/track", (request) => {
+ assert.equal(
+ request.requestBody,
+ "url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
+ );
+ done();
+ });
- assert.notOk(track(generateClickEventOn("a")));
- assert.ok(window.open.calledWith("http://www.google.com", "_blank"));
- }
-);
+ assert.notOk(track(generateClickEventOn("a")));
+ assert.ok(window.open.calledWith("http://www.google.com", "_blank"));
+});
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/click-track-profile-page-test.js b/app/assets/javascripts/discourse/tests/unit/lib/click-track-profile-page-test.js
index 441a9b1a76..fbcc27f707 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/click-track-profile-page-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/click-track-profile-page-test.js
@@ -1,9 +1,10 @@
+import { skip } from "qunit";
import DiscourseURL from "discourse/lib/url";
import ClickTrack from "discourse/lib/click-track";
import { fixture, logIn } from "discourse/tests/helpers/qunit-helpers";
import pretender from "discourse/tests/helpers/create-pretender";
-QUnit.module("lib:click-track-profile-page", {
+module("lib:click-track-profile-page", {
beforeEach() {
logIn();
@@ -51,7 +52,7 @@ function generateClickEventOn(selector) {
return $.Event("click", { currentTarget: fixture(selector).first() });
}
-QUnit.skip("tracks internal URLs", async (assert) => {
+skip("tracks internal URLs", async (assert) => {
assert.expect(2);
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
@@ -64,7 +65,7 @@ QUnit.skip("tracks internal URLs", async (assert) => {
assert.notOk(track(generateClickEventOn("#same-site")));
});
-QUnit.skip("tracks external URLs", async (assert) => {
+skip("tracks external URLs", async (assert) => {
assert.expect(2);
const done = assert.async();
@@ -79,7 +80,7 @@ QUnit.skip("tracks external URLs", async (assert) => {
assert.notOk(track(generateClickEventOn("a")));
});
-QUnit.skip("tracks external URLs in other posts", async (assert) => {
+skip("tracks external URLs in other posts", async (assert) => {
assert.expect(2);
const done = assert.async();
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/click-track-test.js b/app/assets/javascripts/discourse/tests/unit/lib/click-track-test.js
index 3ec9f35f40..0528478fc9 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/click-track-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/click-track-test.js
@@ -1,3 +1,5 @@
+import { skip } from "qunit";
+import { test, module } from "qunit";
import { later } from "@ember/runloop";
import DiscourseURL from "discourse/lib/url";
import ClickTrack from "discourse/lib/click-track";
@@ -5,7 +7,7 @@ import { fixture, logIn } from "discourse/tests/helpers/qunit-helpers";
import User from "discourse/models/user";
import pretender from "discourse/tests/helpers/create-pretender";
-QUnit.module("lib:click-track", {
+module("lib:click-track", {
beforeEach() {
logIn();
@@ -51,7 +53,7 @@ function generateClickEventOn(selector) {
return $.Event("click", { currentTarget: fixture(selector).first() });
}
-QUnit.skip("tracks internal URLs", async (assert) => {
+skip("tracks internal URLs", async (assert) => {
assert.expect(2);
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
@@ -67,11 +69,11 @@ QUnit.skip("tracks internal URLs", async (assert) => {
assert.notOk(track(generateClickEventOn("#same-site")));
});
-QUnit.test("does not track elements with no href", async (assert) => {
+test("does not track elements with no href", async (assert) => {
assert.ok(track(generateClickEventOn(".a-without-href")));
});
-QUnit.test("does not track attachments", async (assert) => {
+test("does not track attachments", async (assert) => {
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
pretender.post("/clicks/track", () => assert.ok(false));
@@ -84,7 +86,7 @@ QUnit.test("does not track attachments", async (assert) => {
);
});
-QUnit.skip("tracks external URLs", async (assert) => {
+skip("tracks external URLs", async (assert) => {
assert.expect(2);
const done = assert.async();
@@ -99,75 +101,69 @@ QUnit.skip("tracks external URLs", async (assert) => {
assert.notOk(track(generateClickEventOn("a")));
});
-QUnit.skip(
- "tracks external URLs when opening in another window",
- async (assert) => {
- assert.expect(3);
- User.currentProp("external_links_in_new_tab", true);
+skip("tracks external URLs when opening in another window", async (assert) => {
+ assert.expect(3);
+ User.currentProp("external_links_in_new_tab", true);
- const done = assert.async();
- pretender.post("/clicks/track", (request) => {
- assert.ok(
- request.requestBody,
- "url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
- );
- done();
- });
+ const done = assert.async();
+ pretender.post("/clicks/track", (request) => {
+ assert.ok(
+ request.requestBody,
+ "url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
+ );
+ done();
+ });
- assert.notOk(track(generateClickEventOn("a")));
- assert.ok(window.open.calledWith("http://www.google.com", "_blank"));
- }
-);
+ assert.notOk(track(generateClickEventOn("a")));
+ assert.ok(window.open.calledWith("http://www.google.com", "_blank"));
+});
-QUnit.test("does not track clicks on lightboxes", async (assert) => {
+test("does not track clicks on lightboxes", async (assert) => {
assert.notOk(track(generateClickEventOn(".lightbox")));
});
-QUnit.test("does not track clicks when forcibly disabled", async (assert) => {
+test("does not track clicks when forcibly disabled", async (assert) => {
assert.notOk(track(generateClickEventOn(".no-track-link")));
});
-QUnit.test("does not track clicks on back buttons", async (assert) => {
+test("does not track clicks on back buttons", async (assert) => {
assert.notOk(track(generateClickEventOn(".back")));
});
-QUnit.test("does not track right clicks inside quotes", async (assert) => {
+test("does not track right clicks inside quotes", async (assert) => {
const event = generateClickEventOn(".quote a:first-child");
event.which = 3;
assert.ok(track(event));
});
-QUnit.test("does not track clicks links in quotes", async (assert) => {
+test("does not track clicks links in quotes", async (assert) => {
User.currentProp("external_links_in_new_tab", true);
assert.notOk(track(generateClickEventOn(".quote a:last-child")));
assert.ok(window.open.calledWith("https://google.com/", "_blank"));
});
-QUnit.test("does not track clicks on category badges", async (assert) => {
+test("does not track clicks on category badges", async (assert) => {
assert.notOk(track(generateClickEventOn(".hashtag")));
});
-QUnit.test("does not track clicks on mailto", async (assert) => {
+test("does not track clicks on mailto", async (assert) => {
assert.ok(track(generateClickEventOn(".mailto")));
});
-QUnit.test(
- "removes the href and put it as a data attribute",
- async (assert) => {
- User.currentProp("external_links_in_new_tab", true);
+test("removes the href and put it as a data attribute", async (assert) => {
+ User.currentProp("external_links_in_new_tab", true);
- assert.notOk(track(generateClickEventOn("a")));
+ assert.notOk(track(generateClickEventOn("a")));
- var $link = fixture("a").first();
- assert.ok($link.hasClass("no-href"));
- assert.equal($link.data("href"), "http://www.google.com/");
- assert.blank($link.attr("href"));
- assert.ok($link.data("auto-route"));
- assert.ok(window.open.calledWith("http://www.google.com/", "_blank"));
- }
-);
+ var $link = fixture("a").first();
+ assert.ok($link.hasClass("no-href"));
+ assert.equal($link.data("href"), "http://www.google.com/");
+ assert.blank($link.attr("href"));
+ assert.ok($link.data("auto-route"));
+ assert.ok(window.open.calledWith("http://www.google.com/", "_blank"));
+});
-QUnit.test("restores the href after a while", async (assert) => {
+test("restores the href after a while", async (assert) => {
assert.expect(2);
assert.notOk(track(generateClickEventOn("a")));
@@ -187,24 +183,24 @@ function badgeClickCount(assert, id, expected) {
assert.equal(parseInt($badge.html(), 10), expected);
}
-QUnit.test("does not update badge clicks on my own link", async (assert) => {
+test("does not update badge clicks on my own link", async (assert) => {
sandbox.stub(User, "currentProp").withArgs("id").returns(314);
badgeClickCount(assert, "with-badge", 1);
});
-QUnit.test("does not update badge clicks in my own post", async (assert) => {
+test("does not update badge clicks in my own post", async (assert) => {
sandbox.stub(User, "currentProp").withArgs("id").returns(3141);
badgeClickCount(assert, "with-badge-but-not-mine", 1);
});
-QUnit.test("updates badge counts correctly", async (assert) => {
+test("updates badge counts correctly", async (assert) => {
badgeClickCount(assert, "inside-onebox", 1);
badgeClickCount(assert, "inside-onebox-forced", 2);
badgeClickCount(assert, "with-badge", 2);
});
function testOpenInANewTab(description, clickEventModifier) {
- QUnit.test(description, async (assert) => {
+ test(description, async (assert) => {
var clickEvent = generateClickEventOn("a");
clickEventModifier(clickEvent);
assert.ok(track(clickEvent));
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/computed-test.js b/app/assets/javascripts/discourse/tests/unit/lib/computed-test.js
index 10429f3bf0..748b17969b 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/computed-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/computed-test.js
@@ -1,3 +1,4 @@
+import { test } from "qunit";
import I18n from "I18n";
import EmberObject from "@ember/object";
import {
@@ -24,7 +25,7 @@ discourseModule("lib:computed", {
},
});
-QUnit.test("setting", function (assert) {
+test("setting", function (assert) {
let t = EmberObject.extend({
siteSettings: this.siteSettings,
vehicle: setting("vehicle"),
@@ -43,7 +44,7 @@ QUnit.test("setting", function (assert) {
);
});
-QUnit.test("propertyEqual", (assert) => {
+test("propertyEqual", (assert) => {
var t = EmberObject.extend({
same: propertyEqual("cookies", "biscuits"),
}).create({
@@ -56,7 +57,7 @@ QUnit.test("propertyEqual", (assert) => {
assert.ok(!t.get("same"), "it isn't true when one property is different");
});
-QUnit.test("propertyNotEqual", (assert) => {
+test("propertyNotEqual", (assert) => {
var t = EmberObject.extend({
diff: propertyNotEqual("cookies", "biscuits"),
}).create({
@@ -69,7 +70,7 @@ QUnit.test("propertyNotEqual", (assert) => {
assert.ok(t.get("diff"), "it is true when one property is different");
});
-QUnit.test("fmt", (assert) => {
+test("fmt", (assert) => {
var t = EmberObject.extend({
exclaimyUsername: fmt("username", "!!! %@ !!!"),
multiple: fmt("username", "mood", "%@ is %@"),
@@ -103,7 +104,7 @@ QUnit.test("fmt", (assert) => {
);
});
-QUnit.test("i18n", (assert) => {
+test("i18n", (assert) => {
var t = EmberObject.extend({
exclaimyUsername: i18n("username", "!!! %@ !!!"),
multiple: i18n("username", "mood", "%@ is %@"),
@@ -137,7 +138,7 @@ QUnit.test("i18n", (assert) => {
);
});
-QUnit.test("url", (assert) => {
+test("url", (assert) => {
var t, testClass;
testClass = EmberObject.extend({
@@ -160,7 +161,7 @@ QUnit.test("url", (assert) => {
);
});
-QUnit.test("htmlSafe", (assert) => {
+test("htmlSafe", (assert) => {
const cookies = "cookies and biscuits
"; const t = EmberObject.extend({ desc: htmlSafe("cookies"), diff --git a/app/assets/javascripts/discourse/tests/unit/lib/emoji-store-test.js b/app/assets/javascripts/discourse/tests/unit/lib/emoji-store-test.js index 14066a74c9..adf9c0c22c 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/emoji-store-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/emoji-store-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { discourseModule } from "discourse/tests/helpers/qunit-helpers"; discourseModule("lib:emoji-emojiStore", { @@ -10,22 +11,22 @@ discourseModule("lib:emoji-emojiStore", { }, }); -QUnit.test("defaults", function (assert) { +test("defaults", function (assert) { assert.deepEqual(this.emojiStore.favorites, []); assert.equal(this.emojiStore.diversity, 1); }); -QUnit.test("diversity", function (assert) { +test("diversity", function (assert) { this.emojiStore.diversity = 2; assert.equal(this.emojiStore.diversity, 2); }); -QUnit.test("favorites", function (assert) { +test("favorites", function (assert) { this.emojiStore.favorites = ["smile"]; assert.deepEqual(this.emojiStore.favorites, ["smile"]); }); -QUnit.test("track", function (assert) { +test("track", function (assert) { this.emojiStore.track("woman:t4"); assert.deepEqual(this.emojiStore.favorites, ["woman:t4"]); this.emojiStore.track("otter"); diff --git a/app/assets/javascripts/discourse/tests/unit/lib/emoji-test.js b/app/assets/javascripts/discourse/tests/unit/lib/emoji-test.js index 19fabb83e1..b8490e22f1 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/emoji-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/emoji-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { emojiSearch } from "pretty-text/emoji"; import { IMAGE_VERSION as v } from "pretty-text/emoji/version"; import { emojiUnescape } from "discourse/lib/text"; @@ -5,7 +6,7 @@ import { discourseModule } from "discourse/tests/helpers/qunit-helpers"; discourseModule("lib:emoji"); -QUnit.test("emojiUnescape", function (assert) { +test("emojiUnescape", function (assert) { const testUnescape = (input, expected, description, settings = {}) => { const originalSettings = {}; for (const [key, value] of Object.entries(settings)) { @@ -130,7 +131,7 @@ QUnit.test("emojiUnescape", function (assert) { ); }); -QUnit.test("Emoji search", (assert) => { +test("Emoji search", (assert) => { // able to find an alias assert.equal(emojiSearch("+1").length, 1); diff --git a/app/assets/javascripts/discourse/tests/unit/lib/formatter-test.js b/app/assets/javascripts/discourse/tests/unit/lib/formatter-test.js index 0c490f2c01..22914c5361 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/formatter-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/formatter-test.js @@ -1,3 +1,4 @@ +import { test } from "qunit"; import { relativeAge, autoUpdatingRelativeAge, @@ -48,7 +49,7 @@ function strip(html) { return $(html).text(); } -QUnit.test("formating medium length dates", function (assert) { +test("formating medium length dates", function (assert) { let shortDateYear = shortDateTester("MMM D, 'YY"); assert.equal( @@ -119,7 +120,7 @@ QUnit.test("formating medium length dates", function (assert) { assert.equal(strip(formatDays(10, { format: "medium" })), shortDateYear(10)); }); -QUnit.test("formating tiny dates", function (assert) { +test("formating tiny dates", function (assert) { let shortDateYear = shortDateTester("MMM 'YY"); assert.equal(formatMins(0), "1m"); @@ -182,7 +183,7 @@ QUnit.test("formating tiny dates", function (assert) { this.siteSettings.relative_date_duration = originalValue; }); -QUnit.test("autoUpdatingRelativeAge", function (assert) { +test("autoUpdatingRelativeAge", function (assert) { var d = moment().subtract(1, "day").toDate(); var $elem = $(autoUpdatingRelativeAge(d)); @@ -212,7 +213,7 @@ QUnit.test("autoUpdatingRelativeAge", function (assert) { assert.equal($elem.html(), "1 day"); }); -QUnit.test("updateRelativeAge", function (assert) { +test("updateRelativeAge", function (assert) { var d = new Date(); var $elem = $(autoUpdatingRelativeAge(d)); $elem.data("time", d.getTime() - 2 * 60 * 1000); @@ -230,7 +231,7 @@ QUnit.test("updateRelativeAge", function (assert) { assert.equal($elem.html(), "2 mins ago"); }); -QUnit.test("number", function (assert) { +test("number", function (assert) { assert.equal(number(123), "123", "it returns a string version of the number"); assert.equal(number("123"), "123", "it works with a string command"); assert.equal(number(NaN), "0", "it returns 0 for NaN"); @@ -261,7 +262,7 @@ QUnit.test("number", function (assert) { ); }); -QUnit.test("durationTiny", function (assert) { +test("durationTiny", function (assert) { assert.equal(durationTiny(), "—", "undefined is a dash"); assert.equal(durationTiny(null), "—", "null is a dash"); assert.equal(durationTiny(0), "< 1m", "0 seconds shows as < 1m"); diff --git a/app/assets/javascripts/discourse/tests/unit/lib/get-url-test.js b/app/assets/javascripts/discourse/tests/unit/lib/get-url-test.js index d11ee283e2..65506c85df 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/get-url-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/get-url-test.js @@ -1,3 +1,4 @@ +import { test, module } from "qunit"; import { default as getURL, setupURL, @@ -9,21 +10,21 @@ import { withoutPrefix, } from "discourse-common/lib/get-url"; -QUnit.module("lib:get-url"); +module("lib:get-url"); -QUnit.test("isAbsoluteURL", (assert) => { +test("isAbsoluteURL", (assert) => { setupURL(null, "https://example.com", "/forum"); assert.ok(isAbsoluteURL("https://example.com/test/thing")); assert.ok(!isAbsoluteURL("http://example.com/test/thing")); assert.ok(!isAbsoluteURL("https://discourse.org/test/thing")); }); -QUnit.test("getAbsoluteURL", (assert) => { +test("getAbsoluteURL", (assert) => { setupURL(null, "https://example.com", "/forum"); assert.equal(getAbsoluteURL("/cool/path"), "https://example.com/cool/path"); }); -QUnit.test("withoutPrefix", (assert) => { +test("withoutPrefix", (assert) => { setPrefix("/eviltrout"); assert.equal(withoutPrefix("/eviltrout/hello"), "/hello"); assert.equal(withoutPrefix("/eviltrout/"), "/"); @@ -40,7 +41,7 @@ QUnit.test("withoutPrefix", (assert) => { assert.equal(withoutPrefix("/"), "/"); }); -QUnit.test("getURL with empty paths", (assert) => { +test("getURL with empty paths", (assert) => { setupURL(null, "https://example.com", "/"); assert.equal(getURL("/"), "/"); assert.equal(getURL(""), ""); @@ -52,7 +53,7 @@ QUnit.test("getURL with empty paths", (assert) => { assert.equal(getURL(""), ""); }); -QUnit.test("getURL on subfolder install", (assert) => { +test("getURL on subfolder install", (assert) => { setupURL(null, "", "/forum"); assert.equal(getURL("/"), "/forum/", "root url has subfolder"); assert.equal( @@ -80,7 +81,7 @@ QUnit.test("getURL on subfolder install", (assert) => { ); }); -QUnit.test("getURLWithCDN on subfolder install with S3", (assert) => { +test("getURLWithCDN on subfolder install with S3", (assert) => { setupURL(null, "", "/forum"); setupS3CDN( "//test.s3-us-west-1.amazonaws.com/site", diff --git a/app/assets/javascripts/discourse/tests/unit/lib/highlight-search-test.js.es6 b/app/assets/javascripts/discourse/tests/unit/lib/highlight-search-test.js similarity index 85% rename from app/assets/javascripts/discourse/tests/unit/lib/highlight-search-test.js.es6 rename to app/assets/javascripts/discourse/tests/unit/lib/highlight-search-test.js index a677ab25fd..be226af537 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/highlight-search-test.js.es6 +++ b/app/assets/javascripts/discourse/tests/unit/lib/highlight-search-test.js @@ -1,9 +1,10 @@ import highlightSearch, { CLASS_NAME } from "discourse/lib/highlight-search"; import { fixture } from "discourse/tests/helpers/qunit-helpers"; +import { test } from "qunit"; -QUnit.module("lib:highlight-search"); +module("lib:highlight-search"); -QUnit.test("highlighting text", (assert) => { +test("highlighting text", (assert) => { fixture().html( `This is some text to highlight
@@ -25,7 +26,7 @@ QUnit.test("highlighting text", (assert) => { ); }); -QUnit.test("highlighting unicode text", (assert) => { +test("highlighting unicode text", (assert) => { fixture().html( `This is some தமிழ் & русский text to highlight
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/i18n-test.js b/app/assets/javascripts/discourse/tests/unit/lib/i18n-test.js index 7a8c20498f..7b713bb2e5 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/i18n-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/i18n-test.js @@ -1,5 +1,6 @@ +import { test, module } from "qunit"; import I18n from "I18n"; -QUnit.module("lib:i18n", { +module("lib:i18n", { _locale: I18n.locale, _fallbackLocale: I18n.fallbackLocale, _translations: I18n.translations, @@ -98,12 +99,12 @@ QUnit.module("lib:i18n", { }, }); -QUnit.test("defaults", (assert) => { +test("defaults", (assert) => { assert.equal(I18n.defaultLocale, "en", "it has English as default locale"); assert.ok(I18n.pluralizationRules["en"], "it has English pluralizer"); }); -QUnit.test("translations", (assert) => { +test("translations", (assert) => { assert.equal( I18n.t("topic.reply.title"), "Répondre", @@ -122,7 +123,7 @@ QUnit.test("translations", (assert) => { assert.equal(I18n.t("hello.universe"), "", "allows empty strings"); }); -QUnit.test("extra translations", (assert) => { +test("extra translations", (assert) => { I18n.locale = "pl_PL"; I18n.extras = { en: { @@ -194,7 +195,7 @@ QUnit.test("extra translations", (assert) => { ); }); -QUnit.test("pluralizations", (assert) => { +test("pluralizations", (assert) => { assert.equal(I18n.t("character_count", { count: 0 }), "0 ZERO"); assert.equal(I18n.t("character_count", { count: 1 }), "1 ONE"); assert.equal(I18n.t("character_count", { count: 2 }), "2 TWO"); @@ -210,7 +211,7 @@ QUnit.test("pluralizations", (assert) => { assert.equal(I18n.t("word_count", { count: 100 }), "100 words"); }); -QUnit.test("fallback", (assert) => { +test("fallback", (assert) => { assert.equal( I18n.t("days", { count: 1 }), "1 day", @@ -242,7 +243,7 @@ QUnit.test("fallback", (assert) => { ); }); -QUnit.test("Dollar signs are properly escaped", (assert) => { +test("Dollar signs are properly escaped", (assert) => { assert.equal( I18n.t("dollar_sign", { description: "$& $&", diff --git a/app/assets/javascripts/discourse/tests/unit/lib/icon-library-test.js b/app/assets/javascripts/discourse/tests/unit/lib/icon-library-test.js index fbfae424e7..209dfcea2a 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/icon-library-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/icon-library-test.js @@ -1,12 +1,13 @@ +import { test, module } from "qunit"; import { iconHTML, iconNode, convertIconClass, } from "discourse-common/lib/icon-library"; -QUnit.module("lib:icon-library"); +module("lib:icon-library"); -QUnit.test("return icon markup", (assert) => { +test("return icon markup", (assert) => { assert.ok(iconHTML("bars").indexOf('use xlink:href="#bars"') > -1); const nodeIcon = iconNode("bars"); @@ -17,7 +18,7 @@ QUnit.test("return icon markup", (assert) => { ); }); -QUnit.test("convert icon names", (assert) => { +test("convert icon names", (assert) => { const fa5Icon = convertIconClass("fab fa-facebook"); assert.ok(iconHTML(fa5Icon).indexOf("fab-facebook") > -1, "FA 5 syntax"); diff --git a/app/assets/javascripts/discourse/tests/unit/lib/key-value-store-test.js b/app/assets/javascripts/discourse/tests/unit/lib/key-value-store-test.js index 70d4469c4e..5af532ef57 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/key-value-store-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/key-value-store-test.js @@ -1,14 +1,15 @@ +import { test, module } from "qunit"; import KeyValueStore from "discourse/lib/key-value-store"; -QUnit.module("lib:key-value-store"); +module("lib:key-value-store"); -QUnit.test("it's able to get the result back from the store", (assert) => { +test("it's able to get the result back from the store", (assert) => { const store = new KeyValueStore("_test"); store.set({ key: "bob", value: "uncle" }); assert.equal(store.get("bob"), "uncle"); }); -QUnit.test("is able to nuke the store", (assert) => { +test("is able to nuke the store", (assert) => { const store = new KeyValueStore("_test"); store.set({ key: "bob1", value: "uncle" }); store.abandonLocal(); diff --git a/app/assets/javascripts/discourse/tests/unit/lib/link-mentions-test.js b/app/assets/javascripts/discourse/tests/unit/lib/link-mentions-test.js index 1adcf98514..507714524d 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/link-mentions-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/link-mentions-test.js @@ -1,3 +1,4 @@ +import { test, module } from "qunit"; import { fetchUnseenMentions, linkSeenMentions, @@ -5,9 +6,9 @@ import { import { Promise } from "rsvp"; import pretender from "discourse/tests/helpers/create-pretender"; -QUnit.module("lib:link-mentions"); +module("lib:link-mentions"); -QUnit.test("linkSeenMentions replaces users and groups", async (assert) => { +test("linkSeenMentions replaces users and groups", async (assert) => { pretender.get("/u/is_local_username", () => [ 200, { "Content-Type": "application/json" }, diff --git a/app/assets/javascripts/discourse/tests/unit/lib/load-script-test.js b/app/assets/javascripts/discourse/tests/unit/lib/load-script-test.js index acb8093ae4..03a3533f46 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/load-script-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/load-script-test.js @@ -1,27 +1,26 @@ +import { skip } from "qunit"; +import { test, module } from "qunit"; import { loadScript, cacheBuster } from "discourse/lib/load-script"; import { PUBLIC_JS_VERSIONS as jsVersions } from "discourse/lib/public-js-versions"; -QUnit.module("lib:load-script"); +module("lib:load-script"); -QUnit.skip( - "load with a script tag, and callbacks are only executed after script is loaded", - async (assert) => { - assert.ok( - typeof window.ace === "undefined", - "ensures ace is not previously loaded" - ); +skip("load with a script tag, and callbacks are only executed after script is loaded", async (assert) => { + assert.ok( + typeof window.ace === "undefined", + "ensures ace is not previously loaded" + ); - const src = "/javascripts/ace/ace.js"; + const src = "/javascripts/ace/ace.js"; - await loadScript(src); - assert.ok( - typeof window.ace !== "undefined", - "callbacks should only be executed after the script has fully loaded" - ); - } -); + await loadScript(src); + assert.ok( + typeof window.ace !== "undefined", + "callbacks should only be executed after the script has fully loaded" + ); +}); -QUnit.test("works when a value is not present", (assert) => { +test("works when a value is not present", (assert) => { assert.equal( cacheBuster("/javascripts/my-script.js"), "/javascripts/my-script.js" @@ -32,16 +31,13 @@ QUnit.test("works when a value is not present", (assert) => { ); }); -QUnit.test( - "generates URLs with version number in the query params", - (assert) => { - assert.equal( - cacheBuster("/javascripts/pikaday.js"), - `/javascripts/${jsVersions["pikaday.js"]}` - ); - assert.equal( - cacheBuster("/javascripts/ace/ace.js"), - `/javascripts/${jsVersions["ace/ace.js"]}` - ); - } -); +test("generates URLs with version number in the query params", (assert) => { + assert.equal( + cacheBuster("/javascripts/pikaday.js"), + `/javascripts/${jsVersions["pikaday.js"]}` + ); + assert.equal( + cacheBuster("/javascripts/ace/ace.js"), + `/javascripts/${jsVersions["ace/ace.js"]}` + ); +}); diff --git a/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.js b/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.js index 93ca35eed4..06ad0f599a 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.js @@ -1,3 +1,4 @@ +import { test, module } from "qunit"; import { load } from "pretty-text/oneboxer"; import { ajax } from "discourse/lib/ajax"; import { failedCache, localCache } from "pretty-text/oneboxer-cache"; @@ -14,9 +15,9 @@ function loadOnebox(element) { }); } -QUnit.module("lib:oneboxer"); +module("lib:oneboxer"); -QUnit.test("load - failed onebox", async (assert) => { +test("load - failed onebox", async (assert) => { let element = document.createElement("A"); element.setAttribute("href", "http://somebadurl.com"); @@ -34,7 +35,7 @@ QUnit.test("load - failed onebox", async (assert) => { ); }); -QUnit.test("load - successful onebox", async (assert) => { +test("load - successful onebox", async (assert) => { const html = `