{{/if}}
{{/d-section}}
diff --git a/app/assets/javascripts/discourse/app/widgets/link.js b/app/assets/javascripts/discourse/app/widgets/link.js
index dc2d52e143..63452b0520 100644
--- a/app/assets/javascripts/discourse/app/widgets/link.js
+++ b/app/assets/javascripts/discourse/app/widgets/link.js
@@ -97,14 +97,18 @@ export default createWidget("link", {
);
}
}
-
return result;
},
click(e) {
+ if (this.attrs.attributes && this.attrs.attributes.target === "_blank") {
+ return;
+ }
+
if (wantsNewWindow(e)) {
return;
}
+
e.preventDefault();
if (this.attrs.action) {
diff --git a/app/assets/javascripts/discourse/app/widgets/user-menu.js b/app/assets/javascripts/discourse/app/widgets/user-menu.js
index b37354b9f9..79379340f7 100644
--- a/app/assets/javascripts/discourse/app/widgets/user-menu.js
+++ b/app/assets/javascripts/discourse/app/widgets/user-menu.js
@@ -27,8 +27,8 @@ createWidget("user-menu-links", {
return {
label: "user.preferences",
className: "user-preferences-link",
- icon: "cog",
- href: `${this.attrs.path}/preferences`,
+ icon: "user",
+ href: `${this.attrs.path}/summary`,
action: UserMenuAction.QUICK_ACCESS,
actionParam: QuickAccess.PROFILE,
};
diff --git a/test/javascripts/acceptance/about-test.js b/app/assets/javascripts/discourse/tests/acceptance/about-test.js
similarity index 69%
rename from test/javascripts/acceptance/about-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/about-test.js
index 755fa7232b..f58b5e4682 100644
--- a/test/javascripts/acceptance/about-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/about-test.js
@@ -1,7 +1,8 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/account-created-test.js b/app/assets/javascripts/discourse/tests/acceptance/account-created-test.js
similarity index 86%
rename from test/javascripts/acceptance/account-created-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/account-created-test.js
index 1680f14088..a03faf24bc 100644
--- a/test/javascripts/acceptance/account-created-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/account-created-test.js
@@ -1,9 +1,10 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/admin-emails-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-emails-test.js
similarity index 79%
rename from test/javascripts/acceptance/admin-emails-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/admin-emails-test.js
index 1de408c83e..33d5f161f4 100644
--- a/test/javascripts/acceptance/admin-emails-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-emails-test.js
@@ -1,5 +1,6 @@
-import { acceptance } from "helpers/qunit-helpers";
-import pretender from "helpers/create-pretender";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+import pretender from "discourse/tests/helpers/create-pretender";
acceptance("Admin - Emails", { loggedIn: true });
@@ -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/test/javascripts/acceptance/admin-search-log-term-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-search-log-term-test.js
similarity index 69%
rename from test/javascripts/acceptance/admin-search-log-term-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/admin-search-log-term-test.js
index ea5e96e275..b0b9a000c0 100644
--- a/test/javascripts/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 { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/admin-search-logs-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-search-logs-test.js
similarity index 74%
rename from test/javascripts/acceptance/admin-search-logs-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/admin-search-logs-test.js
index fafbd651cd..e7808c4319 100644
--- a/test/javascripts/acceptance/admin-search-logs-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-search-logs-test.js
@@ -1,7 +1,8 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/admin-site-settings-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js
similarity index 76%
rename from test/javascripts/acceptance/admin-site-settings-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js
index 0780a1b3cb..2b8d7241aa 100644
--- a/test/javascripts/acceptance/admin-site-settings-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js
@@ -1,5 +1,6 @@
-import { acceptance } from "helpers/qunit-helpers";
-import siteSettingFixture from "fixtures/site_settings";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+import siteSettingFixture from "discourse/tests/fixtures/site-settings";
var titleOverride = undefined;
@@ -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/test/javascripts/acceptance/admin-site-text-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-site-text-test.js
similarity index 85%
rename from test/javascripts/acceptance/admin-site-text-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/admin-site-text-test.js
index 06bed8874f..83bb145a2e 100644
--- a/test/javascripts/acceptance/admin-site-text-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-site-text-test.js
@@ -1,8 +1,9 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/admin-suspend-user-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-suspend-user-test.js
similarity index 87%
rename from test/javascripts/acceptance/admin-suspend-user-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/admin-suspend-user-test.js
index 9f67ff1bee..577d6fc19c 100644
--- a/test/javascripts/acceptance/admin-suspend-user-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-suspend-user-test.js
@@ -1,5 +1,6 @@
-import selectKit from "helpers/select-kit-helper";
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Admin - Suspend User", {
loggedIn: true,
@@ -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/test/javascripts/acceptance/admin-user-badges-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-user-badges-test.js
similarity index 54%
rename from test/javascripts/acceptance/admin-user-badges-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/admin-user-badges-test.js
index 9686b2bba0..0a0b07ee81 100644
--- a/test/javascripts/acceptance/admin-user-badges-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-user-badges-test.js
@@ -1,8 +1,9 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/admin-user-emails-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-user-emails-test.js
similarity index 80%
rename from test/javascripts/acceptance/admin-user-emails-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/admin-user-emails-test.js
index 7e21e056aa..618553fb6b 100644
--- a/test/javascripts/acceptance/admin-user-emails-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-user-emails-test.js
@@ -1,5 +1,6 @@
+import { test } from "qunit";
import I18n from "I18n";
-import { acceptance } from "helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Admin - User Emails", { loggedIn: true });
@@ -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/test/javascripts/acceptance/admin-user-index-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-user-index-test.js
similarity index 86%
rename from test/javascripts/acceptance/admin-user-index-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/admin-user-index-test.js
index 841b1a6f8b..2f509c05fc 100644
--- a/test/javascripts/acceptance/admin-user-index-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-user-index-test.js
@@ -1,6 +1,7 @@
-import selectKit from "helpers/select-kit-helper";
-import { acceptance } from "helpers/qunit-helpers";
-import pretender from "helpers/create-pretender";
+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";
acceptance("Admin - User Index", {
loggedIn: true,
@@ -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/test/javascripts/acceptance/admin-users-list-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-users-list-test.js
similarity index 89%
rename from test/javascripts/acceptance/admin-users-list-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/admin-users-list-test.js
index db73491332..b6e35e40bb 100644
--- a/test/javascripts/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 "helpers/qunit-helpers";
+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/test/javascripts/acceptance/admin-watched-words-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-watched-words-test.js
similarity index 88%
rename from test/javascripts/acceptance/admin-watched-words-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/admin-watched-words-test.js
index 9ee3356a31..087bef8070 100644
--- a/test/javascripts/acceptance/admin-watched-words-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-watched-words-test.js
@@ -1,7 +1,8 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/auth-complete-test.js b/app/assets/javascripts/discourse/tests/acceptance/auth-complete-test.js
similarity index 81%
rename from test/javascripts/acceptance/auth-complete-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/auth-complete-test.js
index d7f43d5dd1..9b3cb3a4f0 100644
--- a/test/javascripts/acceptance/auth-complete-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/auth-complete-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Auth Complete", {
beforeEach() {
const node = document.createElement("meta");
@@ -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/test/javascripts/acceptance/badges-test.js b/app/assets/javascripts/discourse/tests/acceptance/badges-test.js
similarity index 70%
rename from test/javascripts/acceptance/badges-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/badges-test.js
index 2707bb3b37..26ba43123b 100644
--- a/test/javascripts/acceptance/badges-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/badges-test.js
@@ -1,9 +1,10 @@
-import selectKit from "helpers/select-kit-helper";
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/bookmarks-test.js b/app/assets/javascripts/discourse/tests/acceptance/bookmarks-test.js
similarity index 86%
rename from test/javascripts/acceptance/bookmarks-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/bookmarks-test.js
index c897b6fb65..44da9f79c0 100644
--- a/test/javascripts/acceptance/bookmarks-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/bookmarks-test.js
@@ -1,12 +1,15 @@
+import { skip } from "qunit";
+import { test } from "qunit";
import I18n from "I18n";
-import selectKit from "helpers/select-kit-helper";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
import {
acceptance,
loggedInUser,
acceptanceUseFakeClock,
-} from "helpers/qunit-helpers";
-import pretender from "helpers/create-pretender";
-import { parsePostData } from "helpers/create-pretender";
+} from "discourse/tests/helpers/qunit-helpers";
+import pretender, {
+ parsePostData,
+} from "discourse/tests/helpers/create-pretender";
acceptance("Bookmarking", {
loggedIn: true,
@@ -235,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/test/javascripts/acceptance/category-banner-test.js b/app/assets/javascripts/discourse/tests/acceptance/category-banner-test.js
similarity index 77%
rename from test/javascripts/acceptance/category-banner-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/category-banner-test.js
index ea51c986a3..d2569ce99b 100644
--- a/test/javascripts/acceptance/category-banner-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/category-banner-test.js
@@ -1,5 +1,6 @@
-import { acceptance } from "helpers/qunit-helpers";
-import DiscoveryFixtures from "fixtures/discovery_fixtures";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+import DiscoveryFixtures from "discourse/tests/fixtures/discovery-fixtures";
acceptance("Category Banners", {
pretend(server, helper) {
@@ -29,13 +30,13 @@ acceptance("Category Banners", {
slug: "test-read-only-with-banner",
permission: null,
read_only_banner:
- "You need to video yourself doing the secret handshake to post here",
+ "You need to video yourself
doing
the secret handshake to post here",
},
],
},
});
-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");
@@ -55,6 +56,10 @@ QUnit.test("Displays category banners when set", async (assert) => {
await click(".modal-footer>.btn-primary");
assert.ok(!visible(".bootbox.modal"), "it closes the modal");
assert.ok(visible(".category-read-only-banner"), "it shows a banner");
+ assert.ok(
+ find(".category-read-only-banner .inner").length === 1,
+ "it allows staff to embed html in the message"
+ );
});
acceptance("Anonymous Category Banners", {
@@ -80,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
new file mode 100644
index 0000000000..3de106a145
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/acceptance/category-chooser-test.js
@@ -0,0 +1,27 @@
+import { test } from "qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+
+acceptance("CategoryChooser", {
+ loggedIn: true,
+ settings: {
+ allow_uncategorized_topics: false,
+ },
+});
+
+test("does not display uncategorized if not allowed", async (assert) => {
+ const categoryChooser = selectKit(".category-chooser");
+
+ await visit("/");
+ await click("#create-topic");
+
+ await categoryChooser.expand();
+
+ assert.ok(categoryChooser.rowByIndex(0).name() !== "uncategorized");
+});
+
+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);
+});
diff --git a/test/javascripts/acceptance/category-edit-security-test.js b/app/assets/javascripts/discourse/tests/acceptance/category-edit-security-test.js
similarity index 89%
rename from test/javascripts/acceptance/category-edit-security-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/category-edit-security-test.js
index e6e0e7fd14..e5abbbda70 100644
--- a/test/javascripts/acceptance/category-edit-security-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/category-edit-security-test.js
@@ -1,11 +1,12 @@
-import selectKit from "helpers/select-kit-helper";
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
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/test/javascripts/acceptance/category-edit-test.js b/app/assets/javascripts/discourse/tests/acceptance/category-edit-test.js
similarity index 85%
rename from test/javascripts/acceptance/category-edit-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/category-edit-test.js
index a3a8268c80..2025688a58 100644
--- a/test/javascripts/acceptance/category-edit-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/category-edit-test.js
@@ -1,13 +1,15 @@
-import selectKit from "helpers/select-kit-helper";
+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 "helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Category Edit", {
loggedIn: true,
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/test/javascripts/acceptance/click-track-test.js b/app/assets/javascripts/discourse/tests/acceptance/click-track-test.js
similarity index 66%
rename from test/javascripts/acceptance/click-track-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/click-track-test.js
index d8a982d61c..0ae883a975 100644
--- a/test/javascripts/acceptance/click-track-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/click-track-test.js
@@ -1,9 +1,10 @@
-import pretender from "helpers/create-pretender";
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/composer-actions-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js
similarity index 57%
rename from test/javascripts/acceptance/composer-actions-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js
index 821665371a..191831f418 100644
--- a/test/javascripts/acceptance/composer-actions-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js
@@ -1,6 +1,10 @@
+import { test } from "qunit";
import I18n from "I18n";
-import selectKit from "helpers/select-kit-helper";
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import {
+ acceptance,
+ updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
import { _clearSnapshots } from "select-kit/components/composer-actions";
import { toggleCheckDraftPopup } from "discourse/controllers/composer";
import Draft from "discourse/models/draft";
@@ -14,27 +18,262 @@ acceptance("Composer Actions", {
site: {
can_tag_topics: true,
},
+ pretend(server) {
+ server.get("/t/130.json", () => {
+ return [
+ 200,
+ { "Content-Type": "application/json" },
+ {
+ post_stream: {
+ posts: [
+ {
+ id: 133,
+ name: null,
+ username: "bianca",
+ avatar_template:
+ "/letter_avatar_proxy/v4/letter/b/3be4f8/{size}.png",
+ created_at: "2020-07-05T09:28:36.371Z",
+ cooked:
+ "
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas a varius ipsum. Nunc euismod, metus non vulputate malesuada, ligula metus pharetra tortor, vel sodales arcu lacus sed mauris. Nam semper, orci vitae fringilla placerat, dui tellus convallis felis, ultricies laoreet sapien mi et metus. Mauris facilisis, mi fermentum rhoncus feugiat, dolor est vehicula leo, id porta leo ex non enim. In a ligula vel tellus commodo scelerisque non in ex. Pellentesque semper leo quam, nec varius est viverra eget. Donec vehicula sem et massa faucibus tempus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas a varius ipsum. Nunc euismod, metus non vulputate malesuada, ligula metus pharetra tortor, vel sodales arcu lacus sed mauris. Nam semper, orci vitae fringilla placerat, dui tellus convallis felis, ultricies laoreet sapien mi et metus. Mauris facilisis, mi fermentum rhoncus feugiat, dolor est vehicula leo, id porta leo ex non enim. In a ligula vel tellus commodo scelerisque non in ex. Pellentesque semper leo quam, nec varius est viverra eget. Donec vehicula sem et massa faucibus tempus.
@@ -39,6 +38,5 @@ This is another test This is a great title
`.trim()
- );
- }
-);
+ );
+});
diff --git a/test/javascripts/acceptance/composer-tags-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-tags-test.js
similarity index 82%
rename from test/javascripts/acceptance/composer-tags-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/composer-tags-test.js
index da2502158b..056cedb560 100644
--- a/test/javascripts/acceptance/composer-tags-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-tags-test.js
@@ -1,6 +1,10 @@
+import { test } from "qunit";
import Category from "discourse/models/category";
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
-import selectKit from "helpers/select-kit-helper";
+import {
+ acceptance,
+ updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
acceptance("Composer - Tags", {
loggedIn: true,
@@ -14,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");
@@ -31,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/test/javascripts/acceptance/composer-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js
similarity index 74%
rename from test/javascripts/acceptance/composer-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/composer-test.js
index 0639560a88..92c9565db9 100644
--- a/test/javascripts/acceptance/composer-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js
@@ -1,15 +1,17 @@
+import { skip } from "qunit";
+import { test } from "qunit";
import I18n from "I18n";
import { run } from "@ember/runloop";
-import selectKit from "helpers/select-kit-helper";
-import { acceptance } from "helpers/qunit-helpers";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { toggleCheckDraftPopup } from "discourse/controllers/composer";
import Draft from "discourse/models/draft";
import { Promise } from "rsvp";
acceptance("Composer", {
loggedIn: true,
- pretend(pretenderServer, helper) {
- pretenderServer.post("/uploads/lookup-urls", () => {
+ pretend(server, helper) {
+ server.post("/uploads/lookup-urls", () => {
return helper.response([]);
});
},
@@ -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");
@@ -827,20 +810,3 @@ QUnit.test("Image resizing buttons", async (assert) => {
"it does not unescapes script tags in code blocks"
);
});
-
-QUnit.test("can reply to a private message", async (assert) => {
- let submitted;
-
- /* global server */
- server.post("/posts", () => {
- submitted = true;
- return [200, { "Content-Type": "application/json" }, {}];
- });
-
- await visit("/t/34");
- await click(".topic-post:eq(0) button.reply");
- await fillIn(".d-editor-input", "this is the *content* of the reply");
- await click("#reply-control button.create");
-
- assert.ok(submitted);
-});
diff --git a/test/javascripts/acceptance/composer-topic-links-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js
similarity index 78%
rename from test/javascripts/acceptance/composer-topic-links-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js
index a962bbc7fd..f2eb648875 100644
--- a/test/javascripts/acceptance/composer-topic-links-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js
@@ -1,4 +1,8 @@
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import {
+ acceptance,
+ updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
acceptance("Composer topic featured links", {
loggedIn: true,
@@ -9,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");
@@ -28,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");
@@ -47,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");
@@ -66,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";
@@ -84,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(
@@ -106,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,
@@ -140,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/test/javascripts/acceptance/composer-uncategorized-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js
similarity index 61%
rename from test/javascripts/acceptance/composer-uncategorized-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js
index 26ff2f1148..b908e034d2 100644
--- a/test/javascripts/acceptance/composer-uncategorized-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js
@@ -1,5 +1,9 @@
-import selectKit from "helpers/select-kit-helper";
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import {
+ acceptance,
+ updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
acceptance(
"Composer disabled, uncategorized not allowed when any topic_template present",
@@ -12,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("/");
@@ -83,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/test/javascripts/acceptance/create-account-external-test.js b/app/assets/javascripts/discourse/tests/acceptance/create-account-external-test.js
similarity index 82%
rename from test/javascripts/acceptance/create-account-external-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/create-account-external-test.js
index 75466ce96d..d9bdfef09f 100644
--- a/test/javascripts/acceptance/create-account-external-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/create-account-external-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Create Account - external auth", {
beforeEach() {
@@ -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/test/javascripts/acceptance/create-account-user-fields-test.js b/app/assets/javascripts/discourse/tests/acceptance/create-account-user-fields-test.js
similarity index 92%
rename from test/javascripts/acceptance/create-account-user-fields-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/create-account-user-fields-test.js
index 8bd6f0ca99..89c88c9d45 100644
--- a/test/javascripts/acceptance/create-account-user-fields-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/create-account-user-fields-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Create Account - User Fields", {
site: {
@@ -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/test/javascripts/acceptance/custom-html-set-test.js b/app/assets/javascripts/discourse/tests/acceptance/custom-html-set-test.js
similarity index 72%
rename from test/javascripts/acceptance/custom-html-set-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/custom-html-set-test.js
index 84c235aba9..2a4277ab9f 100644
--- a/test/javascripts/acceptance/custom-html-set-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/custom-html-set-test.js
@@ -1,15 +1,16 @@
-import { acceptance } from "helpers/qunit-helpers";
+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: "monster",
});
diff --git a/test/javascripts/acceptance/custom-html-template-test.js b/app/assets/javascripts/discourse/tests/acceptance/custom-html-template-test.js
similarity index 69%
rename from test/javascripts/acceptance/custom-html-template-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/custom-html-template-test.js
index 21fff43f41..f74358a381 100644
--- a/test/javascripts/acceptance/custom-html-template-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/custom-html-template-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("CustomHTML template", {
beforeEach() {
@@ -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/test/javascripts/acceptance/dashboard-test.js b/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js
similarity index 88%
rename from test/javascripts/acceptance/dashboard-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js
index d2296ad1f3..54f618476f 100644
--- a/test/javascripts/acceptance/dashboard-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js
@@ -1,5 +1,6 @@
-import selectKit from "helpers/select-kit-helper";
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Dashboard", {
loggedIn: true,
@@ -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/test/javascripts/acceptance/email-notice-test.js b/app/assets/javascripts/discourse/tests/acceptance/email-notice-test.js
similarity index 74%
rename from test/javascripts/acceptance/email-notice-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/email-notice-test.js
index 2a664140f5..5707aae706 100644
--- a/test/javascripts/acceptance/email-notice-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/email-notice-test.js
@@ -1,10 +1,14 @@
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import {
+ acceptance,
+ updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
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(
@@ -13,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(
@@ -22,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
new file mode 100644
index 0000000000..f356963665
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js
@@ -0,0 +1,137 @@
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+
+acceptance("EmojiPicker", {
+ loggedIn: true,
+ beforeEach() {
+ this.emojiStore = this.container.lookup("service:emoji-store");
+ this.emojiStore.reset();
+ },
+ afterEach() {
+ this.emojiStore.reset();
+ },
+});
+
+test("emoji picker can be opened/closed", async (assert) => {
+ await visit("/t/internationalization-localization/280");
+ await click("#topic-footer-buttons .btn.create");
+
+ await click("button.emoji.btn");
+ assert.ok(exists(".emoji-picker.opened"), "it opens the picker");
+
+ await click("button.emoji.btn");
+ assert.notOk(exists(".emoji-picker.opened"), "it closes the picker");
+});
+
+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");
+ await click(".emoji-picker-emoji-area img.emoji[title='grinning']");
+
+ assert.equal(
+ find(".d-editor-input").val(),
+ ":grinning:",
+ "it adds the emoji code in the editor when selected"
+ );
+});
+
+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 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"
+ );
+});
+
+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 .category-button[data-section="recent"]'),
+ "it shows recent category icon"
+ );
+
+ 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[data-section="recent"]'),
+ "it hides recent section"
+ );
+
+ assert.notOk(
+ exists('.emoji-picker .category-button[data-section="recent"]'),
+ "it hides recent category icon"
+ );
+});
+
+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(
+ /grinning/.test(
+ find(".section.recent .section-group img.emoji").first().attr("src")
+ ),
+ true,
+ "it puts the last used emoji in first"
+ );
+});
+
+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");
+ await click(".emoji-picker button.diversity-scale.medium-dark");
+ await click("button.emoji.btn");
+ await click("button.emoji.btn");
+
+ assert.ok(
+ exists(".emoji-picker button.diversity-scale.medium-dark .d-icon"),
+ true,
+ "it stores diversity scale"
+ );
+});
diff --git a/test/javascripts/acceptance/emoji-test.js b/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js
similarity index 81%
rename from test/javascripts/acceptance/emoji-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/emoji-test.js
index 00218ffc3c..e3bcf210ad 100644
--- a/test/javascripts/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 "helpers/qunit-helpers";
+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/test/javascripts/acceptance/encoded-category-test.js b/app/assets/javascripts/discourse/tests/acceptance/encoded-category-test.js
similarity index 88%
rename from test/javascripts/acceptance/encoded-category-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/encoded-category-test.js
index d31e71d662..f3e1a66f8b 100644
--- a/test/javascripts/acceptance/encoded-category-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/encoded-category-test.js
@@ -1,5 +1,6 @@
-import { acceptance } from "helpers/qunit-helpers";
-import DiscoveryFixtures from "fixtures/discovery_fixtures";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+import DiscoveryFixtures from "discourse/tests/fixtures/discovery-fixtures";
acceptance("Encoded Sub Category Discovery", {
pretend(server, helper) {
@@ -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/test/javascripts/acceptance/enforce-second-factor-test.js b/app/assets/javascripts/discourse/tests/acceptance/enforce-second-factor-test.js
similarity index 87%
rename from test/javascripts/acceptance/enforce-second-factor-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/enforce-second-factor-test.js
index 6f59631d87..945bad39a2 100644
--- a/test/javascripts/acceptance/enforce-second-factor-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/enforce-second-factor-test.js
@@ -1,4 +1,8 @@
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import {
+ acceptance,
+ updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
acceptance("Enforce Second Factor", {
loggedIn: true,
@@ -12,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";
@@ -34,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");
@@ -58,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/test/javascripts/acceptance/forgot-password-test.js b/app/assets/javascripts/discourse/tests/acceptance/forgot-password-test.js
similarity index 92%
rename from test/javascripts/acceptance/forgot-password-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/forgot-password-test.js
index bbd532a651..56b606eab8 100644
--- a/test/javascripts/acceptance/forgot-password-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/forgot-password-test.js
@@ -1,5 +1,6 @@
+import { test } from "qunit";
import I18n from "I18n";
-import { acceptance } from "helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
let userFound = false;
@@ -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/test/javascripts/acceptance/group-card-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-card-mobile-test.js
similarity index 80%
rename from test/javascripts/acceptance/group-card-mobile-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/group-card-mobile-test.js
index d7a5e8083c..0b90426056 100644
--- a/test/javascripts/acceptance/group-card-mobile-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-card-mobile-test.js
@@ -1,9 +1,10 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/group-card-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-card-test.js
similarity index 78%
rename from test/javascripts/acceptance/group-card-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/group-card-test.js
index 06a1d596c5..89113098af 100644
--- a/test/javascripts/acceptance/group-card-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-card-test.js
@@ -1,9 +1,10 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/group-index-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js
similarity index 80%
rename from test/javascripts/acceptance/group-index-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/group-index-test.js
index a35956958e..1abdcb3f43 100644
--- a/test/javascripts/acceptance/group-index-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js
@@ -1,9 +1,13 @@
+import { test } from "qunit";
import I18n from "I18n";
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
+import {
+ acceptance,
+ updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
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(
@@ -26,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");
@@ -39,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/test/javascripts/acceptance/group-manage-categories-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-categories-test.js
similarity index 74%
rename from test/javascripts/acceptance/group-manage-categories-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/group-manage-categories-test.js
index af3d850f05..918970d03c 100644
--- a/test/javascripts/acceptance/group-manage-categories-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-categories-test.js
@@ -1,7 +1,11 @@
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
+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(
@@ -12,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(
@@ -21,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/test/javascripts/acceptance/group-manage-interaction-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-interaction-test.js
similarity index 89%
rename from test/javascripts/acceptance/group-manage-interaction-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/group-manage-interaction-test.js
index 0f2d2b741c..5631f4f5ec 100644
--- a/test/javascripts/acceptance/group-manage-interaction-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-interaction-test.js
@@ -1,4 +1,8 @@
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import {
+ acceptance,
+ updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
acceptance("Managing Group Interaction Settings", {
loggedIn: true,
@@ -7,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,
@@ -47,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/test/javascripts/acceptance/group-manage-logs-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-logs-test.js
similarity index 95%
rename from test/javascripts/acceptance/group-manage-logs-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/group-manage-logs-test.js
index 0e1976ddc5..c666c2eb6b 100644
--- a/test/javascripts/acceptance/group-manage-logs-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-logs-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Group logs", {
loggedIn: true,
@@ -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/test/javascripts/acceptance/group-manage-membership-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-membership-test.js
similarity index 91%
rename from test/javascripts/acceptance/group-manage-membership-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/group-manage-membership-test.js
index 0e2af2fee5..acb0e76072 100644
--- a/test/javascripts/acceptance/group-manage-membership-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-membership-test.js
@@ -1,11 +1,15 @@
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
-import selectKit from "helpers/select-kit-helper";
+import { test } from "qunit";
+import {
+ acceptance,
+ updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
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");
@@ -72,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/test/javascripts/acceptance/group-manage-profile-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-profile-test.js
similarity index 79%
rename from test/javascripts/acceptance/group-manage-profile-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/group-manage-profile-test.js
index 34c744dee7..2d8b5de924 100644
--- a/test/javascripts/acceptance/group-manage-profile-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-profile-test.js
@@ -1,7 +1,11 @@
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
+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(
@@ -12,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(
@@ -33,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/test/javascripts/acceptance/group-manage-tags-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-tags-test.js
similarity index 73%
rename from test/javascripts/acceptance/group-manage-tags-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/group-manage-tags-test.js
index e71c43f64c..d8cf22ed58 100644
--- a/test/javascripts/acceptance/group-manage-tags-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-tags-test.js
@@ -1,7 +1,11 @@
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
+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(
@@ -12,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(
@@ -21,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/test/javascripts/acceptance/group-requests-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-requests-test.js
similarity index 94%
rename from test/javascripts/acceptance/group-requests-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/group-requests-test.js
index 39759517f9..42bd1a6120 100644
--- a/test/javascripts/acceptance/group-requests-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-requests-test.js
@@ -1,5 +1,6 @@
-import { acceptance } from "helpers/qunit-helpers";
-import { parsePostData } from "helpers/create-pretender";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+import { parsePostData } from "discourse/tests/helpers/create-pretender";
let requests = [];
@@ -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/test/javascripts/acceptance/group-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-test.js
similarity index 86%
rename from test/javascripts/acceptance/group-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/group-test.js
index 3990c05558..4dba725f8f 100644
--- a/test/javascripts/acceptance/group-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-test.js
@@ -1,7 +1,8 @@
+import { test } from "qunit";
import I18n from "I18n";
-import selectKit from "helpers/select-kit-helper";
-import { acceptance } from "helpers/qunit-helpers";
-import pretender from "helpers/create-pretender";
+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";
let groupArgs = {
settings: {
@@ -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/test/javascripts/acceptance/groups-index-test.js b/app/assets/javascripts/discourse/tests/acceptance/groups-index-test.js
similarity index 88%
rename from test/javascripts/acceptance/groups-index-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/groups-index-test.js
index 5868920f8b..48adf928b5 100644
--- a/test/javascripts/acceptance/groups-index-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/groups-index-test.js
@@ -1,8 +1,9 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/groups-new-test.js b/app/assets/javascripts/discourse/tests/acceptance/groups-new-test.js
similarity index 89%
rename from test/javascripts/acceptance/groups-new-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/groups-new-test.js
index 85954e6521..b43f40b045 100644
--- a/test/javascripts/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 "helpers/qunit-helpers";
+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/test/javascripts/acceptance/hamburger-menu-test.js b/app/assets/javascripts/discourse/tests/acceptance/hamburger-menu-test.js
similarity index 70%
rename from test/javascripts/acceptance/hamburger-menu-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/hamburger-menu-test.js
index 11fe87742d..25b95d2805 100644
--- a/test/javascripts/acceptance/hamburger-menu-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/hamburger-menu-test.js
@@ -1,4 +1,8 @@
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import {
+ acceptance,
+ updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
acceptance("Opening the hamburger menu with some reviewables", {
loggedIn: true,
@@ -7,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/test/javascripts/acceptance/hashtags-test.js b/app/assets/javascripts/discourse/tests/acceptance/hashtags-test.js
similarity index 86%
rename from test/javascripts/acceptance/hashtags-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/hashtags-test.js
index 4a8559ea6d..a5e99a0b54 100644
--- a/test/javascripts/acceptance/hashtags-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/hashtags-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Category and Tag Hashtags", {
loggedIn: true,
@@ -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/test/javascripts/acceptance/invite-accept-test.js b/app/assets/javascripts/discourse/tests/acceptance/invite-accept-test.js
similarity index 94%
rename from test/javascripts/acceptance/invite-accept-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/invite-accept-test.js
index eb8d85431e..3c24b3c21b 100644
--- a/test/javascripts/acceptance/invite-accept-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/invite-accept-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import PreloadStore from "discourse/lib/preload-store";
acceptance("Invite Accept", {
@@ -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/test/javascripts/acceptance/invite-show-user-fields-test.js b/app/assets/javascripts/discourse/tests/acceptance/invite-show-user-fields-test.js
similarity index 92%
rename from test/javascripts/acceptance/invite-show-user-fields-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/invite-show-user-fields-test.js
index f27b91850f..1883acf188 100644
--- a/test/javascripts/acceptance/invite-show-user-fields-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/invite-show-user-fields-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import PreloadStore from "discourse/lib/preload-store";
acceptance("Accept Invite - User Fields", {
@@ -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/test/javascripts/acceptance/jump-to-test.js b/app/assets/javascripts/discourse/tests/acceptance/jump-to-test.js
similarity index 88%
rename from test/javascripts/acceptance/jump-to-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/jump-to-test.js
index fca677999f..7bf47d2494 100644
--- a/test/javascripts/acceptance/jump-to-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/jump-to-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Jump to", {
loggedIn: true,
@@ -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/test/javascripts/acceptance/keyboard-shortcuts-test.js b/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js
similarity index 90%
rename from test/javascripts/acceptance/keyboard-shortcuts-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js
index 76c3bca928..fc91ab988b 100644
--- a/test/javascripts/acceptance/keyboard-shortcuts-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/keyboard-shortcuts-test.js
@@ -1,5 +1,6 @@
-import { acceptance } from "helpers/qunit-helpers";
-import pretender from "helpers/create-pretender";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+import pretender from "discourse/tests/helpers/create-pretender";
acceptance("Keyboard Shortcuts", { loggedIn: true });
diff --git a/test/javascripts/acceptance/login-redirect-test.js b/app/assets/javascripts/discourse/tests/acceptance/login-redirect-test.js
similarity index 64%
rename from test/javascripts/acceptance/login-redirect-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/login-redirect-test.js
index a1a0ebf38f..b69449a8c0 100644
--- a/test/javascripts/acceptance/login-redirect-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/login-redirect-test.js
@@ -1,7 +1,8 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/login-required-test.js b/app/assets/javascripts/discourse/tests/acceptance/login-required-test.js
similarity index 79%
rename from test/javascripts/acceptance/login-required-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/login-required-test.js
index a34fc49a39..f51993d737 100644
--- a/test/javascripts/acceptance/login-required-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/login-required-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Login Required", {
settings: {
@@ -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/test/javascripts/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
similarity index 77%
rename from test/javascripts/acceptance/login-with-email-and-hide-email-address-taken-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/login-with-email-and-hide-email-address-taken-test.js
index 6bdfb5ad7b..be8c5f69ce 100644
--- a/test/javascripts/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,6 +1,7 @@
+import { test } from "qunit";
import I18n from "I18n";
-import { acceptance } from "helpers/qunit-helpers";
-import pretender from "helpers/create-pretender";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+import pretender from "discourse/tests/helpers/create-pretender";
acceptance("Login with email - hide email address taken", {
settings: {
@@ -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/test/javascripts/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
similarity index 68%
rename from test/javascripts/acceptance/login-with-email-and-no-social-logins-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/login-with-email-and-no-social-logins-test.js
index ccf32b18be..20be2900f8 100644
--- a/test/javascripts/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,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Login with email - no social logins", {
settings: {
@@ -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/test/javascripts/acceptance/login-with-email-disabled-test.js b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-disabled-test.js
similarity index 74%
rename from test/javascripts/acceptance/login-with-email-disabled-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/login-with-email-disabled-test.js
index 9203cbffe0..8512658ed5 100644
--- a/test/javascripts/acceptance/login-with-email-disabled-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-disabled-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Login with email disabled", {
settings: {
@@ -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/test/javascripts/acceptance/login-with-email-test.js b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-test.js
similarity index 93%
rename from test/javascripts/acceptance/login-with-email-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/login-with-email-test.js
index 786c56ddf7..1005e33736 100644
--- a/test/javascripts/acceptance/login-with-email-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-test.js
@@ -1,5 +1,6 @@
+import { test } from "qunit";
import I18n from "I18n";
-import { acceptance } from "helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
let userFound = false;
@@ -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/test/javascripts/acceptance/mobile-discovery-test.js b/app/assets/javascripts/discourse/tests/acceptance/mobile-discovery-test.js
similarity index 68%
rename from test/javascripts/acceptance/mobile-discovery-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/mobile-discovery-test.js
index a83a7872e7..8e5d3aa0f0 100644
--- a/test/javascripts/acceptance/mobile-discovery-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/mobile-discovery-test.js
@@ -1,7 +1,8 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/mobile-sign-in-test.js b/app/assets/javascripts/discourse/tests/acceptance/mobile-sign-in-test.js
similarity index 58%
rename from test/javascripts/acceptance/mobile-sign-in-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/mobile-sign-in-test.js
index b5a9e604c3..63f98611e4 100644
--- a/test/javascripts/acceptance/mobile-sign-in-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/mobile-sign-in-test.js
@@ -1,8 +1,9 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/mobile-users-test.js b/app/assets/javascripts/discourse/tests/acceptance/mobile-users-test.js
similarity index 52%
rename from test/javascripts/acceptance/mobile-users-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/mobile-users-test.js
index 1b67837bff..bb636b60fc 100644
--- a/test/javascripts/acceptance/mobile-users-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/mobile-users-test.js
@@ -1,8 +1,9 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/modal-test.js b/app/assets/javascripts/discourse/tests/acceptance/modal-test.js
similarity index 91%
rename from test/javascripts/acceptance/modal-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/modal-test.js
index 8414007d7a..f6bde32267 100644
--- a/test/javascripts/acceptance/modal-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/modal-test.js
@@ -1,6 +1,11 @@
+import { skip } from "qunit";
+import { test } from "qunit";
import I18n from "I18n";
import { run } from "@ember/runloop";
-import { acceptance, controllerFor } from "helpers/qunit-helpers";
+import {
+ acceptance,
+ controllerFor,
+} from "discourse/tests/helpers/qunit-helpers";
import showModal from "discourse/lib/show-modal";
acceptance("Modal", {
@@ -21,7 +26,7 @@ acceptance("Modal", {
},
});
-QUnit.skip("modal", async function (assert) {
+skip("modal", async function (assert) {
await visit("/");
assert.ok(
@@ -71,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" },
@@ -88,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}}"
@@ -123,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/test/javascripts/acceptance/new-message-test.js b/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js
similarity index 76%
rename from test/javascripts/acceptance/new-message-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/new-message-test.js
index 155cea28a8..f264d2da25 100644
--- a/test/javascripts/acceptance/new-message-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js
@@ -1,8 +1,9 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/new-topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/new-topic-test.js
similarity index 69%
rename from test/javascripts/acceptance/new-topic-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/new-topic-test.js
index ad75ca3a11..9cebe072a6 100644
--- a/test/javascripts/acceptance/new-topic-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/new-topic-test.js
@@ -1,16 +1,17 @@
-import selectKit from "helpers/select-kit-helper";
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/notifications-filter-test.js b/app/assets/javascripts/discourse/tests/acceptance/notifications-filter-test.js
similarity index 82%
rename from test/javascripts/acceptance/notifications-filter-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/notifications-filter-test.js
index 6b35838def..300dc4ec40 100644
--- a/test/javascripts/acceptance/notifications-filter-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/notifications-filter-test.js
@@ -1,5 +1,6 @@
-import { acceptance } from "helpers/qunit-helpers";
-import selectKit from "helpers/select-kit-helper";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
acceptance("NotificationsFilter", {
loggedIn: true,
diff --git a/test/javascripts/acceptance/page-publishing-test.js b/app/assets/javascripts/discourse/tests/acceptance/page-publishing-test.js
similarity index 88%
rename from test/javascripts/acceptance/page-publishing-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/page-publishing-test.js
index d84681c922..7ccfe91e54 100644
--- a/test/javascripts/acceptance/page-publishing-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/page-publishing-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Page Publishing", {
loggedIn: true,
@@ -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/test/javascripts/acceptance/password-reset-test.js b/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js
similarity index 92%
rename from test/javascripts/acceptance/password-reset-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js
index f8dd9ebc0e..88e966d55d 100644
--- a/test/javascripts/acceptance/password-reset-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js
@@ -1,7 +1,8 @@
+import { test } from "qunit";
import I18n from "I18n";
-import { acceptance } from "helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import PreloadStore from "discourse/lib/preload-store";
-import { parsePostData } from "helpers/create-pretender";
+import { parsePostData } from "discourse/tests/helpers/create-pretender";
acceptance("Password Reset", {
pretend(server, helper) {
@@ -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/test/javascripts/acceptance/personal-message-test.js b/app/assets/javascripts/discourse/tests/acceptance/personal-message-test.js
similarity index 68%
rename from test/javascripts/acceptance/personal-message-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/personal-message-test.js
index f21f8c406f..0d0f58027d 100644
--- a/test/javascripts/acceptance/personal-message-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/personal-message-test.js
@@ -1,11 +1,12 @@
+import { test } from "qunit";
import I18n from "I18n";
-import { acceptance } from "helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
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/test/javascripts/acceptance/plugin-keyboard-shortcut-test.js b/app/assets/javascripts/discourse/tests/acceptance/plugin-keyboard-shortcut-test.js
similarity index 93%
rename from test/javascripts/acceptance/plugin-keyboard-shortcut-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/plugin-keyboard-shortcut-test.js
index 790331bd0b..12717a15e3 100644
--- a/test/javascripts/acceptance/plugin-keyboard-shortcut-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/plugin-keyboard-shortcut-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+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";
import KeyboardShortcutInitializer from "discourse/initializers/keyboard-shortcuts";
diff --git a/test/javascripts/acceptance/plugin-outlet-connector-class-test.js b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-connector-class-test.js
similarity index 93%
rename from test/javascripts/acceptance/plugin-outlet-connector-class-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-connector-class-test.js
index 92416f1f22..d996bd8a04 100644
--- a/test/javascripts/acceptance/plugin-outlet-connector-class-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-connector-class-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/plugin-outlet-decorator-test.js b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-decorator-test.js
similarity index 61%
rename from test/javascripts/acceptance/plugin-outlet-decorator-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-decorator-test.js
index 94ecb7d5a1..e295308115 100644
--- a/test/javascripts/acceptance/plugin-outlet-decorator-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-decorator-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { withPluginApi } from "discourse/lib/plugin-api";
const PREFIX = "javascripts/single-test/connectors";
@@ -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/test/javascripts/acceptance/plugin-outlet-multi-template-test.js b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-multi-template-test.js
similarity index 87%
rename from test/javascripts/acceptance/plugin-outlet-multi-template-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-multi-template-test.js
index 1b48bc664a..6fedbb1505 100644
--- a/test/javascripts/acceptance/plugin-outlet-multi-template-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-multi-template-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { clearCache } from "discourse/lib/plugin-connectors";
const HELLO = "javascripts/multi-test/connectors/user-profile-primary/hello";
@@ -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/test/javascripts/acceptance/plugin-outlet-single-template-test.js b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-single-template-test.js
similarity index 78%
rename from test/javascripts/acceptance/plugin-outlet-single-template-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-single-template-test.js
index d7460c9d61..68a30530a9 100644
--- a/test/javascripts/acceptance/plugin-outlet-single-template-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/plugin-outlet-single-template-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
const CONNECTOR =
"javascripts/single-test/connectors/user-profile-primary/hello";
@@ -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
new file mode 100644
index 0000000000..bc80964a31
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/acceptance/post-admin-menu-test.js
@@ -0,0 +1,33 @@
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+
+acceptance("Post - Admin Menu Anonymous Users", { loggedIn: false });
+
+test("Enter as a anon user", async (assert) => {
+ await visit("/t/internationalization-localization/280");
+ await click(".show-more-actions");
+
+ assert.ok(exists("#topic"), "The topic was rendered");
+ assert.ok(
+ exists("#post_1 .post-controls .edit"),
+ "The edit button was not rendered"
+ );
+ assert.ok(
+ !exists(".show-post-admin-menu"),
+ "The wrench button was not rendered"
+ );
+});
+
+acceptance("Post - Admin Menu", { loggedIn: true });
+
+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");
+});
diff --git a/test/javascripts/acceptance/preferences-test.js b/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js
similarity index 88%
rename from test/javascripts/acceptance/preferences-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/preferences-test.js
index ba256f72cb..82639e9f5e 100644
--- a/test/javascripts/acceptance/preferences-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js
@@ -1,6 +1,10 @@
+import { test } from "qunit";
import I18n from "I18n";
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
-import selectKit from "helpers/select-kit-helper";
+import {
+ acceptance,
+ updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
import User from "discourse/models/user";
function preferencesPretender(server, helper) {
@@ -66,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");
@@ -121,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");
@@ -140,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");
@@ -154,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(
@@ -175,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");
@@ -195,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");
@@ -221,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");
@@ -257,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");
@@ -284,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");
@@ -298,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(
@@ -309,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(
@@ -364,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(
@@ -415,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");
@@ -438,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/test/javascripts/acceptance/raw-plugin-outlet-test.js b/app/assets/javascripts/discourse/tests/acceptance/raw-plugin-outlet-test.js
similarity index 80%
rename from test/javascripts/acceptance/raw-plugin-outlet-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/raw-plugin-outlet-test.js
index 580f5ad3d4..32705c3f77 100644
--- a/test/javascripts/acceptance/raw-plugin-outlet-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/raw-plugin-outlet-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import compile from "handlebars-compiler";
import {
addRawTemplate,
@@ -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/test/javascripts/acceptance/redirect-to-top-test.js b/app/assets/javascripts/discourse/tests/acceptance/redirect-to-top-test.js
similarity index 76%
rename from test/javascripts/acceptance/redirect-to-top-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/redirect-to-top-test.js
index f207c00971..17691af824 100644
--- a/test/javascripts/acceptance/redirect-to-top-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/redirect-to-top-test.js
@@ -1,5 +1,9 @@
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
-import DiscoveryFixtures from "fixtures/discovery_fixtures";
+import { test } from "qunit";
+import {
+ acceptance,
+ updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
+import DiscoveryFixtures from "discourse/tests/fixtures/discovery-fixtures";
acceptance("Redirect to Top", {
pretend(server, helper) {
@@ -16,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: {
@@ -29,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: {
@@ -42,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/test/javascripts/acceptance/reports-test.js b/app/assets/javascripts/discourse/tests/acceptance/reports-test.js
similarity index 71%
rename from test/javascripts/acceptance/reports-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/reports-test.js
index 93cbbff368..7841043184 100644
--- a/test/javascripts/acceptance/reports-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/reports-test.js
@@ -1,10 +1,11 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/review-test.js b/app/assets/javascripts/discourse/tests/acceptance/review-test.js
similarity index 87%
rename from test/javascripts/acceptance/review-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/review-test.js
index 62fc40d7f4..996dedcb22 100644
--- a/test/javascripts/acceptance/review-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/review-test.js
@@ -1,5 +1,6 @@
-import selectKit from "helpers/select-kit-helper";
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Review", {
loggedIn: true,
@@ -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/test/javascripts/acceptance/search-full-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js
similarity index 60%
rename from test/javascripts/acceptance/search-full-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/search-full-test.js
index 4388ac7106..00639c47d2 100644
--- a/test/javascripts/acceptance/search-full-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js
@@ -1,5 +1,11 @@
-import selectKit from "helpers/select-kit-helper";
-import { selectDate, acceptance, waitFor } from "helpers/qunit-helpers";
+import { skip } from "qunit";
+import { test } from "qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import {
+ selectDate,
+ acceptance,
+ waitFor,
+} from "discourse/tests/helpers/qunit-helpers";
acceptance("Search - Full Page", {
settings: { tagging_enabled: true },
@@ -83,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");
@@ -103,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");
@@ -115,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");
@@ -148,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"
);
@@ -172,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");
@@ -292,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"
);
@@ -315,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(
@@ -376,27 +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_post_count:5",
- 'has updated search term to "none 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"'
+ );
+});
-QUnit.test("validate advanced search when initially empty", async (assert) => {
+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"'
+ );
+});
+
+test("validate advanced search when initially empty", async (assert) => {
await visit("/search?expanded=true");
await click(".search-advanced-options .in-likes");
diff --git a/test/javascripts/acceptance/search-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-mobile-test.js
similarity index 86%
rename from test/javascripts/acceptance/search-mobile-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/search-mobile-test.js
index 47a110eeff..e1d38800ae 100644
--- a/test/javascripts/acceptance/search-mobile-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/search-mobile-test.js
@@ -1,8 +1,9 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/search-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-test.js
similarity index 90%
rename from test/javascripts/acceptance/search-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/search-test.js
index eda6a22e16..6cfc09e267 100644
--- a/test/javascripts/acceptance/search-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/search-test.js
@@ -1,5 +1,6 @@
-import selectKit from "helpers/select-kit-helper";
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
const emptySearchContextCallbacks = [];
@@ -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/test/javascripts/acceptance/share-and-invite-desktop-test.js b/app/assets/javascripts/discourse/tests/acceptance/share-and-invite-desktop-test.js
similarity index 70%
rename from test/javascripts/acceptance/share-and-invite-desktop-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/share-and-invite-desktop-test.js
index 445f17701e..c2c12e5018 100644
--- a/test/javascripts/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 { acceptance } from "helpers/qunit-helpers";
+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,9 +65,28 @@ 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");
assert.ok(exists("#share-link"), "it shows the share modal");
});
+
+acceptance("Share url with badges disabled - desktop", {
+ loggedIn: true,
+ settings: {
+ enable_badges: false,
+ },
+});
+
+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"
+ );
+});
diff --git a/test/javascripts/acceptance/share-and-invite-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/share-and-invite-mobile-test.js
similarity index 62%
rename from test/javascripts/acceptance/share-and-invite-mobile-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/share-and-invite-mobile-test.js
index c21ae36b00..f67a5203aa 100644
--- a/test/javascripts/acceptance/share-and-invite-mobile-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/share-and-invite-mobile-test.js
@@ -1,12 +1,13 @@
-import selectKit from "helpers/select-kit-helper";
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Share and Invite modal - mobile", {
loggedIn: true,
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,9 +55,32 @@ 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");
assert.ok(exists("#share-link"), "it shows the share modal");
});
+
+acceptance("Share url with badges disabled - mobile", {
+ loggedIn: true,
+ mobileView: true,
+ settings: {
+ enable_badges: false,
+ },
+});
+
+test("topic footer button - badges disabled - mobile", async (assert) => {
+ await visit("/t/internationalization-localization/280");
+
+ const subject = selectKit(".topic-footer-mobile-dropdown");
+ await subject.expand();
+ await subject.selectRowByValue("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"
+ );
+});
diff --git a/test/javascripts/acceptance/shared-drafts-test.js b/app/assets/javascripts/discourse/tests/acceptance/shared-drafts-test.js
similarity index 67%
rename from test/javascripts/acceptance/shared-drafts-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/shared-drafts-test.js
index 7f46522f3e..caaceef158 100644
--- a/test/javascripts/acceptance/shared-drafts-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/shared-drafts-test.js
@@ -1,9 +1,10 @@
-import selectKit from "helpers/select-kit-helper";
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/sign-in-test.js b/app/assets/javascripts/discourse/tests/acceptance/sign-in-test.js
similarity index 91%
rename from test/javascripts/acceptance/sign-in-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/sign-in-test.js
index d3c8dbe75a..1f2e5adae5 100644
--- a/test/javascripts/acceptance/sign-in-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/sign-in-test.js
@@ -1,7 +1,9 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/static-test.js b/app/assets/javascripts/discourse/tests/acceptance/static-test.js
similarity index 85%
rename from test/javascripts/acceptance/static-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/static-test.js
index d8aa41060f..c201bc4c0f 100644
--- a/test/javascripts/acceptance/static-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/static-test.js
@@ -1,7 +1,8 @@
-import { acceptance } from "helpers/qunit-helpers";
+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
new file mode 100644
index 0000000000..c3183d6ad1
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/acceptance/tag-groups-test.js
@@ -0,0 +1,74 @@
+import { test } from "qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+
+acceptance("Tag Groups", {
+ loggedIn: true,
+ settings: { tagging_enabled: true },
+ pretend(server, helper) {
+ server.post("/tag_groups", () => {
+ return helper.response({
+ tag_group: {
+ id: 42,
+ name: "test tag group",
+ tag_names: ["monkey"],
+ parent_tag_name: [],
+ one_per_topic: false,
+ permissions: { everyone: 1 },
+ },
+ });
+ });
+
+ server.get("/groups/search.json", () => {
+ return helper.response([
+ {
+ id: 88,
+ name: "tl1",
+ },
+ {
+ id: 89,
+ name: "tl2",
+ },
+ ]);
+ });
+ },
+});
+
+test("tag groups can be saved and deleted", async (assert) => {
+ const tags = selectKit(".tag-chooser");
+
+ await visit("/tag_groups");
+ await click(".content-list .btn");
+
+ await fillIn(".tag-group-content h1 input", "test tag group");
+ await tags.expand();
+ await tags.selectRowByValue("monkey");
+
+ await click(".tag-group-content .btn.btn-default");
+
+ await click(".tag-chooser .choice:first");
+ assert.ok(!find(".tag-group-content .btn.btn-danger")[0].disabled);
+});
+
+QUnit.test(
+ "tag groups can have multiple groups added to them",
+ async (assert) => {
+ const tags = selectKit(".tag-chooser");
+ const groups = selectKit(".group-chooser");
+
+ await visit("/tag_groups");
+ await click(".content-list .btn");
+
+ await fillIn(".tag-group-content h1 input", "test tag group");
+ await tags.expand();
+ await tags.selectRowByValue("monkey");
+
+ await click("#private-permission");
+ assert.ok(find(".tag-group-content .btn.btn-default:disabled").length);
+
+ await groups.expand();
+ await groups.selectRowByIndex(1);
+ await groups.selectRowByIndex(0);
+ assert.ok(!find(".tag-group-content .btn.btn-default")[0].disabled);
+ }
+);
diff --git a/test/javascripts/acceptance/tags-intersection-test.js b/app/assets/javascripts/discourse/tests/acceptance/tags-intersection-test.js
similarity index 86%
rename from test/javascripts/acceptance/tags-intersection-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/tags-intersection-test.js
index ad0b6ddf9a..cf7f7a26b2 100644
--- a/test/javascripts/acceptance/tags-intersection-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/tags-intersection-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Tags intersection", {
loggedIn: true,
@@ -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/test/javascripts/acceptance/tags-test.js b/app/assets/javascripts/discourse/tests/acceptance/tags-test.js
similarity index 96%
rename from test/javascripts/acceptance/tags-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/tags-test.js
index 44dbd9dbb0..81226a4730 100644
--- a/test/javascripts/acceptance/tags-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/tags-test.js
@@ -1,9 +1,13 @@
-import { updateCurrentUser, acceptance } from "helpers/qunit-helpers";
-import pretender from "helpers/create-pretender";
+import { test } from "qunit";
+import {
+ updateCurrentUser,
+ acceptance,
+} from "discourse/tests/helpers/qunit-helpers";
+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");
@@ -20,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
new file mode 100644
index 0000000000..9cc2605aa3
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-admin-menu-test.js
@@ -0,0 +1,47 @@
+import { test } from "qunit";
+import {
+ acceptance,
+ updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
+
+acceptance("Topic - Admin Menu Anonymous Users", { loggedIn: false });
+
+test("Enter as a regular user", async (assert) => {
+ 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 not rendered"
+ );
+});
+
+acceptance("Topic - Admin Menu", { loggedIn: true });
+
+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");
+});
+
+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");
+});
+
+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");
+
+ assert.equal(
+ document.activeElement,
+ document.querySelector(".topic-admin-multi-select > button")
+ );
+});
diff --git a/test/javascripts/acceptance/topic-anonymous-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-anonymous-test.js
similarity index 74%
rename from test/javascripts/acceptance/topic-anonymous-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/topic-anonymous-test.js
index a5cfe42f22..477e2fe579 100644
--- a/test/javascripts/acceptance/topic-anonymous-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-anonymous-test.js
@@ -1,7 +1,8 @@
-import { acceptance } from "helpers/qunit-helpers";
+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/test/javascripts/acceptance/topic-discovery-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-test.js
similarity index 80%
rename from test/javascripts/acceptance/topic-discovery-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/topic-discovery-test.js
index 8f6ee95824..5b2b32e529 100644
--- a/test/javascripts/acceptance/topic-discovery-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-test.js
@@ -1,6 +1,7 @@
+import { test } from "qunit";
import DiscourseURL from "discourse/lib/url";
-import selectKit from "helpers/select-kit-helper";
-import { acceptance } from "helpers/qunit-helpers";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import MessageBus from "message-bus-client";
acceptance("Topic Discovery", {
@@ -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/test/javascripts/acceptance/topic-edit-timer-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-edit-timer-test.js
similarity index 93%
rename from test/javascripts/acceptance/topic-edit-timer-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/topic-edit-timer-test.js
index 6a2c091227..125fab78fa 100644
--- a/test/javascripts/acceptance/topic-edit-timer-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-edit-timer-test.js
@@ -1,5 +1,10 @@
-import selectKit from "helpers/select-kit-helper";
-import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
+import { skip } from "qunit";
+import { test } from "qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import {
+ acceptance,
+ updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
acceptance("Topic - Edit timer", {
loggedIn: true,
@@ -19,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");
@@ -31,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");
@@ -50,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");
@@ -103,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");
@@ -141,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");
@@ -174,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");
@@ -188,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");
@@ -214,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/test/javascripts/acceptance/topic-footer-buttons-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-footer-buttons-mobile-test.js
similarity index 83%
rename from test/javascripts/acceptance/topic-footer-buttons-mobile-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/topic-footer-buttons-mobile-test.js
index c8ebaa0c09..9f9c20b196 100644
--- a/test/javascripts/acceptance/topic-footer-buttons-mobile-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-footer-buttons-mobile-test.js
@@ -1,8 +1,9 @@
+import { test } from "qunit";
import I18n from "I18n";
-import selectKit from "helpers/select-kit-helper";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
import { withPluginApi } from "discourse/lib/plugin-api";
import { clearTopicFooterButtons } from "discourse/lib/register-topic-footer-button";
-import { acceptance } from "helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
let _test;
@@ -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/test/javascripts/acceptance/topic-list-tracker-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-list-tracker-test.js
similarity index 77%
rename from test/javascripts/acceptance/topic-list-tracker-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/topic-list-tracker-test.js
index c58000843e..c19784c9ce 100644
--- a/test/javascripts/acceptance/topic-list-tracker-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-list-tracker-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import {
nextTopicUrl,
previousTopicUrl,
@@ -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/test/javascripts/acceptance/topic-move-posts-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-move-posts-test.js
similarity index 92%
rename from test/javascripts/acceptance/topic-move-posts-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/topic-move-posts-test.js
index 96fec0a9e9..4c35d63b9e 100644
--- a/test/javascripts/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 "helpers/qunit-helpers";
+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/test/javascripts/acceptance/topic-notifications-button-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-notifications-button-test.js
similarity index 85%
rename from test/javascripts/acceptance/topic-notifications-button-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/topic-notifications-button-test.js
index 48e65e0b3c..0b91fe4ecb 100644
--- a/test/javascripts/acceptance/topic-notifications-button-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-notifications-button-test.js
@@ -1,5 +1,6 @@
-import selectKit from "helpers/select-kit-helper";
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Topic Notifications button", {
loggedIn: true,
@@ -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
new file mode 100644
index 0000000000..fff821e3ae
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js
@@ -0,0 +1,114 @@
+import { test } from "qunit";
+import I18n from "I18n";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+
+function selectText(selector) {
+ const range = document.createRange();
+ const node = document.querySelector(selector);
+ range.selectNodeContents(node);
+
+ const selection = window.getSelection();
+ selection.removeAllRanges();
+ selection.addRange(range);
+}
+
+acceptance("Topic - Quote button - logged in", {
+ loggedIn: true,
+ settings: {
+ share_quote_visibility: "anonymous",
+ share_quote_buttons: "twitter|email",
+ },
+});
+
+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("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");
+
+ 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,
+ settings: {
+ share_quote_visibility: "anonymous",
+ share_quote_buttons: "twitter|email",
+ },
+});
+
+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"
+ );
+});
+
+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");
+
+ 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"
+ );
+});
+
+test("Shows nothing when visibility is disabled", async function (assert) {
+ this.siteSettings.share_quote_visibility = "none";
+
+ await visit("/t/internationalization-localization/280");
+ selectText("#post_5 blockquote");
+
+ assert.equal(
+ find(".quote-sharing").length,
+ 0,
+ "it does not show quote sharing"
+ );
+
+ assert.equal(
+ find(".insert-quote").length,
+ 0,
+ "it does not show the quote button"
+ );
+});
diff --git a/test/javascripts/acceptance/topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-test.js
similarity index 68%
rename from test/javascripts/acceptance/topic-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/topic-test.js
index 8e673168aa..091e4564da 100644
--- a/test/javascripts/acceptance/topic-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-test.js
@@ -1,7 +1,9 @@
+import { skip } from "qunit";
+import { test } from "qunit";
import I18n from "I18n";
import { withPluginApi } from "discourse/lib/plugin-api";
-import selectKit from "helpers/select-kit-helper";
-import { acceptance } from "helpers/qunit-helpers";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
acceptance("Topic", {
@@ -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");
@@ -152,12 +154,12 @@ QUnit.test("Updating the topic title with emojis", async (assert) => {
assert.equal(
find(".fancy-title").html().trim(),
- `emojis title `,
+ `emojis title `,
"it displays the new title with emojis"
);
});
-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");
@@ -167,31 +169,28 @@ QUnit.test("Updating the topic title with unicode emojis", async (assert) => {
assert.equal(
find(".fancy-title").html().trim(),
- `emojis title `,
+ `emojis title `,
"it displays the new title with escaped unicode emojis"
);
});
-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(),
- `TestTitle`,
- "it displays the new title with escaped unicode emojis"
- );
- }
-);
+ assert.equal(
+ find(".fancy-title").html().trim(),
+ `TestTitle`,
+ "it displays the new title with escaped unicode emojis"
+ );
+});
-QUnit.test("Suggested topics", async (assert) => {
+test("Suggested topics", async (assert) => {
await visit("/t/internationalization-localization/280");
assert.equal(
@@ -200,7 +199,7 @@ QUnit.test("Suggested topics", async (assert) => {
);
});
-QUnit.skip("Deleting a topic", async (assert) => {
+skip("Deleting a topic", async (assert) => {
await visit("/t/internationalization-localization/280");
await click(".topic-post:eq(0) button.show-more-actions");
await click(".widget-button.delete");
@@ -208,7 +207,7 @@ QUnit.skip("Deleting a topic", async (assert) => {
assert.ok(exists(".widget-button.recover"), "it shows the recover button");
});
-QUnit.test("Group category moderator posts", async (assert) => {
+test("Group category moderator posts", async (assert) => {
await visit("/t/topic-for-group-moderators/2480");
assert.ok(exists(".category-moderator"), "it has a class applied");
@@ -223,7 +222,7 @@ acceptance("Topic featured links", {
},
});
-QUnit.skip("remove featured link", async (assert) => {
+skip("remove featured link", async (assert) => {
await visit("/t/-/299/1");
assert.ok(
exists(".title-wrapper .topic-featured-link"),
@@ -241,7 +240,7 @@ QUnit.skip("remove featured link", async (assert) => {
assert.ok(!exists(".title-wrapper .topic-featured-link"), "link is gone");
});
-QUnit.test("Converting to a public topic", async (assert) => {
+test("Converting to a public topic", async (assert) => {
await visit("/t/test-pm/34");
assert.ok(exists(".private_message"));
await click(".toggle-admin-menu");
@@ -255,7 +254,7 @@ QUnit.test("Converting to a public topic", async (assert) => {
assert.ok(!exists(".private_message"));
});
-QUnit.test("Unpinning unlisted topic", async (assert) => {
+test("Unpinning unlisted topic", async (assert) => {
await visit("/t/internationalization-localization/280");
await click(".toggle-admin-menu");
@@ -269,7 +268,7 @@ QUnit.test("Unpinning unlisted topic", async (assert) => {
assert.ok(exists(".topic-admin-pin"), "it should show the multi select menu");
});
-QUnit.test("selecting posts", async (assert) => {
+test("selecting posts", async (assert) => {
await visit("/t/internationalization-localization/280");
await click(".toggle-admin-menu");
await click(".topic-admin-multi-select .btn");
@@ -285,7 +284,7 @@ QUnit.test("selecting posts", async (assert) => {
);
});
-QUnit.test("select below", async (assert) => {
+test("select below", async (assert) => {
await visit("/t/internationalization-localization/280");
await click(".toggle-admin-menu");
await click(".topic-admin-multi-select .btn");
@@ -308,7 +307,7 @@ QUnit.test("select below", async (assert) => {
);
});
-QUnit.test("View Hidden Replies", async (assert) => {
+test("View Hidden Replies", async (assert) => {
await visit("/t/internationalization-localization/280");
await click(".gap");
@@ -325,7 +324,7 @@ function selectText(selector) {
selection.addRange(range);
}
-QUnit.test("Quoting a quote keeps the original poster name", async (assert) => {
+test("Quoting a quote keeps the original poster name", async (assert) => {
await visit("/t/internationalization-localization/280");
selectText("#post_5 blockquote");
await click(".quote-button .insert-quote");
@@ -337,51 +336,56 @@ QUnit.test("Quoting a quote keeps the original poster name", async (assert) => {
);
});
-QUnit.test(
- "Quoting a quote with the Reply button keeps the original poster name",
- async (assert) => {
- await visit("/t/internationalization-localization/280");
- selectText("#post_5 blockquote");
- await click(".reply");
+test("Quoting a quote of a different topic keeps the original topic title", async (assert) => {
+ await visit("/t/internationalization-localization/280");
+ selectText("#post_9 blockquote");
+ await click(".quote-button .insert-quote");
- assert.ok(
- find(".d-editor-input")
- .val()
- .indexOf('quote="codinghorror said, post:3, topic:280"') !== -1
- );
- }
-);
+ assert.ok(
+ find(".d-editor-input")
+ .val()
+ .indexOf(
+ 'quote="A new topic with a link to another topic, post:3, topic:62"'
+ ) !== -1
+ );
+});
-QUnit.test(
- "Quoting a quote with replyAsNewTopic keeps the original poster name",
- async (assert) => {
- await visit("/t/internationalization-localization/280");
- selectText("#post_5 blockquote");
- await keyEvent(document, "keypress", "j".charCodeAt(0));
- await keyEvent(document, "keypress", "t".charCodeAt(0));
+test("Quoting a quote with the Reply button keeps the original poster name", async (assert) => {
+ await visit("/t/internationalization-localization/280");
+ selectText("#post_5 blockquote");
+ await click(".reply");
- assert.ok(
- find(".d-editor-input")
- .val()
- .indexOf('quote="codinghorror said, post:3, topic:280"') !== -1
- );
- }
-);
+ assert.ok(
+ find(".d-editor-input")
+ .val()
+ .indexOf('quote="codinghorror said, post:3, topic:280"') !== -1
+ );
+});
-QUnit.test(
- "Quoting by selecting text can mark the quote as full",
- async (assert) => {
- await visit("/t/internationalization-localization/280");
- selectText("#post_5 .cooked");
- await click(".quote-button .insert-quote");
+test("Quoting a quote with replyAsNewTopic keeps the original poster name", async (assert) => {
+ await visit("/t/internationalization-localization/280");
+ selectText("#post_5 blockquote");
+ await keyEvent(document, "keypress", "j".charCodeAt(0));
+ await keyEvent(document, "keypress", "t".charCodeAt(0));
- assert.ok(
- find(".d-editor-input")
- .val()
- .indexOf('quote="pekka, post:5, topic:280, full:true"') !== -1
- );
- }
-);
+ assert.ok(
+ find(".d-editor-input")
+ .val()
+ .indexOf('quote="codinghorror said, post:3, topic:280"') !== -1
+ );
+});
+
+test("Quoting by selecting text can mark the quote as full", async (assert) => {
+ await visit("/t/internationalization-localization/280");
+ selectText("#post_5 .cooked");
+ await click(".quote-button .insert-quote");
+
+ assert.ok(
+ find(".d-editor-input")
+ .val()
+ .indexOf('quote="pekka, post:5, topic:280, full:true"') !== -1
+ );
+});
acceptance("Topic with title decorated", {
loggedIn: true,
@@ -394,7 +398,7 @@ acceptance("Topic with title decorated", {
},
});
-QUnit.test("Decorate topic title", async (assert) => {
+test("Decorate topic title", async (assert) => {
await visit("/t/internationalization-localization/280");
assert.ok(
diff --git a/test/javascripts/acceptance/unknown-test.js b/app/assets/javascripts/discourse/tests/acceptance/unknown-test.js
similarity index 75%
rename from test/javascripts/acceptance/unknown-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/unknown-test.js
index 5584c7087e..f762eb2851 100644
--- a/test/javascripts/acceptance/unknown-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/unknown-test.js
@@ -1,13 +1,14 @@
-import { acceptance } from "helpers/qunit-helpers";
-import pretender from "helpers/create-pretender";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+import pretender from "discourse/tests/helpers/create-pretender";
acceptance("Unknown");
-QUnit.test("Permalink Unknown URL", async (assert) => {
+test("Permalink Unknown URL", async (assert) => {
await visit("/url-that-doesn't-exist");
assert.ok(exists(".page-not-found"), "The not found content is present");
});
-QUnit.test("Permalink URL to a Topic", async (assert) => {
+test("Permalink URL to a Topic", async (assert) => {
pretender.get("/permalink-check.json", () => {
return [
200,
@@ -24,7 +25,7 @@ QUnit.test("Permalink URL to a Topic", async (assert) => {
assert.ok(exists(".topic-post"));
});
-QUnit.test("Permalink URL to a static page", async (assert) => {
+test("Permalink URL to a static page", async (assert) => {
pretender.get("/permalink-check.json", () => {
return [
200,
diff --git a/test/javascripts/acceptance/user-anonymous-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-anonymous-test.js
similarity index 83%
rename from test/javascripts/acceptance/user-anonymous-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/user-anonymous-test.js
index aa14b9f3ee..91ff16297c 100644
--- a/test/javascripts/acceptance/user-anonymous-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-anonymous-test.js
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("User Anonymous");
function hasStream(assert) {
@@ -11,13 +12,13 @@ function hasTopicList(assert) {
assert.ok(count(".topic-list tr") > 0, "it has a topic list");
}
-QUnit.test("Root URL", async (assert) => {
+test("Root URL", async (assert) => {
await visit("/u/eviltrout");
assert.ok($("body.user-summary-page").length, "has the body class");
assert.equal(currentPath(), "user.summary", "it defaults to summary");
});
-QUnit.test("Filters", async (assert) => {
+test("Filters", async (assert) => {
await visit("/u/eviltrout/activity");
assert.ok($("body.user-activity-page").length, "has the body class");
hasStream(assert);
@@ -31,13 +32,13 @@ QUnit.test("Filters", async (assert) => {
assert.ok(exists(".user-stream.filter-5"), "stream has filter class");
});
-QUnit.test("Badges", async (assert) => {
+test("Badges", async (assert) => {
await visit("/u/eviltrout/badges");
assert.ok($("body.user-badges-page").length, "has the body class");
assert.ok(exists(".user-badges-list .badge-card"), "shows a badge");
});
-QUnit.test("Restricted Routes", async (assert) => {
+test("Restricted Routes", async (assert) => {
await visit("/u/eviltrout/preferences");
assert.equal(
diff --git a/test/javascripts/acceptance/user-bookmarks-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-bookmarks-test.js
similarity index 86%
rename from test/javascripts/acceptance/user-bookmarks-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/user-bookmarks-test.js
index fc1f689ffa..7537c2f91f 100644
--- a/test/javascripts/acceptance/user-bookmarks-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-bookmarks-test.js
@@ -1,7 +1,8 @@
-import { acceptance } from "helpers/qunit-helpers";
-import selectKit from "helpers/select-kit-helper";
-import pretender from "helpers/create-pretender";
-import userFixtures from "fixtures/user_fixtures";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import pretender from "discourse/tests/helpers/create-pretender";
+import userFixtures from "discourse/tests/fixtures/user-fixtures";
acceptance("User's bookmarks", {
loggedIn: true,
diff --git a/test/javascripts/acceptance/user-card-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-card-mobile-test.js
similarity index 81%
rename from test/javascripts/acceptance/user-card-mobile-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/user-card-mobile-test.js
index 6b35a46879..8cc4223147 100644
--- a/test/javascripts/acceptance/user-card-mobile-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-card-mobile-test.js
@@ -1,9 +1,10 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { skip } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import DiscourseURL from "discourse/lib/url";
acceptance("User Card - Mobile", { mobileView: true });
-QUnit.skip("user card", async (assert) => {
+skip("user card", async (assert) => {
await visit("/t/internationalization-localization/280");
assert.ok(
invisible(".user-card"),
diff --git a/test/javascripts/acceptance/user-card-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-card-test.js
similarity index 75%
rename from test/javascripts/acceptance/user-card-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/user-card-test.js
index 4c1e81c07a..13bf3e5268 100644
--- a/test/javascripts/acceptance/user-card-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-card-test.js
@@ -1,8 +1,10 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { skip } from "qunit";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import DiscourseURL from "discourse/lib/url";
-import pretender from "helpers/create-pretender";
-import userFixtures from "fixtures/user_fixtures";
+import pretender from "discourse/tests/helpers/create-pretender";
+import userFixtures from "discourse/tests/fixtures/user-fixtures";
import User from "discourse/models/user";
acceptance("User Card - Show Local Time", {
@@ -10,7 +12,7 @@ acceptance("User Card - Show Local Time", {
settings: { display_local_time_in_user_card: true },
});
-QUnit.skip("user card local time", async (assert) => {
+skip("user card local time", async (assert) => {
User.current().changeTimezone("Australia/Brisbane");
let cardResponse = Object.assign({}, userFixtures["/u/eviltrout/card.json"]);
cardResponse.user.timezone = "Australia/Perth";
@@ -60,32 +62,29 @@ QUnit.skip("user card local time", async (assert) => {
);
});
-QUnit.test(
- "user card local time - does not update timezone for another user",
- async (assert) => {
- User.current().changeTimezone("Australia/Brisbane");
- let cardResponse = Object.assign({}, userFixtures["/u/charlie/card.json"]);
- delete cardResponse.user.timezone;
+test("user card local time - does not update timezone for another user", async (assert) => {
+ User.current().changeTimezone("Australia/Brisbane");
+ let cardResponse = Object.assign({}, userFixtures["/u/charlie/card.json"]);
+ delete cardResponse.user.timezone;
- pretender.get("/u/charlie/card.json", () => [
- 200,
- { "Content-Type": "application/json" },
- cardResponse,
- ]);
+ pretender.get("/u/charlie/card.json", () => [
+ 200,
+ { "Content-Type": "application/json" },
+ cardResponse,
+ ]);
- await visit("/t/internationalization-localization/280");
- await click("a[data-user-card=charlie]:first");
+ await visit("/t/internationalization-localization/280");
+ await click("a[data-user-card=charlie]:first");
- assert.not(
- exists(".user-card .local-time"),
- "it does not show the local time if the user card returns a null/undefined timezone for another user"
- );
- }
-);
+ assert.not(
+ exists(".user-card .local-time"),
+ "it does not show the local time if the user card returns a null/undefined timezone for another user"
+ );
+});
acceptance("User Card", { loggedIn: true });
-QUnit.skip("user card", async (assert) => {
+skip("user card", async (assert) => {
await visit("/t/internationalization-localization/280");
assert.ok(invisible(".user-card"), "user card is invisible by default");
diff --git a/test/javascripts/acceptance/user-drafts-stream-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js
similarity index 77%
rename from test/javascripts/acceptance/user-drafts-stream-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js
index a892c2a8be..f5e4972cc1 100644
--- a/test/javascripts/acceptance/user-drafts-stream-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js
@@ -1,8 +1,9 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("User Drafts", { loggedIn: true });
-QUnit.test("Stream", async (assert) => {
+test("Stream", async (assert) => {
await visit("/u/eviltrout/activity/drafts");
assert.ok(find(".user-stream-item").length === 3, "has drafts");
@@ -13,7 +14,7 @@ QUnit.test("Stream", async (assert) => {
);
});
-QUnit.test("Stream - resume draft", async (assert) => {
+test("Stream - resume draft", async (assert) => {
await visit("/u/eviltrout/activity/drafts");
assert.ok(find(".user-stream-item").length > 0, "has drafts");
diff --git a/test/javascripts/acceptance/user-preferences-interface-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js
similarity index 88%
rename from test/javascripts/acceptance/user-preferences-interface-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js
index 1cc396a984..f92eb1cc20 100644
--- a/test/javascripts/acceptance/user-preferences-interface-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js
@@ -1,5 +1,6 @@
-import { acceptance } from "helpers/qunit-helpers";
-import selectKit from "helpers/select-kit-helper";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
import Site from "discourse/models/site";
import Session from "discourse/models/session";
import cookie, { removeCookie } from "discourse/lib/cookie";
@@ -8,7 +9,7 @@ acceptance("User Preferences - Interface", {
loggedIn: true,
});
-QUnit.test("font size change", async (assert) => {
+test("font size change", async (assert) => {
removeCookie("text_size");
const savePreferences = async () => {
@@ -53,15 +54,12 @@ QUnit.test("font size change", async (assert) => {
removeCookie("text_size");
});
-QUnit.test(
- "does not show option to disable dark mode by default",
- async (assert) => {
- await visit("/u/eviltrout/preferences/interface");
- assert.equal($(".control-group.dark-mode").length, 0);
- }
-);
+test("does not show option to disable dark mode by default", async (assert) => {
+ await visit("/u/eviltrout/preferences/interface");
+ assert.equal($(".control-group.dark-mode").length, 0);
+});
-QUnit.test("shows light/dark color scheme pickers", async (assert) => {
+test("shows light/dark color scheme pickers", async (assert) => {
let site = Site.current();
site.set("user_color_schemes", [
{ id: 2, name: "Cool Breeze" },
@@ -87,7 +85,7 @@ acceptance("User Preferences Color Schemes (with default dark scheme)", {
pretend: interfacePretender,
});
-QUnit.test("show option to disable dark mode", async (assert) => {
+test("show option to disable dark mode", async (assert) => {
await visit("/u/eviltrout/preferences/interface");
assert.ok(
@@ -96,7 +94,7 @@ QUnit.test("show option to disable dark mode", async (assert) => {
);
});
-QUnit.test("no color scheme picker by default", async (assert) => {
+test("no color scheme picker by default", async (assert) => {
let site = Site.current();
site.set("user_color_schemes", []);
@@ -104,7 +102,7 @@ QUnit.test("no color scheme picker by default", async (assert) => {
assert.equal($(".control-group.color-scheme").length, 0);
});
-QUnit.test("light color scheme picker", async (assert) => {
+test("light color scheme picker", async (assert) => {
let site = Site.current();
site.set("user_color_schemes", [{ id: 2, name: "Cool Breeze" }]);
@@ -117,7 +115,7 @@ QUnit.test("light color scheme picker", async (assert) => {
);
});
-QUnit.test("light and dark color scheme pickers", async (assert) => {
+test("light and dark color scheme pickers", async (assert) => {
let site = Site.current();
let session = Session.current();
session.userDarkSchemeId = 1; // same as default set in site settings
diff --git a/test/javascripts/acceptance/user-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-test.js
similarity index 82%
rename from test/javascripts/acceptance/user-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/user-test.js
index f4b28465bc..f170e731b2 100644
--- a/test/javascripts/acceptance/user-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-test.js
@@ -1,11 +1,12 @@
-import { acceptance } from "helpers/qunit-helpers";
-import pretender from "helpers/create-pretender";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+import pretender from "discourse/tests/helpers/create-pretender";
import Draft from "discourse/models/draft";
import { Promise } from "rsvp";
acceptance("User", { loggedIn: true });
-QUnit.test("Invalid usernames", async (assert) => {
+test("Invalid usernames", async (assert) => {
pretender.get("/u/eviltrout%2F..%2F..%2F.json", () => {
return [400, { "Content-Type": "application/json" }, {}];
});
@@ -15,23 +16,23 @@ QUnit.test("Invalid usernames", async (assert) => {
assert.equal(currentPath(), "exception-unknown");
});
-QUnit.test("Unicode usernames", async (assert) => {
+test("Unicode usernames", async (assert) => {
await visit("/u/%E3%83%A9%E3%82%A4%E3%82%AA%E3%83%B3/summary");
assert.equal(currentPath(), "user.summary");
});
-QUnit.test("Invites", async (assert) => {
+test("Invites", async (assert) => {
await visit("/u/eviltrout/invited/pending");
assert.ok($("body.user-invites-page").length, "has the body class");
});
-QUnit.test("Messages", async (assert) => {
+test("Messages", async (assert) => {
await visit("/u/eviltrout/messages");
assert.ok($("body.user-messages-page").length, "has the body class");
});
-QUnit.test("Notifications", async (assert) => {
+test("Notifications", async (assert) => {
await visit("/u/eviltrout/notifications");
assert.ok($("body.user-notifications-page").length, "has the body class");
@@ -44,7 +45,7 @@ QUnit.test("Notifications", async (assert) => {
);
});
-QUnit.test("Root URL - Viewing Self", async (assert) => {
+test("Root URL - Viewing Self", async (assert) => {
await visit("/u/eviltrout");
assert.ok($("body.user-activity-page").length, "has the body class");
assert.equal(
@@ -55,7 +56,7 @@ QUnit.test("Root URL - Viewing Self", async (assert) => {
assert.ok(exists(".container.viewing-self"), "has the viewing-self class");
});
-QUnit.test("Viewing Summary", async (assert) => {
+test("Viewing Summary", async (assert) => {
await visit("/u/eviltrout/summary");
assert.ok(exists(".replies-section li a"), "replies");
@@ -68,7 +69,7 @@ QUnit.test("Viewing Summary", async (assert) => {
assert.ok(exists(".top-categories-section .category-link"), "top categories");
});
-QUnit.test("Viewing Drafts", async (assert) => {
+test("Viewing Drafts", async (assert) => {
sandbox.stub(Draft, "get").returns(
Promise.resolve({
draft: null,
diff --git a/test/javascripts/acceptance/users-test.js b/app/assets/javascripts/discourse/tests/acceptance/users-test.js
similarity index 69%
rename from test/javascripts/acceptance/users-test.js
rename to app/assets/javascripts/discourse/tests/acceptance/users-test.js
index ecb7e4dc77..7147fd4cac 100644
--- a/test/javascripts/acceptance/users-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/users-test.js
@@ -1,24 +1,25 @@
-import { acceptance } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("User Directory");
-QUnit.test("Visit Page", async (assert) => {
+test("Visit Page", async (assert) => {
await visit("/u");
assert.ok($("body.users-page").length, "has the body class");
assert.ok(exists(".directory table tr"), "has a list of users");
});
-QUnit.test("Visit All Time", async (assert) => {
+test("Visit All Time", async (assert) => {
await visit("/u?period=all");
assert.ok(exists(".time-read"), "has time read column");
});
-QUnit.test("Visit Without Usernames", async (assert) => {
+test("Visit Without Usernames", async (assert) => {
await visit("/u?exclude_usernames=system");
assert.ok($("body.users-page").length, "has the body class");
assert.ok(exists(".directory table tr"), "has a list of users");
});
-QUnit.test("Visit With Group Filter", async (assert) => {
+test("Visit With Group Filter", async (assert) => {
await visit("/u?group=trust_level_0");
assert.ok($("body.users-page").length, "has the body class");
assert.ok(exists(".directory table tr"), "has a list of users");
diff --git a/test/javascripts/fixtures/about.js b/app/assets/javascripts/discourse/tests/fixtures/about.js
similarity index 100%
rename from test/javascripts/fixtures/about.js
rename to app/assets/javascripts/discourse/tests/fixtures/about.js
diff --git a/test/javascripts/fixtures/badges_fixture.js b/app/assets/javascripts/discourse/tests/fixtures/badges-fixture.js
similarity index 100%
rename from test/javascripts/fixtures/badges_fixture.js
rename to app/assets/javascripts/discourse/tests/fixtures/badges-fixture.js
diff --git a/test/javascripts/fixtures/category-fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/category-fixtures.js
similarity index 100%
rename from test/javascripts/fixtures/category-fixtures.js
rename to app/assets/javascripts/discourse/tests/fixtures/category-fixtures.js
diff --git a/app/assets/javascripts/discourse/tests/fixtures/concerns/notification-types.js b/app/assets/javascripts/discourse/tests/fixtures/concerns/notification-types.js
new file mode 100644
index 0000000000..222a849104
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/fixtures/concerns/notification-types.js
@@ -0,0 +1,34 @@
+// DO NOT EDIT THIS FILE!!!
+// Update it by running `rake javascript:update_constants`
+
+
+export const NOTIFICATION_TYPES = {
+ mentioned: 1,
+ replied: 2,
+ quoted: 3,
+ edited: 4,
+ liked: 5,
+ private_message: 6,
+ invited_to_private_message: 7,
+ invitee_accepted: 8,
+ posted: 9,
+ moved_post: 10,
+ linked: 11,
+ granted_badge: 12,
+ invited_to_topic: 13,
+ custom: 14,
+ group_mentioned: 15,
+ group_message_summary: 16,
+ watching_first_post: 17,
+ topic_reminder: 18,
+ liked_consolidated: 19,
+ post_approved: 20,
+ code_review_commit_approved: 21,
+ membership_request_accepted: 22,
+ membership_request_consolidated: 23,
+ bookmark_reminder: 24,
+ reaction: 25,
+ votes_released: 26,
+ event_reminder: 27,
+ event_invitation: 28,
+};
diff --git a/test/javascripts/fixtures/dashboard-general.js b/app/assets/javascripts/discourse/tests/fixtures/dashboard-general.js
similarity index 100%
rename from test/javascripts/fixtures/dashboard-general.js
rename to app/assets/javascripts/discourse/tests/fixtures/dashboard-general.js
diff --git a/test/javascripts/fixtures/dashboard.js b/app/assets/javascripts/discourse/tests/fixtures/dashboard.js
similarity index 100%
rename from test/javascripts/fixtures/dashboard.js
rename to app/assets/javascripts/discourse/tests/fixtures/dashboard.js
diff --git a/test/javascripts/fixtures/directory-fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/directory-fixtures.js
similarity index 100%
rename from test/javascripts/fixtures/directory-fixtures.js
rename to app/assets/javascripts/discourse/tests/fixtures/directory-fixtures.js
diff --git a/test/javascripts/fixtures/discovery_fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/discovery-fixtures.js
similarity index 100%
rename from test/javascripts/fixtures/discovery_fixtures.js
rename to app/assets/javascripts/discourse/tests/fixtures/discovery-fixtures.js
diff --git a/test/javascripts/fixtures/draft.js b/app/assets/javascripts/discourse/tests/fixtures/draft.js
similarity index 100%
rename from test/javascripts/fixtures/draft.js
rename to app/assets/javascripts/discourse/tests/fixtures/draft.js
diff --git a/test/javascripts/fixtures/drafts.js b/app/assets/javascripts/discourse/tests/fixtures/drafts.js
similarity index 100%
rename from test/javascripts/fixtures/drafts.js
rename to app/assets/javascripts/discourse/tests/fixtures/drafts.js
diff --git a/test/javascripts/fixtures/group-fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/group-fixtures.js
similarity index 100%
rename from test/javascripts/fixtures/group-fixtures.js
rename to app/assets/javascripts/discourse/tests/fixtures/group-fixtures.js
diff --git a/test/javascripts/fixtures/groups-fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/groups-fixtures.js
similarity index 100%
rename from test/javascripts/fixtures/groups-fixtures.js
rename to app/assets/javascripts/discourse/tests/fixtures/groups-fixtures.js
diff --git a/test/javascripts/fixtures/notification_fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/notification-fixtures.js
similarity index 79%
rename from test/javascripts/fixtures/notification_fixtures.js
rename to app/assets/javascripts/discourse/tests/fixtures/notification-fixtures.js
index 9ab4d8d76e..ac2fe07fe9 100644
--- a/test/javascripts/fixtures/notification_fixtures.js
+++ b/app/assets/javascripts/discourse/tests/fixtures/notification-fixtures.js
@@ -1,5 +1,5 @@
/*jshint maxlen:10000000 */
-import { NOTIFICATION_TYPES } from "fixtures/concerns/notification-types";
+import { NOTIFICATION_TYPES } from "./concerns/notification-types";
export default {
"/notifications": {
@@ -11,13 +11,13 @@ export default {
post_number: 2,
topic_id: 1234,
slug: "a-slug",
- data: { topic_title: "some title", display_username: "velesin" }
+ data: { topic_title: "some title", display_username: "velesin" },
},
{
id: 456,
notification_type: NOTIFICATION_TYPES.liked_consolidated,
read: false,
- data: { display_username: "aquaman", count: "5" }
+ data: { display_username: "aquaman", count: "5" },
},
{
id: 789,
@@ -30,8 +30,8 @@ export default {
group_id: 41,
group_name: "test",
inbox_count: 5,
- username: "test2"
- }
+ username: "test2",
+ },
},
{
id: 1234,
@@ -40,7 +40,7 @@ export default {
post_number: null,
topic_id: null,
slug: null,
- data: { display_username: "test1" }
+ data: { display_username: "test1" },
},
{
id: 5678,
@@ -49,8 +49,8 @@ export default {
post_number: null,
topic_id: null,
slug: null,
- data: { group_id: 41, group_name: "test" }
- }
- ]
- }
+ data: { group_id: 41, group_name: "test" },
+ },
+ ],
+ },
};
diff --git a/test/javascripts/fixtures/poll.js b/app/assets/javascripts/discourse/tests/fixtures/poll.js
similarity index 100%
rename from test/javascripts/fixtures/poll.js
rename to app/assets/javascripts/discourse/tests/fixtures/poll.js
diff --git a/test/javascripts/fixtures/post.js b/app/assets/javascripts/discourse/tests/fixtures/post.js
similarity index 100%
rename from test/javascripts/fixtures/post.js
rename to app/assets/javascripts/discourse/tests/fixtures/post.js
diff --git a/test/javascripts/fixtures/private_messages_fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/private-messages-fixtures.js
similarity index 100%
rename from test/javascripts/fixtures/private_messages_fixtures.js
rename to app/assets/javascripts/discourse/tests/fixtures/private-messages-fixtures.js
diff --git a/test/javascripts/fixtures/problems.js b/app/assets/javascripts/discourse/tests/fixtures/problems.js
similarity index 100%
rename from test/javascripts/fixtures/problems.js
rename to app/assets/javascripts/discourse/tests/fixtures/problems.js
diff --git a/test/javascripts/fixtures/reports_bulk.js b/app/assets/javascripts/discourse/tests/fixtures/reports-bulk.js
similarity index 100%
rename from test/javascripts/fixtures/reports_bulk.js
rename to app/assets/javascripts/discourse/tests/fixtures/reports-bulk.js
diff --git a/test/javascripts/fixtures/reports.js b/app/assets/javascripts/discourse/tests/fixtures/reports.js
similarity index 100%
rename from test/javascripts/fixtures/reports.js
rename to app/assets/javascripts/discourse/tests/fixtures/reports.js
diff --git a/test/javascripts/fixtures/search-fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/search-fixtures.js
similarity index 100%
rename from test/javascripts/fixtures/search-fixtures.js
rename to app/assets/javascripts/discourse/tests/fixtures/search-fixtures.js
diff --git a/test/javascripts/fixtures/session-fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/session-fixtures.js
similarity index 100%
rename from test/javascripts/fixtures/session-fixtures.js
rename to app/assets/javascripts/discourse/tests/fixtures/session-fixtures.js
diff --git a/test/javascripts/fixtures/site-fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/site-fixtures.js
similarity index 91%
rename from test/javascripts/fixtures/site-fixtures.js
rename to app/assets/javascripts/discourse/tests/fixtures/site-fixtures.js
index bdb8504b8f..2cd86c81e5 100644
--- a/test/javascripts/fixtures/site-fixtures.js
+++ b/app/assets/javascripts/discourse/tests/fixtures/site-fixtures.js
@@ -1,4 +1,4 @@
-import { NOTIFICATION_TYPES } from "fixtures/concerns/notification-types";
+import { NOTIFICATION_TYPES } from "./concerns/notification-types";
export default {
"site.json": {
@@ -11,7 +11,7 @@ export default {
regular: 1,
moderator_action: 2,
small_action: 3,
- whisper: 4
+ whisper: 4,
},
groups: [
{ id: 1, name: "admins" },
@@ -22,7 +22,7 @@ export default {
{ id: 11, name: "trust_level_1" },
{ id: 12, name: "trust_level_2" },
{ id: 13, name: "trust_level_3" },
- { id: 14, name: "trust_level_4" }
+ { id: 14, name: "trust_level_4" },
],
filters: [
"latest",
@@ -32,7 +32,7 @@ export default {
"read",
"posted",
"search",
- "bookmarks"
+ "bookmarks",
],
periods: ["all", "yearly", "quarterly", "monthly", "weekly", "daily"],
top_menu_items: [
@@ -44,7 +44,7 @@ export default {
"posted",
"categories",
"top",
- "bookmarks"
+ "bookmarks",
],
anonymous_top_menu_items: ["latest", "top", "categories"],
uncategorized_category_id: 17,
@@ -67,7 +67,7 @@ export default {
background_url: null,
show_subcategory_list: false,
default_view: "latest",
- topic_template: "my topic template"
+ topic_template: "my topic template",
},
{
id: 10,
@@ -85,7 +85,7 @@ export default {
notification_level: null,
background_url: null,
show_subcategory_list: false,
- default_view: "latest"
+ default_view: "latest",
},
{
id: 26,
@@ -102,7 +102,7 @@ export default {
permission: 1,
parent_category_id: 2,
notification_level: null,
- background_url: null
+ background_url: null,
},
{
id: 7,
@@ -121,7 +121,7 @@ export default {
background_url: null,
show_subcategory_list: true,
default_view: "latest",
- subcategory_list_style: "boxes_with_featured_topics"
+ subcategory_list_style: "boxes_with_featured_topics",
},
{
id: 6,
@@ -139,7 +139,7 @@ export default {
notification_level: null,
background_url: null,
show_subcategory_list: false,
- default_view: "latest"
+ default_view: "latest",
},
{
id: 24,
@@ -154,7 +154,7 @@ export default {
read_restricted: true,
permission: 1,
notification_level: null,
- background_url: null
+ background_url: null,
},
{
id: 28,
@@ -171,7 +171,7 @@ export default {
permission: 1,
parent_category_id: 7,
notification_level: null,
- background_url: null
+ background_url: null,
},
{
id: 27,
@@ -188,7 +188,7 @@ export default {
permission: 1,
parent_category_id: 7,
notification_level: null,
- background_url: null
+ background_url: null,
},
{
id: 4,
@@ -206,7 +206,7 @@ export default {
notification_level: null,
background_url: null,
show_subcategory_list: false,
- default_view: "latest"
+ default_view: "latest",
},
{
id: 14,
@@ -224,7 +224,7 @@ export default {
notification_level: null,
background_url: null,
show_subcategory_list: false,
- default_view: "latest"
+ default_view: "latest",
},
{
id: 12,
@@ -241,7 +241,7 @@ export default {
permission: 1,
notification_level: null,
show_subcategory_list: false,
- default_view: "latest"
+ default_view: "latest",
},
{
id: 13,
@@ -258,7 +258,7 @@ export default {
permission: 1,
notification_level: null,
show_subcategory_list: false,
- default_view: "latest"
+ default_view: "latest",
},
{
id: 5,
@@ -275,7 +275,7 @@ export default {
permission: 1,
notification_level: null,
show_subcategory_list: false,
- default_view: "latest"
+ default_view: "latest",
},
{
id: 11,
@@ -292,7 +292,7 @@ export default {
permission: 1,
notification_level: null,
show_subcategory_list: false,
- default_view: "latest"
+ default_view: "latest",
},
{
id: 22,
@@ -308,7 +308,7 @@ export default {
read_restricted: false,
permission: 1,
parent_category_id: 5,
- notification_level: null
+ notification_level: null,
},
{
id: 1,
@@ -326,7 +326,7 @@ export default {
notification_level: null,
can_edit: true,
show_subcategory_list: false,
- default_view: "latest"
+ default_view: "latest",
},
{
id: 17,
@@ -343,7 +343,7 @@ export default {
permission: 1,
notification_level: null,
show_subcategory_list: false,
- default_view: "latest"
+ default_view: "latest",
},
{
id: 21,
@@ -359,7 +359,7 @@ export default {
read_restricted: false,
permission: 1,
parent_category_id: 6,
- notification_level: null
+ notification_level: null,
},
{
id: 8,
@@ -376,7 +376,7 @@ export default {
permission: 1,
notification_level: null,
show_subcategory_list: false,
- default_view: "latest"
+ default_view: "latest",
},
{
id: 9,
@@ -393,7 +393,7 @@ export default {
permission: 1,
notification_level: null,
show_subcategory_list: false,
- default_view: "latest"
+ default_view: "latest",
},
{
id: 2,
@@ -411,8 +411,8 @@ export default {
notification_level: null,
show_subcategory_list: true,
default_view: "latest",
- subcategory_list_style: "boxes"
- }
+ subcategory_list_style: "boxes",
+ },
],
post_action_types: [
{
@@ -424,7 +424,7 @@ export default {
is_flag: false,
icon: null,
id: 1,
- is_custom_flag: false
+ is_custom_flag: false,
},
{
name_key: "like",
@@ -435,7 +435,7 @@ export default {
is_flag: false,
icon: "heart",
id: 2,
- is_custom_flag: false
+ is_custom_flag: false,
},
{
name_key: "off_topic",
@@ -447,7 +447,7 @@ export default {
is_flag: true,
icon: null,
id: 3,
- is_custom_flag: false
+ is_custom_flag: false,
},
{
name_key: "inappropriate",
@@ -460,7 +460,7 @@ export default {
is_flag: true,
icon: null,
id: 4,
- is_custom_flag: false
+ is_custom_flag: false,
},
{
name_key: "vote",
@@ -471,7 +471,7 @@ export default {
is_flag: false,
icon: null,
id: 5,
- is_custom_flag: false
+ is_custom_flag: false,
},
{
name_key: "spam",
@@ -483,7 +483,7 @@ export default {
is_flag: true,
icon: null,
id: 8,
- is_custom_flag: false
+ is_custom_flag: false,
},
{
name_key: "notify_user",
@@ -496,7 +496,7 @@ export default {
is_flag: true,
icon: null,
id: 6,
- is_custom_flag: true
+ is_custom_flag: true,
},
{
name_key: "notify_moderators",
@@ -508,8 +508,8 @@ export default {
is_flag: true,
icon: null,
id: 7,
- is_custom_flag: true
- }
+ is_custom_flag: true,
+ },
],
topic_flag_types: [
{
@@ -521,7 +521,7 @@ export default {
is_flag: true,
icon: null,
id: 4,
- is_custom_flag: false
+ is_custom_flag: false,
},
{
name_key: "spam",
@@ -532,7 +532,7 @@ export default {
is_flag: true,
icon: null,
id: 8,
- is_custom_flag: false
+ is_custom_flag: false,
},
{
name_key: "notify_moderators",
@@ -543,42 +543,42 @@ export default {
is_flag: true,
icon: null,
id: 7,
- is_custom_flag: true
- }
+ is_custom_flag: true,
+ },
],
trust_levels: [
{
id: 0,
- name: "new user"
+ name: "new user",
},
{
id: 1,
- name: "basic user"
+ name: "basic user",
},
{
id: 2,
- name: "member"
+ name: "member",
},
{
id: 3,
- name: "regular"
+ name: "regular",
},
{
id: 4,
- name: "leader"
- }
+ name: "leader",
+ },
],
archetypes: [
{
id: "regular",
name: "Regular Topic",
- options: []
+ options: [],
},
{
id: "banner",
name: "translation missing: en.archetypes.banner.title",
- options: []
- }
+ options: [],
+ },
],
auth_providers: [
{
@@ -590,9 +590,9 @@ export default {
frame_width: 580,
frame_height: 400,
can_connect: true,
- can_revoke: true
- }
- ]
- }
- }
+ can_revoke: true,
+ },
+ ],
+ },
+ },
};
diff --git a/test/javascripts/fixtures/site_settings.js b/app/assets/javascripts/discourse/tests/fixtures/site-settings.js
similarity index 100%
rename from test/javascripts/fixtures/site_settings.js
rename to app/assets/javascripts/discourse/tests/fixtures/site-settings.js
diff --git a/test/javascripts/fixtures/static_fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/static-fixtures.js
similarity index 100%
rename from test/javascripts/fixtures/static_fixtures.js
rename to app/assets/javascripts/discourse/tests/fixtures/static-fixtures.js
diff --git a/test/javascripts/fixtures/top_fixture.js b/app/assets/javascripts/discourse/tests/fixtures/top-fixtures.js
similarity index 100%
rename from test/javascripts/fixtures/top_fixture.js
rename to app/assets/javascripts/discourse/tests/fixtures/top-fixtures.js
diff --git a/test/javascripts/fixtures/topic.js b/app/assets/javascripts/discourse/tests/fixtures/topic.js
similarity index 99%
rename from test/javascripts/fixtures/topic.js
rename to app/assets/javascripts/discourse/tests/fixtures/topic.js
index beddf91d94..0eaa20ad1d 100644
--- a/test/javascripts/fixtures/topic.js
+++ b/app/assets/javascripts/discourse/tests/fixtures/topic.js
@@ -851,7 +851,7 @@ export default {
uploaded_avatar_id: 5253,
created_at: "2013-02-07T14:14:12.666Z",
cooked:
- '\n\n
Yeah, that\'s why I\'ve always been a friend of message_error_nametooshort placeholders, until I asked the SO question linked above. The accepted answer makes a good argument against those placeholders: you want translations to break even on small changes in the English original because the translations will probably need to reflect the change, too. Maybe that\'s not the case right now as new stuff is being checked in pretty much every couple of hours, but in the long run, it\'ll be overwhelmingly true.
',
+ '\n
repost after a reload thank you!
',
post_number: 9,
post_type: 1,
updated_at: "2013-02-07T14:18:09.569Z",
diff --git a/test/javascripts/fixtures/user-badges.js b/app/assets/javascripts/discourse/tests/fixtures/user-badges.js
similarity index 100%
rename from test/javascripts/fixtures/user-badges.js
rename to app/assets/javascripts/discourse/tests/fixtures/user-badges.js
diff --git a/test/javascripts/fixtures/user_fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/user-fixtures.js
similarity index 100%
rename from test/javascripts/fixtures/user_fixtures.js
rename to app/assets/javascripts/discourse/tests/fixtures/user-fixtures.js
diff --git a/test/javascripts/fixtures/watched-words-fixtures.js b/app/assets/javascripts/discourse/tests/fixtures/watched-words-fixtures.js
similarity index 100%
rename from test/javascripts/fixtures/watched-words-fixtures.js
rename to app/assets/javascripts/discourse/tests/fixtures/watched-words-fixtures.js
diff --git a/test/javascripts/helpers/assertions.js b/app/assets/javascripts/discourse/tests/helpers/assertions.js
similarity index 100%
rename from test/javascripts/helpers/assertions.js
rename to app/assets/javascripts/discourse/tests/helpers/assertions.js
diff --git a/test/javascripts/helpers/component-test.js b/app/assets/javascripts/discourse/tests/helpers/component-test.js
similarity index 93%
rename from test/javascripts/helpers/component-test.js
rename to app/assets/javascripts/discourse/tests/helpers/component-test.js
index 7fd5727544..5509343240 100644
--- a/test/javascripts/helpers/component-test.js
+++ b/app/assets/javascripts/discourse/tests/helpers/component-test.js
@@ -1,11 +1,12 @@
import EmberObject from "@ember/object";
-import createStore from "helpers/create-store";
+import createStore from "discourse/tests/helpers/create-store";
import { autoLoadModules } from "discourse/initializers/auto-load-modules";
import TopicTrackingState from "discourse/models/topic-tracking-state";
import User from "discourse/models/user";
import Site from "discourse/models/site";
import Session from "discourse/models/session";
-import { currentSettings } from "helpers/site-settings";
+import { currentSettings } from "discourse/tests/helpers/site-settings";
+import { test } from "qunit";
export default function (name, opts) {
opts = opts || {};
diff --git a/test/javascripts/helpers/create-pretender.js b/app/assets/javascripts/discourse/tests/helpers/create-pretender.js
similarity index 99%
rename from test/javascripts/helpers/create-pretender.js
rename to app/assets/javascripts/discourse/tests/helpers/create-pretender.js
index 5632aa3d2b..5bc446fd59 100644
--- a/test/javascripts/helpers/create-pretender.js
+++ b/app/assets/javascripts/discourse/tests/helpers/create-pretender.js
@@ -1,4 +1,5 @@
import User from "discourse/models/user";
+import Pretender from "pretender";
export function parsePostData(query) {
const result = {};
@@ -40,6 +41,10 @@ export let fixturesByUrl;
export default new Pretender();
+export function pretenderHelpers() {
+ return { parsePostData, response, success };
+}
+
export function applyDefaultHandlers(pretender) {
// Autoload any `*-pretender` files
Object.keys(requirejs.entries).forEach((e) => {
@@ -416,7 +421,7 @@ export function applyDefaultHandlers(pretender) {
pretender.post("/u/action/send_activation_email", success);
pretender.put("/u/update-activation-email", success);
- pretender.get("/u/hp.json", function () {
+ pretender.get("/session/hp.json", function () {
return response({
value: "32faff1b1ef1ac3",
challenge: "61a3de0ccf086fb9604b76e884d75801",
diff --git a/test/javascripts/helpers/create-store.js b/app/assets/javascripts/discourse/tests/helpers/create-store.js
similarity index 96%
rename from test/javascripts/helpers/create-store.js
rename to app/assets/javascripts/discourse/tests/helpers/create-store.js
index 4556e8011c..80eb23704c 100644
--- a/test/javascripts/helpers/create-store.js
+++ b/app/assets/javascripts/discourse/tests/helpers/create-store.js
@@ -4,7 +4,7 @@ import KeyValueStore from "discourse/lib/key-value-store";
import TopicListAdapter from "discourse/adapters/topic-list";
import TopicTrackingState from "discourse/models/topic-tracking-state";
import { buildResolver } from "discourse-common/resolver";
-import { currentSettings } from "helpers/site-settings";
+import { currentSettings } from "discourse/tests/helpers/site-settings";
const CatAdapter = RestAdapter.extend({
primaryKey: "cat_id",
diff --git a/test/javascripts/helpers/d-editor-helper.js b/app/assets/javascripts/discourse/tests/helpers/d-editor-helper.js
similarity index 100%
rename from test/javascripts/helpers/d-editor-helper.js
rename to app/assets/javascripts/discourse/tests/helpers/d-editor-helper.js
diff --git a/test/javascripts/helpers/fixture-pretender.js b/app/assets/javascripts/discourse/tests/helpers/fixture-pretender.js
similarity index 90%
rename from test/javascripts/helpers/fixture-pretender.js
rename to app/assets/javascripts/discourse/tests/helpers/fixture-pretender.js
index 8ed9babff4..32ad7ef595 100644
--- a/test/javascripts/helpers/fixture-pretender.js
+++ b/app/assets/javascripts/discourse/tests/helpers/fixture-pretender.js
@@ -4,7 +4,7 @@ export default function (helpers) {
// Load any fixtures automatically
Object.keys(require._eak_seen).forEach((entry) => {
- if (/^fixtures/.test(entry)) {
+ if (/^discourse\/tests\/fixtures/.test(entry)) {
const fixture = require(entry, null, null, true);
if (fixture && fixture.default) {
const obj = fixture.default;
diff --git a/test/javascripts/helpers/html-helper.js b/app/assets/javascripts/discourse/tests/helpers/html-helper.js
similarity index 100%
rename from test/javascripts/helpers/html-helper.js
rename to app/assets/javascripts/discourse/tests/helpers/html-helper.js
diff --git a/test/javascripts/helpers/qunit-helpers.js b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
similarity index 89%
rename from test/javascripts/helpers/qunit-helpers.js
rename to app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
index 668ef6db30..f69f7361fe 100644
--- a/test/javascripts/helpers/qunit-helpers.js
+++ b/app/assets/javascripts/discourse/tests/helpers/qunit-helpers.js
@@ -1,9 +1,7 @@
import { Promise } from "rsvp";
import { isEmpty } from "@ember/utils";
import { later } from "@ember/runloop";
-/* global QUnit, resetSite */
-
-import sessionFixtures from "fixtures/session-fixtures";
+import sessionFixtures from "discourse/tests/fixtures/session-fixtures";
import HeaderComponent from "discourse/components/site-header";
import { forceMobile, resetMobile } from "discourse/lib/mobile";
import { resetPluginApi } from "discourse/lib/plugin-api";
@@ -26,12 +24,20 @@ import { resetCustomPostMessageCallbacks } from "discourse/controllers/topic";
import { _clearSnapshots } from "select-kit/components/composer-actions";
import User from "discourse/models/user";
import { mapRoutes } from "discourse/mapping-router";
-import { currentSettings, mergeSettings } from "helpers/site-settings";
+import {
+ currentSettings,
+ mergeSettings,
+} from "discourse/tests/helpers/site-settings";
import { getOwner } from "discourse-common/lib/get-owner";
import { setTopicList } from "discourse/lib/topic-list-tracker";
import { setURLContainer } from "discourse/lib/url";
import { setDefaultOwner } from "discourse-common/lib/get-owner";
import bootbox from "bootbox";
+import { moduleFor } from "ember-qunit";
+import QUnit, { module } from "qunit";
+import siteFixtures from "discourse/tests/fixtures/site-fixtures";
+import Site from "discourse/models/site";
+import createStore from "discourse/tests/helpers/create-store";
export function currentUser() {
return User.create(sessionFixtures["/session/current.json"].current_user);
@@ -109,6 +115,13 @@ $.fn.modal = AcceptanceModal;
let _pretenderCallbacks = {};
+export function resetSite(siteSettings, extras) {
+ let siteAttrs = $.extend({}, siteFixtures["site.json"].site, extras || {});
+ siteAttrs.store = createStore();
+ siteAttrs.siteSettings = siteSettings;
+ return Site.resetCurrent(Site.create(siteAttrs));
+}
+
export function applyPretender(name, server, helper) {
const cb = _pretenderCallbacks[name];
if (cb) {
@@ -131,7 +144,7 @@ export function controllerModule(name, args = {}) {
}
export function discourseModule(name, hooks) {
- QUnit.module(name, {
+ module(name, {
beforeEach() {
this.container = getOwner(this);
this.siteSettings = currentSettings();
@@ -147,14 +160,19 @@ export function discourseModule(name, hooks) {
});
}
+export function addPretenderCallback(name, fn) {
+ if (name && fn) {
+ _pretenderCallbacks[name] = fn;
+ }
+}
+
export function acceptance(name, options) {
+ name = `Acceptance: ${name}`;
options = options || {};
- if (options.pretend) {
- _pretenderCallbacks[name] = options.pretend;
- }
+ addPretenderCallback(name, options.pretend);
- QUnit.module("Acceptance: " + name, {
+ module(name, {
beforeEach() {
resetMobile();
diff --git a/test/javascripts/helpers/review-pretender.js b/app/assets/javascripts/discourse/tests/helpers/review-pretender.js
similarity index 100%
rename from test/javascripts/helpers/review-pretender.js
rename to app/assets/javascripts/discourse/tests/helpers/review-pretender.js
diff --git a/test/javascripts/helpers/select-kit-helper.js b/app/assets/javascripts/discourse/tests/helpers/select-kit-helper.js
similarity index 99%
rename from test/javascripts/helpers/select-kit-helper.js
rename to app/assets/javascripts/discourse/tests/helpers/select-kit-helper.js
index 63c45adc3e..8e5932e424 100644
--- a/test/javascripts/helpers/select-kit-helper.js
+++ b/app/assets/javascripts/discourse/tests/helpers/select-kit-helper.js
@@ -1,3 +1,4 @@
+import { moduleForComponent } from "ember-qunit";
import { isEmpty } from "@ember/utils";
function checkSelectKitIsNotExpanded(selector) {
diff --git a/test/javascripts/helpers/site-settings.js b/app/assets/javascripts/discourse/tests/helpers/site-settings.js
similarity index 99%
rename from test/javascripts/helpers/site-settings.js
rename to app/assets/javascripts/discourse/tests/helpers/site-settings.js
index 4d2242cc88..ba52f3f9b5 100644
--- a/test/javascripts/helpers/site-settings.js
+++ b/app/assets/javascripts/discourse/tests/helpers/site-settings.js
@@ -101,7 +101,6 @@ const ORIGINAL_SETTINGS = {
};
let siteSettings = Object.assign({}, ORIGINAL_SETTINGS);
-Discourse.SiteSettings = siteSettings;
export function currentSettings() {
return siteSettings;
diff --git a/test/javascripts/helpers/site.js b/app/assets/javascripts/discourse/tests/helpers/site.js
similarity index 100%
rename from test/javascripts/helpers/site.js
rename to app/assets/javascripts/discourse/tests/helpers/site.js
diff --git a/test/javascripts/helpers/store-pretender.js b/app/assets/javascripts/discourse/tests/helpers/store-pretender.js
similarity index 100%
rename from test/javascripts/helpers/store-pretender.js
rename to app/assets/javascripts/discourse/tests/helpers/store-pretender.js
diff --git a/test/javascripts/helpers/textarea-selection-helper.js b/app/assets/javascripts/discourse/tests/helpers/textarea-selection-helper.js
similarity index 100%
rename from test/javascripts/helpers/textarea-selection-helper.js
rename to app/assets/javascripts/discourse/tests/helpers/textarea-selection-helper.js
diff --git a/test/javascripts/helpers/widget-test.js b/app/assets/javascripts/discourse/tests/helpers/widget-test.js
similarity index 50%
rename from test/javascripts/helpers/widget-test.js
rename to app/assets/javascripts/discourse/tests/helpers/widget-test.js
index 6cd3fbd16f..91f8daaa48 100644
--- a/test/javascripts/helpers/widget-test.js
+++ b/app/assets/javascripts/discourse/tests/helpers/widget-test.js
@@ -1,9 +1,14 @@
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import componentTest from "discourse/tests/helpers/component-test";
+import { addPretenderCallback } from "discourse/tests/helpers/qunit-helpers";
export function moduleForWidget(name, options = {}) {
+ let fullName = `widget:${name}`;
+ addPretenderCallback(fullName, options.pretend);
+
moduleForComponent(
name,
- `widget:${name}`,
+ fullName,
Object.assign(
{ integration: true },
{ beforeEach: options.beforeEach, afterEach: options.afterEach }
diff --git a/test/javascripts/components/ace-editor-test.js b/app/assets/javascripts/discourse/tests/integration/components/ace-editor-test.js
similarity index 91%
rename from test/javascripts/components/ace-editor-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/ace-editor-test.js
index b5ed8303fb..44792a75e9 100644
--- a/test/javascripts/components/ace-editor-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/ace-editor-test.js
@@ -1,4 +1,5 @@
-import componentTest from "helpers/component-test";
+import componentTest from "discourse/tests/helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
moduleForComponent("ace-editor", { integration: true });
diff --git a/test/javascripts/components/admin-report-test.js b/app/assets/javascripts/discourse/tests/integration/components/admin-report-test.js
similarity index 95%
rename from test/javascripts/components/admin-report-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/admin-report-test.js
index 56ac97de5a..d288b3deab 100644
--- a/test/javascripts/components/admin-report-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/admin-report-test.js
@@ -1,5 +1,6 @@
-import componentTest from "helpers/component-test";
-import pretender from "helpers/create-pretender";
+import { moduleForComponent } from "ember-qunit";
+import componentTest from "discourse/tests/helpers/component-test";
+import pretender from "discourse/tests/helpers/create-pretender";
moduleForComponent("admin-report", {
integration: true,
diff --git a/test/javascripts/components/badge-title-test.js b/app/assets/javascripts/discourse/tests/integration/components/badge-title-test.js
similarity index 77%
rename from test/javascripts/components/badge-title-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/badge-title-test.js
index 33a2f1eac9..4d9b0c9f26 100644
--- a/test/javascripts/components/badge-title-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/badge-title-test.js
@@ -1,7 +1,8 @@
-import selectKit from "helpers/select-kit-helper";
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
import EmberObject from "@ember/object";
-import pretender from "helpers/create-pretender";
+import pretender from "discourse/tests/helpers/create-pretender";
moduleForComponent("badge-title", { integration: true });
diff --git a/test/javascripts/components/cook-text-test.js b/app/assets/javascripts/discourse/tests/integration/components/cook-text-test.js
similarity index 84%
rename from test/javascripts/components/cook-text-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/cook-text-test.js
index 051e6efdb7..b0e10f4b1f 100644
--- a/test/javascripts/components/cook-text-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/cook-text-test.js
@@ -1,5 +1,6 @@
-import componentTest from "helpers/component-test";
-import pretender from "helpers/create-pretender";
+import { moduleForComponent } from "ember-qunit";
+import componentTest from "discourse/tests/helpers/component-test";
+import pretender from "discourse/tests/helpers/create-pretender";
import { resetCache } from "pretty-text/upload-short-url";
moduleForComponent("cook-text", { integration: true });
diff --git a/test/javascripts/components/d-button-test.js b/app/assets/javascripts/discourse/tests/integration/components/d-button-test.js
similarity index 97%
rename from test/javascripts/components/d-button-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/d-button-test.js
index ce41d19428..759938d11e 100644
--- a/test/javascripts/components/d-button-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/d-button-test.js
@@ -1,5 +1,6 @@
+import { moduleForComponent } from "ember-qunit";
import I18n from "I18n";
-import componentTest from "helpers/component-test";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("d-button", { integration: true });
componentTest("icon only button", {
diff --git a/test/javascripts/components/d-editor-test.js b/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js
similarity index 98%
rename from test/javascripts/components/d-editor-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js
index fec3ae228a..b207338bf0 100644
--- a/test/javascripts/components/d-editor-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js
@@ -1,13 +1,14 @@
+import { moduleForComponent } from "ember-qunit";
import I18n from "I18n";
import { next } from "@ember/runloop";
import { clearToolbarCallbacks } from "discourse/components/d-editor";
-import componentTest from "helpers/component-test";
+import componentTest from "discourse/tests/helpers/component-test";
import { withPluginApi } from "discourse/lib/plugin-api";
-import formatTextWithSelection from "helpers/d-editor-helper";
+import formatTextWithSelection from "discourse/tests/helpers/d-editor-helper";
import {
setTextareaSelection,
getTextareaSelection,
-} from "helpers/textarea-selection-helper";
+} from "discourse/tests/helpers/textarea-selection-helper";
moduleForComponent("d-editor", { integration: true });
diff --git a/test/javascripts/components/d-icon-test.js b/app/assets/javascripts/discourse/tests/integration/components/d-icon-test.js
similarity index 86%
rename from test/javascripts/components/d-icon-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/d-icon-test.js
index 7ee20a999a..60db5afac9 100644
--- a/test/javascripts/components/d-icon-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/d-icon-test.js
@@ -1,4 +1,5 @@
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("d-icon", { integration: true });
diff --git a/test/javascripts/components/date-input-test.js b/app/assets/javascripts/discourse/tests/integration/components/date-input-test.js
similarity index 91%
rename from test/javascripts/components/date-input-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/date-input-test.js
index 769f935429..96b7cbad0a 100644
--- a/test/javascripts/components/date-input-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/date-input-test.js
@@ -1,4 +1,5 @@
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("date-input", { integration: true });
diff --git a/test/javascripts/components/date-time-input-range-test.js b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-range-test.js
similarity index 88%
rename from test/javascripts/components/date-time-input-range-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/date-time-input-range-test.js
index 7e0f76f461..9425e4feda 100644
--- a/test/javascripts/components/date-time-input-range-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-range-test.js
@@ -1,4 +1,5 @@
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("date-time-input-range", { integration: true });
diff --git a/test/javascripts/components/date-time-input-test.js b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.js
similarity index 93%
rename from test/javascripts/components/date-time-input-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.js
index c859fe26e3..37812fe4df 100644
--- a/test/javascripts/components/date-time-input-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.js
@@ -1,4 +1,5 @@
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("date-time-input", { integration: true });
diff --git a/test/javascripts/components/group-membership-button-test.js b/app/assets/javascripts/discourse/tests/integration/components/group-membership-button-test.js
similarity index 88%
rename from test/javascripts/components/group-membership-button-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/group-membership-button-test.js
index 2d17c0ed6d..331c3daffc 100644
--- a/test/javascripts/components/group-membership-button-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/group-membership-button-test.js
@@ -1,6 +1,9 @@
+import { test } from "qunit";
+import { moduleFor } from "ember-qunit";
+
moduleFor("component:group-membership-button");
-QUnit.test("canJoinGroup", function (assert) {
+test("canJoinGroup", function (assert) {
this.subject().setProperties({
model: { public_admission: false, is_group_user: true },
});
@@ -28,7 +31,7 @@ QUnit.test("canJoinGroup", function (assert) {
);
});
-QUnit.test("canLeaveGroup", function (assert) {
+test("canLeaveGroup", function (assert) {
this.subject().setProperties({
model: { public_exit: false, is_group_user: false },
});
@@ -56,7 +59,7 @@ QUnit.test("canLeaveGroup", function (assert) {
);
});
-QUnit.test("canRequestMembership", function (assert) {
+test("canRequestMembership", function (assert) {
this.subject().setProperties({
model: { allow_membership_requests: true, is_group_user: true },
});
@@ -76,7 +79,7 @@ QUnit.test("canRequestMembership", function (assert) {
);
});
-QUnit.test("userIsGroupUser", function (assert) {
+test("userIsGroupUser", function (assert) {
this.subject().setProperties({
model: { is_group_user: true },
});
diff --git a/test/javascripts/components/highlighted-code-test.js b/app/assets/javascripts/discourse/tests/integration/components/highlighted-code-test.js
similarity index 88%
rename from test/javascripts/components/highlighted-code-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/highlighted-code-test.js
index 5159a22af7..c4a86900fc 100644
--- a/test/javascripts/components/highlighted-code-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/highlighted-code-test.js
@@ -1,4 +1,5 @@
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import componentTest from "discourse/tests/helpers/component-test";
const LONG_CODE_BLOCK = "puts a\n".repeat(15000);
diff --git a/test/javascripts/components/html-safe-helper-test.js b/app/assets/javascripts/discourse/tests/integration/components/html-safe-helper-test.js
similarity index 72%
rename from test/javascripts/components/html-safe-helper-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/html-safe-helper-test.js
index 08fbb28e3c..28eba894a8 100644
--- a/test/javascripts/components/html-safe-helper-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/html-safe-helper-test.js
@@ -1,4 +1,5 @@
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("html-safe-helper", { integration: true });
componentTest("default", {
diff --git a/test/javascripts/components/iframed-html-test.js b/app/assets/javascripts/discourse/tests/integration/components/iframed-html-test.js
similarity index 84%
rename from test/javascripts/components/iframed-html-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/iframed-html-test.js
index d95e045429..ff1fcc4ce7 100644
--- a/test/javascripts/components/iframed-html-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/iframed-html-test.js
@@ -1,4 +1,5 @@
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("iframed-html", { integration: true });
diff --git a/test/javascripts/components/image-uploader-test.js b/app/assets/javascripts/discourse/tests/integration/components/image-uploader-test.js
similarity index 93%
rename from test/javascripts/components/image-uploader-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/image-uploader-test.js
index ffe1d28285..5b714a3a44 100644
--- a/test/javascripts/components/image-uploader-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/image-uploader-test.js
@@ -1,4 +1,5 @@
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("image-uploader", { integration: true });
componentTest("with image", {
diff --git a/test/javascripts/components/keyboard-shortcuts-test.js b/app/assets/javascripts/discourse/tests/integration/components/keyboard-shortcuts-test.js
similarity index 91%
rename from test/javascripts/components/keyboard-shortcuts-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/keyboard-shortcuts-test.js
index 19ccbe946f..4b88456758 100644
--- a/test/javascripts/components/keyboard-shortcuts-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/keyboard-shortcuts-test.js
@@ -1,9 +1,10 @@
+import { test, module } from "qunit";
import DiscourseURL from "discourse/lib/url";
var testMouseTrap;
import KeyboardShortcuts from "discourse/lib/keyboard-shortcuts";
-QUnit.module("lib:keyboard-shortcuts", {
+module("lib:keyboard-shortcuts", {
beforeEach() {
var _bindings = {};
@@ -115,21 +116,21 @@ Object.keys(functionBindings).forEach((func) => {
});
});
-QUnit.test("selectDown calls _moveSelection with 1", (assert) => {
+test("selectDown calls _moveSelection with 1", (assert) => {
var stub = sandbox.stub(KeyboardShortcuts, "_moveSelection");
KeyboardShortcuts.selectDown();
assert.ok(stub.calledWith(1), "_moveSelection is called with 1");
});
-QUnit.test("selectUp calls _moveSelection with -1", (assert) => {
+test("selectUp calls _moveSelection with -1", (assert) => {
var stub = sandbox.stub(KeyboardShortcuts, "_moveSelection");
KeyboardShortcuts.selectUp();
assert.ok(stub.calledWith(-1), "_moveSelection is called with -1");
});
-QUnit.test("goBack calls history.back", (assert) => {
+test("goBack calls history.back", (assert) => {
var called = false;
sandbox.stub(history, "back").callsFake(function () {
called = true;
@@ -139,14 +140,14 @@ QUnit.test("goBack calls history.back", (assert) => {
assert.ok(called, "history.back is called");
});
-QUnit.test("nextSection calls _changeSection with 1", (assert) => {
+test("nextSection calls _changeSection with 1", (assert) => {
var spy = sandbox.spy(KeyboardShortcuts, "_changeSection");
KeyboardShortcuts.nextSection();
assert.ok(spy.calledWith(1), "_changeSection is called with 1");
});
-QUnit.test("prevSection calls _changeSection with -1", (assert) => {
+test("prevSection calls _changeSection with -1", (assert) => {
var spy = sandbox.spy(KeyboardShortcuts, "_changeSection");
KeyboardShortcuts.prevSection();
diff --git a/test/javascripts/components/load-more-test.js b/app/assets/javascripts/discourse/tests/integration/components/load-more-test.js
similarity index 83%
rename from test/javascripts/components/load-more-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/load-more-test.js
index 0d10793ee6..d5a9310b3d 100644
--- a/test/javascripts/components/load-more-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/load-more-test.js
@@ -1,5 +1,6 @@
+import { moduleForComponent } from "ember-qunit";
import { configureEyeline } from "discourse/lib/eyeline";
-import componentTest from "helpers/component-test";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("load-more", { integration: true });
diff --git a/test/javascripts/components/secret-value-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/secret-value-list-test.js
similarity index 95%
rename from test/javascripts/components/secret-value-list-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/secret-value-list-test.js
index 7ee2f9b004..c07ab3a5d5 100644
--- a/test/javascripts/components/secret-value-list-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/secret-value-list-test.js
@@ -1,5 +1,6 @@
+import { moduleForComponent } from "ember-qunit";
import I18n from "I18n";
-import componentTest from "helpers/component-test";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("secret-value-list", { integration: true });
componentTest("adding a value", {
diff --git a/test/javascripts/components/select-kit/api-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/api-test.js
similarity index 96%
rename from test/javascripts/components/select-kit/api-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/api-test.js
index 1b4efdae39..3954ba077c 100644
--- a/test/javascripts/components/select-kit/api-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/api-test.js
@@ -1,9 +1,9 @@
-import componentTest from "helpers/component-test";
+import componentTest from "discourse/tests/helpers/component-test";
import selectKit, {
testSelectKitModule,
setDefaultState,
DEFAULT_CONTENT,
-} from "helpers/select-kit-helper";
+} from "discourse/tests/helpers/select-kit-helper";
import { withPluginApi } from "discourse/lib/plugin-api";
import { clearCallbacks } from "select-kit/mixins/plugin-api";
diff --git a/test/javascripts/components/select-kit/category-chooser-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/category-chooser-test.js
similarity index 73%
rename from test/javascripts/components/select-kit/category-chooser-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/category-chooser-test.js
index 57e3fe6860..5ccdf32e38 100644
--- a/test/javascripts/components/select-kit/category-chooser-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/category-chooser-test.js
@@ -1,6 +1,7 @@
+import createStore from "discourse/tests/helpers/create-store";
import I18n from "I18n";
-import componentTest from "helpers/component-test";
-import { testSelectKitModule } from "helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
+import { testSelectKitModule } from "discourse/tests/helpers/select-kit-helper";
testSelectKitModule("category-chooser");
@@ -144,3 +145,52 @@ componentTest("with allowed uncategorized and none", {
assert.equal(this.subject.header().label(), "root none label");
},
});
+
+componentTest("filter is case insensitive", {
+ template: template(),
+
+ async test(assert) {
+ await this.subject.expand();
+ await this.subject.fillInFilter("bug");
+
+ assert.ok(this.subject.rows().length, 1);
+ assert.equal(this.subject.rowByIndex(0).name(), "bug");
+
+ await this.subject.emptyFilter();
+ await this.subject.fillInFilter("Bug");
+
+ assert.ok(this.subject.rows().length, 1);
+ assert.equal(this.subject.rowByIndex(0).name(), "bug");
+ },
+});
+
+componentTest("filter works with non english characters", {
+ template: `
+ {{category-chooser
+ value=value
+ content=content
+ }}
+ `,
+
+ beforeEach() {
+ const store = createStore();
+ const nonEnglishCat = store.createRecord("category", {
+ id: 1,
+ name: "chữ Quốc ngữ",
+ });
+ const englishCat = store.createRecord("category", {
+ id: 2,
+ name: "Baz",
+ });
+
+ this.set("content", [nonEnglishCat, englishCat]);
+ },
+
+ async test(assert) {
+ await this.subject.expand();
+ await this.subject.fillInFilter("hữ");
+
+ assert.ok(this.subject.rows().length, 1);
+ assert.equal(this.subject.rowByIndex(0).name(), "chữ Quốc ngữ");
+ },
+});
diff --git a/test/javascripts/components/select-kit/category-drop-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/category-drop-test.js
similarity index 98%
rename from test/javascripts/components/select-kit/category-drop-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/category-drop-test.js
index 914f68d155..c52cbe3850 100644
--- a/test/javascripts/components/select-kit/category-drop-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/category-drop-test.js
@@ -1,8 +1,8 @@
import I18n from "I18n";
import DiscourseURL from "discourse/lib/url";
import Category from "discourse/models/category";
-import componentTest from "helpers/component-test";
-import { testSelectKitModule } from "helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
+import { testSelectKitModule } from "discourse/tests/helpers/select-kit-helper";
import {
NO_CATEGORIES_ID,
ALL_CATEGORIES_ID,
diff --git a/test/javascripts/components/select-kit/combo-box-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/combo-box-test.js
similarity index 91%
rename from test/javascripts/components/select-kit/combo-box-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/combo-box-test.js
index 7ceb8599ac..ccbd9f29b1 100644
--- a/test/javascripts/components/select-kit/combo-box-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/combo-box-test.js
@@ -1,5 +1,6 @@
-import selectKit from "helpers/select-kit-helper";
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("select-kit/combo-box", {
integration: true,
diff --git a/test/javascripts/components/select-kit/dropdown-select-box-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/dropdown-select-box-test.js
similarity index 92%
rename from test/javascripts/components/select-kit/dropdown-select-box-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/dropdown-select-box-test.js
index 4819533d13..817be1aadc 100644
--- a/test/javascripts/components/select-kit/dropdown-select-box-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/dropdown-select-box-test.js
@@ -1,5 +1,6 @@
-import selectKit from "helpers/select-kit-helper";
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("select-kit/dropdown-select-box", {
integration: true,
diff --git a/test/javascripts/components/select-kit/list-setting-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/list-setting-test.js
similarity index 82%
rename from test/javascripts/components/select-kit/list-setting-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/list-setting-test.js
index b1f0571624..a702859684 100644
--- a/test/javascripts/components/select-kit/list-setting-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/list-setting-test.js
@@ -1,5 +1,5 @@
-import componentTest from "helpers/component-test";
-import { testSelectKitModule } from "helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
+import { testSelectKitModule } from "discourse/tests/helpers/select-kit-helper";
testSelectKitModule("list-setting");
diff --git a/test/javascripts/components/select-kit/mini-tag-chooser-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/mini-tag-chooser-test.js
similarity index 91%
rename from test/javascripts/components/select-kit/mini-tag-chooser-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/mini-tag-chooser-test.js
index 24ecb7c5d0..8c54e0cd5d 100644
--- a/test/javascripts/components/select-kit/mini-tag-chooser-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/mini-tag-chooser-test.js
@@ -1,6 +1,6 @@
import I18n from "I18n";
-import componentTest from "helpers/component-test";
-import { testSelectKitModule } from "helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
+import { testSelectKitModule } from "discourse/tests/helpers/select-kit-helper";
testSelectKitModule("mini-tag-chooser");
diff --git a/test/javascripts/components/select-kit/multi-select-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/multi-select-test.js
similarity index 88%
rename from test/javascripts/components/select-kit/multi-select-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/multi-select-test.js
index f501fa3a19..1f97c1fdec 100644
--- a/test/javascripts/components/select-kit/multi-select-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/multi-select-test.js
@@ -1,5 +1,5 @@
-import componentTest from "helpers/component-test";
-import { testSelectKitModule } from "helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
+import { testSelectKitModule } from "discourse/tests/helpers/select-kit-helper";
testSelectKitModule("multi-select");
diff --git a/test/javascripts/components/select-kit/notifications-button-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/notifications-button-test.js
similarity index 87%
rename from test/javascripts/components/select-kit/notifications-button-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/notifications-button-test.js
index 50c168d19b..463a75ff38 100644
--- a/test/javascripts/components/select-kit/notifications-button-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/notifications-button-test.js
@@ -1,8 +1,8 @@
-import componentTest from "helpers/component-test";
+import componentTest from "discourse/tests/helpers/component-test";
import {
testSelectKitModule,
setDefaultState,
-} from "helpers/select-kit-helper";
+} from "discourse/tests/helpers/select-kit-helper";
testSelectKitModule("notifications-button");
diff --git a/test/javascripts/components/select-kit/pinned-options-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/pinned-options-test.js
similarity index 87%
rename from test/javascripts/components/select-kit/pinned-options-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/pinned-options-test.js
index e5503c4307..32d24a0f6d 100644
--- a/test/javascripts/components/select-kit/pinned-options-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/pinned-options-test.js
@@ -1,5 +1,6 @@
-import selectKit from "helpers/select-kit-helper";
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
import Topic from "discourse/models/topic";
const buildTopic = function (pinned = true) {
diff --git a/test/javascripts/components/select-kit/single-select-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/single-select-test.js
similarity index 97%
rename from test/javascripts/components/select-kit/single-select-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/single-select-test.js
index 7e81a1f74b..e7473b0c1d 100644
--- a/test/javascripts/components/select-kit/single-select-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/single-select-test.js
@@ -1,6 +1,6 @@
import I18n from "I18n";
-import componentTest from "helpers/component-test";
-import { testSelectKitModule } from "helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
+import { testSelectKitModule } from "discourse/tests/helpers/select-kit-helper";
testSelectKitModule("single-select");
diff --git a/test/javascripts/components/select-kit/tag-drop-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/tag-drop-test.js
similarity index 90%
rename from test/javascripts/components/select-kit/tag-drop-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/tag-drop-test.js
index 65f7702436..be6223d831 100644
--- a/test/javascripts/components/select-kit/tag-drop-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/tag-drop-test.js
@@ -1,9 +1,9 @@
import I18n from "I18n";
-import componentTest from "helpers/component-test";
-import { testSelectKitModule } from "helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
+import { testSelectKitModule } from "discourse/tests/helpers/select-kit-helper";
import Site from "discourse/models/site";
import { set } from "@ember/object";
-import pretender from "helpers/create-pretender";
+import pretender from "discourse/tests/helpers/create-pretender";
testSelectKitModule("tag-drop", {
beforeEach() {
diff --git a/test/javascripts/components/select-kit/topic-notifications-button-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/topic-notifications-button-test.js
similarity index 89%
rename from test/javascripts/components/select-kit/topic-notifications-button-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/topic-notifications-button-test.js
index 16567159b8..6656bda882 100644
--- a/test/javascripts/components/select-kit/topic-notifications-button-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/topic-notifications-button-test.js
@@ -1,6 +1,7 @@
+import { moduleForComponent } from "ember-qunit";
import I18n from "I18n";
-import selectKit from "helpers/select-kit-helper";
-import componentTest from "helpers/component-test";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
import Topic from "discourse/models/topic";
const buildTopic = function (level, archetype = "regular") {
diff --git a/test/javascripts/components/select-kit/topic-notifications-options-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/topic-notifications-options-test.js
similarity index 91%
rename from test/javascripts/components/select-kit/topic-notifications-options-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/topic-notifications-options-test.js
index fb30a393db..9a072ebaec 100644
--- a/test/javascripts/components/select-kit/topic-notifications-options-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/topic-notifications-options-test.js
@@ -1,6 +1,7 @@
+import { moduleForComponent } from "ember-qunit";
import I18n from "I18n";
-import selectKit from "helpers/select-kit-helper";
-import componentTest from "helpers/component-test";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
import Topic from "discourse/models/topic";
const buildTopic = function (archetype) {
diff --git a/test/javascripts/components/select-kit/user-chooser-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/user-chooser-test.js
similarity index 79%
rename from test/javascripts/components/select-kit/user-chooser-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/user-chooser-test.js
index eed4e3b659..c3d006fa3b 100644
--- a/test/javascripts/components/select-kit/user-chooser-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/user-chooser-test.js
@@ -1,5 +1,5 @@
-import componentTest from "helpers/component-test";
-import { testSelectKitModule } from "helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
+import { testSelectKitModule } from "discourse/tests/helpers/select-kit-helper";
testSelectKitModule("user-chooser");
diff --git a/test/javascripts/components/share-button-test.js b/app/assets/javascripts/discourse/tests/integration/components/share-button-test.js
similarity index 76%
rename from test/javascripts/components/share-button-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/share-button-test.js
index e8bac153d7..9a137ff183 100644
--- a/test/javascripts/components/share-button-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/share-button-test.js
@@ -1,4 +1,5 @@
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("share-button", { integration: true });
diff --git a/test/javascripts/components/share-button.js b/app/assets/javascripts/discourse/tests/integration/components/share-button.js
similarity index 100%
rename from test/javascripts/components/share-button.js
rename to app/assets/javascripts/discourse/tests/integration/components/share-button.js
diff --git a/test/javascripts/components/simple-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/simple-list-test.js
similarity index 94%
rename from test/javascripts/components/simple-list-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/simple-list-test.js
index 4150381898..c66c8d7c5c 100644
--- a/test/javascripts/components/simple-list-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/simple-list-test.js
@@ -1,4 +1,5 @@
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("simple-list", { integration: true });
componentTest("adding a value", {
diff --git a/test/javascripts/components/text-field-test.js b/app/assets/javascripts/discourse/tests/integration/components/text-field-test.js
similarity index 95%
rename from test/javascripts/components/text-field-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/text-field-test.js
index 11d43bd211..21eb8d00c6 100644
--- a/test/javascripts/components/text-field-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/text-field-test.js
@@ -1,5 +1,6 @@
+import { moduleForComponent } from "ember-qunit";
import I18n from "I18n";
-import componentTest from "helpers/component-test";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("text-field", { integration: true });
diff --git a/test/javascripts/components/time-input-test.js b/app/assets/javascripts/discourse/tests/integration/components/time-input-test.js
similarity index 86%
rename from test/javascripts/components/time-input-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/time-input-test.js
index eed1195b41..6773b1b8e8 100644
--- a/test/javascripts/components/time-input-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/time-input-test.js
@@ -1,5 +1,6 @@
-import selectKit from "helpers/select-kit-helper";
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("time-input", {
integration: true,
diff --git a/test/javascripts/components/user-selector-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-selector-test.js
similarity index 93%
rename from test/javascripts/components/user-selector-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/user-selector-test.js
index d09816e3cf..4e54429693 100644
--- a/test/javascripts/components/user-selector-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/user-selector-test.js
@@ -1,4 +1,5 @@
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("user-selector", { integration: true });
diff --git a/test/javascripts/components/value-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/value-list-test.js
similarity index 94%
rename from test/javascripts/components/value-list-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/value-list-test.js
index e0769901da..e1708c5865 100644
--- a/test/javascripts/components/value-list-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/value-list-test.js
@@ -1,5 +1,6 @@
-import selectKit from "helpers/select-kit-helper";
-import componentTest from "helpers/component-test";
+import { moduleForComponent } from "ember-qunit";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
+import componentTest from "discourse/tests/helpers/component-test";
moduleForComponent("value-list", { integration: true });
componentTest("adding a value", {
diff --git a/test/javascripts/widgets/actions-summary-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/actions-summary-test.js
similarity index 86%
rename from test/javascripts/widgets/actions-summary-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/actions-summary-test.js
index 038ab9ac37..9a48443590 100644
--- a/test/javascripts/widgets/actions-summary-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/actions-summary-test.js
@@ -1,4 +1,7 @@
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
moduleForWidget("actions-summary");
diff --git a/test/javascripts/widgets/avatar-flair-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/avatar-flair-test.js
similarity index 91%
rename from test/javascripts/widgets/avatar-flair-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/avatar-flair-test.js
index 99e1556b64..7d435a63a3 100644
--- a/test/javascripts/widgets/avatar-flair-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/avatar-flair-test.js
@@ -1,4 +1,7 @@
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
moduleForWidget("avatar-flair");
diff --git a/test/javascripts/widgets/button-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/button-test.js
similarity index 93%
rename from test/javascripts/widgets/button-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/button-test.js
index 51574c5e52..b0bcab35e1 100644
--- a/test/javascripts/widgets/button-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/button-test.js
@@ -1,4 +1,7 @@
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
moduleForWidget("button");
diff --git a/test/javascripts/widgets/default-notification-item-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/default-notification-item-test.js
similarity index 90%
rename from test/javascripts/widgets/default-notification-item-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/default-notification-item-test.js
index 1c0c4fa364..993785323a 100644
--- a/test/javascripts/widgets/default-notification-item-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/default-notification-item-test.js
@@ -1,6 +1,9 @@
import EmberObject from "@ember/object";
-import pretender from "helpers/create-pretender";
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import pretender from "discourse/tests/helpers/create-pretender";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
moduleForWidget("default-notification-item");
diff --git a/test/javascripts/widgets/hamburger-menu-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/hamburger-menu-test.js
similarity index 98%
rename from test/javascripts/widgets/hamburger-menu-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/hamburger-menu-test.js
index 661b8e662a..b4ad25bdc6 100644
--- a/test/javascripts/widgets/hamburger-menu-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/hamburger-menu-test.js
@@ -1,4 +1,7 @@
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
import { NotificationLevels } from "discourse/lib/notification-levels";
moduleForWidget("hamburger-menu");
diff --git a/test/javascripts/widgets/header-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/header-test.js
similarity index 96%
rename from test/javascripts/widgets/header-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/header-test.js
index ddd699ef10..14350d12e6 100644
--- a/test/javascripts/widgets/header-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/header-test.js
@@ -1,4 +1,7 @@
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
moduleForWidget("header");
diff --git a/test/javascripts/widgets/home-logo-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/home-logo-test.js
similarity index 98%
rename from test/javascripts/widgets/home-logo-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/home-logo-test.js
index d12a376c6f..021057bd3b 100644
--- a/test/javascripts/widgets/home-logo-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/home-logo-test.js
@@ -1,4 +1,7 @@
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
import Session from "discourse/models/session";
moduleForWidget("home-logo");
diff --git a/test/javascripts/widgets/post-links-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/post-links-test.js
similarity index 94%
rename from test/javascripts/widgets/post-links-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/post-links-test.js
index 1eea33c997..1062a74dcd 100644
--- a/test/javascripts/widgets/post-links-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/post-links-test.js
@@ -1,4 +1,7 @@
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
moduleForWidget("post-links");
diff --git a/test/javascripts/widgets/post-menu-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/post-menu-test.js
similarity index 92%
rename from test/javascripts/widgets/post-menu-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/post-menu-test.js
index f95776f1b1..c20c8d251a 100644
--- a/test/javascripts/widgets/post-menu-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/post-menu-test.js
@@ -1,4 +1,7 @@
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
import { withPluginApi } from "discourse/lib/plugin-api";
moduleForWidget("post-menu");
diff --git a/test/javascripts/widgets/post-stream-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/post-stream-test.js
similarity index 97%
rename from test/javascripts/widgets/post-stream-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/post-stream-test.js
index c9b58e98af..daff6490ea 100644
--- a/test/javascripts/widgets/post-stream-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/post-stream-test.js
@@ -1,4 +1,7 @@
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
import Topic from "discourse/models/topic";
import Post from "discourse/models/post";
diff --git a/test/javascripts/widgets/post-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/post-test.js
similarity index 99%
rename from test/javascripts/widgets/post-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/post-test.js
index 802b5e76ce..1e888b0e28 100644
--- a/test/javascripts/widgets/post-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/post-test.js
@@ -1,6 +1,9 @@
import I18n from "I18n";
import EmberObject from "@ember/object";
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
moduleForWidget("post");
diff --git a/test/javascripts/widgets/poster-name-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/poster-name-test.js
similarity index 95%
rename from test/javascripts/widgets/poster-name-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/poster-name-test.js
index 8f308f409d..30a72e7c2c 100644
--- a/test/javascripts/widgets/poster-name-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/poster-name-test.js
@@ -1,4 +1,7 @@
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
moduleForWidget("poster-name");
diff --git a/test/javascripts/widgets/quick-access-item-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/quick-access-item-test.js
similarity index 89%
rename from test/javascripts/widgets/quick-access-item-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/quick-access-item-test.js
index 5101d2a481..5300656f59 100644
--- a/test/javascripts/widgets/quick-access-item-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/quick-access-item-test.js
@@ -1,4 +1,7 @@
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
moduleForWidget("quick-access-item");
diff --git a/test/javascripts/widgets/small-user-list-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/small-user-list-test.js
similarity index 86%
rename from test/javascripts/widgets/small-user-list-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/small-user-list-test.js
index 2e6ef1ea1f..f955df662d 100644
--- a/test/javascripts/widgets/small-user-list-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/small-user-list-test.js
@@ -1,4 +1,7 @@
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
moduleForWidget("small-user-list");
diff --git a/test/javascripts/widgets/topic-admin-menu-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/topic-admin-menu-test.js
similarity index 95%
rename from test/javascripts/widgets/topic-admin-menu-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/topic-admin-menu-test.js
index 3351e3ee1a..07b6f21d64 100644
--- a/test/javascripts/widgets/topic-admin-menu-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/topic-admin-menu-test.js
@@ -1,4 +1,7 @@
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
import Topic from "discourse/models/topic";
import Category from "discourse/models/category";
diff --git a/test/javascripts/widgets/topic-participant-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/topic-participant-test.js
similarity index 93%
rename from test/javascripts/widgets/topic-participant-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/topic-participant-test.js
index 4aafd112bf..51ae5d2ac0 100644
--- a/test/javascripts/widgets/topic-participant-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/topic-participant-test.js
@@ -1,4 +1,7 @@
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
moduleForWidget("topic-participant");
diff --git a/test/javascripts/widgets/topic-status-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/topic-status-test.js
similarity index 91%
rename from test/javascripts/widgets/topic-status-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/topic-status-test.js
index d9a677dda4..31c7786cc1 100644
--- a/test/javascripts/widgets/topic-status-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/topic-status-test.js
@@ -1,4 +1,7 @@
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
import TopicStatusIcons from "discourse/helpers/topic-status-icons";
moduleForWidget("topic-status");
diff --git a/test/javascripts/widgets/user-menu-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/user-menu-test.js
similarity index 98%
rename from test/javascripts/widgets/user-menu-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/user-menu-test.js
index 3a286dd838..601be8a455 100644
--- a/test/javascripts/widgets/user-menu-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/user-menu-test.js
@@ -1,6 +1,9 @@
import I18n from "I18n";
import DiscourseURL from "discourse/lib/url";
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
moduleForWidget("user-menu");
diff --git a/test/javascripts/widgets/widget-dropdown-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/widget-dropdown-test.js
similarity index 98%
rename from test/javascripts/widgets/widget-dropdown-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/widget-dropdown-test.js
index 09796d5dc8..f3d58c3767 100644
--- a/test/javascripts/widgets/widget-dropdown-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/widget-dropdown-test.js
@@ -1,5 +1,8 @@
import I18n from "I18n";
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
moduleForWidget("widget-dropdown");
diff --git a/test/javascripts/widgets/widget-test.js b/app/assets/javascripts/discourse/tests/integration/widgets/widget-test.js
similarity index 99%
rename from test/javascripts/widgets/widget-test.js
rename to app/assets/javascripts/discourse/tests/integration/widgets/widget-test.js
index 01ff5f5796..1d807bfdbf 100644
--- a/test/javascripts/widgets/widget-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/widgets/widget-test.js
@@ -1,6 +1,9 @@
import I18n from "I18n";
import { next } from "@ember/runloop";
-import { moduleForWidget, widgetTest } from "helpers/widget-test";
+import {
+ moduleForWidget,
+ widgetTest,
+} from "discourse/tests/helpers/widget-test";
import { createWidget } from "discourse/widgets/widget";
import { withPluginApi } from "discourse/lib/plugin-api";
import { Promise } from "rsvp";
diff --git a/test/javascripts/plugin_tests.js.erb b/app/assets/javascripts/discourse/tests/plugin_tests.js.erb
similarity index 100%
rename from test/javascripts/plugin_tests.js.erb
rename to app/assets/javascripts/discourse/tests/plugin_tests.js.erb
diff --git a/app/assets/javascripts/discourse/tests/setup-tests.js b/app/assets/javascripts/discourse/tests/setup-tests.js
new file mode 100644
index 0000000000..8f8f689d2c
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/setup-tests.js
@@ -0,0 +1,191 @@
+import {
+ resetSettings,
+ currentSettings,
+} from "discourse/tests/helpers/site-settings";
+import { getOwner, setDefaultOwner } from "discourse-common/lib/get-owner";
+import { setupURL, setupS3CDN } from "discourse-common/lib/get-url";
+import { createHelperContext } from "discourse-common/lib/helpers";
+import { buildResolver } from "discourse-common/resolver";
+import createPretender, {
+ pretenderHelpers,
+ applyDefaultHandlers,
+} from "discourse/tests/helpers/create-pretender";
+import { flushMap } from "discourse/models/store";
+import { ScrollingDOMMethods } from "discourse/mixins/scrolling";
+import DiscourseURL from "discourse/lib/url";
+import {
+ resetSite,
+ applyPretender,
+} from "discourse/tests/helpers/qunit-helpers";
+import PreloadStore from "discourse/lib/preload-store";
+import User from "discourse/models/user";
+import Session from "discourse/models/session";
+import { clearAppEventsCache } from "discourse/services/app-events";
+import QUnit from "qunit";
+import MessageBus from "message-bus-client";
+import deprecated from "discourse-common/lib/deprecated";
+import sinon from "sinon";
+import { setResolver } from "@ember/test-helpers";
+
+export default function setupTests(App) {
+ setResolver(buildResolver("discourse").create({ namespace: App }));
+
+ sinon.config = {
+ injectIntoThis: false,
+ injectInto: null,
+ properties: ["spy", "stub", "mock", "clock", "sandbox"],
+ useFakeTimers: true,
+ useFakeServer: false,
+ };
+
+ // Stop the message bus so we don't get ajax calls
+ MessageBus.stop();
+
+ document.write(
+ '
'
+ );
+ document.write(
+ ""
+ );
+
+ App.rootElement = "#ember-testing";
+ App.setupForTesting();
+ App.injectTestHelpers();
+ App.SiteSettings = currentSettings();
+ App.start();
+
+ // disable logster error reporting
+ if (window.Logster) {
+ window.Logster.enabled = false;
+ } else {
+ window.Logster = { enabled: false };
+ }
+
+ let server;
+
+ Object.defineProperty(window, "server", {
+ get() {
+ deprecated(
+ "Accessing the global variable `server` is deprecated. Use a `pretend()` method instead.",
+ {
+ since: "2.6.0.beta.3",
+ dropFrom: "2.6.0",
+ }
+ );
+ return server;
+ },
+ });
+
+ QUnit.testStart(function (ctx) {
+ let settings = resetSettings();
+ server = createPretender;
+ applyDefaultHandlers(server);
+ server.handlers = [];
+
+ server.prepareBody = function (body) {
+ if (body && typeof body === "object") {
+ return JSON.stringify(body);
+ }
+ return body;
+ };
+
+ if (QUnit.config.logAllRequests) {
+ server.handledRequest = function (verb, path) {
+ // eslint-disable-next-line no-console
+ console.log("REQ: " + verb + " " + path);
+ };
+ }
+
+ server.unhandledRequest = function (verb, path) {
+ if (QUnit.config.logAllRequests) {
+ // eslint-disable-next-line no-console
+ console.log("REQ: " + verb + " " + path + " missing");
+ }
+
+ const error =
+ "Unhandled request in test environment: " + path + " (" + verb + ")";
+
+ window.console.error(error);
+ throw new Error(error);
+ };
+
+ server.checkPassthrough = (request) =>
+ request.requestHeaders["Discourse-Script"];
+
+ applyPretender(ctx.module, server, pretenderHelpers());
+
+ setupURL(null, "http://localhost:3000", "");
+ setupS3CDN(null, null);
+
+ Session.resetCurrent();
+ User.resetCurrent();
+ let site = resetSite(settings);
+ createHelperContext({
+ siteSettings: settings,
+ capabilities: {},
+ site,
+ });
+
+ DiscourseURL.redirectedTo = null;
+ DiscourseURL.redirectTo = function (url) {
+ DiscourseURL.redirectedTo = url;
+ };
+
+ PreloadStore.reset();
+
+ window.sandbox = sinon;
+ window.sandbox.stub(ScrollingDOMMethods, "screenNotFull");
+ window.sandbox.stub(ScrollingDOMMethods, "bindOnScroll");
+ window.sandbox.stub(ScrollingDOMMethods, "unbindOnScroll");
+
+ // Unless we ever need to test this, let's leave it off.
+ $.fn.autocomplete = function () {};
+ });
+
+ QUnit.testDone(function () {
+ window.sandbox.restore();
+
+ // Destroy any modals
+ $(".modal-backdrop").remove();
+ flushMap();
+
+ // ensures any event not removed is not leaking between tests
+ // most likely in intialisers, other places (controller, component...)
+ // should be fixed in code
+ clearAppEventsCache(getOwner(this));
+
+ MessageBus.unsubscribe("*");
+ server = null;
+ window.Mousetrap.reset();
+ });
+
+ // Load ES6 tests
+ function getUrlParameter(name) {
+ name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
+ var regex = new RegExp("[\\?&]" + name + "=([^]*)");
+ var results = regex.exec(location.search);
+ return results === null
+ ? ""
+ : decodeURIComponent(results[1].replace(/\+/g, " "));
+ }
+
+ let skipCore = getUrlParameter("qunit_skip_core") === "1";
+ let pluginPath = getUrlParameter("qunit_single_plugin")
+ ? "/" + getUrlParameter("qunit_single_plugin") + "/"
+ : "/plugins/";
+
+ Object.keys(requirejs.entries).forEach(function (entry) {
+ let isTest = /\-test/.test(entry);
+ let regex = new RegExp(pluginPath);
+ let isPlugin = regex.test(entry);
+
+ if (isTest && (!skipCore || isPlugin)) {
+ require(entry, null, null, true);
+ }
+ });
+
+ // forces 0 as duration for all jquery animations
+ jQuery.fx.off = true;
+ setDefaultOwner(App.__container__);
+ resetSite();
+}
diff --git a/app/assets/javascripts/discourse/tests/test_helper.js b/app/assets/javascripts/discourse/tests/test_helper.js
new file mode 100644
index 0000000000..d84c9b15b6
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/test_helper.js
@@ -0,0 +1,47 @@
+// discourse-skip-module
+
+//= require env
+//= require jquery.debug
+//= require jquery.ui.widget
+//= require ember.debug
+//= require message-bus
+//= require qunit/qunit/qunit
+//= require ember-qunit
+//= require fake_xml_http_request
+//= require route-recognizer
+//= require pretender/pretender
+//= require locales/i18n
+//= require locales/en_US
+//= require discourse-loader
+
+// Our base application
+//= require vendor
+//= require discourse-shims
+//= require pretty-text-bundle
+//= require markdown-it-bundle
+//= require application
+//= require admin
+
+// These are not loaded in prod or development
+// But we need them for testing handlebars templates in qunit
+//= require handlebars
+//= require ember-template-compiler
+
+// Test helpers
+//= require sinon/pkg/sinon
+//= require_tree ./helpers
+//= require break_string
+
+// Finally, the tests themselves
+//= require_tree ./fixtures
+//= require_tree ./acceptance
+//= require_tree ./integration
+//= require_tree ./unit
+//= require_tree ../../admin/tests/admin
+//= require plugin_tests
+//= require setup-tests
+//= require test-shims
+//= require jquery.magnific-popup.min.js
+
+let setupTests = require("discourse/tests/setup-tests").default;
+setupTests(window.Discourse);
diff --git a/test/javascripts/controllers/avatar-selector-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/avatar-selector-test.js
similarity index 53%
rename from test/javascripts/controllers/avatar-selector-test.js
rename to app/assets/javascripts/discourse/tests/unit/controllers/avatar-selector-test.js
index c6e2301f4d..aff8c19d28 100644
--- a/test/javascripts/controllers/avatar-selector-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/avatar-selector-test.js
@@ -1,4 +1,7 @@
+import EmberObject from "@ember/object";
import { mapRoutes } from "discourse/mapping-router";
+import { moduleFor } from "ember-qunit";
+import { test } from "qunit";
moduleFor("controller:avatar-selector", "controller:avatar-selector", {
beforeEach() {
@@ -7,32 +10,36 @@ moduleFor("controller:avatar-selector", "controller:avatar-selector", {
needs: ["controller:modal"],
});
-QUnit.test("avatarTemplate", function (assert) {
+test("avatarTemplate", function (assert) {
const avatarSelectorController = this.subject();
- avatarSelectorController.setProperties({
- selected: "system",
- user: {
- system_avatar_upload_id: 1,
- gravatar_avatar_upload_id: 2,
- custom_avatar_upload_id: 3,
- },
+ const user = EmberObject.create({
+ avatar_template: "avatar",
+ system_avatar_template: "system",
+ gravatar_avatar_template: "gravatar",
+
+ system_avatar_upload_id: 1,
+ gravatar_avatar_upload_id: 2,
+ custom_avatar_upload_id: 3,
});
+ avatarSelectorController.setProperties({ user });
+
+ user.set("avatar_template", "system");
assert.equal(
avatarSelectorController.get("selectedUploadId"),
1,
"we are using system by default"
);
- avatarSelectorController.set("selected", "gravatar");
+ user.set("avatar_template", "gravatar");
assert.equal(
avatarSelectorController.get("selectedUploadId"),
2,
"we are using gravatar when set"
);
- avatarSelectorController.set("selected", "custom");
+ user.set("avatar_template", "avatar");
assert.equal(
avatarSelectorController.get("selectedUploadId"),
3,
diff --git a/app/assets/javascripts/discourse/tests/unit/controllers/bookmark-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/bookmark-test.js
new file mode 100644
index 0000000000..2c0ff30c0c
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/bookmark-test.js
@@ -0,0 +1,254 @@
+import { moduleFor } from "ember-qunit";
+import { test } from "qunit";
+import { logIn } from "discourse/tests/helpers/qunit-helpers";
+import User from "discourse/models/user";
+import KeyboardShortcutInitializer from "discourse/initializers/keyboard-shortcuts";
+import { REMINDER_TYPES } from "discourse/lib/bookmark";
+import { fakeTime } from "discourse/tests/helpers/qunit-helpers";
+
+let BookmarkController;
+
+moduleFor("controller:bookmark", {
+ beforeEach() {
+ logIn();
+ KeyboardShortcutInitializer.initialize(this.container);
+ BookmarkController = this.subject({
+ currentUser: User.current(),
+ site: { isMobileDevice: false },
+ });
+ BookmarkController.onShow();
+ },
+
+ afterEach() {
+ sandbox.restore();
+ },
+});
+
+function mockMomentTz(dateString) {
+ fakeTime(dateString, BookmarkController.userTimezone);
+}
+
+test("showLaterToday when later today is tomorrow do not show", function (assert) {
+ mockMomentTz("2019-12-11T22:00:00");
+
+ assert.equal(BookmarkController.get("showLaterToday"), false);
+});
+
+test("showLaterToday when later today is after 5pm but before 6pm", function (assert) {
+ mockMomentTz("2019-12-11T15:00:00");
+ assert.equal(BookmarkController.get("showLaterToday"), true);
+});
+
+test("showLaterToday when now is after the cutoff time (5pm)", function (assert) {
+ mockMomentTz("2019-12-11T17:00:00");
+ assert.equal(BookmarkController.get("showLaterToday"), false);
+});
+
+test("showLaterToday when later today is before the end of the day, show", function (assert) {
+ mockMomentTz("2019-12-11T10:00:00");
+
+ assert.equal(BookmarkController.get("showLaterToday"), true);
+});
+
+test("nextWeek gets next week correctly", function (assert) {
+ mockMomentTz("2019-12-11T08:00:00");
+
+ assert.equal(
+ BookmarkController.nextWeek().format("YYYY-MM-DD"),
+ "2019-12-18"
+ );
+});
+
+test("nextMonth gets next month correctly", function (assert) {
+ mockMomentTz("2019-12-11T08:00:00");
+
+ assert.equal(
+ BookmarkController.nextMonth().format("YYYY-MM-DD"),
+ "2020-01-11"
+ );
+});
+
+test("laterThisWeek gets 2 days from now", function (assert) {
+ mockMomentTz("2019-12-10T08:00:00");
+
+ assert.equal(
+ BookmarkController.laterThisWeek().format("YYYY-MM-DD"),
+ "2019-12-12"
+ );
+});
+
+test("laterThisWeek returns null if we are at Thursday already", function (assert) {
+ mockMomentTz("2019-12-12T08:00:00");
+
+ assert.equal(BookmarkController.laterThisWeek(), null);
+});
+
+test("showLaterThisWeek returns true if < Thursday", function (assert) {
+ mockMomentTz("2019-12-10T08:00:00");
+
+ assert.equal(BookmarkController.showLaterThisWeek, true);
+});
+
+test("showLaterThisWeek returns false if > Thursday", function (assert) {
+ mockMomentTz("2019-12-12T08:00:00");
+
+ assert.equal(BookmarkController.showLaterThisWeek, false);
+});
+test("tomorrow gets tomorrow correctly", function (assert) {
+ mockMomentTz("2019-12-11T08:00:00");
+
+ assert.equal(
+ BookmarkController.tomorrow().format("YYYY-MM-DD"),
+ "2019-12-12"
+ );
+});
+
+test("startOfDay changes the time of the provided date to 8:00am correctly", function (assert) {
+ let dt = moment.tz(
+ "2019-12-11T11:37:16",
+ BookmarkController.currentUser.resolvedTimezone(
+ BookmarkController.currentUser
+ )
+ );
+
+ assert.equal(
+ BookmarkController.startOfDay(dt).format("YYYY-MM-DD HH:mm:ss"),
+ "2019-12-11 08:00:00"
+ );
+});
+
+test("laterToday gets 3 hours from now and if before half-past, it rounds down", function (assert) {
+ mockMomentTz("2019-12-11T08:13:00");
+
+ assert.equal(
+ BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
+ "2019-12-11 11:00:00"
+ );
+});
+
+test("laterToday gets 3 hours from now and if after half-past, it rounds up to the next hour", function (assert) {
+ mockMomentTz("2019-12-11T08:43:00");
+
+ assert.equal(
+ BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
+ "2019-12-11 12:00:00"
+ );
+});
+
+test("laterToday is capped to 6pm. later today at 3pm = 6pm, 3:30pm = 6pm, 4pm = 6pm, 4:59pm = 6pm", function (assert) {
+ mockMomentTz("2019-12-11T15:00:00");
+
+ assert.equal(
+ BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
+ "2019-12-11 18:00:00",
+ "3pm should max to 6pm"
+ );
+
+ mockMomentTz("2019-12-11T15:31:00");
+
+ assert.equal(
+ BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
+ "2019-12-11 18:00:00",
+ "3:30pm should max to 6pm"
+ );
+
+ mockMomentTz("2019-12-11T16:00:00");
+
+ assert.equal(
+ BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
+ "2019-12-11 18:00:00",
+ "4pm should max to 6pm"
+ );
+
+ mockMomentTz("2019-12-11T16:59:00");
+
+ assert.equal(
+ BookmarkController.laterToday().format("YYYY-MM-DD HH:mm:ss"),
+ "2019-12-11 18:00:00",
+ "4:59pm should max to 6pm"
+ );
+});
+
+test("showLaterToday returns false if >= 5PM", function (assert) {
+ mockMomentTz("2019-12-11T17:00:01");
+ assert.equal(BookmarkController.showLaterToday, false);
+});
+
+test("showLaterToday returns false if >= 5PM", function (assert) {
+ mockMomentTz("2019-12-11T17:00:01");
+ assert.equal(BookmarkController.showLaterToday, false);
+});
+
+test("reminderAt - custom - defaults to 8:00am if the time is not selected", function (assert) {
+ BookmarkController.customReminderDate = "2028-12-12";
+ BookmarkController.selectedReminderType =
+ BookmarkController.reminderTypes.CUSTOM;
+ const reminderAt = BookmarkController._reminderAt();
+ assert.equal(BookmarkController.customReminderTime, "08:00");
+ assert.equal(
+ reminderAt.toString(),
+ moment
+ .tz(
+ "2028-12-12 08:00",
+ BookmarkController.currentUser.resolvedTimezone(
+ BookmarkController.currentUser
+ )
+ )
+ .toString(),
+ "the custom date and time are parsed correctly with default time"
+ );
+});
+
+test("loadLastUsedCustomReminderDatetime fills the custom reminder date + time if present in localStorage", function (assert) {
+ mockMomentTz("2019-12-11T08:00:00");
+ localStorage.lastCustomBookmarkReminderDate = "2019-12-12";
+ localStorage.lastCustomBookmarkReminderTime = "08:00";
+
+ BookmarkController._loadLastUsedCustomReminderDatetime();
+
+ assert.equal(BookmarkController.lastCustomReminderDate, "2019-12-12");
+ assert.equal(BookmarkController.lastCustomReminderTime, "08:00");
+});
+
+test("loadLastUsedCustomReminderDatetime does not fills the custom reminder date + time if the datetime in localStorage is < now", function (assert) {
+ mockMomentTz("2019-12-11T08:00:00");
+ localStorage.lastCustomBookmarkReminderDate = "2019-12-11";
+ localStorage.lastCustomBookmarkReminderTime = "07:00";
+
+ BookmarkController._loadLastUsedCustomReminderDatetime();
+
+ assert.equal(BookmarkController.lastCustomReminderDate, null);
+ assert.equal(BookmarkController.lastCustomReminderTime, null);
+});
+
+test("user timezone updates when the modal is shown", function (assert) {
+ User.current().changeTimezone(null);
+ let stub = sandbox.stub(moment.tz, "guess").returns("Europe/Moscow");
+ BookmarkController.onShow();
+ assert.equal(BookmarkController.userHasTimezoneSet, true);
+ assert.equal(
+ BookmarkController.userTimezone,
+ "Europe/Moscow",
+ "the user does not have their timezone set and a timezone is guessed"
+ );
+ User.current().changeTimezone("Australia/Brisbane");
+ BookmarkController.onShow();
+ assert.equal(BookmarkController.userHasTimezoneSet, true);
+ assert.equal(
+ BookmarkController.userTimezone,
+ "Australia/Brisbane",
+ "the user does their timezone set"
+ );
+ stub.restore();
+});
+
+test("opening the modal with an existing bookmark with reminder at prefills the custom reminder type", function (assert) {
+ let name = "test";
+ let reminderAt = "2020-05-15T09:45:00";
+ BookmarkController.model = { id: 1, name: name, reminderAt: reminderAt };
+ BookmarkController.onShow();
+ assert.equal(BookmarkController.selectedReminderType, REMINDER_TYPES.CUSTOM);
+ assert.equal(BookmarkController.customReminderDate, "2020-05-15");
+ assert.equal(BookmarkController.customReminderTime, "09:45");
+ assert.equal(BookmarkController.model.name, name);
+});
diff --git a/test/javascripts/controllers/create-account-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/create-account-test.js
similarity index 96%
rename from test/javascripts/controllers/create-account-test.js
rename to app/assets/javascripts/discourse/tests/unit/controllers/create-account-test.js
index 1ab7aebf3b..45f66b4e63 100644
--- a/test/javascripts/controllers/create-account-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/create-account-test.js
@@ -1,5 +1,6 @@
+import { test } from "qunit";
import I18n from "I18n";
-import { controllerModule } from "helpers/qunit-helpers";
+import { controllerModule } from "discourse/tests/helpers/qunit-helpers";
controllerModule("controller:create-account", {
needs: ["controller:modal", "controller:login"],
diff --git a/test/javascripts/controllers/history-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/history-test.js
similarity index 96%
rename from test/javascripts/controllers/history-test.js
rename to app/assets/javascripts/discourse/tests/unit/controllers/history-test.js
index 20385f3638..5a04d41433 100644
--- a/test/javascripts/controllers/history-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/history-test.js
@@ -1,6 +1,8 @@
+import { moduleFor } from "ember-qunit";
+import { test } from "qunit";
moduleFor("controller:history");
-QUnit.test("displayEdit", async function (assert) {
+test("displayEdit", async function (assert) {
const HistoryController = this.subject();
HistoryController.setProperties({
diff --git a/test/javascripts/controllers/preferences-account-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/preferences-account-test.js
similarity index 86%
rename from test/javascripts/controllers/preferences-account-test.js
rename to app/assets/javascripts/discourse/tests/unit/controllers/preferences-account-test.js
index e686c705e1..ce0b1016cd 100644
--- a/test/javascripts/controllers/preferences-account-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/preferences-account-test.js
@@ -1,7 +1,9 @@
+import { moduleFor } from "ember-qunit";
+import { test } from "qunit";
import EmberObject from "@ember/object";
moduleFor("controller:preferences/account");
-QUnit.test("updating of associated accounts", function (assert) {
+test("updating of associated accounts", function (assert) {
const controller = this.subject({
siteSettings: {
enable_google_oauth2_logins: true,
diff --git a/app/assets/javascripts/discourse/tests/unit/controllers/preferences-second-factor-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/preferences-second-factor-test.js
new file mode 100644
index 0000000000..53e249d3ac
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/preferences-second-factor-test.js
@@ -0,0 +1,13 @@
+import { moduleFor } from "ember-qunit";
+import { test } from "qunit";
+moduleFor("controller:preferences/second-factor");
+
+test("displayOAuthWarning when OAuth login methods are enabled", function (assert) {
+ const controller = this.subject({
+ siteSettings: {
+ enable_google_oauth2_logins: true,
+ },
+ });
+
+ assert.equal(controller.get("displayOAuthWarning"), true);
+});
diff --git a/app/assets/javascripts/discourse/tests/unit/controllers/reorder-categories-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/reorder-categories-test.js
new file mode 100644
index 0000000000..2c3eaa32cc
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/reorder-categories-test.js
@@ -0,0 +1,205 @@
+import { moduleFor } from "ember-qunit";
+import { test } from "qunit";
+import EmberObject from "@ember/object";
+import { mapRoutes } from "discourse/mapping-router";
+import createStore from "discourse/tests/helpers/create-store";
+
+moduleFor("controller:reorder-categories", "controller:reorder-categories", {
+ beforeEach() {
+ this.registry.register("router:main", mapRoutes());
+ },
+ needs: ["controller:modal"],
+});
+
+test("reorder set unique position number", function (assert) {
+ const store = createStore();
+
+ const categories = [];
+ for (let i = 0; i < 3; ++i) {
+ categories.push(store.createRecord("category", { id: i, position: 0 }));
+ }
+
+ const site = EmberObject.create({ categories: categories });
+ const reorderCategoriesController = this.subject({ site });
+
+ reorderCategoriesController.reorder();
+
+ reorderCategoriesController
+ .get("categoriesOrdered")
+ .forEach((category, index) => {
+ assert.equal(category.get("position"), index);
+ });
+});
+
+test("reorder places subcategories after their parent categories, while maintaining the relative order", function (assert) {
+ const store = createStore();
+
+ const parent = store.createRecord("category", {
+ id: 1,
+ position: 1,
+ slug: "parent",
+ });
+ const child1 = store.createRecord("category", {
+ id: 2,
+ position: 3,
+ slug: "child1",
+ parent_category_id: 1,
+ });
+ const child2 = store.createRecord("category", {
+ id: 3,
+ position: 0,
+ slug: "child2",
+ parent_category_id: 1,
+ });
+ const other = store.createRecord("category", {
+ id: 4,
+ position: 2,
+ slug: "other",
+ });
+
+ const categories = [child2, parent, other, child1];
+ const expectedOrderSlugs = ["parent", "child2", "child1", "other"];
+
+ const site = EmberObject.create({ categories: categories });
+ const reorderCategoriesController = this.subject({ site });
+
+ reorderCategoriesController.reorder();
+
+ assert.deepEqual(
+ reorderCategoriesController.get("categoriesOrdered").mapBy("slug"),
+ expectedOrderSlugs
+ );
+});
+
+test("changing the position number of a category should place it at given position", function (assert) {
+ const store = createStore();
+
+ const elem1 = store.createRecord("category", {
+ id: 1,
+ position: 0,
+ slug: "foo",
+ });
+
+ const elem2 = store.createRecord("category", {
+ id: 2,
+ position: 1,
+ slug: "bar",
+ });
+
+ const elem3 = store.createRecord("category", {
+ id: 3,
+ position: 2,
+ slug: "test",
+ });
+
+ const categories = [elem1, elem2, elem3];
+ const site = EmberObject.create({ categories: categories });
+ const reorderCategoriesController = this.subject({ site });
+
+ reorderCategoriesController.actions.change.call(
+ reorderCategoriesController,
+ elem1,
+ { target: { value: "2" } }
+ );
+
+ assert.deepEqual(
+ reorderCategoriesController.get("categoriesOrdered").mapBy("slug"),
+ ["test", "bar", "foo"]
+ );
+});
+
+test("changing the position number of a category should place it at given position and respect children", function (assert) {
+ const store = createStore();
+
+ const elem1 = store.createRecord("category", {
+ id: 1,
+ position: 0,
+ slug: "foo",
+ });
+
+ const child1 = store.createRecord("category", {
+ id: 4,
+ position: 1,
+ slug: "foochild",
+ parent_category_id: 1,
+ });
+
+ const elem2 = store.createRecord("category", {
+ id: 2,
+ position: 2,
+ slug: "bar",
+ });
+
+ const elem3 = store.createRecord("category", {
+ id: 3,
+ position: 3,
+ slug: "test",
+ });
+
+ const categories = [elem1, child1, elem2, elem3];
+ const site = EmberObject.create({ categories: categories });
+ const reorderCategoriesController = this.subject({ site });
+
+ reorderCategoriesController.actions.change.call(
+ reorderCategoriesController,
+ elem1,
+ { target: { value: 3 } }
+ );
+
+ assert.deepEqual(
+ reorderCategoriesController.get("categoriesOrdered").mapBy("slug"),
+ ["test", "bar", "foo", "foochild"]
+ );
+});
+
+test("changing the position through click on arrow of a category should place it at given position and respect children", function (assert) {
+ const store = createStore();
+
+ const elem1 = store.createRecord("category", {
+ id: 1,
+ position: 0,
+ slug: "foo",
+ });
+
+ const child1 = store.createRecord("category", {
+ id: 4,
+ position: 1,
+ slug: "foochild",
+ parent_category_id: 1,
+ });
+
+ const child2 = store.createRecord("category", {
+ id: 5,
+ position: 2,
+ slug: "foochildchild",
+ parent_category_id: 4,
+ });
+
+ const elem2 = store.createRecord("category", {
+ id: 2,
+ position: 3,
+ slug: "bar",
+ });
+
+ const elem3 = store.createRecord("category", {
+ id: 3,
+ position: 4,
+ slug: "test",
+ });
+
+ const categories = [elem1, child1, child2, elem2, elem3];
+ const site = EmberObject.create({ categories: categories });
+ const reorderCategoriesController = this.subject({ site });
+
+ reorderCategoriesController.reorder();
+
+ reorderCategoriesController.actions.moveDown.call(
+ reorderCategoriesController,
+ elem1
+ );
+
+ assert.deepEqual(
+ reorderCategoriesController.get("categoriesOrdered").mapBy("slug"),
+ ["bar", "foo", "foochild", "foochildchild", "test"]
+ );
+});
diff --git a/test/javascripts/controllers/topic-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/topic-test.js
similarity index 88%
rename from test/javascripts/controllers/topic-test.js
rename to app/assets/javascripts/discourse/tests/unit/controllers/topic-test.js
index 197b6b11b0..d552ef1f7b 100644
--- a/test/javascripts/controllers/topic-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/topic-test.js
@@ -1,10 +1,12 @@
+import { moduleFor } from "ember-qunit";
+import { test } from "qunit";
import EmberObject from "@ember/object";
import { next } from "@ember/runloop";
import Topic from "discourse/models/topic";
import { Placeholder } from "discourse/lib/posts-with-placeholders";
import User from "discourse/models/user";
import { Promise } from "rsvp";
-import pretender from "helpers/create-pretender";
+import pretender from "discourse/tests/helpers/create-pretender";
moduleFor("controller:topic", "controller:topic", {
needs: [
@@ -25,7 +27,7 @@ function topicWithStream(streamDetails) {
return topic;
}
-QUnit.test("editTopic", function (assert) {
+test("editTopic", function (assert) {
const model = Topic.create();
const controller = this.subject({ model });
@@ -60,7 +62,7 @@ QUnit.test("editTopic", function (assert) {
);
});
-QUnit.test("toggleMultiSelect", function (assert) {
+test("toggleMultiSelect", function (assert) {
const model = Topic.create();
const controller = this.subject({ model });
@@ -100,7 +102,7 @@ QUnit.test("toggleMultiSelect", function (assert) {
);
});
-QUnit.test("selectedPosts", function (assert) {
+test("selectedPosts", function (assert) {
let model = topicWithStream({ posts: [{ id: 1 }, { id: 2 }, { id: 3 }] });
const controller = this.subject({ model });
@@ -117,7 +119,7 @@ QUnit.test("selectedPosts", function (assert) {
);
});
-QUnit.test("selectedAllPosts", function (assert) {
+test("selectedAllPosts", function (assert) {
let model = topicWithStream({ stream: [1, 2, 3] });
const controller = this.subject({ model });
@@ -147,7 +149,7 @@ QUnit.test("selectedAllPosts", function (assert) {
);
});
-QUnit.test("selectedPostsUsername", function (assert) {
+test("selectedPostsUsername", function (assert) {
let model = topicWithStream({
posts: [
{ id: 1, username: "gary" },
@@ -198,7 +200,7 @@ QUnit.test("selectedPostsUsername", function (assert) {
);
});
-QUnit.test("showSelectedPostsAtBottom", function (assert) {
+test("showSelectedPostsAtBottom", function (assert) {
const site = EmberObject.create({ mobileView: false });
const model = Topic.create({ posts_count: 3 });
const controller = this.subject({ model, site });
@@ -220,7 +222,7 @@ QUnit.test("showSelectedPostsAtBottom", function (assert) {
);
});
-QUnit.test("canDeleteSelected", function (assert) {
+test("canDeleteSelected", function (assert) {
const currentUser = User.create({ admin: false });
this.registry.register("current-user:main", currentUser, {
instantiate: false,
@@ -271,7 +273,7 @@ QUnit.test("canDeleteSelected", function (assert) {
);
});
-QUnit.test("Can split/merge topic", function (assert) {
+test("Can split/merge topic", function (assert) {
let model = topicWithStream({
posts: [
{ id: 1, post_number: 1, post_type: 1 },
@@ -316,7 +318,7 @@ QUnit.test("Can split/merge topic", function (assert) {
);
});
-QUnit.test("canChangeOwner", function (assert) {
+test("canChangeOwner", function (assert) {
const currentUser = User.create({ admin: false });
this.registry.register("current-user:main", currentUser, {
instantiate: false,
@@ -358,7 +360,7 @@ QUnit.test("canChangeOwner", function (assert) {
);
});
-QUnit.test("canMergePosts", function (assert) {
+test("canMergePosts", function (assert) {
let model = topicWithStream({
posts: [
{ id: 1, username: "gary", can_delete: true },
@@ -405,7 +407,7 @@ QUnit.test("canMergePosts", function (assert) {
);
});
-QUnit.test("Select/deselect all", function (assert) {
+test("Select/deselect all", function (assert) {
let model = topicWithStream({ stream: [1, 2, 3] });
const controller = this.subject({ model });
@@ -432,7 +434,7 @@ QUnit.test("Select/deselect all", function (assert) {
);
});
-QUnit.test("togglePostSelection", function (assert) {
+test("togglePostSelection", function (assert) {
const controller = this.subject();
const selectedPostIds = controller.get("selectedPostIds");
@@ -455,7 +457,7 @@ QUnit.test("togglePostSelection", function (assert) {
);
});
-// QUnit.test("selectReplies", function(assert) {
+// test("selectReplies", function(assert) {
// const controller = this.subject();
// const selectedPostIds = controller.get("selectedPostIds");
//
@@ -468,7 +470,7 @@ QUnit.test("togglePostSelection", function (assert) {
// assert.equal(selectedPostIds[2], 100, "selected post #100");
// });
-QUnit.test("selectBelow", function (assert) {
+test("selectBelow", function (assert) {
const site = EmberObject.create({
post_types: { small_action: 3, whisper: 4 },
});
@@ -493,7 +495,7 @@ QUnit.test("selectBelow", function (assert) {
assert.equal(selectedPostIds[3], 8, "also selected 3rd post below post #3");
});
-QUnit.test("topVisibleChanged", function (assert) {
+test("topVisibleChanged", function (assert) {
let model = topicWithStream({
posts: [{ id: 1 }],
});
@@ -509,38 +511,35 @@ QUnit.test("topVisibleChanged", function (assert) {
);
});
-QUnit.test(
- "deletePost - no modal is shown if post does not have replies",
- function (assert) {
- pretender.get("/posts/2/reply-ids.json", () => {
- return [200, { "Content-Type": "application/json" }, []];
- });
+test("deletePost - no modal is shown if post does not have replies", function (assert) {
+ pretender.get("/posts/2/reply-ids.json", () => {
+ return [200, { "Content-Type": "application/json" }, []];
+ });
- let destroyed;
- const post = EmberObject.create({
- id: 2,
- post_number: 2,
- can_delete: true,
- reply_count: 3,
- destroy: () => {
- destroyed = true;
- return Promise.resolve();
- },
- });
+ let destroyed;
+ const post = EmberObject.create({
+ id: 2,
+ post_number: 2,
+ can_delete: true,
+ reply_count: 3,
+ destroy: () => {
+ destroyed = true;
+ return Promise.resolve();
+ },
+ });
- const currentUser = EmberObject.create({ moderator: true });
- let model = topicWithStream({
- stream: [2, 3, 4],
- posts: [post, { id: 3 }, { id: 4 }],
- });
- const controller = this.subject({ model, currentUser });
+ const currentUser = EmberObject.create({ moderator: true });
+ let model = topicWithStream({
+ stream: [2, 3, 4],
+ posts: [post, { id: 3 }, { id: 4 }],
+ });
+ const controller = this.subject({ model, currentUser });
- const done = assert.async();
- controller.send("deletePost", post);
+ const done = assert.async();
+ controller.send("deletePost", post);
- next(() => {
- assert.ok(destroyed, "post was destroyed");
- done();
- });
- }
-);
+ next(() => {
+ assert.ok(destroyed, "post was destroyed");
+ done();
+ });
+});
diff --git a/test/javascripts/ember/resolver-test.js b/app/assets/javascripts/discourse/tests/unit/ember/resolver-test.js
similarity index 53%
rename from test/javascripts/ember/resolver-test.js
rename to app/assets/javascripts/discourse/tests/unit/ember/resolver-test.js
index 62877d4dcc..771a1594ac 100644
--- a/test/javascripts/ember/resolver-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/ember/resolver-test.js
@@ -1,3 +1,4 @@
+import { test, module } from "qunit";
import { setResolverOption, buildResolver } from "discourse-common/resolver";
let originalTemplates;
@@ -17,7 +18,7 @@ function setTemplates(lookupTemplateStrings) {
const DiscourseResolver = buildResolver("discourse");
-QUnit.module("lib:resolver", {
+module("lib:resolver", {
beforeEach() {
originalTemplates = Ember.TEMPLATES;
Ember.TEMPLATES = {};
@@ -30,7 +31,7 @@ QUnit.module("lib:resolver", {
},
});
-QUnit.test("finds templates in top level dir", (assert) => {
+test("finds templates in top level dir", (assert) => {
setTemplates(["foobar", "fooBar", "foo_bar", "foo.bar"]);
lookupTemplate(assert, "template:foobar", "foobar", "by lowcased name");
@@ -39,7 +40,7 @@ QUnit.test("finds templates in top level dir", (assert) => {
lookupTemplate(assert, "template:foo.bar", "foo.bar", "by dotted name");
});
-QUnit.test("finds templates in first-level subdir", (assert) => {
+test("finds templates in first-level subdir", (assert) => {
setTemplates(["foo/bar_baz"]);
lookupTemplate(
@@ -68,33 +69,30 @@ QUnit.test("finds templates in first-level subdir", (assert) => {
);
});
-QUnit.test(
- "resolves precedence between overlapping top level dir and first level subdir templates",
- (assert) => {
- setTemplates(["fooBar", "foo_bar", "foo.bar", "foo/bar"]);
+test("resolves precedence between overlapping top level dir and first level subdir templates", (assert) => {
+ setTemplates(["fooBar", "foo_bar", "foo.bar", "foo/bar"]);
- lookupTemplate(
- assert,
- "template:foo.bar",
- "foo/bar",
- "preferring first level subdir for dotted name"
- );
- lookupTemplate(
- assert,
- "template:fooBar",
- "fooBar",
- "preferring top level dir for camel cased name"
- );
- lookupTemplate(
- assert,
- "template:foo_bar",
- "foo_bar",
- "preferring top level dir for underscored name"
- );
- }
-);
+ lookupTemplate(
+ assert,
+ "template:foo.bar",
+ "foo/bar",
+ "preferring first level subdir for dotted name"
+ );
+ lookupTemplate(
+ assert,
+ "template:fooBar",
+ "fooBar",
+ "preferring top level dir for camel cased name"
+ );
+ lookupTemplate(
+ assert,
+ "template:foo_bar",
+ "foo_bar",
+ "preferring top level dir for underscored name"
+ );
+});
-QUnit.test("finds templates in subdir deeper than one level", (assert) => {
+test("finds templates in subdir deeper than one level", (assert) => {
setTemplates(["foo/bar/baz/qux"]);
lookupTemplate(
@@ -148,7 +146,7 @@ QUnit.test("finds templates in subdir deeper than one level", (assert) => {
);
});
-QUnit.test("resolves mobile templates to 'mobile/' namespace", (assert) => {
+test("resolves mobile templates to 'mobile/' namespace", (assert) => {
setTemplates(["mobile/foo", "bar", "mobile/bar", "baz"]);
setResolverOption("mobileView", true);
@@ -173,94 +171,85 @@ QUnit.test("resolves mobile templates to 'mobile/' namespace", (assert) => {
);
});
-QUnit.test(
- "resolves plugin templates to 'javascripts/' namespace",
- (assert) => {
- setTemplates(["javascripts/foo", "bar", "javascripts/bar", "baz"]);
+test("resolves plugin templates to 'javascripts/' namespace", (assert) => {
+ setTemplates(["javascripts/foo", "bar", "javascripts/bar", "baz"]);
- lookupTemplate(
- assert,
- "template:foo",
- "javascripts/foo",
- "finding plugin version even if normal one is not present"
- );
- lookupTemplate(
- assert,
- "template:bar",
- "javascripts/bar",
- "preferring plugin version when both versions are present"
- );
- lookupTemplate(
- assert,
- "template:baz",
- "baz",
- "falling back to a normal version when plugin version is not present"
- );
- }
-);
+ lookupTemplate(
+ assert,
+ "template:foo",
+ "javascripts/foo",
+ "finding plugin version even if normal one is not present"
+ );
+ lookupTemplate(
+ assert,
+ "template:bar",
+ "javascripts/bar",
+ "preferring plugin version when both versions are present"
+ );
+ lookupTemplate(
+ assert,
+ "template:baz",
+ "baz",
+ "falling back to a normal version when plugin version is not present"
+ );
+});
-QUnit.test(
- "resolves templates with 'admin' prefix to 'admin/templates/' namespace",
- (assert) => {
- setTemplates([
- "admin/templates/foo",
- "adminBar",
- "admin_bar",
- "admin.bar",
- "admin/templates/bar",
- ]);
+test("resolves templates with 'admin' prefix to 'admin/templates/' namespace", (assert) => {
+ setTemplates([
+ "admin/templates/foo",
+ "adminBar",
+ "admin_bar",
+ "admin.bar",
+ "admin/templates/bar",
+ ]);
- lookupTemplate(
- assert,
- "template:adminFoo",
- "admin/templates/foo",
- "when prefix is separated by camel case"
- );
- lookupTemplate(
- assert,
- "template:admin_foo",
- "admin/templates/foo",
- "when prefix is separated by underscore"
- );
- lookupTemplate(
- assert,
- "template:admin.foo",
- "admin/templates/foo",
- "when prefix is separated by dot"
- );
+ lookupTemplate(
+ assert,
+ "template:adminFoo",
+ "admin/templates/foo",
+ "when prefix is separated by camel case"
+ );
+ lookupTemplate(
+ assert,
+ "template:admin_foo",
+ "admin/templates/foo",
+ "when prefix is separated by underscore"
+ );
+ lookupTemplate(
+ assert,
+ "template:admin.foo",
+ "admin/templates/foo",
+ "when prefix is separated by dot"
+ );
- lookupTemplate(
- assert,
- "template:adminfoo",
- undefined,
- "but not when prefix is not separated in any way"
- );
- lookupTemplate(
- assert,
- "template:adminBar",
- "adminBar",
- "but not when template with the exact camel cased name exists"
- );
- lookupTemplate(
- assert,
- "template:admin_bar",
- "admin_bar",
- "but not when template with the exact underscored name exists"
- );
- lookupTemplate(
- assert,
- "template:admin.bar",
- "admin.bar",
- "but not when template with the exact dotted name exists"
- );
- }
-);
+ lookupTemplate(
+ assert,
+ "template:adminfoo",
+ undefined,
+ "but not when prefix is not separated in any way"
+ );
+ lookupTemplate(
+ assert,
+ "template:adminBar",
+ "adminBar",
+ "but not when template with the exact camel cased name exists"
+ );
+ lookupTemplate(
+ assert,
+ "template:admin_bar",
+ "admin_bar",
+ "but not when template with the exact underscored name exists"
+ );
+ lookupTemplate(
+ assert,
+ "template:admin.bar",
+ "admin.bar",
+ "but not when template with the exact dotted name exists"
+ );
+});
-QUnit.test(
- "returns 'not_found' template when template name cannot be resolved",
- (assert) => {
- setTemplates(["not_found"]);
+test("returns 'not_found' template when template name cannot be resolved", (assert) => {
+ setTemplates(["not_found"]);
- lookupTemplate(assert, "template:foo/bar/baz", "not_found", "");
- }
-);
+ lookupTemplate(assert, "template:foo/bar/baz", "not_found", "");
+});
diff --git a/test/javascripts/lib/bbcode-test.js b/app/assets/javascripts/discourse/tests/unit/lib/bbcode-test.js
similarity index 68%
rename from test/javascripts/lib/bbcode-test.js
rename to app/assets/javascripts/discourse/tests/unit/lib/bbcode-test.js
index f8b7225335..41530ac39c 100644
--- a/test/javascripts/lib/bbcode-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/bbcode-test.js
@@ -1,8 +1,9 @@
+import { test, module } from "qunit";
import { parseBBCodeTag } from "pretty-text/engines/discourse-markdown/bbcode-block";
-QUnit.module("lib:pretty-text:bbcode");
+module("lib:pretty-text:bbcode");
-QUnit.test("block with multiple quoted attributes", (assert) => {
+test("block with multiple quoted attributes", (assert) => {
const parsed = parseBBCodeTag('[test one="foo" two="bar bar"]', 0, 30);
assert.equal(parsed.tag, "test");
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/bookmark-test.js b/app/assets/javascripts/discourse/tests/unit/lib/bookmark-test.js
new file mode 100644
index 0000000000..7f12fbcce9
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/unit/lib/bookmark-test.js
@@ -0,0 +1,46 @@
+import { test, module } from "qunit";
+import { formattedReminderTime } from "discourse/lib/bookmark";
+import { fakeTime } from "discourse/tests/helpers/qunit-helpers";
+
+module("lib:bookmark", {
+ beforeEach() {
+ fakeTime("2020-04-11 08:00:00", "Australia/Brisbane");
+ },
+
+ afterEach() {
+ sandbox.restore();
+ },
+});
+
+test("formattedReminderTime works when the reminder time is tomorrow", (assert) => {
+ let reminderAt = "2020-04-12 09:45:00";
+ let reminderAtDate = moment
+ .tz(reminderAt, "Australia/Brisbane")
+ .format("H:mm a");
+ assert.equal(
+ formattedReminderTime(reminderAt, "Australia/Brisbane"),
+ "tomorrow at " + reminderAtDate
+ );
+});
+
+test("formattedReminderTime works when the reminder time is today", (assert) => {
+ let reminderAt = "2020-04-11 09:45:00";
+ let reminderAtDate = moment
+ .tz(reminderAt, "Australia/Brisbane")
+ .format("H:mm a");
+ assert.equal(
+ formattedReminderTime(reminderAt, "Australia/Brisbane"),
+ "today at " + reminderAtDate
+ );
+});
+
+test("formattedReminderTime works when the reminder time is in the future", (assert) => {
+ let reminderAt = "2020-04-15 09:45:00";
+ let reminderAtDate = moment
+ .tz(reminderAt, "Australia/Brisbane")
+ .format("H:mm a");
+ assert.equal(
+ formattedReminderTime(reminderAt, "Australia/Brisbane"),
+ "at Apr 15, 2020 " + reminderAtDate
+ );
+});
diff --git a/test/javascripts/lib/break-string-test.js b/app/assets/javascripts/discourse/tests/unit/lib/break-string-test.js
similarity index 83%
rename from test/javascripts/lib/break-string-test.js
rename to app/assets/javascripts/discourse/tests/unit/lib/break-string-test.js
index 32bd03fb28..1a711d6c7d 100644
--- a/test/javascripts/lib/break-string-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/break-string-test.js
@@ -1,8 +1,9 @@
+import { test, module } from "qunit";
/* global BreakString:true */
-QUnit.module("lib:breakString", {});
+module("lib:breakString", {});
-QUnit.test("breakString", (assert) => {
+test("breakString", (assert) => {
var b = function (s, hint) {
return new BreakString(s).break(hint);
};
diff --git a/test/javascripts/lib/category-badge-test.js b/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js
similarity index 89%
rename from test/javascripts/lib/category-badge-test.js
rename to app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js
index 35dd231850..005d729e86 100644
--- a/test/javascripts/lib/category-badge-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js
@@ -1,16 +1,17 @@
-import createStore from "helpers/create-store";
-import { discourseModule } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import createStore from "discourse/tests/helpers/create-store";
+import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
import Site from "discourse/models/site";
discourseModule("lib:category-link");
import { categoryBadgeHTML } from "discourse/helpers/category-link";
-QUnit.test("categoryBadge without a category", (assert) => {
+test("categoryBadge without a category", (assert) => {
assert.blank(categoryBadgeHTML(), "it returns no HTML");
});
-QUnit.test("Regular categoryBadge", (assert) => {
+test("Regular categoryBadge", (assert) => {
const store = createStore();
const category = store.createRecord("category", {
name: "hello",
@@ -37,7 +38,7 @@ QUnit.test("Regular categoryBadge", (assert) => {
);
});
-QUnit.test("undefined color", (assert) => {
+test("undefined color", (assert) => {
const store = createStore();
const noColor = store.createRecord("category", { name: "hello", id: 123 });
const tag = $.parseHTML(categoryBadgeHTML(noColor))[0];
@@ -48,7 +49,7 @@ QUnit.test("undefined color", (assert) => {
);
});
-QUnit.test("topic count", (assert) => {
+test("topic count", (assert) => {
const store = createStore();
const category = store.createRecord("category", { name: "hello", id: 123 });
@@ -63,7 +64,7 @@ QUnit.test("topic count", (assert) => {
);
});
-QUnit.test("allowUncategorized", (assert) => {
+test("allowUncategorized", (assert) => {
const store = createStore();
const uncategorized = store.createRecord("category", {
name: "uncategorized",
@@ -85,7 +86,7 @@ QUnit.test("allowUncategorized", (assert) => {
);
});
-QUnit.test("category names are wrapped in dir-spans", function (assert) {
+test("category names are wrapped in dir-spans", function (assert) {
this.siteSettings.support_mixed_text_direction = true;
const store = createStore();
const rtlCategory = store.createRecord("category", {
@@ -110,7 +111,7 @@ QUnit.test("category names are wrapped in dir-spans", function (assert) {
assert.equal(dirSpan.dir, "ltr");
});
-QUnit.test("recursive", function (assert) {
+test("recursive", function (assert) {
const store = createStore();
const foo = store.createRecord("category", {
diff --git a/test/javascripts/lib/click-track-edit-history-test.js b/app/assets/javascripts/discourse/tests/unit/lib/click-track-edit-history-test.js
similarity index 79%
rename from test/javascripts/lib/click-track-edit-history-test.js
rename to app/assets/javascripts/discourse/tests/unit/lib/click-track-edit-history-test.js
index c0e10fabbd..c3f78758bc 100644
--- a/test/javascripts/lib/click-track-edit-history-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/click-track-edit-history-test.js
@@ -1,10 +1,11 @@
+import { module, skip } from "qunit";
import DiscourseURL from "discourse/lib/url";
import ClickTrack from "discourse/lib/click-track";
-import { fixture, logIn } from "helpers/qunit-helpers";
+import { fixture, logIn } from "discourse/tests/helpers/qunit-helpers";
import User from "discourse/models/user";
-import pretender from "helpers/create-pretender";
+import pretender from "discourse/tests/helpers/create-pretender";
-QUnit.module("lib:click-track-edit-history", {
+module("lib:click-track-edit-history", {
beforeEach() {
logIn();
@@ -58,7 +59,7 @@ function generateClickEventOn(selector) {
return $.Event("click", { currentTarget: fixture(selector).first() });
}
-QUnit.skip("tracks internal URLs", async (assert) => {
+skip("tracks internal URLs", async (assert) => {
assert.expect(2);
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
@@ -74,7 +75,7 @@ QUnit.skip("tracks internal URLs", async (assert) => {
assert.notOk(track(generateClickEventOn("#same-site")));
});
-QUnit.skip("tracks external URLs", async (assert) => {
+skip("tracks external URLs", async (assert) => {
assert.expect(2);
const done = assert.async();
@@ -89,22 +90,19 @@ QUnit.skip("tracks external URLs", async (assert) => {
assert.notOk(track(generateClickEventOn("a")));
});
-QUnit.skip(
- "tracks external URLs when opening in another window",
- async (assert) => {
- assert.expect(3);
- User.currentProp("external_links_in_new_tab", true);
+skip("tracks external URLs when opening in another window", async (assert) => {
+ assert.expect(3);
+ User.currentProp("external_links_in_new_tab", true);
- const done = assert.async();
- pretender.post("/clicks/track", (request) => {
- assert.equal(
- request.requestBody,
- "url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
- );
- done();
- });
+ const done = assert.async();
+ pretender.post("/clicks/track", (request) => {
+ assert.equal(
+ request.requestBody,
+ "url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
+ );
+ done();
+ });
- assert.notOk(track(generateClickEventOn("a")));
- assert.ok(window.open.calledWith("http://www.google.com", "_blank"));
- }
-);
+ assert.notOk(track(generateClickEventOn("a")));
+ assert.ok(window.open.calledWith("http://www.google.com", "_blank"));
+});
diff --git a/test/javascripts/lib/click-track-profile-page-test.js b/app/assets/javascripts/discourse/tests/unit/lib/click-track-profile-page-test.js
similarity index 89%
rename from test/javascripts/lib/click-track-profile-page-test.js
rename to app/assets/javascripts/discourse/tests/unit/lib/click-track-profile-page-test.js
index 84c0c437cd..28fe7faba8 100644
--- a/test/javascripts/lib/click-track-profile-page-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/click-track-profile-page-test.js
@@ -1,9 +1,10 @@
+import { module, skip } from "qunit";
import DiscourseURL from "discourse/lib/url";
import ClickTrack from "discourse/lib/click-track";
-import { fixture, logIn } from "helpers/qunit-helpers";
-import pretender from "helpers/create-pretender";
+import { fixture, logIn } from "discourse/tests/helpers/qunit-helpers";
+import pretender from "discourse/tests/helpers/create-pretender";
-QUnit.module("lib:click-track-profile-page", {
+module("lib:click-track-profile-page", {
beforeEach() {
logIn();
@@ -51,7 +52,7 @@ function generateClickEventOn(selector) {
return $.Event("click", { currentTarget: fixture(selector).first() });
}
-QUnit.skip("tracks internal URLs", async (assert) => {
+skip("tracks internal URLs", async (assert) => {
assert.expect(2);
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
@@ -64,7 +65,7 @@ QUnit.skip("tracks internal URLs", async (assert) => {
assert.notOk(track(generateClickEventOn("#same-site")));
});
-QUnit.skip("tracks external URLs", async (assert) => {
+skip("tracks external URLs", async (assert) => {
assert.expect(2);
const done = assert.async();
@@ -79,7 +80,7 @@ QUnit.skip("tracks external URLs", async (assert) => {
assert.notOk(track(generateClickEventOn("a")));
});
-QUnit.skip("tracks external URLs in other posts", async (assert) => {
+skip("tracks external URLs in other posts", async (assert) => {
assert.expect(2);
const done = assert.async();
diff --git a/test/javascripts/lib/click-track-test.js b/app/assets/javascripts/discourse/tests/unit/lib/click-track-test.js
similarity index 70%
rename from test/javascripts/lib/click-track-test.js
rename to app/assets/javascripts/discourse/tests/unit/lib/click-track-test.js
index 55d29ee425..0528478fc9 100644
--- a/test/javascripts/lib/click-track-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/click-track-test.js
@@ -1,11 +1,13 @@
+import { skip } from "qunit";
+import { test, module } from "qunit";
import { later } from "@ember/runloop";
import DiscourseURL from "discourse/lib/url";
import ClickTrack from "discourse/lib/click-track";
-import { fixture, logIn } from "helpers/qunit-helpers";
+import { fixture, logIn } from "discourse/tests/helpers/qunit-helpers";
import User from "discourse/models/user";
-import pretender from "helpers/create-pretender";
+import pretender from "discourse/tests/helpers/create-pretender";
-QUnit.module("lib:click-track", {
+module("lib:click-track", {
beforeEach() {
logIn();
@@ -51,7 +53,7 @@ function generateClickEventOn(selector) {
return $.Event("click", { currentTarget: fixture(selector).first() });
}
-QUnit.skip("tracks internal URLs", async (assert) => {
+skip("tracks internal URLs", async (assert) => {
assert.expect(2);
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
@@ -67,11 +69,11 @@ QUnit.skip("tracks internal URLs", async (assert) => {
assert.notOk(track(generateClickEventOn("#same-site")));
});
-QUnit.test("does not track elements with no href", async (assert) => {
+test("does not track elements with no href", async (assert) => {
assert.ok(track(generateClickEventOn(".a-without-href")));
});
-QUnit.test("does not track attachments", async (assert) => {
+test("does not track attachments", async (assert) => {
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
pretender.post("/clicks/track", () => assert.ok(false));
@@ -84,7 +86,7 @@ QUnit.test("does not track attachments", async (assert) => {
);
});
-QUnit.skip("tracks external URLs", async (assert) => {
+skip("tracks external URLs", async (assert) => {
assert.expect(2);
const done = assert.async();
@@ -99,75 +101,69 @@ QUnit.skip("tracks external URLs", async (assert) => {
assert.notOk(track(generateClickEventOn("a")));
});
-QUnit.skip(
- "tracks external URLs when opening in another window",
- async (assert) => {
- assert.expect(3);
- User.currentProp("external_links_in_new_tab", true);
+skip("tracks external URLs when opening in another window", async (assert) => {
+ assert.expect(3);
+ User.currentProp("external_links_in_new_tab", true);
- const done = assert.async();
- pretender.post("/clicks/track", (request) => {
- assert.ok(
- request.requestBody,
- "url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
- );
- done();
- });
+ const done = assert.async();
+ pretender.post("/clicks/track", (request) => {
+ assert.ok(
+ request.requestBody,
+ "url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
+ );
+ done();
+ });
- assert.notOk(track(generateClickEventOn("a")));
- assert.ok(window.open.calledWith("http://www.google.com", "_blank"));
- }
-);
+ assert.notOk(track(generateClickEventOn("a")));
+ assert.ok(window.open.calledWith("http://www.google.com", "_blank"));
+});
-QUnit.test("does not track clicks on lightboxes", async (assert) => {
+test("does not track clicks on lightboxes", async (assert) => {
assert.notOk(track(generateClickEventOn(".lightbox")));
});
-QUnit.test("does not track clicks when forcibly disabled", async (assert) => {
+test("does not track clicks when forcibly disabled", async (assert) => {
assert.notOk(track(generateClickEventOn(".no-track-link")));
});
-QUnit.test("does not track clicks on back buttons", async (assert) => {
+test("does not track clicks on back buttons", async (assert) => {
assert.notOk(track(generateClickEventOn(".back")));
});
-QUnit.test("does not track right clicks inside quotes", async (assert) => {
+test("does not track right clicks inside quotes", async (assert) => {
const event = generateClickEventOn(".quote a:first-child");
event.which = 3;
assert.ok(track(event));
});
-QUnit.test("does not track clicks links in quotes", async (assert) => {
+test("does not track clicks links in quotes", async (assert) => {
User.currentProp("external_links_in_new_tab", true);
assert.notOk(track(generateClickEventOn(".quote a:last-child")));
assert.ok(window.open.calledWith("https://google.com/", "_blank"));
});
-QUnit.test("does not track clicks on category badges", async (assert) => {
+test("does not track clicks on category badges", async (assert) => {
assert.notOk(track(generateClickEventOn(".hashtag")));
});
-QUnit.test("does not track clicks on mailto", async (assert) => {
+test("does not track clicks on mailto", async (assert) => {
assert.ok(track(generateClickEventOn(".mailto")));
});
-QUnit.test(
- "removes the href and put it as a data attribute",
- async (assert) => {
- User.currentProp("external_links_in_new_tab", true);
+test("removes the href and put it as a data attribute", async (assert) => {
+ User.currentProp("external_links_in_new_tab", true);
- assert.notOk(track(generateClickEventOn("a")));
+ assert.notOk(track(generateClickEventOn("a")));
- var $link = fixture("a").first();
- assert.ok($link.hasClass("no-href"));
- assert.equal($link.data("href"), "http://www.google.com/");
- assert.blank($link.attr("href"));
- assert.ok($link.data("auto-route"));
- assert.ok(window.open.calledWith("http://www.google.com/", "_blank"));
- }
-);
+ var $link = fixture("a").first();
+ assert.ok($link.hasClass("no-href"));
+ assert.equal($link.data("href"), "http://www.google.com/");
+ assert.blank($link.attr("href"));
+ assert.ok($link.data("auto-route"));
+ assert.ok(window.open.calledWith("http://www.google.com/", "_blank"));
+});
-QUnit.test("restores the href after a while", async (assert) => {
+test("restores the href after a while", async (assert) => {
assert.expect(2);
assert.notOk(track(generateClickEventOn("a")));
@@ -187,24 +183,24 @@ function badgeClickCount(assert, id, expected) {
assert.equal(parseInt($badge.html(), 10), expected);
}
-QUnit.test("does not update badge clicks on my own link", async (assert) => {
+test("does not update badge clicks on my own link", async (assert) => {
sandbox.stub(User, "currentProp").withArgs("id").returns(314);
badgeClickCount(assert, "with-badge", 1);
});
-QUnit.test("does not update badge clicks in my own post", async (assert) => {
+test("does not update badge clicks in my own post", async (assert) => {
sandbox.stub(User, "currentProp").withArgs("id").returns(3141);
badgeClickCount(assert, "with-badge-but-not-mine", 1);
});
-QUnit.test("updates badge counts correctly", async (assert) => {
+test("updates badge counts correctly", async (assert) => {
badgeClickCount(assert, "inside-onebox", 1);
badgeClickCount(assert, "inside-onebox-forced", 2);
badgeClickCount(assert, "with-badge", 2);
});
function testOpenInANewTab(description, clickEventModifier) {
- QUnit.test(description, async (assert) => {
+ test(description, async (assert) => {
var clickEvent = generateClickEventOn("a");
clickEventModifier(clickEvent);
assert.ok(track(clickEvent));
diff --git a/test/javascripts/lib/computed-test.js b/app/assets/javascripts/discourse/tests/unit/lib/computed-test.js
similarity index 91%
rename from test/javascripts/lib/computed-test.js
rename to app/assets/javascripts/discourse/tests/unit/lib/computed-test.js
index 6bb386fdba..748b17969b 100644
--- a/test/javascripts/lib/computed-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/computed-test.js
@@ -1,3 +1,4 @@
+import { test } from "qunit";
import I18n from "I18n";
import EmberObject from "@ember/object";
import {
@@ -10,7 +11,7 @@ import {
htmlSafe,
} from "discourse/lib/computed";
import { setPrefix } from "discourse-common/lib/get-url";
-import { discourseModule } from "helpers/qunit-helpers";
+import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
discourseModule("lib:computed", {
beforeEach() {
@@ -24,7 +25,7 @@ discourseModule("lib:computed", {
},
});
-QUnit.test("setting", function (assert) {
+test("setting", function (assert) {
let t = EmberObject.extend({
siteSettings: this.siteSettings,
vehicle: setting("vehicle"),
@@ -43,7 +44,7 @@ QUnit.test("setting", function (assert) {
);
});
-QUnit.test("propertyEqual", (assert) => {
+test("propertyEqual", (assert) => {
var t = EmberObject.extend({
same: propertyEqual("cookies", "biscuits"),
}).create({
@@ -56,7 +57,7 @@ QUnit.test("propertyEqual", (assert) => {
assert.ok(!t.get("same"), "it isn't true when one property is different");
});
-QUnit.test("propertyNotEqual", (assert) => {
+test("propertyNotEqual", (assert) => {
var t = EmberObject.extend({
diff: propertyNotEqual("cookies", "biscuits"),
}).create({
@@ -69,7 +70,7 @@ QUnit.test("propertyNotEqual", (assert) => {
assert.ok(t.get("diff"), "it is true when one property is different");
});
-QUnit.test("fmt", (assert) => {
+test("fmt", (assert) => {
var t = EmberObject.extend({
exclaimyUsername: fmt("username", "!!! %@ !!!"),
multiple: fmt("username", "mood", "%@ is %@"),
@@ -103,7 +104,7 @@ QUnit.test("fmt", (assert) => {
);
});
-QUnit.test("i18n", (assert) => {
+test("i18n", (assert) => {
var t = EmberObject.extend({
exclaimyUsername: i18n("username", "!!! %@ !!!"),
multiple: i18n("username", "mood", "%@ is %@"),
@@ -137,7 +138,7 @@ QUnit.test("i18n", (assert) => {
);
});
-QUnit.test("url", (assert) => {
+test("url", (assert) => {
var t, testClass;
testClass = EmberObject.extend({
@@ -160,7 +161,7 @@ QUnit.test("url", (assert) => {
);
});
-QUnit.test("htmlSafe", (assert) => {
+test("htmlSafe", (assert) => {
const cookies = "
cookies and biscuits
";
const t = EmberObject.extend({
desc: htmlSafe("cookies"),
diff --git a/test/javascripts/lib/emoji-store-test.js b/app/assets/javascripts/discourse/tests/unit/lib/emoji-store-test.js
similarity index 74%
rename from test/javascripts/lib/emoji-store-test.js
rename to app/assets/javascripts/discourse/tests/unit/lib/emoji-store-test.js
index 8068b2b506..adf9c0c22c 100644
--- a/test/javascripts/lib/emoji-store-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/emoji-store-test.js
@@ -1,4 +1,5 @@
-import { discourseModule } from "helpers/qunit-helpers";
+import { test } from "qunit";
+import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
discourseModule("lib:emoji-emojiStore", {
beforeEach() {
@@ -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/test/javascripts/lib/emoji-test.js b/app/assets/javascripts/discourse/tests/unit/lib/emoji-test.js
similarity index 58%
rename from test/javascripts/lib/emoji-test.js
rename to app/assets/javascripts/discourse/tests/unit/lib/emoji-test.js
index 3a3fed402b..b8490e22f1 100644
--- a/test/javascripts/lib/emoji-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/emoji-test.js
@@ -1,11 +1,12 @@
+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";
-import { discourseModule } from "helpers/qunit-helpers";
+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)) {
@@ -32,12 +33,12 @@ QUnit.test("emojiUnescape", function (assert) {
);
testUnescape(
"emoticons :)",
- `emoticons `,
+ `emoticons `,
"emoticons are still supported"
);
testUnescape(
"With emoji :O: :frog: :smile:",
- `With emoji `,
+ `With emoji `,
"title with emoji"
);
testUnescape(
@@ -47,27 +48,27 @@ QUnit.test("emojiUnescape", function (assert) {
);
testUnescape(
"(:frog:) :)",
- `() `,
+ `() `,
"non-word characters allowed next to emoji"
);
testUnescape(
":smile: hi",
- ` hi`,
+ ` hi`,
"start of line"
);
testUnescape(
"hi :smile:",
- `hi `,
+ `hi `,
"end of line"
);
testUnescape(
"hi :blonde_woman:t4:",
- `hi `,
+ `hi `,
"support for skin tones"
);
testUnescape(
"hi :blonde_woman:t4: :blonde_man:t6:",
- `hi `,
+ `hi `,
"support for multiple skin tones"
);
testUnescape(
@@ -95,7 +96,7 @@ QUnit.test("emojiUnescape", function (assert) {
);
testUnescape(
"Hello 😊 World",
- `Hello World`,
+ `Hello World`,
"emoji from Unicode emoji"
);
testUnescape(
@@ -108,7 +109,7 @@ QUnit.test("emojiUnescape", function (assert) {
);
testUnescape(
"Hello😊World",
- `HelloWorld`,
+ `HelloWorld`,
"emoji from Unicode emoji when inline translation enabled",
{
enable_inline_emoji_translation: true,
@@ -124,13 +125,13 @@ QUnit.test("emojiUnescape", function (assert) {
);
testUnescape(
"hi:smile:",
- `hi`,
+ `hi`,
"emoji when inline translation enabled",
{ enable_inline_emoji_translation: true }
);
});
-QUnit.test("Emoji search", (assert) => {
+test("Emoji search", (assert) => {
// able to find an alias
assert.equal(emojiSearch("+1").length, 1);
diff --git a/test/javascripts/lib/formatter-test.js b/app/assets/javascripts/discourse/tests/unit/lib/formatter-test.js
similarity index 95%
rename from test/javascripts/lib/formatter-test.js
rename to app/assets/javascripts/discourse/tests/unit/lib/formatter-test.js
index 14becfdcf6..15de4b568a 100644
--- a/test/javascripts/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,
@@ -6,7 +7,8 @@ import {
longDate,
durationTiny,
} from "discourse/lib/formatter";
-import { discourseModule } from "helpers/qunit-helpers";
+import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
+import sinon from "sinon";
discourseModule("lib:formatter", {
beforeEach() {
@@ -48,7 +50,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 +121,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 +184,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 +214,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 +232,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 +263,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/test/javascripts/lib/get-url-test.js b/app/assets/javascripts/discourse/tests/unit/lib/get-url-test.js
similarity index 87%
rename from test/javascripts/lib/get-url-test.js
rename to app/assets/javascripts/discourse/tests/unit/lib/get-url-test.js
index d11ee283e2..65506c85df 100644
--- a/test/javascripts/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/test/javascripts/lib/highlight-search-test.js.es6 b/app/assets/javascripts/discourse/tests/unit/lib/highlight-search-test.js
similarity index 79%
rename from test/javascripts/lib/highlight-search-test.js.es6
rename to app/assets/javascripts/discourse/tests/unit/lib/highlight-search-test.js
index 47c1ab3ed6..34958ade38 100644
--- a/test/javascripts/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 "helpers/qunit-helpers";
+import { fixture } from "discourse/tests/helpers/qunit-helpers";
+import { module, test } from "qunit";
-QUnit.module("lib:highlight-search");
+module("lib:highlight-search");
-QUnit.test("highlighting text", (assert) => {
+test("highlighting text", (assert) => {
fixture().html(
`