diff --git a/.eslintrc b/.eslintrc index 8f0efccbc74..c311011c4d8 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 19ab1635bd6..4df70d2c89e 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 05c52ac5e39..70bace09ad3 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 ed462ada167..7dc377972f9 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 b0e06a97340..318f55fdc07 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 bd21cafb497..06eec98328a 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 175d1f29af1..b377f7f31d3 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 d05cc244391..05f4dea5c1f 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 35869979816..f6aa32d9afe 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 3b50422d1e6..f58b5e46827 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 3a93a2fe206..a03faf24bc0 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 8a434281723..33d5f161f4a 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 10747801eee..b0b9a000c00 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 230921fc6c7..e7808c43194 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 d2201846f7e..2b8d7241aab 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 6132441f0a1..83bb145a2e7 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 1eba7ffc3ea..577d6fc19c9 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 561f0f0996e..0a0b07ee819 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 2f931eb67ac..618553fb6b2 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 bef0b7c8245..2f509c05fc1 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 6053f4d37e2..b6e35e40bb5 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 3fcc308114d..087bef8070d 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 a52c027f593..9b3cb3a4f0d 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 7e922571bfa..26ba43123b8 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 0b13db4b6ac..44da9f79c0b 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 57a4d5f029d..d2569ce99ba 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 183d1c90827..f26060feaf2 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 ece3a6417f9..e5abbbda708 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 854927d8092..2025688a589 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 579345e988b..0ae883a9756 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 6c8d1512d54..d5aa28fc4c0 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 a558654b517..01e6b2b3dad 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 7f91a20c7b3..1984037be0a 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 817e933684e..5c7c06af963 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 a214e56f25c..98a3e960edd 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 df50610ad3a..056cedb560b 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 1d1061225ec..db064826e48 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 0fa875c2838..f2eb648875a 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 54d91404bb9..b908e034d27 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 e9f844fc6c5..d9bdfef09f5 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 138428a294e..89c88c9d457 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 51fb329d5e3..2a4277ab9f7 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 25d2d64f2a1..f74358a3816 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 600f86a6843..54f618476f7 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 dfc1a81cc3c..5707aae7060 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 ad0b3d37d73..f356963665b 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 f23d251d373..e3bcf210ada 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 51b686b3125..f3e1a66f8b2 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 d5249a3a307..945bad39a28 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 e7f7bc0adac..56b606eab8d 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 106b7e00c0a..0b904260560 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 4cb5db2ba86..89113098af9 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 0d8f4373358..1abdcb3f430 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 99f64a92e92..918970d03c5 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 60c4aa35cdc..5631f4f5ec7 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 d1fb0010320..c666c2eb6bf 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 2d9876c0a2c..acb0e76072e 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 4c13bf32913..2d8b5de924d 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 71c1c6c7e1b..d8cf22ed584 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 952089e7859..42bd1a61203 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 169aae43913..4dba725f8fd 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 96ff83d28ea..48adf928b50 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 eb638e8890d..b43f40b0456 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 18b5bcee23f..25b95d28052 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 833d0d4f8d1..a5e99a0b54b 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 397ae63a8d0..3c24b3c21bc 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 83f21aac25b..1883acf1887 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 1adbaa7f1a4..7bf47d2494f 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 f93ec01a189..fc91ab988b9 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 6057fed199e..b69449a8c01 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 c5d210c278f..f51993d7377 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 f95242d6ed8..be8c5f69ce6 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 7d002f7448d..20be2900f89 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 6361efe2d9a..8512658ed51 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 9b959cf961c..1005e337368 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 281bf94bf95..8e5d3aa0f03 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 452c8ae8a44..63f98611e4d 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 ad84a25745b..bb636b60fcb 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 b829dd23a5c..f6bde32267c 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 fa8011b466e..f264d2da253 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 cbddf5f6148..9cebe072a61 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 2068e2eafba..300dc4ec40f 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 64acfe8aab7..7ccfe91e547 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 e0ed6433c6a..88e966d55d7 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 1c84889cbff..0d0f58027df 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 f8f2b3c1591..12717a15e33 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 3d2628e0f1a..d996bd8a048 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 c9612adfec3..e2953081152 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 f806ab34534..6fedbb15059 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 e98a67badea..68a30530a94 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 81ed32c84b0..bc80964a311 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 5dec56e8e49..82639e9f5e7 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 6c19832471c..32705c3f778 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 cd668878f68..17691af824f 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 6d42d652406..7841043184a 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 1821b2abdc8..996dedcb226 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 717bd90b4c2..00639c47d2b 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 f7e1e68d9d8..e1d38800ae0 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 0f9cdc5a0f1..6cfc09e267f 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 30a88815018..c2c12e50182 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 f8c180897fa..f67a5203aa6 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 4bc854a636f..caaceef158d 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 4ab6c6c43c9..1f2e5adae50 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 95fd895e6e5..c201bc4c0fa 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 8dab6309704..fe24a9bf5f6 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 5363beb8da4..cf7f7a26b24 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 e1da1c0a290..81226a4730b 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 f6f25b7c9aa..9cc2605aa38 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 b989b10efc9..477e2fe5791 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 bd9a8c826ba..5b2b32e529c 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 20a3554cec1..125fab78fad 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 8e160e07e44..9f9c20b1962 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 5ddb9860fdf..c19784c9ce7 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 ee0e48cc332..4c35d63b9e4 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 f77ecd1a30f..0b91fe4ecb2 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 4068e04bbe7..fff821e3ae8 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 5d05288ee0e..091e4564dab 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(), - `Testcookies 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 14066a74c9d..adf9c0c22c8 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 19fabb83e1c..b8490e22f1c 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 0c490f2c017..22914c5361d 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 d11ee283e2f..65506c85df5 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 a677ab25fdb..be226af5378 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 7a8c20498f2..7b713bb2e5d 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 fbfae424e7b..209dfcea2a0 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 70d4469c4e7..5af532ef573 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 1adcf985148..507714524d1 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 acb8093ae48..03a3533f469 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 93ca35eed4f..06ad0f599a2 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 = `