Skip to content

A platform for community discussion. Free, open, simple.

DEV: Fix no-loose-assertions lint (#29965)

Jarek Radoszef7518d4ad32
diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-emails-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-emails-test.js
index bdbfd74328f..157fda85b64 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/admin-emails-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-emails-test.js
@@ -1,7 +1,7 @@
import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit";
import pretender, { response } from "discourse/tests/helpers/create-pretender";
-import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
const EMAIL = `
From: "somebody" <[email protected]>
@@ -48,11 +48,10 @@ acceptance("Admin - Emails", function (needs) {
await fillIn(".admin-controls input", "[email protected]");
await click(".btn-primary");
- assert.ok(query("#dialog-holder").innerText.includes("some error"));
- assert.ok(
- query("#dialog-holder .dialog-body b"),
- "Error message can contain html"
- );
+ assert.dom("#dialog-holder").includesText("some error");
+ assert
+ .dom("#dialog-holder .dialog-body b")
+ .exists("Error message can contain html");
await click(".dialog-overlay");
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-install-theme-modal-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-install-theme-modal-test.js
index d84f3c1f59b..8c9c694b366 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/admin-install-theme-modal-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-install-theme-modal-test.js
@@ -5,6 +5,7 @@ import { i18n } from "discourse-i18n";
acceptance("Admin - Themes - Install modal", function (needs) {
needs.user();
+
test("closing the modal resets the modal inputs", async function (assert) {
const urlInput = ".install-theme-content .repo input";
const branchInput = ".install-theme-content .branch input";
@@ -24,7 +25,7 @@ acceptance("Admin - Themes - Install modal", function (needs) {
"tests-passed",
"branch input is filled"
);
- assert.ok(query(publicKey), "shows public key");
+ assert.dom(publicKey).exists("shows public key");
await click(".d-modal__footer .d-modal-cancel");
@@ -33,7 +34,7 @@ acceptance("Admin - Themes - Install modal", function (needs) {
await click(".install-theme-content .inputs .advanced-repo");
assert.dom(urlInput).hasValue("", "url input is reset");
assert.dom(branchInput).hasValue("", "branch input is reset");
- assert.notOk(query(publicKey), "hide public key");
+ assert.dom(publicKey).doesNotExist("hide public key");
});
test("show public key for valid ssh theme urls", async function (assert) {
@@ -50,34 +51,35 @@ acceptance("Admin - Themes - Install modal", function (needs) {
await fillIn(urlInput, themeUrl);
await click(".install-theme-content .inputs .advanced-repo");
assert.dom(urlInput).hasValue(themeUrl, "url input is filled");
- assert.ok(query(publicKey), "shows public key");
+ assert.dom(publicKey).exists("shows public key");
// Supports AWS CodeCommit style repo URLs
await fillIn(
urlInput,
"ssh://[email protected]/v1/repos/test-repo.git"
);
- assert.ok(query(publicKey), "shows public key");
+ assert.dom(publicKey).exists("shows public key");
await fillIn(urlInput, "https://github.com/discourse/discourse.git");
- assert.notOk(query(publicKey), "does not show public key for https urls");
+ assert
+ .dom(publicKey)
+ .doesNotExist("does not show public key for https urls");
await fillIn(urlInput, "[email protected]:discourse/discourse.git");
- assert.ok(query(publicKey), "shows public key for valid github repo url");
+ assert.dom(publicKey).exists("shows public key for valid github repo url");
await fillIn(urlInput, "[email protected]:discourse/discourse");
- assert.ok(query(publicKey), "shows public key for valid github repo url");
+ assert.dom(publicKey).exists("shows public key for valid github repo url");
await fillIn(urlInput, "[email protected]/discourse/discourse");
- assert.notOk(
- query(publicKey),
- "does not shows public key for valid github repo url"
- );
+ assert
+ .dom(publicKey)
+ .doesNotExist("does not shows public key for valid github repo url");
});
test("modal can be auto-opened with the right query params", async function (assert) {
await visit("/admin/customize/themes?repoUrl=testUrl&repoName=testName");
- assert.ok(query(".admin-install-theme-modal"), "modal is visible");
+ assert.dom(".admin-install-theme-modal").exists("modal is visible");
assert.strictEqual(
query(".install-theme code").textContent.trim(),
"testUrl",
@@ -96,12 +98,11 @@ acceptance("Admin - Themes - Install modal", function (needs) {
await visit("/admin/customize/themes");
await click(".create-actions .btn-primary");
- assert.notOk(
- query(
+ assert
+ .dom(
'.popular-theme-item[data-name="Graceful"] .popular-theme-buttons button'
- ),
- "no install button is shown for installed themes"
- );
+ )
+ .doesNotExist("no install button is shown for installed themes");
assert.strictEqual(
query(
'.popular-theme-item[data-name="Graceful"] .popular-theme-buttons'
@@ -109,11 +110,10 @@ acceptance("Admin - Themes - Install modal", function (needs) {
i18n("admin.customize.theme.installed")
);
- assert.ok(
- query(
+ assert
+ .dom(
'.popular-theme-item[data-name="Mint"] .popular-theme-buttons button'
- ),
- "install button is shown for not installed themes"
- );
+ )
+ .exists("install button is shown for not installed themes");
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-user-index-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-user-index-test.js
index d14648a65ab..e8c6c5992a6 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/admin-user-index-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-user-index-test.js
@@ -6,7 +6,7 @@ import selectKit from "discourse/tests/helpers/select-kit-helper";
import { i18n } from "discourse-i18n";
const { TOTP, BACKUP_CODE, SECURITY_KEY } = SECOND_FACTOR_METHODS;
-let deleteAndBlock = null;
+let deleteAndBlock;
acceptance("Admin - User Index", function (needs) {
needs.user();
@@ -129,11 +129,7 @@ acceptance("Admin - User Index", function (needs) {
server.delete("/admin/users/5.json", (request) => {
const data = helper.parsePostData(request.requestBody);
- if (data.block_email || data.block_ip || data.block_urls) {
- deleteAndBlock = true;
- } else {
- deleteAndBlock = false;
- }
+ deleteAndBlock = !!(data.block_email || data.block_ip || data.block_urls);
return helper.response({});
});
@@ -307,6 +303,6 @@ acceptance("Admin - User Index", function (needs) {
await click(".btn-user-delete");
await click(".dialog-footer .btn-danger");
- assert.ok(deleteAndBlock, "user does not get blocked");
+ assert.true(deleteAndBlock, "user does not get blocked");
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-users-list-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-users-list-test.js
index 0ea03ab3e02..244a6af6fff 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/admin-users-list-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-users-list-test.js
@@ -32,23 +32,17 @@ acceptance("Admin - Users List", function (needs) {
".users-list .directory-table__column-header--username.sortable"
);
- assert.ok(
- query(".users-list .user:nth-child(1) .username").innerText.includes(
- "eviltrout"
- ),
- "list should be sorted by username"
- );
+ assert
+ .dom(".users-list .user:nth-child(1) .username")
+ .includesText("eviltrout", "list should be sorted by username");
await click(
".users-list .directory-table__column-header--username.sortable"
);
- assert.ok(
- query(".users-list .user:nth-child(1) .username").innerText.includes(
- "discobot"
- ),
- "list should be sorted ascending by username"
- );
+ assert
+ .dom(".users-list .user:nth-child(1) .username")
+ .includesText("discobot", "list should be sorted ascending by username");
});
test("toggles email visibility", async function (assert) {
@@ -81,37 +75,29 @@ acceptance("Admin - Users List", function (needs) {
await visit("/admin/users/list/active");
assert.dom(".admin-title h2").hasText(activeTitle);
- assert.ok(
- query(".users-list .user:nth-child(1) .username").innerText.includes(
- activeUser
- )
- );
+ assert
+ .dom(".users-list .user:nth-child(1) .username")
+ .includesText(activeUser);
await click('a[href="/admin/users/list/new"]');
assert.dom(".admin-title h2").hasText(suspectTitle);
- assert.ok(
- query(".users-list .user:nth-child(1) .username").innerText.includes(
- suspectUser
- )
- );
+ assert
+ .dom(".users-list .user:nth-child(1) .username")
+ .includesText(suspectUser);
await click(".users-list .sortable:nth-child(4)");
assert.dom(".admin-title h2").hasText(suspectTitle);
- assert.ok(
- query(".users-list .user:nth-child(1) .username").innerText.includes(
- suspectUser
- )
- );
+ assert
+ .dom(".users-list .user:nth-child(1) .username")
+ .includesText(suspectUser);
await click('a[href="/admin/users/list/active"]');
assert.dom(".admin-title h2").hasText(activeTitle);
- assert.ok(
- query(".users-list .user:nth-child(1) .username").innerText.includes(
- activeUser
- )
- );
+ assert
+ .dom(".users-list .user:nth-child(1) .username")
+ .includesText(activeUser);
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/category-edit-security-test.js b/app/assets/javascripts/discourse/tests/acceptance/category-edit-security-test.js
index 73e171abeee..d7c20b65eea 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/category-edit-security-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/category-edit-security-test.js
@@ -35,7 +35,7 @@ acceptance("Category Edit - Security", function (needs) {
await click(".row-body .remove-permission");
await availableGroups.expand();
- assert.ok(
+ assert.true(
availableGroups.rowByValue("everyone").exists(),
"everyone has been removed and appears in the available groups"
);
diff --git a/app/assets/javascripts/discourse/tests/acceptance/category-edit-test.js b/app/assets/javascripts/discourse/tests/acceptance/category-edit-test.js
index 659df571f03..362dbe8b468 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/category-edit-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/category-edit-test.js
@@ -18,7 +18,7 @@ acceptance("Category Edit", function (needs) {
assert.strictEqual(
currentURL(),
"/c/bug/edit/general",
- "it jumps to the correct screen"
+ "jumps to the correct screen"
);
assert.dom(".category-breadcrumb .badge-category").hasText("bug");
@@ -35,7 +35,7 @@ acceptance("Category Edit", function (needs) {
assert.strictEqual(
currentURL(),
"/c/bug/edit/general",
- "it stays on the edit screen"
+ "stays on the edit screen"
);
await visit("/c/bug/edit/settings");
@@ -47,13 +47,13 @@ acceptance("Category Edit", function (needs) {
assert.strictEqual(
currentURL(),
"/c/bug/edit/settings",
- "it stays on the edit screen"
+ "stays on the edit screen"
);
sinon.stub(DiscourseURL, "routeTo");
await click(".edit-category-security a");
- assert.ok(
+ assert.true(
DiscourseURL.routeTo.calledWith("/c/bug/edit/security"),
"tab routing works"
);
@@ -141,8 +141,8 @@ acceptance("Category Edit", function (needs) {
await categoryChooser.expand();
const names = [...categoryChooser.rows()].map((row) => row.dataset.name);
- assert.ok(names.includes("(no category)"));
- assert.notOk(names.includes("Uncategorized"));
+ assert.true(names.includes("(no category)"));
+ assert.false(names.includes("Uncategorized"));
});
test("Editing parent category (enabled Uncategorized)", async function (assert) {
@@ -156,8 +156,8 @@ acceptance("Category Edit", function (needs) {
await categoryChooser.expand();
const names = [...categoryChooser.rows()].map((row) => row.dataset.name);
- assert.ok(names.includes("(no category)"));
- assert.notOk(names.includes("Uncategorized"));
+ assert.true(names.includes("(no category)"));
+ assert.false(names.includes("Uncategorized"));
});
test("Index Route", async function (assert) {
@@ -165,7 +165,7 @@ acceptance("Category Edit", function (needs) {
assert.strictEqual(
currentURL(),
"/c/bug/edit/general",
- "it redirects to the general tab"
+ "redirects to the general tab"
);
});
@@ -174,7 +174,7 @@ acceptance("Category Edit", function (needs) {
assert.strictEqual(
currentURL(),
"/c/1-category/edit/general",
- "it goes to the general tab"
+ "goes to the general tab"
);
assert.dom("input.category-name").hasValue("bug");
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/category-new-test.js b/app/assets/javascripts/discourse/tests/acceptance/category-new-test.js
index 03d66f1e3f9..485da5474a0 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/category-new-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/category-new-test.js
@@ -92,7 +92,7 @@ acceptance("Category New", function (needs) {
sinon.stub(DiscourseURL, "routeTo");
await click(".category-back");
- assert.ok(
+ assert.true(
DiscourseURL.routeTo.calledWith("/c/testing/11"),
"back routing works"
);
diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js
index 2b3ee3531c1..9f851dbd66b 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js
@@ -128,7 +128,7 @@ acceptance("Composer Actions", function (needs) {
assert.strictEqual(categoryChooserReplyArea.header().name(), "faq");
assert.dom(".action-title").hasText(i18n("topic.create_long"));
- assert.ok(query(".d-editor-input").value.includes(quote));
+ assert.true(query(".d-editor-input").value.includes(quote));
});
test("reply_as_new_topic without a new_topic draft", async function (assert) {
@@ -211,7 +211,7 @@ acceptance("Composer Actions", function (needs) {
await composerActions.expand();
assert.dom(".action-title").hasText(i18n("topic.create_long"));
- assert.ok(query(".d-editor-input").value.includes(quote));
+ assert.true(query(".d-editor-input").value.includes(quote));
assert.strictEqual(composerActions.rowByIndex(0).value(), "reply_to_post");
assert.strictEqual(composerActions.rowByIndex(1).value(), "reply_to_topic");
assert.strictEqual(composerActions.rowByIndex(2).value(), "shared_draft");
@@ -437,7 +437,7 @@ acceptance("Composer Actions With New Topic Draft", function (needs) {
.hasText(i18n("composer.composer_actions.reply_as_new_topic.confirm"));
await click(".dialog-footer .btn-primary");
- assert.ok(
+ assert.true(
query(".d-editor-input").value.startsWith(
"Continuing the discussion from"
)
diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-image-grid-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-image-grid-test.js
index fbcbd38a30b..64d7b6fd684 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/composer-image-grid-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-image-grid-test.js
@@ -73,12 +73,13 @@ and a second group of images
);
// Second group of images is in paragraph 2
- assert.ok(
- query(
- ".d-editor-preview p:nth-child(2) .wrap-image-grid-button[data-image-count='3']"
- ),
- "Grid button has correct image count"
- );
+ assert
+ .dom(".d-editor-preview p:nth-child(2) .wrap-image-grid-button")
+ .hasAttribute(
+ "data-image-count",
+ "3",
+ "Grid button has correct image count"
+ );
await click(".d-editor-preview p:nth-child(2) .wrap-image-grid-button");
@@ -107,12 +108,13 @@ and a second group of images
await click("#create-topic");
await fillIn(".d-editor-input", uploads.join("\n"));
- assert.ok(
- query(
- ".image-wrapper:first-child .wrap-image-grid-button[data-image-count='2']"
- ),
- "Grid button has correct image count"
- );
+ assert
+ .dom(".image-wrapper:first-child .wrap-image-grid-button")
+ .hasAttribute(
+ "data-image-count",
+ "2",
+ "Grid button has correct image count"
+ );
await click(
".button-wrapper[data-image-index='0'] .wrap-image-grid-button"
@@ -127,10 +129,13 @@ and a second group of images
await fillIn(".d-editor-input", `[grid]\n${uploads[0]}\n[/grid]`);
- assert.ok(
- query(".d-editor-preview .d-image-grid[data-disabled]"),
- "Grid is disabled when there is only one image"
- );
+ assert
+ .dom(".d-editor-preview .d-image-grid")
+ .hasAttribute(
+ "data-disabled",
+ "true",
+ "Grid is disabled when there is only one image"
+ );
await fillIn(
".d-editor-input",
diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js
index 66afc1e72c1..d1dffe548b8 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js
@@ -175,10 +175,10 @@ acceptance("Composer", function (needs) {
await click("#reply-control button.create");
assert
.dom(".title-input .popup-tip.bad")
- .exists("it shows the empty title error");
+ .exists("shows the empty title error");
assert
.dom(".d-editor-textarea-wrapper .popup-tip.bad")
- .exists("it shows the empty body error");
+ .exists("shows the empty body error");
await fillIn("#reply-title", "this is my new topic title");
assert
@@ -215,7 +215,7 @@ acceptance("Composer", function (needs) {
assert.strictEqual(
query("#reply-control .d-editor-input").value.trim(),
`this is the *content* of a post**${example}**`,
- "it supports keyboard shortcuts"
+ "supports keyboard shortcuts"
);
await click("#reply-control a.cancel");
@@ -256,7 +256,7 @@ acceptance("Composer", function (needs) {
assert.strictEqual(
currentURL(),
"/t/internationalization-localization/280",
- "it transitions to the newly created topic URL"
+ "transitions to the newly created topic URL"
);
});
@@ -278,7 +278,7 @@ acceptance("Composer", function (needs) {
await fillIn(".d-editor-input", "enqueue this content please");
await click("#reply-control button.create");
assert.dom(".d-modal").exists("pops up a modal");
- assert.strictEqual(currentURL(), "/", "it doesn't change routes");
+ assert.strictEqual(currentURL(), "/", "doesn't change routes");
await click(".d-modal__footer button");
assert.dom(".d-modal").doesNotExist("the modal can be dismissed");
@@ -294,7 +294,7 @@ acceptance("Composer", function (needs) {
assert
.dom("#dialog-holder .dialog-body")
.hasText("This is a custom response");
- assert.strictEqual(currentURL(), "/", "it doesn't change routes");
+ assert.strictEqual(currentURL(), "/", "doesn't change routes");
await click(".dialog-footer .btn-primary");
assert.strictEqual(
@@ -417,22 +417,20 @@ acceptance("Composer", function (needs) {
await fillIn(".d-editor-input", "this is the content of the first reply");
await visit("/t/this-is-a-test-topic/9");
- assert.ok(
+ assert.true(
currentURL().startsWith("/t/this-is-a-test-topic/9"),
"moves to second topic"
);
await click("#topic-footer-buttons .btn.create");
assert
.dom(".discard-draft-modal.modal")
- .exists("it pops up the discard drafts modal");
+ .exists("pops up the discard drafts modal");
await click(".d-modal__footer button.keep-editing");
assert.dom(".discard-draft-modal.modal").doesNotExist("hides modal");
await click("#topic-footer-buttons .btn.create");
- assert
- .dom(".discard-draft-modal.modal")
- .exists("it pops up the modal again");
+ assert.dom(".discard-draft-modal.modal").exists("pops up the modal again");
await click(".d-modal__footer button.discard-draft");
@@ -484,13 +482,13 @@ acceptance("Composer", function (needs) {
assert
.dom(".topic-post:nth-of-type(1) .post-info.edits")
- .doesNotExist("it has no edits icon at first");
+ .doesNotExist("has no edits icon at first");
await click(".topic-post:nth-of-type(1) button.show-more-actions");
await click(".topic-post:nth-of-type(1) button.edit");
- assert.ok(
+ assert.true(
query(".d-editor-input").value.startsWith("Any plans to support"),
- "it populates the input with the post text"
+ "populates the input with the post text"
);
await fillIn(".d-editor-input", "This is the new text for the post");
@@ -499,19 +497,16 @@ acceptance("Composer", function (needs) {
assert.dom(".d-editor-input").doesNotExist("closes the composer");
assert
.dom(".topic-post:nth-of-type(1) .post-info.edits")
- .exists("it has the edits icon");
- assert.ok(
- query("#topic-title h1").innerText.includes(
- "This is the new text for the title"
- ),
- "it shows the new title"
- );
- assert.ok(
- query(".topic-post:nth-of-type(1) .cooked").innerText.includes(
- "This is the new text for the post"
- ),
- "it updates the post"
- );
+ .exists("has the edits icon");
+ assert
+ .dom("#topic-title h1")
+ .includesText(
+ "This is the new text for the title",
+ "shows the new title"
+ );
+ assert
+ .dom(".topic-post:nth-of-type(1) .cooked")
+ .includesText("This is the new text for the post", "updates the post");
});
test("Editing a post stages new content", async function (assert) {
@@ -544,14 +539,14 @@ acceptance("Composer", function (needs) {
await visit("/t/this-is-a-test-topic/9");
await click(".topic-post:nth-of-type(1) button.edit");
- assert.ok(
+ assert.true(
query(".d-editor-input").value.startsWith("This is the first post."),
- "it populates the input with the post text"
+ "populates the input with the post text"
);
await click(".topic-post:nth-of-type(2) button.edit");
- assert.ok(
+ assert.true(
query(".d-editor-input").value.startsWith("This is the second post."),
- "it populates the input with the post text"
+ "populates the input with the post text"
);
});
@@ -563,12 +558,12 @@ acceptance("Composer", function (needs) {
await click(".topic-post:nth-of-type(2) button.edit");
assert
.dom(".discard-draft-modal.modal")
- .exists("it pops up a confirmation dialog");
+ .exists("pops up a confirmation dialog");
await click(".d-modal__footer button.discard-draft");
- assert.ok(
+ assert.true(
query(".d-editor-input").value.startsWith("This is the second post."),
- "it populates the input with the post text"
+ "populates the input with the post text"
);
});
@@ -576,20 +571,16 @@ acceptance("Composer", function (needs) {
await visit("/t/this-is-a-test-topic/9");
await click(".topic-post:nth-of-type(1) button.edit");
- assert.ok(
+ assert.true(
query(".d-editor-input").value.startsWith("This is the first post."),
- "it populates the input with the post text"
+ "populates the input with the post text"
);
await click(".topic-post:nth-of-type(1) button.reply");
- assert.strictEqual(
- query(".d-editor-input").value,
- "",
- "it clears the input"
- );
+ assert.strictEqual(query(".d-editor-input").value, "", "clears the input");
await click(".topic-post:nth-of-type(1) button.edit");
- assert.ok(
+ assert.true(
query(".d-editor-input").value.startsWith("This is the first post."),
- "it populates the input with the post text"
+ "populates the input with the post text"
);
});
@@ -611,7 +602,7 @@ acceptance("Composer", function (needs) {
assert
.dom(".composer-actions svg.d-icon-far-eye-slash")
- .doesNotExist("it removes the whisper mode");
+ .doesNotExist("removes the whisper mode");
await menu.expand();
await menu.selectRowByName("toggle-whisper");
@@ -620,7 +611,7 @@ acceptance("Composer", function (needs) {
await menu.expand();
- assert.ok(
+ assert.true(
menu.rowByName("toggle-whisper").exists(),
"whisper toggling is still present when going fullscreen"
);
@@ -702,26 +693,23 @@ acceptance("Composer", function (needs) {
await click("#create-topic");
assert
.dom(".reply-details .whisper .d-icon-far-eye-slash")
- .doesNotExist("it should reset the state of the composer's model");
+ .doesNotExist("should reset the state of the composer's model");
await selectKit(".toolbar-popup-menu-options").expand();
await selectKit(".toolbar-popup-menu-options").selectRowByName(
"toggle-invisible"
);
- assert.ok(
- query(".reply-details .unlist").innerText.includes(
- i18n("composer.unlist")
- ),
- "it sets the topic to unlisted"
- );
+ assert
+ .dom(".reply-details .unlist")
+ .includesText(i18n("composer.unlist"), "sets the topic to unlisted");
await visit("/t/this-is-a-test-topic/9");
await click(".topic-post:nth-of-type(1) button.reply");
assert
.dom(".reply-details .whisper")
- .doesNotExist("it should reset the state of the composer's model");
+ .doesNotExist("should reset the state of the composer's model");
});
test("Composer can toggle whisper when switching from reply to whisper to reply to topic", async function (assert) {
@@ -760,7 +748,7 @@ acceptance("Composer", function (needs) {
await click(".topic-post:nth-of-type(2) button.edit");
assert
.dom(".discard-draft-modal.modal")
- .exists("it pops up a confirmation dialog");
+ .exists("pops up a confirmation dialog");
assert.dom(".d-modal__footer button.save-draft").doesNotExist();
assert
.dom(".d-modal__footer button.keep-editing")
@@ -769,9 +757,9 @@ acceptance("Composer", function (needs) {
"has keep editing button"
);
await click(".d-modal__footer button.discard-draft");
- assert.ok(
+ assert.true(
query(".d-editor-input").value.startsWith("This is the second post."),
- "it populates the input with the post text"
+ "populates the input with the post text"
);
});
@@ -786,7 +774,7 @@ acceptance("Composer", function (needs) {
assert
.dom(".discard-draft-modal.modal")
- .exists("it pops up a confirmation dialog");
+ .exists("pops up a confirmation dialog");
assert
.dom(".d-modal__footer button.save-draft")
.hasText(
@@ -803,7 +791,7 @@ acceptance("Composer", function (needs) {
assert.strictEqual(
query(".d-editor-input").value,
"",
- "it clears the composer input"
+ "clears the composer input"
);
});
@@ -848,7 +836,7 @@ acceptance("Composer", function (needs) {
assert.dom(".d-modal__body").doesNotExist("abandon popup shouldn't come");
- assert.ok(
+ assert.true(
query(".d-editor-input").value.includes(longText),
"entered text should still be there"
);
@@ -908,7 +896,7 @@ acceptance("Composer", function (needs) {
.hasAttribute(
"placeholder",
i18n("composer.reply_placeholder"),
- "it should not block because of missing category"
+ "should not block because of missing category"
);
});
@@ -1107,10 +1095,9 @@ acceptance("Composer - Error Extensibility", function (needs) {
await fillIn(".d-editor-input", "this is the *content* of a post");
await click("#reply-control button.create");
assert.dom(".dialog-body").exists("pops up an error message");
- assert.ok(
- query(".dialog-body").innerText.match(/PLUGIN_ABC ERROR/),
- "it contains the server side error text"
- );
+ assert
+ .dom(".dialog-body")
+ .hasText(/PLUGIN_ABC ERROR/, "contains the server side error text");
await click(".dialog-footer .btn-primary");
assert.dom(".dialog-body").doesNotExist("dismisses the error");
assert.dom(".d-editor-input").exists("the composer input is visible");
@@ -1317,11 +1304,11 @@ acceptance("Composer - current time", function (needs) {
shiftKey: true,
});
- const inputValue = query("#reply-control .d-editor-input").value.trim();
-
- assert.ok(
- inputValue.startsWith(`and the time now is: [date=${date}`),
- "it adds the current date"
+ assert.true(
+ query("#reply-control .d-editor-input")
+ .value.trim()
+ .startsWith(`and the time now is: [date=${date}`),
+ "adds the current date"
);
});
});
@@ -1364,7 +1351,7 @@ acceptance("composer buttons API", function (needs) {
Object.assign({ altKey: true }, metaModifier)
);
- assert.strictEqual(editor.value, "hello **the** world", "it adds the bold");
+ assert.strictEqual(editor.value, "hello **the** world", "adds the bold");
const dropdown = selectKit(".toolbar-popup-menu-options");
await dropdown.expand();
@@ -1376,14 +1363,14 @@ acceptance("composer buttons API", function (needs) {
"title",
i18n("some_title") +
` (${translateModKey(PLATFORM_KEY_MODIFIER + "+alt+b")})`,
- "it shows the title with shortcut"
+ "shows the title with shortcut"
);
assert
.dom(row)
.hasText(
i18n("some_label") +
` ${translateModKey(PLATFORM_KEY_MODIFIER + "+alt+b")}`,
- "it shows the label with shortcut"
+ "shows the label with shortcut"
);
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/d-lightbox-test.js b/app/assets/javascripts/discourse/tests/acceptance/d-lightbox-test.js
index 96082f0ebac..c695d9a246f 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/d-lightbox-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/d-lightbox-test.js
@@ -65,7 +65,7 @@ acceptance("Experimental Lightbox - site setting", function (needs) {
setupPretender(server, helper, singleLargeImageMarkup)
);
- test("it does not interfere with Magnific when enable_experimental_lightbox is disabled", async function (assert) {
+ test("does not interfere with Magnific when enable_experimental_lightbox is disabled", async function (assert) {
await visit("/t/internationalization-localization/280");
await click(SELECTORS.DEFAULT_ITEM_SELECTOR);
@@ -82,7 +82,7 @@ acceptance("Experimental Lightbox - layout single image", function (needs) {
setupPretender(server, helper, singleLargeImageMarkup)
);
- test("it shows the correct elements for a single-image lightbox", async function (assert) {
+ test("shows the correct elements for a single-image lightbox", async function (assert) {
await visit("/t/internationalization-localization/280");
await click(SELECTORS.DEFAULT_ITEM_SELECTOR);
@@ -137,7 +137,7 @@ acceptance("Experimental Lightbox - layout multiple images", function (needs) {
setupPretender(server, helper, multipleLargeImagesMarkup)
);
- test("it shows multiple image controls when there's more than one item", async function (assert) {
+ test("shows multiple image controls when there's more than one item", async function (assert) {
await visit("/t/internationalization-localization/280");
await click(SELECTORS.DEFAULT_ITEM_SELECTOR);
@@ -354,7 +354,7 @@ acceptance("Experimental Lightbox - interaction", function (needs) {
assert.dom(SELECTORS.LIGHTBOX_CONTENT).exists();
- assert.ok(
+ assert.true(
classListAddStub.calledWith("has-lightbox"),
"adds has-lightbox class to document element"
);
@@ -363,7 +363,7 @@ acceptance("Experimental Lightbox - interaction", function (needs) {
assert.dom(SELECTORS.LIGHTBOX_CONTENT).doesNotExist();
- assert.ok(
+ assert.true(
classListRemoveStub.calledWith("has-lightbox"),
"removes has-lightbox class from document element"
);
@@ -390,13 +390,13 @@ acceptance("Experimental Lightbox - interaction", function (needs) {
await click(SELECTORS.FULL_SCREEN_BUTTON);
assert.dom(SELECTORS.LIGHTBOX_CONTAINER).hasClass("is-fullscreen");
- assert.ok(requestFullscreenStub.calledOnce, "it calls requestFullscreen");
+ assert.true(requestFullscreenStub.calledOnce, "calls requestFullscreen");
await click(SELECTORS.FULL_SCREEN_BUTTON);
assert.dom(SELECTORS.LIGHTBOX_CONTENT).doesNotHaveClass("is-fullscreen");
- assert.ok(exitFullscreenStub.calledOnce, "it calls exitFullscreen");
+ assert.true(exitFullscreenStub.calledOnce, "calls exitFullscreen");
await click(SELECTORS.CLOSE_BUTTON);
@@ -418,7 +418,7 @@ acceptance("Experimental Lightbox - interaction", function (needs) {
// appends and clicks <a download="..." href="..."></a>
await click(SELECTORS.DOWNLOAD_BUTTON);
- assert.ok(clickStub.called, "The click method was called");
+ assert.true(clickStub.called, "The click method was called");
await click(SELECTORS.CLOSE_BUTTON);
assert.dom(SELECTORS.LIGHTBOX_CONTENT).doesNotExist();
@@ -437,7 +437,7 @@ acceptance("Experimental Lightbox - interaction", function (needs) {
await click(SELECTORS.TAB_BUTTON);
- assert.ok(openStub.called, "The open method was called");
+ assert.true(openStub.called, "The open method was called");
await click(SELECTORS.CLOSE_BUTTON);
@@ -899,7 +899,7 @@ acceptance("Experimental Lightbox - conditional buttons", function (needs) {
setupPretender(server, helper, singleSmallImageMarkup)
);
- test("it doesn't show the newtab and download buttons to anons if prevent_anons_from_downloading_files is enabled", async function (assert) {
+ test("doesn't show the newtab and download buttons to anons if prevent_anons_from_downloading_files is enabled", async function (assert) {
this.siteSettings.prevent_anons_from_downloading_files = true;
await visit("/t/internationalization-localization/280");
await click(SELECTORS.DEFAULT_ITEM_SELECTOR);
@@ -909,7 +909,7 @@ acceptance("Experimental Lightbox - conditional buttons", function (needs) {
assert.dom(SELECTORS.DOWNLOAD_BUTTON).doesNotExist();
});
- test("it doesn't show the zoom button if the image is smaller than the viewport", async function (assert) {
+ test("doesn't show the zoom button if the image is smaller than the viewport", async function (assert) {
await visit("/t/internationalization-localization/280");
await click(SELECTORS.DEFAULT_ITEM_SELECTOR);
diff --git a/app/assets/javascripts/discourse/tests/acceptance/globals-test.js b/app/assets/javascripts/discourse/tests/acceptance/globals-test.js
index c6449853766..1bb171cea7e 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/globals-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/globals-test.js
@@ -10,7 +10,11 @@ acceptance("Acceptance | Globals", function () {
test("Globals function as expected", async function (assert) {
await visit("/");
- assert.ok(window.Discourse, "window.Discourse is present");
+ assert.notStrictEqual(
+ window.Discourse,
+ undefined,
+ "window.Discourse is present"
+ );
assert.strictEqual(
window.Discourse,
diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js
index b330acb94ad..f5d504a2def 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-manage-email-settings-test.js
@@ -11,10 +11,9 @@ acceptance("Managing Group Email Settings - SMTP Disabled", function (needs) {
test("When SiteSetting.enable_smtp is false", async function (assert) {
await visit("/g/discourse/manage/email");
- assert.notOk(
- query(".user-secondary-navigation").innerText.includes("Email"),
- "email link is not shown in the sidebar"
- );
+ assert
+ .dom(".user-secondary-navigation")
+ .doesNotIncludeText("Email", "email link is not shown in the sidebar");
assert.strictEqual(
currentRouteName(),
"group.manage.profile",
@@ -31,10 +30,9 @@ acceptance(
test("When SiteSetting.enable_smtp is true but SiteSetting.enable_imap is false", async function (assert) {
await visit("/g/discourse/manage/email");
- assert.ok(
- query(".user-secondary-navigation").innerText.includes("Email"),
- "email link is shown in the sidebar"
- );
+ assert
+ .dom(".user-secondary-navigation")
+ .includesText("Email", "email link is shown in the sidebar");
assert.strictEqual(
currentRouteName(),
"group.manage.email",
@@ -68,10 +66,9 @@ acceptance(
test("enabling SMTP, testing, and saving", async function (assert) {
await visit("/g/discourse/manage/email");
- assert.ok(
- query(".user-secondary-navigation").innerText.includes("Email"),
- "email link is shown in the sidebar"
- );
+ assert
+ .dom(".user-secondary-navigation")
+ .includesText("Email", "email link is shown in the sidebar");
assert
.dom("#enable_imap")
.isDisabled("IMAP is disabled until SMTP settings are valid");
@@ -315,14 +312,13 @@ acceptance(
"imap mailbox is prefilled"
);
- const regex = /updated: (.*?) by eviltrout/;
assert.dom(".group-email-last-updated-details.for-imap").exists();
- assert.ok(
- regex.test(
- query(".group-email-last-updated-details.for-imap").innerText.trim()
- ),
- "shows last updated imap details"
- );
+ assert
+ .dom(".group-email-last-updated-details.for-imap")
+ .hasText(
+ "Last updated: Jun 16, 2021 by eviltrout",
+ "shows last updated imap details"
+ );
});
}
);
diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-requests-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-requests-test.js
index 274606ec4d9..b342f95683e 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/group-requests-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-requests-test.js
@@ -1,6 +1,6 @@
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
-import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Group Requests", function (needs) {
let requests;
@@ -86,50 +86,37 @@ acceptance("Group Requests", function (needs) {
await visit("/g/Macdonald/requests");
assert.dom(".group-members .group-member").exists({ count: 2 });
- assert.strictEqual(
- query(".group-members .directory-table__row:first-child .user-detail")
- .innerText.trim()
- .replace(/\s+/g, " "),
- "eviltrout Robin Ward"
- );
- assert.strictEqual(
- query(
+ assert
+ .dom(".group-members .directory-table__row:first-child .user-detail")
+ .hasText("eviltrout Robin Ward");
+ assert
+ .dom(
".group-members .directory-table__row:first-child .directory-table__cell:nth-child(3)"
- ).innerText.trim(),
- "Please accept my membership request."
- );
- assert.strictEqual(
- query(
- ".group-members .directory-table__row:first-child .btn-primary"
- ).innerText.trim(),
- "Accept"
- );
- assert.strictEqual(
- query(
- ".group-members .directory-table__row:first-child .btn-danger"
- ).innerText.trim(),
- "Deny"
- );
+ )
+ .includesText("Please accept my membership request.");
+ assert
+ .dom(".group-members .directory-table__row:first-child .btn-primary")
+ .hasText("Accept");
+ assert
+ .dom(".group-members .directory-table__row:first-child .btn-danger")
+ .hasText("Deny");
await click(
".group-members .directory-table__row:first-child .btn-primary"
);
- assert.ok(
- query(
+ assert
+ .dom(
".group-members .directory-table__row:first-child .directory-table__cell:nth-child(4)"
)
- .innerText.trim()
- .startsWith("accepted")
- );
+ .includesText("accepted");
assert.deepEqual(requests, [["19", "true"]]);
await click(".group-members .directory-table__row:last-child .btn-danger");
- assert.strictEqual(
- query(
+ assert
+ .dom(
".group-members .directory-table__row:last-child .directory-table__cell:nth-child(4)"
- ).innerText.trim(),
- "denied"
- );
+ )
+ .hasText("denied");
assert.deepEqual(requests, [
["19", "true"],
["20", undefined],
diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-test.js
index 341f6d7d8d6..52084bf4b14 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/group-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/group-test.js
@@ -25,7 +25,7 @@ acceptance("Group - Anonymous", function (needs) {
assert
.dom(".nav-pills li a[title='Messages']")
- .doesNotExist("it does not show group messages navigation link");
+ .doesNotExist("does not show group messages navigation link");
await click(".nav-pills li a[title='Activity']");
@@ -33,7 +33,7 @@ acceptance("Group - Anonymous", function (needs) {
await click(".activity-nav li a[href='/g/discourse/activity/topics']");
- assert.ok(query(".topic-list"), "it shows the topic list");
+ assert.dom(".topic-list").exists("shows the topic list");
assert.dom(".topic-list-item").exists({ count: 2 }, "lists stream items");
await click(".activity-nav li a[href='/g/discourse/activity/mentions']");
@@ -41,10 +41,10 @@ acceptance("Group - Anonymous", function (needs) {
assert.dom(".user-stream-item").exists("lists stream items");
assert
.dom(".nav-pills li a[title='Edit Group']")
- .doesNotExist("it should not show messages tab if user is not admin");
+ .doesNotExist("does not show messages tab if user is not admin");
assert
.dom(".nav-pills li a[title='Logs']")
- .doesNotExist("it should not show Logs tab if user is not admin");
+ .doesNotExist("does not show Logs tab if user is not admin");
assert.dom(".user-stream-item").exists("lists stream items");
const groupDropdown = selectKit(".group-dropdown");
@@ -66,7 +66,7 @@ acceptance("Group - Anonymous", function (needs) {
assert
.dom(".group-dropdown-filter")
- .doesNotExist("it should not display the default header");
+ .doesNotExist("does not display the default header");
});
test("Anonymous Viewing Automatic Group", async function (assert) {
@@ -74,7 +74,7 @@ acceptance("Group - Anonymous", function (needs) {
assert
.dom(".nav-pills li a[title='Manage']")
- .doesNotExist("it does not show group messages navigation link");
+ .doesNotExist("does not show group messages navigation link");
});
});
@@ -204,7 +204,7 @@ acceptance("Group - Authenticated", function (needs) {
assert.strictEqual(
privateMessageUsers.header().value(),
"discourse",
- "it prefills the group name"
+ "prefills the group name"
);
assert.dom(".add-warning").doesNotExist("groups can't receive warnings");
@@ -218,7 +218,7 @@ acceptance("Group - Authenticated", function (needs) {
.dom("span.empty-state-title")
.hasText(
i18n("no_group_messages_title"),
- "it should display the right text"
+ "should display the right text"
);
});
@@ -230,16 +230,15 @@ acceptance("Group - Authenticated", function (needs) {
.dom(".topic-list-item .link-top-line")
.hasText(
"This is a private message 1",
- "it should display the list of group topics"
+ "should display the list of group topics"
);
await click("#search-button");
await fillIn("#search-term", "something");
- assert.ok(
- query(".search-menu .btn.search-context"),
- "'in messages' toggle is active by default"
- );
+ assert
+ .dom(".search-menu .btn.search-context")
+ .exists("'in messages' toggle is active by default");
});
test("Admin Viewing Group", async function (assert) {
@@ -254,7 +253,7 @@ acceptance("Group - Authenticated", function (needs) {
.exists("displays show group message button");
assert
.dom(".group-info-name")
- .hasText("Awesome Team", "it should display the group name");
+ .hasText("Awesome Team", "should display the group name");
await click(".group-details-button button.btn-danger");
@@ -263,17 +262,20 @@ acceptance("Group - Authenticated", function (needs) {
i18n("admin.groups.delete_with_messages_confirm", {
count: 2,
}),
- "it should warn about orphan messages"
+ "should warn about orphan messages"
);
await click(".dialog-footer .btn-default");
await visit("/g/discourse/activity/posts");
- assert.ok(
- ".user-stream-item a.avatar-link[href='/u/awesomerobot']",
- "avatar link contains href (is tabbable)"
- );
+ assert
+ .dom(".user-stream-item a.avatar-link")
+ .hasAttribute(
+ "href",
+ "/u/awesomerobot",
+ "avatar link contains href (is tabbable)"
+ );
});
test("Moderator Viewing Group", async function (assert) {
@@ -287,7 +289,7 @@ acceptance("Group - Authenticated", function (needs) {
assert
.dom(".group-add-members-modal #set-owner")
- .exists("it allows moderators to set group owners");
+ .exists("allows moderators to set group owners");
await click(".group-add-members-modal .modal-close");
diff --git a/app/assets/javascripts/discourse/tests/acceptance/modal/login/login-with-email-and-no-social-logins-test.js b/app/assets/javascripts/discourse/tests/acceptance/modal/login/login-with-email-and-no-social-logins-test.js
index 30c4ce08ef1..ff0b9850773 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/modal/login/login-with-email-and-no-social-logins-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/modal/login/login-with-email-and-no-social-logins-test.js
@@ -1,12 +1,13 @@
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
-import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Login with email - no social logins", function (needs) {
needs.settings({ enable_local_logins_via_email: true });
needs.pretender((server, helper) => {
server.post("/u/email-login", () => helper.response({ success: "OK" }));
});
+
test("with login with email enabled", async function (assert) {
await visit("/");
await click("header .login-button");
@@ -18,6 +19,6 @@ acceptance("Login with email - no social logins", function (needs) {
await visit("/");
await click("header .login-button");
- assert.notOk(queryAll(".login-buttons").is(":visible"));
+ assert.dom(".login-buttons").doesNotExist();
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js b/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js
index 61f1a72622b..a5eb587ebcd 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js
@@ -100,7 +100,7 @@ acceptance("Password Reset", function (needs) {
await fillIn(".password-reset input", "perf3ctly5ecur3");
sinon.stub(DiscourseURL, "redirectTo");
await click(".password-reset form button[type='submit']");
- assert.ok(DiscourseURL.redirectTo.calledWith("/"), "form is gone");
+ assert.true(DiscourseURL.redirectTo.calledWith("/"), "form is gone");
});
test("Password Reset Page With Second Factor", async function (assert) {
@@ -133,7 +133,7 @@ acceptance("Password Reset", function (needs) {
sinon.stub(DiscourseURL, "redirectTo");
await click(".password-reset form button[type='submit']");
- assert.ok(
+ assert.true(
DiscourseURL.redirectTo.calledWith("/"),
"it redirects after submitting form"
);
diff --git a/app/assets/javascripts/discourse/tests/acceptance/personal-message-test.js b/app/assets/javascripts/discourse/tests/acceptance/personal-message-test.js
index 2b15249b503..7ed21c89e1a 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/personal-message-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/personal-message-test.js
@@ -33,7 +33,11 @@ acceptance("Personal Message", function (needs) {
await click(".archive-topic");
assert.strictEqual(currentURL(), "/u/eviltrout/messages");
- assert.notOk(getCachedTopicList(session), "topic list cached is cleared");
+ assert.strictEqual(
+ getCachedTopicList(session),
+ undefined,
+ "topic list cached is cleared"
+ );
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/plugin-keyboard-shortcut-test.js b/app/assets/javascripts/discourse/tests/acceptance/plugin-keyboard-shortcut-test.js
index 1e34ab41d94..63aa84667f8 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/plugin-keyboard-shortcut-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/plugin-keyboard-shortcut-test.js
@@ -20,10 +20,9 @@ acceptance("Plugin Keyboard Shortcuts - Logged In", function (needs) {
await visit("/t/this-is-a-test-topic/9");
await triggerKeyEvent(document, "keypress", "]".charCodeAt(0));
- assert.ok(
- document.querySelector("#added-element"),
- "the keyboard shortcut callback fires successfully"
- );
+ assert
+ .dom("#added-element", document.body)
+ .exists("the keyboard shortcut callback fires successfully");
});
});
@@ -37,7 +36,7 @@ acceptance("Plugin Keyboard Shortcuts - Anonymous", function () {
});
});
- assert.ok(
+ assert.true(
spy.calledWith("test-path", "]"),
"bindToPath is called due to options provided"
);
diff --git a/app/assets/javascripts/discourse/tests/acceptance/post-inline-mentions-test.js b/app/assets/javascripts/discourse/tests/acceptance/post-inline-mentions-test.js
index 09135e0c507..4e22b0fcb8f 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/post-inline-mentions-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/post-inline-mentions-test.js
@@ -55,7 +55,7 @@ acceptance("Post inline mentions", function (needs) {
const statusElement = query(
".topic-post .cooked .mention .user-status-message img"
);
- assert.ok(
+ assert.true(
statusElement.src.includes(status.emoji),
"status emoji is correct"
);
@@ -84,7 +84,7 @@ acceptance("Post inline mentions", function (needs) {
const statusElement = query(
".topic-post .cooked .mention .user-status-message img"
);
- assert.ok(
+ assert.true(
statusElement.src.includes(status.emoji),
"status emoji is correct"
);
@@ -117,7 +117,7 @@ acceptance("Post inline mentions", function (needs) {
const statusElement = query(
".topic-post .cooked .mention .user-status-message img"
);
- assert.ok(
+ assert.true(
statusElement.src.includes(newStatus.emoji),
"updated status emoji is correct"
);
@@ -169,16 +169,18 @@ acceptance("Post inline mentions – user status tooltip", function (needs) {
.exists("user status is shown");
await mouseMove(".user-status-message");
- const statusTooltip = document.querySelector(
- ".user-status-message-tooltip"
- );
- assert.ok(statusTooltip, "status tooltip is shown");
- assert.ok(
- statusTooltip.querySelector("img").src.includes(status.emoji),
+
+ assert
+ .dom(".user-status-message-tooltip")
+ .exists("status tooltip is shown");
+ assert.true(
+ document
+ .querySelector(".user-status-message-tooltip img")
+ .src.includes(status.emoji),
"emoji is correct"
);
assert
- .dom(".user-status-tooltip-description", statusTooltip)
+ .dom(".user-status-tooltip-description")
.hasText(status.description, "status description is correct");
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/review-test.js b/app/assets/javascripts/discourse/tests/acceptance/review-test.js
index 24a6d1e4338..2bc184bb323 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/review-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/review-test.js
@@ -219,8 +219,9 @@ acceptance("Review", function (needs) {
test("Reviewables can become stale", async function (assert) {
await visit("/review");
- const reviewable = query(`[data-reviewable-id="1234"]`);
- assert.notOk(reviewable.className.includes("reviewable-stale"));
+ assert
+ .dom("[data-reviewable-id='1234']")
+ .doesNotHaveClass("reviewable-stale");
assert.dom("[data-reviewable-id='1234'] .status .pending").exists();
assert.dom(".stale-help").doesNotExist();
@@ -231,10 +232,10 @@ acceptance("Review", function (needs) {
},
});
- assert.ok(reviewable.className.includes("reviewable-stale"));
+ assert.dom("[data-reviewable-id='1234']").hasClass("reviewable-stale");
assert.dom("[data-reviewable-id='1234'] .status .approved").exists();
assert.dom(".stale-help").exists();
- assert.ok(query(".stale-help").innerText.includes("foo"));
+ assert.dom(".stale-help").includesText("foo");
await visit("/");
await visit("/review"); // reload review
diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-test.js
index 6ea46b08fe6..63f0021084b 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/search-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/search-test.js
@@ -62,9 +62,7 @@ acceptance("Search - Anonymous", function (needs) {
await click("#search-button");
assert.dom("#search-term").exists("shows the search input");
- assert
- .dom(".show-advanced-search")
- .exists("it shows full page search button");
+ assert.dom(".show-advanced-search").exists("shows full page search button");
});
test("random quick tips", async function (assert) {
@@ -88,7 +86,7 @@ acceptance("Search - Anonymous", function (needs) {
assert.strictEqual(
query(".full-page-search").value,
"dev",
- "it goes to full search page and preserves the search term"
+ "goes to full search page and preserves the search term"
);
assert
@@ -273,7 +271,7 @@ acceptance("Search - Anonymous", function (needs) {
assert.strictEqual(
query(".full-page-search").value,
"proper topic:280",
- "it goes to full search page and preserves search term + context"
+ "goes to full search page and preserves search term + context"
);
assert
@@ -499,16 +497,16 @@ acceptance("Search - Authenticated", function (needs) {
await visit("/search?expanded=true");
await inSelector.expand();
- assert.ok(inSelector.rowByValue("first").exists());
- assert.ok(inSelector.rowByValue("pinned").exists());
- assert.ok(inSelector.rowByValue("wiki").exists());
- assert.ok(inSelector.rowByValue("images").exists());
+ assert.true(inSelector.rowByValue("first").exists());
+ assert.true(inSelector.rowByValue("pinned").exists());
+ assert.true(inSelector.rowByValue("wiki").exists());
+ assert.true(inSelector.rowByValue("images").exists());
- assert.ok(inSelector.rowByValue("unseen").exists());
- assert.ok(inSelector.rowByValue("posted").exists());
- assert.ok(inSelector.rowByValue("watching").exists());
- assert.ok(inSelector.rowByValue("tracking").exists());
- assert.ok(inSelector.rowByValue("bookmarks").exists());
+ assert.true(inSelector.rowByValue("unseen").exists());
+ assert.true(inSelector.rowByValue("posted").exists());
+ assert.true(inSelector.rowByValue("watching").exists());
+ assert.true(inSelector.rowByValue("tracking").exists());
+ assert.true(inSelector.rowByValue("bookmarks").exists());
assert.dom(".search-advanced-options .in-likes").exists();
assert.dom(".search-advanced-options .in-private").exists();
@@ -649,12 +647,12 @@ acceptance("Search - Authenticated", function (needs) {
await triggerKeyEvent(document.activeElement, "keyup", "ArrowDown");
await triggerKeyEvent(document.activeElement, "keydown", 65); // maps to lowercase a
- assert.ok(
+ assert.true(
query(".d-editor-input").value.includes("a link"),
"still has the original composer content"
);
- assert.ok(
+ assert.true(
query(".d-editor-input").value.includes(
searchFixtures["search/query"].topics[0].slug
),
@@ -1235,7 +1233,7 @@ acceptance("Search - assistant", function (needs) {
await click("#search-button");
assert
.dom(".btn.search-context")
- .exists("it shows the button when reinvoking search");
+ .exists("shows the button when reinvoking search");
await fillIn("#search-term", "emoji");
await query("input#search-term").focus();
diff --git a/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js
index 163ad0c6ebf..e3abb071ff8 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js
@@ -37,7 +37,7 @@ acceptance("Share and Invite modal", function (needs) {
.dom("#modal-alert.alert-warning")
.doesNotExist("it does not show the alert with restricted groups");
- assert.ok(
+ assert.true(
query("input.invite-link").value.includes(
"/t/internationalization-localization/280?u=eviltrout"
),
@@ -127,7 +127,7 @@ acceptance("Share url with badges disabled - desktop", function (needs) {
await visit("/t/internationalization-localization/280");
await click("#topic-footer-button-share-and-invite");
- assert.notOk(
+ assert.false(
query("input.invite-link").value.includes("?u=eviltrout"),
"it doesn't add the username param when badges are disabled"
);
@@ -148,7 +148,7 @@ acceptance("With username in share links disabled - desktop", function (needs) {
await visit("/t/internationalization-localization/280");
await click("#topic-footer-button-share-and-invite");
- assert.notOk(
+ assert.false(
query("input.invite-link").value.includes("?u=eviltrout"),
"it doesn't add the username param when username in share links are disabled"
);
diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-categories-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-categories-section-test.js
index 4002280122d..11558ba0e67 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-categories-section-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-categories-section-test.js
@@ -973,7 +973,7 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) {
await click(".btn-sidebar-toggle");
- assert.ok(
+ assert.true(
Object.keys(topicTrackingState.stateChangeCallbacks).length <
initialCallbackCount
);
diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js
index 412e1da7ce4..eb6a5784e1f 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js
@@ -1123,7 +1123,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
await click(".btn-sidebar-toggle");
- assert.ok(teardownCalled, "section link teardown callback was called");
+ assert.true(teardownCalled, "section link teardown callback was called");
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-tags-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-tags-section-test.js
index 5271c18261b..bb0e0421266 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-tags-section-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-tags-section-test.js
@@ -530,7 +530,7 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
await click(".btn-sidebar-toggle");
- assert.ok(
+ assert.true(
Object.keys(topicTrackingState.stateChangeCallbacks).length <
initialCallbackCount
);
diff --git a/app/assets/javascripts/discourse/tests/acceptance/tags-test.js b/app/assets/javascripts/discourse/tests/acceptance/tags-test.js
index a3bb2cb19f1..2290d90f44e 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/tags-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/tags-test.js
@@ -430,10 +430,9 @@ acceptance("Tag info", function (needs) {
await click("#show-tag-info");
assert.dom(".tag-info .tag-name").exists("show tag");
- assert.ok(
- query(".tag-info .tag-associations").innerText.includes("Gardening"),
- "show tag group names"
- );
+ assert
+ .dom(".tag-info .tag-associations")
+ .includesText("Gardening", "show tag group names");
assert
.dom(".tag-info .synonyms-list .tag-box")
.exists({ count: 2 }, "shows the synonyms");
@@ -478,21 +477,17 @@ acceptance("Tag info", function (needs) {
assert.strictEqual(
query("#edit-name").value,
"happy-monkey",
- "it displays original tag name"
+ "displays original tag name"
);
assert.strictEqual(
query("#edit-description").value,
"happy monkey description",
- "it displays original tag description"
+ "displays original tag description"
);
await fillIn("#edit-description", "new description");
await click(".submit-edit");
- assert.strictEqual(
- currentURL(),
- "/tag/happy-monkey",
- "it doesn't change URL"
- );
+ assert.strictEqual(currentURL(), "/tag/happy-monkey", "doesn't change URL");
await click(".edit-tag");
await fillIn("#edit-name", "happy-monkey2");
@@ -500,7 +495,7 @@ acceptance("Tag info", function (needs) {
assert.strictEqual(
currentURL(),
"/tag/happy-monkey2",
- "it changes URL to new tag path"
+ "changes URL to new tag path"
);
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/themes-test.js b/app/assets/javascripts/discourse/tests/acceptance/themes-test.js
index 2970d0a9dfc..8ddc27ee275 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/themes-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/themes-test.js
@@ -1,6 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit";
-import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { i18n } from "discourse-i18n";
acceptance("Theme", function (needs) {
@@ -203,29 +203,28 @@ acceptance("Theme", function (needs) {
await visit("/admin/customize/themes");
await click(".themes-list-container__item .info");
- assert.ok(
- query(".control-unit .status-message").innerText.includes(
- i18n("admin.customize.theme.last_attempt")
- ),
- "it says that theme is not completely installed"
- );
+ assert
+ .dom(".control-unit .status-message")
+ .includesText(
+ i18n("admin.customize.theme.last_attempt"),
+ "says that theme is not completely installed"
+ );
await click(".control-unit .btn-primary.finish-install");
assert
.dom(".show-current-style .title span")
- .hasText("discourse-complete-theme", "it updates theme title");
+ .hasText("discourse-complete-theme", "updates theme title");
- assert.notOk(
- query(".metadata.control-unit").innerText.includes(
- i18n("admin.customize.theme.last_attempt")
- ),
- "it does not say that theme is not completely installed"
- );
+ assert
+ .dom(".metadata.control-unit")
+ .doesNotIncludeText(
+ i18n("admin.customize.theme.last_attempt"),
+ "does not say that theme is not completely installed"
+ );
- assert.notOk(
- query(".control-unit .btn-primary.finish-install"),
- "it does not show finish install button"
- );
+ assert
+ .dom(".control-unit .btn-primary.finish-install")
+ .doesNotExist("does not show finish install button");
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-admin-menu-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-admin-menu-test.js
index 26f5661cc69..45343c52c09 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/topic-admin-menu-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-admin-menu-test.js
@@ -69,6 +69,6 @@ acceptance("Topic - Admin Menu", function (needs) {
.dom(".extra-button .d-button-label")
.hasText(i18n("yes_value"), "The label was rendered");
await click(".extra-button");
- assert.ok(this.actionCalled, "The action was called");
+ assert.true(this.actionCalled, "The action was called");
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js
index e2fb66b51c5..cf4be445d81 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js
@@ -4,7 +4,6 @@ import topicFixtures from "discourse/tests/fixtures/topic";
import {
acceptance,
query,
- queryAll,
selectText,
} from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object";
@@ -46,10 +45,10 @@ acceptance("Topic - Quote button - logged in", function (needs) {
assert.dom(".quote-sharing").exists("shows the quote sharing options");
assert
.dom(`.quote-sharing .btn[title='${i18n("share.twitter")}']`)
- .exists("it includes the twitter share button");
+ .exists("includes the twitter share button");
assert
.dom(`.quote-sharing .btn[title='${i18n("share.email")}']`)
- .exists("it includes the email share button");
+ .exists("includes the email share button");
});
test("Quoting a Onebox should not copy the formatting of the rendered Onebox", async function (assert) {
@@ -82,7 +81,7 @@ acceptance("Closed Topic - Quote button - logged in", function (needs) {
assert.dom(".insert-quote").exists("shows the quote button");
await click(".insert-quote");
- assert.ok(
+ assert.true(
query(".d-editor-input")
.value.trim()
.startsWith("Continuing the discussion from"),
@@ -101,16 +100,14 @@ acceptance("Topic - Quote button - anonymous", function (needs) {
await visit("/t/internationalization-localization/280");
await selectText("#post_5 blockquote");
- assert.ok(queryAll(".quote-sharing"), "it shows the quote sharing options");
+ assert.dom(".quote-sharing").exists("shows the quote sharing options");
assert
.dom(`.quote-sharing .btn[title='${i18n("share.twitter")}']`)
- .exists("it includes the twitter share button");
+ .exists("includes the twitter share button");
assert
.dom(`.quote-sharing .btn[title='${i18n("share.email")}']`)
- .exists("it includes the email share button");
- assert
- .dom(".insert-quote")
- .doesNotExist("it does not show the quote button");
+ .exists("includes the email share button");
+ assert.dom(".insert-quote").doesNotExist("does not show the quote button");
});
test("Shows single share button when site setting only has one item", async function (assert) {
@@ -122,10 +119,10 @@ acceptance("Topic - Quote button - anonymous", function (needs) {
assert.dom(".quote-sharing").exists("shows the quote sharing options");
assert
.dom(`.quote-sharing .btn[title='${i18n("share.twitter")}']`)
- .exists("it includes the twitter share button");
+ .exists("includes the twitter share button");
assert
.dom(".quote-share-label")
- .doesNotExist("it does not show the Share label");
+ .doesNotExist("does not show the Share label");
});
test("Shows nothing when visibility is disabled", async function (assert) {
@@ -148,7 +145,7 @@ acceptance("Topic - Quote button - keyboard shortcut", function (needs) {
await triggerKeyEvent(document, "keypress", "Q");
assert.dom(".d-editor-input").exists("the editor is open");
- assert.ok(
+ assert.true(
query(".d-editor-input").value.includes("Any plans to support"),
"editor includes selected text"
);
diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-test.js
index 1ba6489d105..257340d0e16 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/topic-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-test.js
@@ -51,12 +51,12 @@ acceptance("Topic", function (needs) {
assert.strictEqual(
query(".d-editor-input").value.trim(),
`Continuing the discussion from [Internationalization / localization](${window.location.origin}/t/internationalization-localization/280):`,
- "it fills composer with the ring string"
+ "fills composer with the ring string"
);
assert.strictEqual(
selectKit(".category-chooser").header().value(),
"2",
- "it fills category selector with the right category"
+ "fills category selector with the right category"
);
});
@@ -70,14 +70,14 @@ acceptance("Topic", function (needs) {
assert.strictEqual(
query(".d-editor-input").value.trim(),
`Continuing the discussion from [PM for testing](${window.location.origin}/t/pm-for-testing/12):`,
- "it fills composer with the ring string"
+ "fills composer with the ring string"
);
const privateMessageUsers = selectKit("#private-message-users");
assert.strictEqual(
privateMessageUsers.header().value(),
"someguy,test,Group",
- "it fills up the composer correctly"
+ "fills up the composer correctly"
);
});
@@ -94,7 +94,7 @@ acceptance("Topic", function (needs) {
assert
.dom(".post-action-menu__copy-link-checkmark")
- .exists("it shows the Link Copied! message");
+ .exists("shows the Link Copied! message");
});
test("Showing and hiding the edit controls", async function (assert) {
@@ -125,10 +125,10 @@ acceptance("Topic", function (needs) {
assert
.dom("#topic-title .badge-category")
- .hasText("faq", "it displays the new category");
+ .hasText("faq", "displays the new category");
assert
.dom(".fancy-title")
- .hasText("this is the new title", "it displays the new title");
+ .hasText("this is the new title", "displays the new title");
});
test("Marking a topic as wiki", async function (assert) {
@@ -148,7 +148,7 @@ acceptance("Topic", function (needs) {
assert
.dom(".fancy-title")
- .hasText("PM for testing", "it routes to the right topic");
+ .hasText("PM for testing", "routes to the right topic");
await visit("/t/280/20");
@@ -156,7 +156,7 @@ acceptance("Topic", function (needs) {
.dom(".fancy-title")
.hasText(
"Internationalization / localization",
- "it routes to the right topic"
+ "routes to the right topic"
);
});
@@ -251,7 +251,7 @@ acceptance("Topic", function (needs) {
assert
.dom(".topic-post.user-suspended > #post_1")
- .exists("it has a class applied");
+ .exists("has a class applied");
});
});
@@ -319,9 +319,7 @@ acceptance("Topic featured links", function (needs) {
await click(".topic-admin-visible .btn");
await click(".toggle-admin-menu");
- assert
- .dom(".topic-admin-pin")
- .exists("it should show the multi select menu");
+ assert.dom(".topic-admin-pin").exists("should show the multi select menu");
});
test("selecting posts", async function (assert) {
@@ -331,11 +329,11 @@ acceptance("Topic featured links", function (needs) {
assert
.dom(".selected-posts:not(.hidden)")
- .exists("it should show the multi select menu");
+ .exists("should show the multi select menu");
assert
.dom(".select-all")
- .exists("it should allow users to select all the posts");
+ .exists("should allow users to select all the posts");
});
test("select below", async function (assert) {
@@ -373,7 +371,7 @@ acceptance("Topic featured links", function (needs) {
await selectText("#post_5 blockquote");
await click(".quote-button .insert-quote");
- assert.ok(
+ assert.true(
query(".d-editor-input").value.includes(
'quote="codinghorror said, post:3, topic:280"'
)
@@ -385,7 +383,7 @@ acceptance("Topic featured links", function (needs) {
await selectText("#post_9 blockquote");
await click(".quote-button .insert-quote");
- assert.ok(
+ assert.true(
query(".d-editor-input").value.includes(
'quote="A new topic with a link to another topic, post:3, topic:62"'
)
@@ -397,7 +395,7 @@ acceptance("Topic featured links", function (needs) {
await selectText("#post_5 blockquote");
await click(".reply");
- assert.ok(
+ assert.true(
query(".d-editor-input").value.includes(
'quote="codinghorror said, post:3, topic:280"'
)
@@ -413,7 +411,7 @@ acceptance("Topic featured links", function (needs) {
await triggerKeyEvent(document, "keypress", "J");
await triggerKeyEvent(document, "keypress", "T");
- assert.ok(
+ assert.true(
query(".d-editor-input").value.includes(
'quote="codinghorror said, post:3, topic:280"'
)
@@ -425,7 +423,7 @@ acceptance("Topic featured links", function (needs) {
await visit("/t/internationalization-localization/280");
await selectText("#post_5 .cooked");
await click(".quote-button .insert-quote");
- assert.ok(
+ assert.true(
query(".d-editor-input").value.includes(
'quote="pekka, post:5, topic:280, full:true"'
)
@@ -468,17 +466,16 @@ acceptance("Topic with title decorated", function (needs) {
test("Decorate topic title", async function (assert) {
await visit("/t/internationalization-localization/280");
- assert.ok(
- query(".fancy-title").innerText.endsWith("-280-topic-title"),
- "it decorates topic title"
- );
+ assert
+ .dom(".fancy-title")
+ .hasText(/-280-topic-title$/, "decorates topic title");
- assert.ok(
- query(".raw-topic-link:nth-child(1)").innerText.endsWith(
- "-27331-topic-list-item-title"
- ),
- "it decorates topic list item title"
- );
+ assert
+ .dom(".raw-topic-link:nth-child(1)")
+ .hasText(
+ /-27331-topic-list-item-title$/,
+ "decorates topic list item title"
+ );
});
});
@@ -493,11 +490,9 @@ acceptance("Topic pinning/unpinning as an admin", function (needs) {
assert
.dom(".feature-topic .btn-primary")
- .exists("it should show the 'Pin Topic' button");
+ .exists("should show the 'Pin Topic' button");
- assert
- .dom(".make-banner")
- .exists("it should show the 'Banner Topic' button");
+ assert.dom(".make-banner").exists("should show the 'Banner Topic' button");
});
});
@@ -512,11 +507,9 @@ acceptance("Topic pinning/unpinning as a staff member", function (needs) {
assert
.dom(".feature-topic .btn-primary")
- .exists("it should show the 'Pin Topic' button");
+ .exists("should show the 'Pin Topic' button");
- assert
- .dom(".make-banner")
- .exists("it should show the 'Banner Topic' button");
+ assert.dom(".make-banner").exists("should show the 'Banner Topic' button");
});
});
@@ -531,11 +524,11 @@ acceptance("Topic pinning/unpinning as a group moderator", function (needs) {
assert
.dom(".feature-topic .btn-primary")
- .exists("it should show the 'Pin Topic' button");
+ .exists("should show the 'Pin Topic' button");
assert
.dom(".make-banner")
- .doesNotExist("it should not show the 'Banner Topic' button");
+ .doesNotExist("should not show the 'Banner Topic' button");
});
});
@@ -605,26 +598,26 @@ acceptance("Navigating between topics", function (needs) {
test("clicking slug-less URLs within the same topic", async function (assert) {
await visit("/t/-/280");
await click("a.same-topic-slugless");
- assert.ok(currentURL().includes("/280"));
+ assert.true(currentURL().includes("/280"));
await click("a.same-topic-slugless-post");
- assert.ok(currentURL().includes("/280"));
+ assert.true(currentURL().includes("/280"));
});
test("clicking slug-less URLs to a different topic", async function (assert) {
await visit("/t/-/280");
await click("a.diff-topic-slugless");
- assert.ok(currentURL().includes("/28830"));
+ assert.true(currentURL().includes("/28830"));
await visit("/t/-/280");
await click("a.diff-topic-slugless-post");
- assert.ok(currentURL().includes("/28830"));
+ assert.true(currentURL().includes("/28830"));
});
test("clicking post URLs", async function (assert) {
await visit("/t/-/280");
await click("a.by-post-id");
- assert.ok(currentURL().includes("/280"));
+ assert.true(currentURL().includes("/280"));
});
});
@@ -646,10 +639,10 @@ acceptance("Topic stats update automatically", function () {
await publishToMessageBus("/topic/280", likesChangedFixture);
assert.dom(likesCountSelectors).hasText(expectedLikesCount);
- assert.notEqual(
+ assert.notStrictEqual(
oldLikesCount,
expectedLikesCount,
- "it updates the likes count on the topic stats"
+ "updates the likes count on the topic stats"
);
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-timeline-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-timeline-test.js
index 4fcda9c75a6..8f6feccaae9 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/topic-timeline-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-timeline-test.js
@@ -332,21 +332,21 @@ acceptance("Glimmer Topic Timeline", function (needs) {
});
});
- test("it has a topic admin menu", async function (assert) {
+ test("has a topic admin menu", async function (assert) {
await visit("/t/internationalization-localization");
assert
.dom(".timeline-controls .topic-admin-menu-button")
.exists("admin menu is present");
});
- test("it has a reply-to-post button", async function (assert) {
+ test("has a reply-to-post button", async function (assert) {
await visit("/t/internationalization-localization");
assert
.dom(".timeline-footer-controls .reply-to-post")
.exists("reply to post button is present");
});
- test("it has a topic notification button", async function (assert) {
+ test("has a topic notification button", async function (assert) {
await visit("/t/internationalization-localization");
assert
.dom(".timeline-footer-controls .topic-notifications-button")
@@ -381,7 +381,7 @@ acceptance("Glimmer Topic Timeline", function (needs) {
test("clicking the timeline padding updates the position", async function (assert) {
await visit("/t/internationalization-localization/280/2");
await click(".timeline-scrollarea .timeline-padding");
- assert.notOk(
+ assert.false(
currentURL().includes("/280/2"),
"The position of the currently viewed post has been updated from it's initial position"
);
diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-user-status-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-user-status-test.js
index 37a2df464a7..bbb952ffe09 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/topic-user-status-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-user-status-test.js
@@ -72,7 +72,7 @@ acceptance("Topic - User Status - live updates", function (needs) {
assert
.dom(".topic-post .user-status-message")
.exists({ count: 3 }, "all posts has user status");
- assert.ok(
+ assert.true(
query(".topic-post .user-status-message .emoji").src.includes(
status.emoji
),
@@ -85,7 +85,7 @@ acceptance("Topic - User Status - live updates", function (needs) {
assert
.dom(".topic-post .user-status-message")
.exists({ count: 3 }, "all posts has user status");
- assert.ok(
+ assert.true(
query(".topic-post .user-status-message .emoji").src.includes(
newStatus.emoji
),
@@ -100,7 +100,7 @@ acceptance("Topic - User Status - live updates", function (needs) {
assert
.dom(".topic-post .user-status-message")
.exists({ count: 3 }, "all posts has user status");
- assert.ok(
+ assert.true(
query(".topic-post .user-status-message .emoji").src.includes(
status.emoji
),
@@ -119,7 +119,7 @@ acceptance("Topic - User Status - live updates", function (needs) {
assert
.dom(".topic-post .user-status-message")
.exists({ count: 3 }, "all posts have user status");
- assert.ok(
+ assert.true(
query(".topic-post .user-status-message .emoji").src.includes(
newStatus.emoji
),
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js
index 21c8c7df503..eed128ca6ac 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js
@@ -444,7 +444,7 @@ acceptance("User menu", function (needs) {
await click("#user-menu-button-profile");
const summaryLink = query("#quick-access-profile ul li.summary a");
- assert.ok(
+ assert.true(
summaryLink.href.endsWith("/u/eviltrout/summary"),
"has a link to the summary page of the user"
);
@@ -453,13 +453,12 @@ acceptance("User menu", function (needs) {
i18n("user.summary.title"),
"summary link has the right label"
);
- assert.ok(
- summaryLink.querySelector(".d-icon-user"),
- "summary link has the right icon"
- );
+ assert
+ .dom(".d-icon-user", summaryLink)
+ .exists("summary link has the right icon");
const activityLink = query("#quick-access-profile ul li.activity a");
- assert.ok(
+ assert.true(
activityLink.href.endsWith("/u/eviltrout/activity"),
"has a link to the activity page of the user"
);
@@ -468,13 +467,12 @@ acceptance("User menu", function (needs) {
i18n("user.activity_stream"),
"activity link has the right label"
);
- assert.ok(
- activityLink.querySelector(".d-icon-bars-staggered"),
- "activity link has the right icon"
- );
+ assert
+ .dom(".d-icon-bars-staggered", activityLink)
+ .exists("activity link has the right icon");
const invitesLink = query("#quick-access-profile ul li.invites a");
- assert.ok(
+ assert.true(
invitesLink.href.endsWith("/u/eviltrout/invited"),
"has a link to the invites page of the user"
);
@@ -483,10 +481,9 @@ acceptance("User menu", function (needs) {
i18n("user.invited.title"),
"invites link has the right label"
);
- assert.ok(
- invitesLink.querySelector(".d-icon-user-plus"),
- "invites link has the right icon"
- );
+ assert
+ .dom(".d-icon-user-plus", invitesLink)
+ .exists("invites link has the right icon");
await clickOutside();
updateCurrentUser({ can_invite_to_forum: false });
@@ -499,7 +496,7 @@ acceptance("User menu", function (needs) {
.doesNotExist("invites link not shown when the user can't invite");
const draftsLink = query("#quick-access-profile ul li.drafts a");
- assert.ok(
+ assert.true(
draftsLink.href.endsWith("/u/eviltrout/activity/drafts"),
"has a link to the drafts page of the user"
);
@@ -508,13 +505,12 @@ acceptance("User menu", function (needs) {
i18n("drafts.label_with_count", { count: 13 }),
"drafts link has the right label with count of the user's drafts"
);
- assert.ok(
- draftsLink.querySelector(".d-icon-user_menu\\.drafts"),
- "drafts link has the right icon"
- );
+ assert
+ .dom(".d-icon-user_menu\\.drafts", draftsLink)
+ .exists("drafts link has the right icon");
const preferencesLink = query("#quick-access-profile ul li.preferences a");
- assert.ok(
+ assert.true(
preferencesLink.href.endsWith("/u/eviltrout/preferences"),
"has a link to the preferences page of the user"
);
@@ -523,10 +519,9 @@ acceptance("User menu", function (needs) {
i18n("user.preferences.title"),
"preferences link has the right label"
);
- assert.ok(
- preferencesLink.querySelector(".d-icon-gear"),
- "preferences link has the right icon"
- );
+ assert
+ .dom(".d-icon-gear", preferencesLink)
+ .exists("preferences link has the right icon");
let doNotDisturbButton = query(
"#quick-access-profile ul li.do-not-disturb .btn"
@@ -539,10 +534,9 @@ acceptance("User menu", function (needs) {
i18n("pause_notifications.label"),
"Do Not Disturb button has the right label"
);
- assert.ok(
- doNotDisturbButton.querySelector(".d-icon-toggle-off"),
- "Do Not Disturb button has the right icon"
- );
+ assert
+ .dom(".d-icon-toggle-off", doNotDisturbButton)
+ .exists("Do Not Disturb button has the right icon");
await clickOutside();
const date = new Date();
@@ -562,10 +556,11 @@ acceptance("User menu", function (needs) {
`${i18n("pause_notifications.label")} 2h`,
"Do Not Disturb button has the right label when Do Not Disturb is enabled"
);
- assert.ok(
- doNotDisturbButton.querySelector(".d-icon-toggle-on"),
- "Do Not Disturb button has the right icon when Do Not Disturb is enabled"
- );
+ assert
+ .dom(".d-icon-toggle-on", doNotDisturbButton)
+ .exists(
+ "Do Not Disturb button has the right icon when Do Not Disturb is enabled"
+ );
assert
.dom("#quick-access-profile ul li.enable-anonymous .btn")
@@ -581,10 +576,11 @@ acceptance("User menu", function (needs) {
i18n("switch_to_anon"),
"toggle anonymous button has the right label when the user isn't anonymous"
);
- assert.ok(
- toggleAnonButton.querySelector(".d-icon-user-secret"),
- "toggle anonymous button has the right icon when the user isn't anonymous"
- );
+ assert
+ .dom(".d-icon-user-secret", toggleAnonButton)
+ .exists(
+ "toggle anonymous button has the right icon when the user isn't anonymous"
+ );
await clickOutside();
updateCurrentUser({ is_anonymous: true });
@@ -602,10 +598,11 @@ acceptance("User menu", function (needs) {
i18n("switch_from_anon"),
"toggle anonymous button has the right label when the user is anonymous"
);
- assert.ok(
- toggleAnonButton.querySelector(".d-icon-ban"),
- "toggle anonymous button has the right icon when the user is anonymous"
- );
+ assert
+ .dom(".d-icon-ban", toggleAnonButton)
+ .exists(
+ "toggle anonymous button has the right icon when the user is anonymous"
+ );
await clickOutside();
updateCurrentUser({
@@ -701,10 +698,9 @@ acceptance("User menu", function (needs) {
i18n("user.log_out"),
"logout button has the right label"
);
- assert.ok(
- logoutButton.querySelector(".d-icon-right-from-bracket"),
- "logout button has the right icon"
- );
+ assert
+ .dom(".d-icon-right-from-bracket", logoutButton)
+ .exists("logout button has the right icon");
});
test("Extra items added to profile tab via plugin API are rendered properly", async function (assert) {
@@ -729,22 +725,20 @@ acceptance("User menu", function (needs) {
const item1 = query("#quick-access-profile ul li.test-1-item");
- assert.ok(
- item1.querySelector(".d-icon-wrench"),
- "The first item's icon is rendered"
- );
- assert.ok(
+ assert
+ .dom(".d-icon-wrench", item1)
+ .exists("The first item's icon is rendered");
+ assert.true(
item1.querySelector("a").href.endsWith("/test_1_path"),
"The first item's link is present with correct href"
);
const item2 = query("#quick-access-profile ul li.test-2-item");
- assert.notOk(
- item2.querySelector(".d-icon"),
- "The second item doesn't have an icon"
- );
- assert.ok(
+ assert
+ .dom(".d-icon", item2)
+ .doesNotExist("The second item doesn't have an icon");
+ assert.true(
item2.querySelector("a").href.endsWith("/test_2_path"),
"The second item's link is present with correct href"
);
@@ -958,11 +952,11 @@ acceptance("User menu - Dismiss button", function (needs) {
);
await click(".d-modal__footer .btn-default"); // click cancel on the dismiss modal
- assert.notOk(markRead, "mark-read request isn't sent");
+ assert.false(markRead, "mark-read request isn't sent");
await click(".user-menu .notifications-dismiss");
await click(".d-modal__footer .btn-primary"); // click confirm on the dismiss modal
- assert.ok(markRead, "mark-read request is sent");
+ assert.true(markRead, "mark-read request is sent");
});
test("shows confirmation modal for the bookmarks list", async function (assert) {
@@ -994,7 +988,7 @@ acceptance("User menu - Dismiss button", function (needs) {
}),
"confirmation modal is shown when there are unread bookmark reminder notifications"
);
- assert.notOk(markRead, "mark-read request isn't sent");
+ assert.false(markRead, "mark-read request isn't sent");
await click(".d-modal__footer .btn-primary"); // confirm dismiss on the dismiss modal
@@ -1007,7 +1001,7 @@ acceptance("User menu - Dismiss button", function (needs) {
assert
.dom("#user-menu-button-bookmarks .badge-notification")
.doesNotExist("bookmarks tab no longer has bubble");
- assert.ok(markRead, "mark-read request is sent");
+ assert.true(markRead, "mark-read request is sent");
assert.strictEqual(
markReadRequestBody,
"dismiss_types=bookmark_reminder",
@@ -1045,7 +1039,7 @@ acceptance("User menu - Dismiss button", function (needs) {
}),
"confirmation modal is shown when there are unread messages notifications"
);
- assert.notOk(markRead, "mark-read request isn't sent");
+ assert.false(markRead, "mark-read request isn't sent");
await click(".d-modal__footer .btn-primary"); // confirm dismiss on the dismiss modal
@@ -1058,7 +1052,7 @@ acceptance("User menu - Dismiss button", function (needs) {
assert
.dom("#user-menu-button-messages .badge-notification")
.doesNotExist("messages tab no longer has bubble");
- assert.ok(markRead, "mark-read request is sent");
+ assert.true(markRead, "mark-read request is sent");
assert.strictEqual(
markReadRequestBody,
"dismiss_types=private_message%2Cgroup_message_summary",
@@ -1073,7 +1067,7 @@ acceptance("User menu - Dismiss button", function (needs) {
await click("#user-menu-button-likes");
await click(".user-menu .notifications-dismiss");
- assert.ok(
+ assert.true(
markRead,
"mark-read request is sent without a confirmation modal"
);
@@ -1098,7 +1092,7 @@ acceptance("User menu - Dismiss button", function (needs) {
assert
.dom("#user-menu-button-other-notifications .badge-notification")
.doesNotExist();
- assert.ok(
+ assert.true(
markRead,
"mark-read request is sent without a confirmation modal"
);
@@ -1112,14 +1106,14 @@ acceptance("User menu - avatars", function (needs) {
show_user_menu_avatars: true,
});
- test("It shows user avatars for various notifications on all notifications pane", async function (assert) {
+ test("shows user avatars for various notifications on all notifications pane", async function (assert) {
await visit("/");
await click(".d-header-icons .current-user button");
assert.dom("li.notification.edited .icon-avatar").exists();
assert.dom("li.notification.replied .icon-avatar").exists();
});
- test("It shows user avatars for messages", async function (assert) {
+ test("shows user avatars for messages", async function (assert) {
await visit("/");
await click(".d-header-icons .current-user button");
await click("#user-menu-button-messages");
@@ -1128,7 +1122,7 @@ acceptance("User menu - avatars", function (needs) {
assert.dom("li.message .icon-avatar").exists();
});
- test("It shows user avatars for bookmark items and bookmark reminder notification items", async function (assert) {
+ test("shows user avatars for bookmark items and bookmark reminder notification items", async function (assert) {
await visit("/");
await click(".d-header-icons .current-user button");
await click("#user-menu-button-bookmarks");
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.js
index c5d6ac0125a..46664b0318a 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.js
@@ -108,7 +108,7 @@ acceptance("User Preferences - Account", function (needs) {
await click(".dialog-footer .btn-primary");
- assert.ok(
+ assert.true(
DiscourseURL.redirectAbsolute.calledWith("/"),
"redirects to home after deleting"
);
@@ -119,7 +119,7 @@ acceptance("User Preferences - Account", function (needs) {
assert
.dom(".pref-associated-accounts")
- .exists("it has the connected accounts section");
+ .exists("has the connected accounts section");
assert
.dom(
@@ -296,7 +296,7 @@ acceptance("User Preferences — Account - Download Archive", function (needs) {
test("Can see and trigger download for account data", async function (assert) {
await visit(`/u/${currentUser}/preferences/account`);
- assert.ok(query(".btn-request-archive"), "button exists");
+ assert.dom(".btn-request-archive").exists("button exists");
await click(".btn-request-archive");
await click("#dialog-holder .btn-primary");
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js
index daa0a46a2c9..a479b7156b8 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js
@@ -307,7 +307,7 @@ acceptance(
// dark scheme
await selectKit(".dark-color-scheme .combobox").expand();
- assert.ok(
+ assert.true(
selectKit(".dark-color-scheme .combobox").rowByValue(1).exists(),
"default dark scheme is included"
);
@@ -361,10 +361,9 @@ acceptance(
await selectKit(".light-color-scheme .combobox").expand();
await selectKit(".light-color-scheme .combobox").selectRowByValue(3);
- assert.notOk(
- document.querySelector("link#cs-preview-light"),
- "stylesheet not loaded"
- );
+ assert
+ .dom("link#cs-preview-light", document.body)
+ .doesNotExist("stylesheet not loaded");
});
}
);
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-tracking-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-tracking-test.js
index 6c80b9faf58..247d116e613 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-tracking-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-tracking-test.js
@@ -47,7 +47,7 @@ acceptance("User Preferences - Tracking", function (needs) {
await watchedTagsSelector.expand();
- assert.notOk(
+ assert.false(
watchedTagsSelector.rowByValue("monkey").exists(),
"tag that has already been selected is not available for selection"
);
@@ -61,7 +61,7 @@ acceptance("User Preferences - Tracking", function (needs) {
await mutedTagsSelector.expand();
["monkey", "gazelle"].forEach((tagName) => {
- assert.notOk(
+ assert.false(
mutedTagsSelector.rowByValue(tagName).exists(),
`tag "${tagName}" has already been selected is not available for selection`
);
@@ -76,7 +76,7 @@ acceptance("User Preferences - Tracking", function (needs) {
await watchedFirstPostTagsSelector.expand();
["dog", "gazelle", "monkey"].forEach((tagName) => {
- assert.notOk(
+ assert.false(
watchedFirstPostTagsSelector.rowByValue(tagName).exists(),
"tag `${tagName}` has already been selected is not available for selection"
);
@@ -107,7 +107,7 @@ acceptance("User Preferences - Tracking", function (needs) {
await trackedCategoriesSelector.expand();
- assert.notOk(
+ assert.false(
trackedCategoriesSelector.rowByValue("3").exists(),
"category that has already been selected is not available for selection"
);
@@ -121,7 +121,7 @@ acceptance("User Preferences - Tracking", function (needs) {
await mutedCategoriesSelector.expand();
["3", "4"].forEach((categoryId) => {
- assert.notOk(
+ assert.false(
mutedCategoriesSelector.rowByValue(categoryId).exists(),
`category id "${categoryId}" that has already been selected is not available for selection`
);
@@ -136,7 +136,7 @@ acceptance("User Preferences - Tracking", function (needs) {
await watchedFirstCategoriesSelector.expand();
["3", "4", "6"].forEach((categoryId) => {
- assert.notOk(
+ assert.false(
watchedFirstCategoriesSelector.rowByValue(categoryId).exists(),
`category id "${categoryId}" that has already been selected is not available for selection`
);
@@ -170,7 +170,7 @@ acceptance("User Preferences - Tracking", function (needs) {
await trackedCategoriesSelector.expand();
- assert.notOk(
+ assert.false(
trackedCategoriesSelector.rowByValue("4").exists(),
"category that is set to regular is not available for selection"
);
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js
index b5aae432155..0c383ee0d4d 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js
@@ -704,11 +704,12 @@ acceptance(
test("suggested messages without new or unread", async function (assert) {
await visit("/t/12");
- assert.strictEqual(
- query(".more-topics__browse-more").innerText.trim(),
- "Want to read more? Browse other messages in personal messages.",
- "displays the right browse more message"
- );
+ assert
+ .dom(".more-topics__browse-more")
+ .hasText(
+ "Want to read more? Browse other messages in personal messages.",
+ "displays the right browse more message"
+ );
});
test("suggested messages with new and unread", async function (assert) {
@@ -716,40 +717,41 @@ acceptance(
await publishNewToMessageBus({ userId: 5, topicId: 1 });
- assert.strictEqual(
- query(".more-topics__browse-more").innerText.trim(),
- "There is 1 new message remaining, or browse other personal messages",
- "displays the right browse more message"
- );
+ assert
+ .dom(".more-topics__browse-more")
+ .hasText(
+ "There is 1 new message remaining, or browse other personal messages",
+ "displays the right browse more message"
+ );
await publishUnreadToMessageBus({ userId: 5, topicId: 2 });
- assert.strictEqual(
- query(".more-topics__browse-more").innerText.trim(),
- "There is 1 unread and 1 new message remaining, or browse other personal messages",
- "displays the right browse more message"
- );
+ assert
+ .dom(".more-topics__browse-more")
+ .hasText(
+ "There is 1 unread and 1 new message remaining, or browse other personal messages",
+ "displays the right browse more message"
+ );
await publishReadToMessageBus({ userId: 5, topicId: 2 });
- assert.strictEqual(
- query(".more-topics__browse-more").innerText.trim(),
- "There is 1 new message remaining, or browse other personal messages",
- "displays the right browse more message"
- );
+ assert
+ .dom(".more-topics__browse-more")
+ .hasText(
+ "There is 1 new message remaining, or browse other personal messages",
+ "displays the right browse more message"
+ );
});
test("suggested messages for group messages without new or unread", async function (assert) {
await visit("/t/13");
- assert.ok(
- query(".more-topics__browse-more")
- .innerText.trim()
- .match(
- /Want to read more\? Browse other messages in\s+awesome_group\./
- ),
- "displays the right browse more message"
- );
+ assert
+ .dom(".more-topics__browse-more")
+ .hasText(
+ /Want to read more\? Browse other messages in\s+awesome_group\./,
+ "displays the right browse more message"
+ );
});
test("suggested messages for group messages with new and unread", async function (assert) {
@@ -757,25 +759,21 @@ acceptance(
await publishGroupNewToMessageBus({ groupIds: [14], topicId: 1 });
- assert.ok(
- query(".more-topics__browse-more")
- .innerText.trim()
- .match(
- /There is 1 new message remaining, or browse other messages in\s+awesome_group/
- ),
- "displays the right browse more message"
- );
+ assert
+ .dom(".more-topics__browse-more")
+ .hasText(
+ /There is 1 new message remaining, or browse other messages in\s+awesome_group/,
+ "displays the right browse more message"
+ );
await publishGroupUnreadToMessageBus({ groupIds: [14], topicId: 2 });
- assert.ok(
- query(".more-topics__browse-more")
- .innerText.trim()
- .match(
- /There is 1 unread and 1 new message remaining, or browse other messages in\s+awesome_group/
- ),
- "displays the right browse more message"
- );
+ assert
+ .dom(".more-topics__browse-more")
+ .hasText(
+ /There is 1 unread\s+and 1 new message remaining, or browse other messages in\s+awesome_group/,
+ "displays the right browse more message"
+ );
});
}
);
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js
index 8b805b179b4..e924d9418f1 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js
@@ -5,7 +5,7 @@ import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object";
import { i18n } from "discourse-i18n";
-let deleteAndBlock = null;
+let deleteAndBlock;
acceptance("User Profile - Summary", function (needs) {
needs.user();
@@ -142,11 +142,7 @@ acceptance("User Profile - Summary - Admin", function (needs) {
server.delete("/admin/users/5.json", (request) => {
const data = helper.parsePostData(request.requestBody);
- if (data.block_email || data.block_ip || data.block_urls) {
- deleteAndBlock = true;
- } else {
- deleteAndBlock = false;
- }
+ deleteAndBlock = !!(data.block_email || data.block_ip || data.block_urls);
return helper.response({});
});
@@ -161,7 +157,7 @@ acceptance("User Profile - Summary - Admin", function (needs) {
await click(".btn-delete-user");
await click(".dialog-footer .btn-primary");
- assert.notOk(deleteAndBlock, "first button does not block user");
+ assert.false(deleteAndBlock, "first button does not block user");
});
test("Delete and block", async function (assert) {
@@ -173,6 +169,6 @@ acceptance("User Profile - Summary - Admin", function (needs) {
.hasText(i18n("admin.user.delete_confirm_title"), "dialog has a title");
await click(".dialog-footer .btn-danger");
- assert.ok(deleteAndBlock, "second button also block user");
+ assert.true(deleteAndBlock, "second button also block user");
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/users-test.js b/app/assets/javascripts/discourse/tests/acceptance/users-test.js
index 17a0e6a983a..b319ab6465f 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/users-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/users-test.js
@@ -57,25 +57,27 @@ acceptance("User Directory", function () {
await visit("/u");
- const firstRowUserField = query(
- ".directory .directory-table__body .directory-table__row:first-child .directory-table__value--user-field"
- );
-
- const userFieldLink = firstRowUserField.querySelector("a");
-
- assert.ok(userFieldLink, "User field is displayed as a link");
+ assert
+ .dom(
+ ".directory .directory-table__body .directory-table__row:first-child .directory-table__value--user-field a"
+ )
+ .exists("User field is displayed as a link");
- assert.strictEqual(
- userFieldLink.getAttribute("href"),
- "/u?name=Blue&order=likes_received",
- "The link points to the correct URL"
- );
+ assert
+ .dom(
+ ".directory .directory-table__body .directory-table__row:first-child .directory-table__value--user-field a"
+ )
+ .hasAttribute(
+ "href",
+ "/u?name=Blue&order=likes_received",
+ "The link points to the correct URL"
+ );
- assert.strictEqual(
- userFieldLink.textContent.trim(),
- "Blue",
- "Link text is correct"
- );
+ assert
+ .dom(
+ ".directory .directory-table__body .directory-table__row:first-child .directory-table__value--user-field a"
+ )
+ .hasText("Blue", "Link text is correct");
});
test("Visit With Group Filter", async function (assert) {
@@ -104,10 +106,9 @@ acceptance("User Directory", function () {
await triggerKeyEvent(secondHeading, "keypress", "Enter");
- assert.ok(
- query(`${secondHeading} .d-icon-chevron-up`),
- "list has been sorted"
- );
+ assert
+ .dom(`${secondHeading} .d-icon-chevron-up`)
+ .exists("list has been sorted");
});
test("Visit with no users", async function (assert) {
diff --git a/app/assets/javascripts/discourse/tests/acceptance/video-placeholder-test.js b/app/assets/javascripts/discourse/tests/acceptance/video-placeholder-test.js
index f518752444e..88b76f1ec57 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/video-placeholder-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/video-placeholder-test.js
@@ -6,24 +6,22 @@ acceptance("Video Placeholder Test", function () {
test("placeholder shows up on posts with videos", async function (assert) {
await visit("/t/54081");
- const postWithVideo = document.querySelector(
- ".video-placeholder-container"
- );
- assert.ok(
- postWithVideo.hasAttribute("data-video-src"),
- "Video placeholder should have the 'data-video-src' attribute"
- );
-
- const overlay = postWithVideo.querySelector(".video-placeholder-overlay");
+ assert
+ .dom(".video-placeholder-container")
+ .hasAttribute(
+ "data-video-src",
+ /^\/uploads\/.+/,
+ "Video placeholder has the 'data-video-src' attribute"
+ );
assert.dom("video").doesNotExist("The video element does not exist yet");
- await click(overlay); // Play button is clicked
+ await click(".video-placeholder-overlay"); // Play button is clicked
assert.dom(".video-container").exists("The video container appears");
assert
- .dom(postWithVideo)
+ .dom(".video-placeholder-container")
.hasStyle({ cursor: "auto" }, "The cursor is set back to normal");
assert
@@ -40,7 +38,7 @@ acceptance("Video Placeholder Test", function () {
"Video src is correctly set"
);
- const video = postWithVideo.querySelector("video");
+ const video = document.querySelector("video");
video.play = function () {}; // We don't actually want the video to play in our test
const canPlayEvent = new Event("canplay");
video.dispatchEvent(canPlayEvent);
diff --git a/app/assets/javascripts/discourse/tests/integration/components/admin-schema-theme-setting/editor-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/admin-schema-theme-setting/editor-test.gjs
index 8caa59f9fbe..11c171c771d 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/admin-schema-theme-setting/editor-test.gjs
+++ b/app/assets/javascripts/discourse/tests/integration/components/admin-schema-theme-setting/editor-test.gjs
@@ -1288,7 +1288,7 @@ module(
tree.refresh();
assert.strictEqual(tree.nodes.length, 4);
- assert.ok(tree.nodes[2].active);
+ assert.true(tree.nodes[2].active);
assert.dom(tree.nodes[2].textElement).hasText("level1 3");
assert.dom(TOP_LEVEL_ADD_BTN).hasText("level1");
});
diff --git a/app/assets/javascripts/discourse/tests/integration/components/date-input-test.js b/app/assets/javascripts/discourse/tests/integration/components/date-input-test.js
index bc338f8876c..4191a95d703 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/date-input-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/date-input-test.js
@@ -2,17 +2,6 @@ import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
-import { query } from "discourse/tests/helpers/qunit-helpers";
-
-function dateInput() {
- return query(".date-picker");
-}
-
-function setDate(date) {
- this.set("date", date);
-}
-
-function noop() {}
const DEFAULT_DATE = moment("2019-01-29");
@@ -24,35 +13,35 @@ module("Integration | Component | date-input", function (hooks) {
await render(hbs`<DateInput @date={{this.date}} />`);
- assert.strictEqual(dateInput().value, "2019-01-29");
+ assert.dom(".date-picker").hasValue("2019-01-29");
});
test("prevents mutations", async function (assert) {
this.setProperties({ date: DEFAULT_DATE });
- this.set("onChange", noop);
+ this.set("onChange", () => {});
await render(
hbs`<DateInput @date={{this.date}} @onChange={{this.onChange}} />`
);
- dateInput().value = "2019-01-02";
- dateInput().dispatchEvent(new Event("change"));
+ document.querySelector(".date-picker").value = "2019-01-02";
+ document.querySelector(".date-picker").dispatchEvent(new Event("change"));
- assert.ok(this.date.isSame(DEFAULT_DATE));
+ assert.true(this.date.isSame(DEFAULT_DATE));
});
test("allows mutations through actions", async function (assert) {
this.setProperties({ date: DEFAULT_DATE });
- this.set("onChange", setDate);
+ this.set("onChange", (date) => this.set("date", date));
await render(
hbs`<DateInput @date={{this.date}} @onChange={{this.onChange}} />`
);
- dateInput().value = "2019-02-02";
- dateInput().dispatchEvent(new Event("change"));
+ document.querySelector(".date-picker").value = "2019-02-02";
+ document.querySelector(".date-picker").dispatchEvent(new Event("change"));
- assert.ok(this.date.isSame(moment("2019-02-02")));
+ assert.true(this.date.isSame(moment("2019-02-02")));
});
test("always shows date in timezone of input timestamp", async function (assert) {
@@ -63,11 +52,11 @@ module("Integration | Component | date-input", function (hooks) {
await render(
hbs`<DateInput @date={{this.date}} @onChange={{this.onChange}} />`
);
- assert.strictEqual(dateInput().value, "2023-05-05");
+ assert.dom(".date-picker").hasValue("2023-05-05");
this.setProperties({
date: moment.tz("2023-05-05T10:00:00", "ETC/GMT+12"),
});
- assert.strictEqual(dateInput().value, "2023-05-05");
+ assert.dom(".date-picker").hasValue("2023-05-05");
});
});
diff --git a/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.js b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.js
index 6b9d60e3fd4..ec4d857af91 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-test.js
@@ -37,7 +37,7 @@ module("Integration | Component | date-time-input", function (hooks) {
dateInput().value = "2019-01-02";
- assert.ok(this.date.isSame(DEFAULT_DATE_TIME));
+ assert.true(this.date.isSame(DEFAULT_DATE_TIME));
});
test("allows mutations through actions", async function (assert) {
@@ -51,7 +51,7 @@ module("Integration | Component | date-time-input", function (hooks) {
dateInput().value = "2019-01-02";
dateInput().dispatchEvent(new Event("change"));
- assert.ok(this.date.isSame(moment("2019-01-02 14:45")));
+ assert.true(this.date.isSame(moment("2019-01-02 14:45")));
});
test("can hide time", async function (assert) {
diff --git a/app/assets/javascripts/discourse/tests/integration/components/dialog-holder-test.js b/app/assets/javascripts/discourse/tests/integration/components/dialog-holder-test.js
index c12eeafcf5e..e6bc3b2acf7 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/dialog-holder-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/dialog-holder-test.js
@@ -22,8 +22,8 @@ module("Integration | Component | dialog-holder", function (hooks) {
test("basics", async function (assert) {
await render(hbs`<DialogHolder />`);
- assert.ok(query("#dialog-holder"), "element is in DOM");
- assert.dom("#dialog-holder").hasText("", "dialog is empty by default");
+ assert.dom("#dialog-holder").exists("element is in DOM");
+ assert.dom("#dialog-holder").hasNoText("dialog is empty by default");
this.dialog.alert({
message: "This is an error",
@@ -38,20 +38,20 @@ module("Integration | Component | dialog-holder", function (hooks) {
// dismiss by clicking on overlay
await click(".dialog-overlay");
- assert.ok(query("#dialog-holder"), "element is still in DOM");
+ assert.dom("#dialog-holder").exists("element is still in DOM");
assert.strictEqual(
query(".dialog-overlay").offsetWidth,
0,
"overlay is not visible"
);
- assert.dom("#dialog-holder").hasText("", "dialog is empty");
+ assert.dom("#dialog-holder").hasNoText("dialog is empty");
});
test("basics - dismiss using Esc", async function (assert) {
let cancelCallbackCalled = false;
await render(hbs`<DialogHolder />`);
- assert.ok(query("#dialog-holder"), "element is in DOM");
- assert.dom("#dialog-holder").hasText("", "dialog is empty by default");
+ assert.dom("#dialog-holder").exists("element is in DOM");
+ assert.dom("#dialog-holder").hasNoText("dialog is empty by default");
this.dialog.alert({
message: "This is an error",
@@ -69,8 +69,8 @@ module("Integration | Component | dialog-holder", function (hooks) {
// dismiss by pressing Esc
await triggerKeyEvent(document.activeElement, "keydown", "Escape");
- assert.ok(cancelCallbackCalled, "cancel callback called");
- assert.ok(query("#dialog-holder"), "element is still in DOM");
+ assert.true(cancelCallbackCalled, "cancel callback called");
+ assert.dom("#dialog-holder").exists("element is still in DOM");
assert.strictEqual(
query(".dialog-overlay").offsetWidth,
@@ -78,7 +78,7 @@ module("Integration | Component | dialog-holder", function (hooks) {
"overlay is not visible"
);
- assert.dom("#dialog-holder").hasText("", "dialog is empty");
+ assert.dom("#dialog-holder").hasNoText("dialog is empty");
});
test("alert with title", async function (assert) {
@@ -95,26 +95,23 @@ module("Integration | Component | dialog-holder", function (hooks) {
.dom("#dialog-title")
.hasText("And this is a title", "dialog has title");
- assert.ok(
- query("#dialog-holder[aria-labelledby='dialog-title']"),
- "aria-labelledby is correctly set"
- );
+ assert.dom("#dialog-holder").hasAria("labelledby", "dialog-title");
- assert.ok(query(".dialog-close"), "close button present");
- assert.ok(query("#dialog-holder"), "element is still in DOM");
+ assert.dom(".dialog-close").exists("close button present");
+ assert.dom("#dialog-holder").exists("element is still in DOM");
assert
.dom(".dialog-body")
.hasText("This is a note.", "dialog message is shown");
await click(".dialog-close");
- assert.ok(query("#dialog-holder"), "element is still in DOM");
+ assert.dom("#dialog-holder").exists("element is still in DOM");
assert.strictEqual(
query(".dialog-overlay").offsetWidth,
0,
"overlay is not visible"
);
- assert.dom("#dialog-holder").hasText("", "dialog is empty");
+ assert.dom("#dialog-holder").hasNoText("dialog is empty");
});
test("alert with a string parameter", async function (assert) {
@@ -161,10 +158,10 @@ module("Integration | Component | dialog-holder", function (hooks) {
await click(".dialog-footer .btn-primary");
- assert.ok(confirmCallbackCalled, "confirm callback called");
- assert.notOk(cancelCallbackCalled, "cancel callback NOT called");
+ assert.true(confirmCallbackCalled, "confirm callback called");
+ assert.false(cancelCallbackCalled, "cancel callback NOT called");
- assert.dom("#dialog-holder").hasText("", "dialog is empty");
+ assert.dom("#dialog-holder").hasNoText("dialog is empty");
});
test("cancel callback", async function (assert) {
@@ -189,10 +186,10 @@ module("Integration | Component | dialog-holder", function (hooks) {
.hasText("A confirm message", "dialog message is shown");
await click(".dialog-footer .btn-default");
- assert.notOk(confirmCallbackCalled, "confirm callback NOT called");
- assert.ok(cancelCallbackCalled, "cancel callback called");
+ assert.false(confirmCallbackCalled, "confirm callback NOT called");
+ assert.true(cancelCallbackCalled, "cancel callback called");
- assert.dom("#dialog-holder").hasText("", "dialog has been dismissed");
+ assert.dom("#dialog-holder").hasNoText("dialog has been dismissed");
});
test("yes/no confirm", async function (assert) {
@@ -244,19 +241,17 @@ module("Integration | Component | dialog-holder", function (hooks) {
.dom(".dialog-footer .btn-danger")
.hasText("Danger ahead", "dialog custom button is present");
- assert.notOk(
- query(".dialog-footer .btn-primary"),
- "default confirm button is not present"
- );
- assert.notOk(
- query(".dialog-footer .btn-default"),
- "default cancel button is not present"
- );
+ assert
+ .dom(".dialog-footer .btn-primary")
+ .doesNotExist("default confirm button is not present");
+ assert
+ .dom(".dialog-footer .btn-default")
+ .doesNotExist("default cancel button is not present");
await click(".dialog-footer .btn-danger");
- assert.ok(customCallbackTriggered, "custom action was triggered");
+ assert.true(customCallbackTriggered, "custom action was triggered");
- assert.dom("#dialog-holder").hasText("", "dialog has been dismissed");
+ assert.dom("#dialog-holder").hasNoText("dialog has been dismissed");
});
test("alert with custom classes", async function (assert) {
@@ -272,22 +267,25 @@ module("Integration | Component | dialog-holder", function (hooks) {
.dom(".dialog-body")
.hasText("An alert with custom classes", "dialog message is shown");
- assert.ok(
- query("#dialog-holder.dialog-special.dialog-super"),
- "additional classes are present"
- );
+ assert
+ .dom("#dialog-holder.dialog-special.dialog-super")
+ .exists("additional classes are present");
await click(".dialog-footer .btn-primary");
- assert.notOk(
- query("#dialog-holder.dialog-special"),
- "additional class removed on dismissal"
- );
+ assert
+ .dom("#dialog-holder")
+ .doesNotHaveClass(
+ "dialog-special",
+ "additional class removed on dismissal"
+ );
- assert.notOk(
- query("#dialog-holder.dialog-super"),
- "additional class removed on dismissal"
- );
+ assert
+ .dom("#dialog-holder")
+ .doesNotHaveClass(
+ "dialog-super",
+ "additional class removed on dismissal"
+ );
});
test("notice", async function (assert) {
@@ -298,8 +296,8 @@ module("Integration | Component | dialog-holder", function (hooks) {
assert.dom(".dialog-body").hasText("Noted!", "message is shown");
- assert.notOk(query(".dialog-footer"), "no footer");
- assert.notOk(query(".dialog-header"), "no header");
+ assert.dom(".dialog-footer").doesNotExist("no footer");
+ assert.dom(".dialog-header").doesNotExist("no header");
});
test("delete confirm", async function (assert) {
@@ -319,10 +317,9 @@ module("Integration | Component | dialog-holder", function (hooks) {
"dialog primary button use danger class and label is Delete"
);
- assert.notOk(
- query(".dialog-footer .btn-primary"),
- ".btn-primary element is not present in the dialog"
- );
+ assert
+ .dom(".dialog-footer .btn-primary")
+ .doesNotExist(".btn-primary element is not present in the dialog");
});
test("delete confirm with confirmation phrase component", async function (assert) {
diff --git a/app/assets/javascripts/discourse/tests/integration/components/float-kit/d-menu-test.js b/app/assets/javascripts/discourse/tests/integration/components/float-kit/d-menu-test.js
index 018bd591408..685adc00ba4 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/float-kit/d-menu-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/float-kit/d-menu-test.js
@@ -62,7 +62,7 @@ module("Integration | Component | FloatKit | d-menu", function (hooks) {
hbs`<DMenu @inline={{true}} @onRegisterApi={{this.onRegisterApi}} />`
);
- assert.ok(this.api instanceof DMenuInstance);
+ assert.true(this.api instanceof DMenuInstance);
});
test("@onShow", async function (assert) {
@@ -320,7 +320,7 @@ module("Integration | Component | FloatKit | d-menu", function (hooks) {
await click(".second.fk-d-menu__trigger");
- assert.dom(".fk-d-menu.first").exists("it doesn’t autoclose");
+ assert.dom(".fk-d-menu.first").exists("doesn’t autoclose");
assert.dom(".fk-d-menu.second").exists();
});
diff --git a/app/assets/javascripts/discourse/tests/integration/components/float-kit/d-toast-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/float-kit/d-toast-test.gjs
index ea03a60c185..2ceef71fa9c 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/float-kit/d-toast-test.gjs
+++ b/app/assets/javascripts/discourse/tests/integration/components/float-kit/d-toast-test.gjs
@@ -6,10 +6,8 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import DToast from "float-kit/components/d-toast";
import DToastInstance from "float-kit/lib/d-toast-instance";
-const TOAST_SELECTOR = ".fk-d-toast";
-
function createCustomToastInstance(owner, options, newClose) {
- const custom = class CustomToastInstance extends DToastInstance {
+ class CustomToastInstance extends DToastInstance {
constructor() {
super(owner, options);
}
@@ -18,9 +16,9 @@ function createCustomToastInstance(owner, options, newClose) {
close() {
newClose.apply(this);
}
- };
+ }
- return new custom(owner, options);
+ return new CustomToastInstance(owner, options);
}
module("Integration | Component | FloatKit | d-toast", function (hooks) {
@@ -35,23 +33,23 @@ module("Integration | Component | FloatKit | d-toast", function (hooks) {
await render(<template><DToast @toast={{toast}} /></template>);
- assert.dom(TOAST_SELECTOR).exists();
+ assert.dom(".fk-d-toast").exists();
- await triggerEvent(TOAST_SELECTOR, "touchstart", {
+ await triggerEvent(".fk-d-toast", "touchstart", {
touches: [{ clientX: 0, clientY: 0 }],
changedTouches: [{ clientX: 0, clientY: 0 }],
});
- await triggerEvent(TOAST_SELECTOR, "touchmove", {
+ await triggerEvent(".fk-d-toast", "touchmove", {
touches: [{ clientX: 0, clientY: -100 }],
changedTouches: [{ clientX: 0, clientY: -100 }],
});
- await triggerEvent(TOAST_SELECTOR, "touchend", {
+ await triggerEvent(".fk-d-toast", "touchend", {
touches: [{ clientX: 0, clientY: -100 }],
changedTouches: [{ clientX: 0, clientY: -100 }],
});
- assert.ok(closing);
+ assert.true(closing);
});
});
diff --git a/app/assets/javascripts/discourse/tests/integration/components/float-kit/d-tooltip-test.js b/app/assets/javascripts/discourse/tests/integration/components/float-kit/d-tooltip-test.js
index 5b48d0ee992..7180610f1a6 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/float-kit/d-tooltip-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/float-kit/d-tooltip-test.js
@@ -55,7 +55,7 @@ module("Integration | Component | FloatKit | d-tooltip", function (hooks) {
hbs`<DTooltip @inline={{true}} @onRegisterApi={{this.onRegisterApi}} />`
);
- assert.ok(this.api instanceof DTooltipInstance);
+ assert.true(this.api instanceof DTooltipInstance);
});
test("@onShow", async function (assert) {
diff --git a/app/assets/javascripts/discourse/tests/integration/components/load-more-test.js b/app/assets/javascripts/discourse/tests/integration/components/load-more-test.js
index cfb40e0073d..af671d470d7 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/load-more-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/load-more-test.js
@@ -27,6 +27,6 @@ module("Integration | Component | load-more", function (hooks) {
</LoadMore>
`);
- assert.ok(this.loadedMore);
+ assert.true(this.loadedMore);
});
});
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/api-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/api-test.js
index 1c75c95869c..f5dc1760c41 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/api-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/api-test.js
@@ -46,12 +46,12 @@ module("Integration | Component | select-kit/api", function (hooks) {
assert.strictEqual(this.comboBox.rows().length, 4);
const appendedRow = this.comboBox.rowByIndex(3);
- assert.ok(appendedRow.exists());
+ assert.true(appendedRow.exists());
assert.strictEqual(appendedRow.value(), "alpaca");
await this.comboBox.collapse();
- assert.notOk(this.singleSelect.rowByValue("alpaca").exists());
+ assert.false(this.singleSelect.rowByValue("alpaca").exists());
});
test("modifySelectKit(identifier).prependContent", async function (assert) {
@@ -76,12 +76,12 @@ module("Integration | Component | select-kit/api", function (hooks) {
assert.strictEqual(this.comboBox.rows().length, 4);
const prependedRow = this.comboBox.rowByIndex(0);
- assert.ok(prependedRow.exists());
+ assert.true(prependedRow.exists());
assert.strictEqual(prependedRow.value(), "alpaca");
await this.comboBox.collapse();
- assert.notOk(this.singleSelect.rowByValue("alpaca").exists());
+ assert.false(this.singleSelect.rowByValue("alpaca").exists());
});
test("modifySelectKit(identifier).onChange", async function (assert) {
@@ -125,11 +125,11 @@ module("Integration | Component | select-kit/api", function (hooks) {
assert.strictEqual(this.comboBox.rows().length, 1);
const replacementRow = this.comboBox.rowByIndex(0);
- assert.ok(replacementRow.exists());
+ assert.true(replacementRow.exists());
assert.strictEqual(replacementRow.value(), "alpaca");
await this.comboBox.collapse();
- assert.notOk(this.singleSelect.rowByValue("alpaca").exists());
+ assert.false(this.singleSelect.rowByValue("alpaca").exists());
});
});
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/category-drop-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/category-drop-test.js
index 6212dd359fc..5bd5af9fe06 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/category-drop-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/category-drop-test.js
@@ -49,12 +49,9 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
/>
`);
- const header = this.subject.header().el();
-
- assert.ok(
- header.querySelector(`.d-icon-caret-right`),
- "it uses the correct default icon"
- );
+ assert
+ .dom(".d-icon-caret-right", this.subject.header().el())
+ .exists("uses the correct default icon");
});
test("none", async function (assert) {
@@ -69,7 +66,7 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
assert.strictEqual(
text,
i18n("categories.categories_label"),
- "it uses the noneLabel"
+ "uses the noneLabel"
);
});
@@ -90,10 +87,9 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
await this.subject.expand();
const row = this.subject.rowByValue(this.category.id);
- assert.ok(
- row.el().querySelector(".category-desc"),
- "it shows category description for newcomers"
- );
+ assert
+ .dom(".category-desc", row.el())
+ .exists("shows category description for newcomers");
});
test("[not staff - TL1] displayCategoryDescription", async function (assert) {
@@ -113,10 +109,9 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
await this.subject.expand();
const row = this.subject.rowByValue(this.category.id);
- assert.notOk(
- row.el().querySelector(".category-desc"),
- "it doesn't shows category description for TL0+"
- );
+ assert
+ .dom(".category-desc", row.el())
+ .doesNotExist("doesn't shows category description for TL0+");
});
test("[staff - TL0] displayCategoryDescription", async function (assert) {
@@ -136,10 +131,9 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
await this.subject.expand();
const row = this.subject.rowByValue(this.category.id);
- assert.notOk(
- row.el().querySelector(".category-desc"),
- "it doesn't show category description for staff"
- );
+ assert
+ .dom(".category-desc", row.el())
+ .doesNotExist("doesn't show category description for staff");
});
test("hideParentCategory (default: false)", async function (assert) {
@@ -177,15 +171,14 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
await this.subject.expand();
const parentRow = this.subject.rowByValue(this.parentCategory.id);
- assert.notOk(parentRow.exists(), "the parent row is not showing");
+ assert.false(parentRow.exists(), "the parent row is not showing");
const childCategory = this.categories.firstObject;
const childCategoryId = childCategory.id;
const childRow = this.subject.rowByValue(childCategoryId);
- assert.ok(childRow.exists(), "the child row is showing");
+ assert.true(childRow.exists(), "the child row is showing");
- const categoryStatus = childRow.el().querySelector(".category-status");
- assert.ok(categoryStatus.innerText.trim().match(/^spec/));
+ assert.dom(".category-status", childRow.el()).includesText("spec");
});
test("allow_uncategorized_topics (true)", async function (assert) {
@@ -204,7 +197,7 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
const uncategorizedCategoryId = this.site.uncategorized_category_id;
const row = this.subject.rowByValue(uncategorizedCategoryId);
- assert.ok(row.exists(), "the uncategorized row is showing");
+ assert.true(row.exists(), "the uncategorized row is showing");
});
test("allow_uncategorized_topics (false)", async function (assert) {
@@ -223,7 +216,7 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
const uncategorizedCategoryId = this.site.uncategorized_category_id;
const row = this.subject.rowByValue(uncategorizedCategoryId);
- assert.notOk(row.exists(), "the uncategorized row is not showing");
+ assert.false(row.exists(), "the uncategorized row is not showing");
});
test("countSubcategories (default: false)", async function (assert) {
@@ -246,7 +239,7 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
assert.strictEqual(
topicCount,
"× 481",
- "it doesn't include the topic count of subcategories"
+ "doesn't include the topic count of subcategories"
);
});
@@ -273,7 +266,7 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
assert.strictEqual(
topicCount,
"× 584",
- "it includes the topic count of subcategories"
+ "includes the topic count of subcategories"
);
});
@@ -369,9 +362,9 @@ module("Integration | Component | select-kit/category-drop", function (hooks) {
await this.subject.expand();
await this.subject.selectRowByValue(26);
- assert.ok(
+ assert.true(
DiscourseURL.routeTo.calledWith("/c/feature/spec/26"),
- "it builds a correct URL"
+ "builds a correct URL"
);
});
});
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/combo-box-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/combo-box-test.js
index 9ac6375807d..5c132fedf50 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/combo-box-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/combo-box-test.js
@@ -49,10 +49,7 @@ module("Integration | Component | select-kit/combo-box", function (hooks) {
const header = this.subject.header();
- assert.ok(
- header.el().querySelector(".btn-clear"),
- "it shows the clear button"
- );
+ assert.dom(".btn-clear", header.el()).exists("shows the clear button");
assert.strictEqual(header.value(), DEFAULT_VALUE.toString());
await click(header.el().querySelector(".btn-clear"));
@@ -82,16 +79,14 @@ module("Integration | Component | select-kit/combo-box", function (hooks) {
const header = this.subject.header().el();
- assert.ok(
- header.querySelector(`.d-icon-${this.caretDownIcon}`),
- "it uses the icon provided"
- );
+ assert
+ .dom(`.d-icon-${this.caretDownIcon}`, header)
+ .exists("uses the icon provided");
await this.subject.expand();
- assert.ok(
- header.querySelector(`.d-icon-${this.caretUpIcon}`),
- "it uses the icon provided"
- );
+ assert
+ .dom(`.d-icon-${this.caretUpIcon}`, header)
+ .exists("uses the icon provided");
});
});
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/dropdown-select-box-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/dropdown-select-box-test.js
index 9b87da31840..e2ce5e84522 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/dropdown-select-box-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/dropdown-select-box-test.js
@@ -46,7 +46,7 @@ module(
`);
await this.subject.expand();
- assert.ok(this.subject.isExpanded());
+ assert.true(this.subject.isExpanded());
await this.subject.selectRowByValue(DEFAULT_VALUE);
assert.false(
@@ -83,7 +83,7 @@ module(
.hasAttribute(
"title",
"[en.test_none]",
- "it adds a title attribute to the button"
+ "adds a title attribute to the button"
);
});
@@ -100,10 +100,9 @@ module(
/>
`);
- assert.ok(
- this.subject.header().el().querySelector(".selected-name"),
- "it shows the text of the selected item"
- );
+ assert
+ .dom(".selected-name", this.subject.header().el())
+ .exists("shows the text of the selected item");
});
}
);
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/form-template-chooser-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/form-template-chooser-test.js
index d585b4e0722..45aef2281e1 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/form-template-chooser-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/form-template-chooser-test.js
@@ -45,7 +45,7 @@ module(
});
await render(hbs`<FormTemplateChooser />`);
- assert.ok(this.subject.isDisabled());
+ assert.true(this.subject.isDisabled());
});
}
);
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-test.js
index e587ec45f0d..9f9666a9a68 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/future-date-input-test.js
@@ -89,7 +89,7 @@ module(
const options = getOptions();
const customDateAndTime = i18n("time_shortcut.custom");
- assert.ok(options.includes(customDateAndTime));
+ assert.true(options.includes(customDateAndTime));
});
test("doesn't show 'Custom date and time' if disabled", async function (assert) {
@@ -117,7 +117,7 @@ module(
const options = getOptions();
const now = i18n("time_shortcut.now");
- assert.ok(options.includes(now));
+ assert.true(options.includes(now));
});
test("changing date/time updates the input correctly", async function (assert) {
@@ -129,13 +129,13 @@ module(
await fillIn(".time-input", "11:15");
- assert.ok(this.input.includes("2032-01-01"));
- assert.ok(this.input.includes("11:15"));
+ assert.true(this.input.includes("2032-01-01"));
+ assert.true(this.input.includes("11:15"));
await fillIn(".date-picker", "2033-01-01 ");
- assert.ok(this.input.includes("2033-01-01"));
- assert.ok(this.input.includes("11:15"));
+ assert.true(this.input.includes("2033-01-01"));
+ assert.true(this.input.includes("11:15"));
});
}
);
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/multi-select-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/multi-select-test.js
index 784b3e64c77..7c90cb6aad9 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/multi-select-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/multi-select-test.js
@@ -42,21 +42,21 @@ module("Integration | Component | select-kit/multi-select", function (hooks) {
await this.subject.expand();
const content = this.subject.displayedContent();
- assert.strictEqual(content.length, 3, "it shows rows");
+ assert.strictEqual(content.length, 3, "shows rows");
assert.strictEqual(
content[0].name,
this.content.firstObject.name,
- "it has the correct name"
+ "has the correct name"
);
assert.strictEqual(
content[0].id,
this.content.firstObject.id.toString(),
- "it has the correct value"
+ "has the correct value"
);
assert.strictEqual(
this.subject.header().value(),
null,
- "it doesn't set a value from the content"
+ "doesn't set a value from the content"
);
});
@@ -79,9 +79,9 @@ module("Integration | Component | select-kit/multi-select", function (hooks) {
await this.subject.expand();
await this.subject.deselectItemByValue(1);
- assert.ok(
+ assert.true(
this.subject.isExpanded(),
- "it doesn’t close the dropdown when no selection has been made"
+ "doesn’t close the dropdown when no selection has been made"
);
});
@@ -99,7 +99,7 @@ module("Integration | Component | select-kit/multi-select", function (hooks) {
await this.subject.expand();
await this.subject.selectRowByValue(1);
- assert.ok(this.subject.isExpanded(), "it doesn’t close the dropdown");
+ assert.true(this.subject.isExpanded(), "doesn’t close the dropdown");
});
test("pasting", async function (assert) {
@@ -129,6 +129,6 @@ module("Integration | Component | select-kit/multi-select", function (hooks) {
assert
.dom(".selected-content")
- .doesNotExist("it doesn’t render an empty content div");
+ .doesNotExist("doesn’t render an empty content div");
});
});
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/notifications-button-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/notifications-button-test.js
index 9f1e5a1e500..6ebd24b8954 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/notifications-button-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/notifications-button-test.js
@@ -29,14 +29,14 @@ module(
/>
`);
- assert.ok(this.subject.header().value());
+ assert.true(!!this.subject.header().value());
- assert.ok(
+ assert.true(
this.subject
.header()
.label()
.includes(`${this.i18nPrefix}.regular${this.i18nPostfix}`),
- "it shows the regular choice when value is not set"
+ "shows the regular choice when value is not set"
);
assert
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/single-select-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/single-select-test.js
index 526d74eba17..7a44c225074 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/single-select-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/single-select-test.js
@@ -45,21 +45,21 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
await this.subject.expand();
const content = this.subject.displayedContent();
- assert.strictEqual(content.length, 3, "it shows rows");
+ assert.strictEqual(content.length, 3, "shows rows");
assert.strictEqual(
content[0].name,
this.content.firstObject.name,
- "it has the correct name"
+ "has the correct name"
);
assert.strictEqual(
content[0].id,
this.content.firstObject.id.toString(),
- "it has the correct value"
+ "has the correct value"
);
assert.strictEqual(
this.subject.header().value(),
null,
- "it doesn't set a value from the content"
+ "doesn't set a value from the content"
);
});
@@ -71,17 +71,15 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
await this.subject.expand();
const content = this.subject.displayedContent();
- assert.strictEqual(content.length, 3, "it shows rows");
+ assert.strictEqual(content.length, 3, "shows rows");
- assert
- .dom(".select-kit-header")
- .isFocused("it should focus the header first");
+ assert.dom(".select-kit-header").isFocused("focuses the header first");
await tab();
assert
.dom(".select-kit-row:first-child")
- .isFocused("it should focus the first row next");
+ .isFocused("focuses the first row next");
await tab();
@@ -104,7 +102,7 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
await this.subject.expand();
- assert.ok(this.subject.isExpanded(), "dropdown is expanded again");
+ assert.true(this.subject.isExpanded(), "dropdown is expanded again");
await tab({ backwards: true });
@@ -127,7 +125,7 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
assert.strictEqual(
this.subject.header().value(this.content),
"1",
- "it selects the correct content to display"
+ "selects the correct content to display"
);
});
@@ -148,14 +146,14 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
`);
await this.subject.expand();
- assert.ok(this.subject.filter().exists(), "it shows the filter");
+ assert.true(this.subject.filter().exists(), "shows the filter");
const filter = this.subject.displayedContent()[1].name;
await this.subject.fillInFilter(filter);
assert.strictEqual(
this.subject.displayedContent()[0].name,
filter,
- "it filters the list"
+ "filters the list"
);
});
@@ -182,7 +180,7 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
assert.strictEqual(
this.subject.displayedContent().length,
1,
- "it returns only 1 result"
+ "returns only 1 result"
);
});
@@ -474,7 +472,7 @@ module("Integration | Component | select-kit/single-select", function (hooks) {
const header = query(".select-kit-header").getBoundingClientRect();
const body = query(".select-kit-body").getBoundingClientRect();
- assert.ok(header.bottom > body.top, "it correctly offsets the body");
+ assert.true(header.bottom > body.top, "correctly offsets the body");
});
test("options.expandedOnInsert", async function (assert) {
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/tag-drop-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/tag-drop-test.gjs
similarity index 54%
rename from app/assets/javascripts/discourse/tests/integration/components/select-kit/tag-drop-test.js
rename to app/assets/javascripts/discourse/tests/integration/components/select-kit/tag-drop-test.gjs
index e821a136eae..bd914bf4c1c 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/tag-drop-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/tag-drop-test.gjs
@@ -1,29 +1,19 @@
+import { hash } from "@ember/helper";
import { render } from "@ember/test-helpers";
-import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import pretender, { response } from "discourse/tests/helpers/create-pretender";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { i18n } from "discourse-i18n";
-
-function initTags(context) {
- const categories = context.site.categoriesList;
- const category = categories.findBy("id", 2);
-
- // top_tags
- context.setProperties({
- currentCategory: category,
- tagId: "jeff",
- });
-}
+import TagDrop from "select-kit/components/tag-drop";
module("Integration | Component | select-kit/tag-drop", function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
- this.set("subject", selectKit());
+ this.subject = selectKit();
- this.site.set("top_tags", ["jeff", "neil", "arpit", "régis"]);
+ this.site.top_tags = ["jeff", "neil", "arpit", "régis"];
pretender.get("/tags/filter/search", (params) => {
if (params.queryParams.q === "dav") {
@@ -35,17 +25,16 @@ module("Integration | Component | select-kit/tag-drop", function (hooks) {
});
test("default", async function (assert) {
- initTags(this);
+ const categories = this.site.categoriesList;
+ const category = categories.findBy("id", 2);
- await render(hbs`
+ await render(<template>
<TagDrop
- @currentCategory={{this.currentCategory}}
- @tagId={{this.tagId}}
- @options={{hash
- tagId=this.tagId
- }}
+ @currentCategory={{category}}
+ @tagId={{"jeff"}}
+ @options={{hash tagId="jeff"}}
/>
- `);
+ </template>);
await this.subject.expand();
@@ -54,46 +43,43 @@ module("Integration | Component | select-kit/tag-drop", function (hooks) {
assert.strictEqual(
content[0].name,
i18n("tagging.selector_remove_filter"),
- "it has the correct label for removing the tag filter"
+ "has the correct label for removing the tag filter"
);
assert.strictEqual(
content[1].name,
i18n("tagging.selector_no_tags"),
- "it has the translated label for no-tags"
+ "has the translated label for no-tags"
);
await this.subject.fillInFilter("dav");
- assert.strictEqual(
- this.subject.rows()[0].textContent.trim(),
- "David",
- "it has no tag count when filtering in a category context"
- );
+ assert
+ .dom(this.subject.rows()[0])
+ .hasText(
+ "David",
+ "has no tag count when filtering in a category context"
+ );
});
test("default global (no category)", async function (assert) {
- await render(hbs`<TagDrop />`);
+ await render(<template><TagDrop /></template>);
await this.subject.expand();
await this.subject.fillInFilter("dav");
- assert.strictEqual(
- this.subject.rows()[0].textContent.trim(),
- "David x2",
- "it has the tag count"
- );
+ assert.dom(this.subject.rows()[0]).hasText("David x2", "has the tag count");
});
- test("default global (no category)", async function (assert) {
+ test("default global (no category, max tags)", async function (assert) {
this.siteSettings.max_tags_in_filter_list = 3;
- await render(hbs`<TagDrop />`);
+ await render(<template><TagDrop /></template>);
await this.subject.expand();
- assert.dom(".filter-for-more").exists("it has the 'filter for more' note");
+ assert.dom(".filter-for-more").exists("has the 'filter for more' note");
await this.subject.fillInFilter("dav");
assert
.dom(".filter-for-more")
- .doesNotExist("it does not have the 'filter for more' note");
+ .doesNotExist("does not have the 'filter for more' note");
});
});
diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js
index bced760f93c..1a9b40eaf52 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js
@@ -43,11 +43,11 @@ module(
[NOTIFICATION_TYPES.bookmark_reminder]: 72,
});
await render(template);
- const dismiss = query(".panel-body-bottom .notifications-dismiss");
- assert.ok(
- dismiss,
- "dismiss button is shown if the user has unread bookmark_reminder notifications"
- );
+ assert
+ .dom(".panel-body-bottom .notifications-dismiss")
+ .exists(
+ "dismiss button is shown if the user has unread bookmark_reminder notifications"
+ );
assert
.dom(".panel-body-bottom .notifications-dismiss")
.hasAttribute(
diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/messages-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/messages-list-test.js
index 07db8ccf70b..3e0672281bc 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/messages-list-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/messages-list-test.js
@@ -270,11 +270,11 @@ module("Integration | Component | user-menu | messages-list", function (hooks) {
});
await render(template);
- const dismiss = query(".panel-body-bottom .notifications-dismiss");
- assert.ok(
- dismiss,
- "dismiss button is shown if the user has unread private_message notifications"
- );
+ assert
+ .dom(".panel-body-bottom .notifications-dismiss")
+ .exists(
+ "dismiss button is shown if the user has unread private_message notifications"
+ );
assert
.dom(".panel-body-bottom .notifications-dismiss")
.hasAttribute(
diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js
index 653d08b2859..dc5e690b32e 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js
@@ -115,7 +115,7 @@ module(
});
assert.strictEqual(notificationsFetches, 1);
await click(".panel-body-bottom .btn.notifications-dismiss");
- assert.ok(markRead, "request to the server is made");
+ assert.true(markRead, "request to the server is made");
assert.strictEqual(
notificationsFetches,
2,
@@ -213,23 +213,23 @@ module(
});
await render(template);
const items = queryAll("ul li");
- assert.ok(
+ assert.true(
items[0].textContent.includes("hello world 0011"),
"the first pending reviewable is displayed 1st because it's most recent among pending reviewables and unread notifications"
);
- assert.ok(
+ assert.true(
items[1].textContent.includes("Unread notification #01"),
"the first unread notification is displayed 2nd because it's the 2nd most recent among pending reviewables and unread notifications"
);
- assert.ok(
+ assert.true(
items[2].textContent.includes("Unread notification #02"),
"the second unread notification is displayed 3rd because it's the 3rd most recent among pending reviewables and unread notifications"
);
- assert.ok(
+ assert.true(
items[3].textContent.includes("hello world 0033"),
"the second pending reviewable is displayed 4th because it's the 4th most recent among pending reviewables and unread notifications"
);
- assert.ok(
+ assert.true(
items[4].textContent.includes("Read notification #01"),
"read notifications come after the pending reviewables and unread notifications"
);
diff --git a/app/assets/javascripts/discourse/tests/integration/components/watched-word-uploader-test.js b/app/assets/javascripts/discourse/tests/integration/components/watched-word-uploader-test.js
index 95fa6f8c605..d78525ef5e7 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/watched-word-uploader-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/watched-word-uploader-test.js
@@ -30,7 +30,7 @@ module("Integration | Component | watched-word-uploader", function (hooks) {
)[0][1].meta.action_key,
"flag"
);
- assert.ok(
+ assert.true(
dialog.alert.calledWith(
i18n("admin.watched_words.form.upload_successful")
),
diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-test-with-glimmer-post-menu-test.js b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-test-with-glimmer-post-menu-test.js
index 784e6b5d2c3..5ca5f80062e 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-test-with-glimmer-post-menu-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-test-with-glimmer-post-menu-test.js
@@ -120,7 +120,7 @@ module(
`);
await click(".post-info .wiki");
- assert.ok(
+ assert.true(
this.historyShown,
"clicking the wiki icon displays the post history"
);
@@ -136,7 +136,7 @@ module(
`);
await click(".post-info .wiki");
- assert.ok(this.editPostCalled, "clicking wiki icon edits the post");
+ assert.true(this.editPostCalled, "clicking wiki icon edits the post");
});
test("via-email", async function (assert) {
@@ -149,7 +149,7 @@ module(
);
await click(".post-info.via-email");
- assert.ok(
+ assert.true(
this.rawEmailShown,
"clicking the envelope shows the raw email"
);
@@ -182,7 +182,7 @@ module(
);
await click(".post-info.edits button");
- assert.ok(this.historyShown, "clicking the pencil shows the history");
+ assert.true(this.historyShown, "clicking the pencil shows the history");
});
test("history without view permission", async function (assert) {
@@ -285,7 +285,7 @@ module(
);
await click(".topic-body .expand-hidden");
- assert.ok(this.unhidden, "triggers the action");
+ assert.true(this.unhidden, "triggers the action");
});
test(`cooked content hidden - can't view hidden post`, async function (assert) {
@@ -374,7 +374,7 @@ module(
await click(
"[data-content][data-identifier='admin-post-menu'] .permanently-delete"
);
- assert.ok(this.deleted);
+ assert.true(this.deleted);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@@ -409,7 +409,7 @@ module(
await click(
"[data-content][data-identifier='admin-post-menu'] .permanently-delete"
);
- assert.ok(this.deleted);
+ assert.true(this.deleted);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@@ -444,7 +444,7 @@ module(
"[data-content][data-identifier='admin-post-menu'] .toggle-post-type"
);
- assert.ok(this.toggled);
+ assert.true(this.toggled);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@@ -473,7 +473,7 @@ module(
await click(
"[data-content][data-identifier='admin-post-menu'] .rebuild-html"
);
- assert.ok(this.baked);
+ assert.true(this.baked);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@@ -499,7 +499,7 @@ module(
"[data-content][data-identifier='admin-post-menu'] .unhide-post"
);
- assert.ok(unhidden);
+ assert.true(unhidden);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
@@ -531,7 +531,7 @@ module(
await click(
"[data-content][data-identifier='admin-post-menu'] .change-owner"
);
- assert.ok(this.owned);
+ assert.true(this.owned);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-test.js b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-test.js
index 6ce8076c4e7..ae4199b54eb 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-test.js
@@ -101,7 +101,7 @@ module("Integration | Component | Widget | post", function (hooks) {
`);
await click(".post-info .wiki");
- assert.ok(
+ assert.true(
this.historyShown,
"clicking the wiki icon displays the post history"
);
@@ -116,7 +116,7 @@ module("Integration | Component | Widget | post", function (hooks) {
`);
await click(".post-info .wiki");
- assert.ok(this.editPostCalled, "clicking wiki icon edits the post");
+ assert.true(this.editPostCalled, "clicking wiki icon edits the post");
});
test("via-email", async function (assert) {
@@ -129,7 +129,10 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click(".post-info.via-email");
- assert.ok(this.rawEmailShown, "clicking the envelope shows the raw email");
+ assert.true(
+ this.rawEmailShown,
+ "clicking the envelope shows the raw email"
+ );
});
test("via-email without permission", async function (assert) {
@@ -159,7 +162,7 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click(".post-info.edits button");
- assert.ok(this.historyShown, "clicking the pencil shows the history");
+ assert.true(this.historyShown, "clicking the pencil shows the history");
});
test("history without view permission", async function (assert) {
@@ -254,7 +257,7 @@ module("Integration | Component | Widget | post", function (hooks) {
assert
.dom(".actions button.post-action-menu__copy-link")
- .exists("it renders a copy link button");
+ .exists("renders a copy link button");
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb
@@ -309,7 +312,7 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click(".actions button.like");
- assert.ok(this.loginShown);
+ assert.true(this.loginShown);
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb
@@ -323,7 +326,7 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click("button.edit");
- assert.ok(this.editPostCalled, "it triggered the edit action");
+ assert.true(this.editPostCalled, "triggered the edit action");
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb
@@ -347,7 +350,7 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click("button.delete");
- assert.ok(this.deletePostCalled, "it triggered the delete action");
+ assert.true(this.deletePostCalled, "triggered the delete action");
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb
@@ -395,7 +398,7 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click("button.recover");
- assert.ok(this.recovered);
+ assert.true(this.recovered);
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb
@@ -420,7 +423,7 @@ module("Integration | Component | Widget | post", function (hooks) {
await click(".show-more-actions");
await click("button.delete");
- assert.ok(this.deletePostCalled, "it triggered the delete action");
+ assert.true(this.deletePostCalled, "triggered the delete action");
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb
@@ -461,7 +464,7 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click("button.recover");
- assert.ok(this.recovered);
+ assert.true(this.recovered);
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb
@@ -486,7 +489,7 @@ module("Integration | Component | Widget | post", function (hooks) {
assert.dom("button.create-flag").exists();
await click("button.create-flag");
- assert.ok(this.flagsShown, "it triggered the action");
+ assert.true(this.flagsShown, "triggered the action");
});
test(`flagging: can't flag`, async function (assert) {
@@ -580,7 +583,7 @@ module("Integration | Component | Widget | post", function (hooks) {
);
await click(".topic-body .expand-hidden");
- assert.ok(this.unhidden, "triggers the action");
+ assert.true(this.unhidden, "triggers the action");
});
test(`cooked content hidden - can't view hidden post`, async function (assert) {
@@ -697,7 +700,7 @@ module("Integration | Component | Widget | post", function (hooks) {
await click(
"[data-content][data-identifier='admin-post-menu'] .permanently-delete"
);
- assert.ok(this.deleted);
+ assert.true(this.deleted);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@@ -732,7 +735,7 @@ module("Integration | Component | Widget | post", function (hooks) {
await click(
"[data-content][data-identifier='admin-post-menu'] .permanently-delete"
);
- assert.ok(this.deleted);
+ assert.true(this.deleted);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@@ -766,7 +769,7 @@ module("Integration | Component | Widget | post", function (hooks) {
"[data-content][data-identifier='admin-post-menu'] .toggle-post-type"
);
- assert.ok(this.toggled);
+ assert.true(this.toggled);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@@ -794,7 +797,7 @@ module("Integration | Component | Widget | post", function (hooks) {
await click(
"[data-content][data-identifier='admin-post-menu'] .rebuild-html"
);
- assert.ok(this.baked);
+ assert.true(this.baked);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@@ -827,7 +830,7 @@ module("Integration | Component | Widget | post", function (hooks) {
"[data-content][data-identifier='admin-post-menu'] .unhide-post"
);
- assert.ok(unhidden);
+ assert.true(unhidden);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
@@ -858,7 +861,7 @@ module("Integration | Component | Widget | post", function (hooks) {
await click(
"[data-content][data-identifier='admin-post-menu'] .change-owner"
);
- assert.ok(this.owned);
+ assert.true(this.owned);
assert
.dom("[data-content][data-identifier='admin-post-menu']")
.doesNotExist("also hides the menu");
@@ -874,7 +877,7 @@ module("Integration | Component | Widget | post", function (hooks) {
`);
await click(".post-controls .create");
- assert.ok(this.replied);
+ assert.true(this.replied);
});
// glimmer-post-menu: deprecated in favor of spec/system/post_menu_spec.rb
diff --git a/app/assets/javascripts/discourse/tests/unit/controllers/admin-user-badges-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/admin-user-badges-test.js
index 9adf56e9bab..0afb08a226e 100644
--- a/app/assets/javascripts/discourse/tests/unit/controllers/admin-user-badges-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/admin-user-badges-test.js
@@ -103,7 +103,7 @@ module("Unit | Controller | admin-user-badges", function (hooks) {
controller.performGrantBadge();
await settled();
- assert.ok(
+ assert.true(
GrantBadgeStub.calledWith(badgeToGrant.id, user.username, badgeReason)
);
diff --git a/app/assets/javascripts/discourse/tests/unit/controllers/topic-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/topic-test.js
index 8856530a0fa..df0ad7dc52f 100644
--- a/app/assets/javascripts/discourse/tests/unit/controllers/topic-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/controllers/topic-test.js
@@ -25,12 +25,12 @@ module("Unit | Controller | topic", function (hooks) {
const controller = getOwner(this).lookup("controller:topic");
const model = this.store.createRecord("topic");
controller.setProperties({ model });
- assert.notOk(controller.editingTopic, "we are not editing by default");
+ assert.false(controller.editingTopic, "we are not editing by default");
controller.set("model.details.can_edit", false);
controller.editTopic();
- assert.notOk(
+ assert.false(
controller.editingTopic,
"calling editTopic doesn't enable editing unless the user can edit"
);
@@ -38,7 +38,7 @@ module("Unit | Controller | topic", function (hooks) {
controller.set("model.details.can_edit", true);
controller.editTopic();
- assert.ok(
+ assert.true(
controller.editingTopic,
"calling editTopic enables editing if the user can edit"
);
@@ -47,7 +47,7 @@ module("Unit | Controller | topic", function (hooks) {
controller.send("cancelEditingTopic");
- assert.notOk(
+ assert.false(
controller.editingTopic,
"cancelling edit mode reverts the property value"
);
@@ -70,12 +70,12 @@ module("Unit | Controller | topic", function (hooks) {
model.set("views", 10000);
controller.send("deleteTopic");
- assert.notOk(destroyed, "don't destroy popular topic");
- assert.ok(modalDisplayed, "display confirmation modal for popular topic");
+ assert.false(destroyed, "don't destroy popular topic");
+ assert.true(modalDisplayed, "display confirmation modal for popular topic");
model.set("views", 3);
controller.send("deleteTopic");
- assert.ok(destroyed, "destroy not popular topic");
+ assert.true(destroyed, "destroy not popular topic");
});
test("deleteTopic permanentDelete", function (assert) {
@@ -104,7 +104,7 @@ module("Unit | Controller | topic", function (hooks) {
const controller = getOwner(this).lookup("controller:topic");
controller.setProperties({ model });
- assert.notOk(
+ assert.false(
controller.multiSelect,
"multi selection mode is disabled by default"
);
@@ -115,7 +115,7 @@ module("Unit | Controller | topic", function (hooks) {
controller.send("toggleMultiSelect");
await settled();
- assert.ok(
+ assert.true(
controller.multiSelect,
"calling 'toggleMultiSelect' once enables multi selection mode"
);
@@ -131,7 +131,7 @@ module("Unit | Controller | topic", function (hooks) {
controller.send("toggleMultiSelect");
await settled();
- assert.notOk(
+ assert.false(
controller.multiSelect,
"calling 'toggleMultiSelect' twice disables multi selection mode"
);
@@ -156,7 +156,7 @@ module("Unit | Controller | topic", function (hooks) {
2,
"selectedPosts only contains already loaded posts"
);
- assert.notOk(
+ assert.false(
controller.selectedPosts.some((p) => p === undefined),
"selectedPosts only contains valid post objects"
);
@@ -168,13 +168,13 @@ module("Unit | Controller | topic", function (hooks) {
controller.setProperties({ model });
controller.set("selectedPostIds", [1, 2]);
- assert.notOk(controller.selectedAllPosts, "not all posts are selected");
+ assert.false(controller.selectedAllPosts, "not all posts are selected");
controller.selectedPostIds.pushObject(3);
- assert.ok(controller.selectedAllPosts, "all posts are selected");
+ assert.true(controller.selectedAllPosts, "all posts are selected");
controller.selectedPostIds.pushObject(42);
- assert.ok(
+ assert.true(
controller.selectedAllPosts,
"all posts (including filtered posts) are selected"
);
@@ -183,9 +183,9 @@ module("Unit | Controller | topic", function (hooks) {
"postStream.isMegaTopic": true,
posts_count: 1,
});
- assert.ok(
+ assert.true(
controller.selectedAllPosts,
- "it uses the topic's post count for mega-topics"
+ "uses the topic's post count for mega-topics"
);
});
@@ -241,18 +241,18 @@ module("Unit | Controller | topic", function (hooks) {
const controller = getOwner(this).lookup("controller:topic");
controller.setProperties({ model });
- assert.notOk(controller.showSelectedPostsAtBottom, "false on desktop");
+ assert.false(controller.showSelectedPostsAtBottom, "false on desktop");
const site = getOwner(this).lookup("service:site");
site.set("mobileView", true);
- assert.notOk(
+ assert.false(
controller.showSelectedPostsAtBottom,
"requires at least 3 posts on mobile"
);
model.set("posts_count", 4);
- assert.ok(
+ assert.true(
controller.showSelectedPostsAtBottom,
"true when mobile and more than 3 posts"
);
@@ -275,31 +275,31 @@ module("Unit | Controller | topic", function (hooks) {
currentUser,
});
- assert.notOk(
+ assert.false(
controller.canDeleteSelected,
"false when no posts are selected"
);
controller.selectedPostIds.pushObject(1);
- assert.notOk(
+ assert.false(
controller.canDeleteSelected,
"false when can't delete one of the selected posts"
);
controller.selectedPostIds.replace(0, 1, [2, 3]);
- assert.ok(
+ assert.true(
controller.canDeleteSelected,
"true when all selected posts can be deleted"
);
controller.selectedPostIds.pushObject(1);
- assert.notOk(
+ assert.false(
controller.canDeleteSelected,
"false when all posts are selected and user is staff"
);
currentUser.set("admin", true);
- assert.ok(
+ assert.true(
controller.canDeleteSelected,
"true when all posts are selected and user is staff"
);
@@ -319,33 +319,33 @@ module("Unit | Controller | topic", function (hooks) {
const controller = getOwner(this).lookup("controller:topic");
controller.setProperties({ model });
- assert.notOk(
+ assert.false(
controller.canMergeTopic,
"can't merge topic when no posts are selected"
);
controller.selectedPostIds.pushObject(1);
- assert.notOk(
+ assert.false(
controller.canMergeTopic,
"can't merge topic when can't move posts"
);
model.set("details.can_move_posts", true);
- assert.ok(controller.canMergeTopic, "can merge topic");
+ assert.true(controller.canMergeTopic, "can merge topic");
controller.selectedPostIds.removeObject(1);
controller.selectedPostIds.pushObject(2);
- assert.ok(
+ assert.true(
controller.canMergeTopic,
"can merge topic when 1st post is not a regular post"
);
controller.selectedPostIds.pushObject(3);
- assert.ok(
+ assert.true(
controller.canMergeTopic,
"can merge topic when all posts are selected"
);
@@ -365,19 +365,19 @@ module("Unit | Controller | topic", function (hooks) {
const controller = getOwner(this).lookup("controller:topic");
controller.setProperties({ model, currentUser });
- assert.notOk(controller.canChangeOwner, "false when no posts are selected");
+ assert.false(controller.canChangeOwner, "false when no posts are selected");
controller.selectedPostIds.pushObject(1);
- assert.notOk(controller.canChangeOwner, "false when not admin");
+ assert.false(controller.canChangeOwner, "false when not admin");
currentUser.set("admin", true);
- assert.ok(
+ assert.true(
controller.canChangeOwner,
"true when admin and one post is selected"
);
controller.selectedPostIds.pushObject(2);
- assert.notOk(
+ assert.false(
controller.canChangeOwner,
"false when admin but more than 1 user"
);
@@ -400,19 +400,19 @@ module("Unit | Controller | topic", function (hooks) {
const controller = getOwner(this).lookup("controller:topic");
controller.setProperties({ model, currentUser });
- assert.notOk(controller.canChangeOwner, "false when no posts are selected");
+ assert.false(controller.canChangeOwner, "false when no posts are selected");
controller.selectedPostIds.pushObject(1);
- assert.notOk(controller.canChangeOwner, "false when not moderator");
+ assert.false(controller.canChangeOwner, "false when not moderator");
currentUser.set("moderator", true);
- assert.ok(
+ assert.true(
controller.canChangeOwner,
"true when moderator and one post is selected"
);
controller.selectedPostIds.pushObject(2);
- assert.notOk(
+ assert.false(
controller.canChangeOwner,
"false when moderator but more than 1 user"
);
@@ -432,28 +432,28 @@ module("Unit | Controller | topic", function (hooks) {
const controller = getOwner(this).lookup("controller:topic");
controller.setProperties({ model });
- assert.notOk(controller.canMergePosts, "false when no posts are selected");
+ assert.false(controller.canMergePosts, "false when no posts are selected");
controller.selectedPostIds.pushObject(1);
- assert.notOk(
+ assert.false(
controller.canMergePosts,
"false when only one post is selected"
);
controller.selectedPostIds.pushObject(2);
- assert.notOk(
+ assert.false(
controller.canMergePosts,
"false when selected posts are from different users"
);
controller.selectedPostIds.replace(1, 1, [3]);
- assert.notOk(
+ assert.false(
controller.canMergePosts,
"false when selected posts can't be deleted"
);
controller.selectedPostIds.replace(1, 1, [4]);
- assert.ok(
+ assert.true(
controller.canMergePosts,
"true when all selected posts are deletable and by the same user"
);
@@ -553,19 +553,19 @@ module("Unit | Controller | topic", function (hooks) {
assert.strictEqual(
controller.selectedPostsCount,
2,
- "It should select two, the post and its replies"
+ "selects two, the post and its replies"
);
controller.send("togglePostSelection", { id: 1 });
assert.strictEqual(
controller.selectedPostsCount,
1,
- "It should be selecting one only "
+ "is selecting one only"
);
assert.strictEqual(
controller.selectedPostIds[0],
2,
- "It should be selecting the reply id "
+ "is selecting the reply id"
);
controller.send("selectReplies", { id: 1 });
@@ -574,7 +574,7 @@ module("Unit | Controller | topic", function (hooks) {
assert.strictEqual(
controller.selectedPostsCount,
2,
- "It should be selecting two, even if reply was already selected"
+ "is selecting two, even if reply was already selected"
);
});
@@ -591,7 +591,7 @@ module("Unit | Controller | topic", function (hooks) {
post: placeholder,
}),
undefined,
- "it should work with a post-placeholder"
+ "works with a post-placeholder"
);
});
@@ -620,7 +620,7 @@ module("Unit | Controller | topic", function (hooks) {
controller.send("deletePost", post);
next(() => {
- assert.ok(destroyed, "post was destroyed");
+ assert.true(destroyed, "post was destroyed");
done();
});
});
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js b/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js
index 3ac979b3fd3..970433317bc 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js
@@ -9,10 +9,10 @@ module("Unit | Utility | category-badge", function (hooks) {
setupTest(hooks);
test("categoryBadge without a category", function (assert) {
- assert.blank(categoryBadgeHTML(), "it returns no HTML");
+ assert.blank(categoryBadgeHTML(), "returns no HTML");
});
- test("Regular categoryBadge", function (assert) {
+ test("regular categoryBadge", function (assert) {
const store = getOwner(this).lookup("service:store");
const category = store.createRecord("category", {
name: "hello",
@@ -23,11 +23,11 @@ module("Unit | Utility | category-badge", function (hooks) {
});
const tag = $.parseHTML(categoryBadgeHTML(category))[0];
- assert.strictEqual(tag.tagName, "A", "it creates a `a` wrapper tag");
+ assert.strictEqual(tag.tagName, "A", "creates a `a` wrapper tag");
assert.strictEqual(
tag.className.trim(),
"badge-category__wrapper",
- "it has the correct class"
+ "has the correct class"
);
const label = tag.children[0];
@@ -37,7 +37,7 @@ module("Unit | Utility | category-badge", function (hooks) {
assert.strictEqual(
label.children[0].innerText,
"hello",
- "it has the category name"
+ "has the category name"
);
});
@@ -48,7 +48,7 @@ module("Unit | Utility | category-badge", function (hooks) {
assert.blank(
tag.attributes["style"],
- "it has no color style because there are no colors"
+ "has no color style because there are no colors"
);
});
@@ -56,9 +56,9 @@ module("Unit | Utility | category-badge", function (hooks) {
const store = getOwner(this).lookup("service:store");
const category = store.createRecord("category", { name: "hello", id: 123 });
- assert.notOk(
+ assert.false(
categoryBadgeHTML(category).includes("topic-count"),
- "it does not include topic count by default"
+ "does not include topic count by default"
);
assert.true(
categoryBadgeHTML(category, { topicCount: 20 }).indexOf("topic-count") >
@@ -79,11 +79,11 @@ module("Unit | Utility | category-badge", function (hooks) {
assert.blank(
categoryBadgeHTML(uncategorized),
- "it doesn't return HTML for uncategorized by default"
+ "doesn't return HTML for uncategorized by default"
);
assert.present(
categoryBadgeHTML(uncategorized, { allowUncategorized: true }),
- "it returns HTML"
+ "returns HTML"
);
});
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/dag-test.js b/app/assets/javascripts/discourse/tests/unit/lib/dag-test.js
index c944d2a57be..b6db15e0c0b 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/dag-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/dag-test.js
@@ -5,18 +5,16 @@ import DAG from "discourse/lib/dag";
module("Unit | Lib | DAG", function (hooks) {
setupTest(hooks);
- let dag;
-
- test("DAG.from should create a DAG instance from the provided entries", function (assert) {
- dag = DAG.from([
+ test("DAG.from creates a DAG instance from the provided entries", function (assert) {
+ const dag = DAG.from([
["key1", "value1", { after: "key2" }],
["key2", "value2", { before: "key3" }],
["key3", "value3", { before: "key1" }],
]);
- assert.ok(dag.has("key1"));
- assert.ok(dag.has("key2"));
- assert.ok(dag.has("key3"));
+ assert.true(dag.has("key1"));
+ assert.true(dag.has("key2"));
+ assert.true(dag.has("key3"));
const resolved = dag.resolve();
const keys = resolved.map((entry) => entry.key);
@@ -24,32 +22,32 @@ module("Unit | Lib | DAG", function (hooks) {
assert.deepEqual(keys, ["key2", "key3", "key1"]);
});
- test("should add items to the map", function (assert) {
- dag = new DAG();
+ test("adds items to the map", function (assert) {
+ const dag = new DAG();
dag.add("key1", "value1");
dag.add("key2", "value2");
dag.add("key3", "value3");
- assert.ok(dag.has("key1"));
- assert.ok(dag.has("key2"));
- assert.ok(dag.has("key3"));
+ assert.true(dag.has("key1"));
+ assert.true(dag.has("key2"));
+ assert.true(dag.has("key3"));
// adding a new item
- assert.ok(
+ assert.true(
dag.add("key4", "value4"),
"adding an item returns true when the item is added"
);
- assert.ok(dag.has("key4"));
+ assert.true(dag.has("key4"));
// adding an item that already exists
- assert.notOk(
+ assert.false(
dag.add("key1", "value1"),
"adding an item returns false when the item already exists"
);
});
- test("should not throw an error when throwErrorOnCycle is false when adding an item creates a cycle", function (assert) {
- dag = new DAG({
+ test("does not throw an error when throwErrorOnCycle is false when adding an item creates a cycle", function (assert) {
+ const dag = new DAG({
throwErrorOnCycle: false,
defaultPosition: { before: "key3" },
});
@@ -60,9 +58,9 @@ module("Unit | Lib | DAG", function (hooks) {
// This would normally cause a cycle if throwErrorOnCycle was true
dag.add("key3", "value3", { after: "key1" });
- assert.ok(dag.has("key1"));
- assert.ok(dag.has("key2"));
- assert.ok(dag.has("key3"));
+ assert.true(dag.has("key1"));
+ assert.true(dag.has("key2"));
+ assert.true(dag.has("key3"));
const resolved = dag.resolve();
const keys = resolved.map((entry) => entry.key);
@@ -71,10 +69,10 @@ module("Unit | Lib | DAG", function (hooks) {
assert.deepEqual(keys, ["key3", "key2", "key1"]);
});
- test("should call the method specified for onAddItem callback when an item is added", function (assert) {
+ test("calls the method specified for onAddItem callback when an item is added", function (assert) {
let called = 0;
- dag = new DAG({
+ const dag = new DAG({
onAddItem: () => {
called++;
},
@@ -87,28 +85,28 @@ module("Unit | Lib | DAG", function (hooks) {
assert.strictEqual(called, 1, "the callback was not called");
});
- test("should remove an item from the map", function (assert) {
- dag = new DAG();
+ test("removes an item from the map", function (assert) {
+ const dag = new DAG();
dag.add("key1", "value1");
dag.add("key2", "value2");
dag.add("key3", "value3");
let removed = dag.delete("key2");
- assert.ok(dag.has("key1"));
+ assert.true(dag.has("key1"));
assert.false(dag.has("key2"));
- assert.ok(dag.has("key3"));
+ assert.true(dag.has("key3"));
- assert.ok(removed, "delete returns true when the item is removed");
+ assert.true(removed, "delete returns true when the item is removed");
removed = dag.delete("key2");
- assert.notOk(removed, "delete returns false when the item doesn't exist");
+ assert.false(removed, "delete returns false when the item doesn't exist");
});
- test("should call the method specified for onDeleteItem callback when an item is removed", function (assert) {
+ test("calls the method specified for onDeleteItem callback when an item is removed", function (assert) {
let called = 0;
- dag = new DAG({
+ const dag = new DAG({
onDeleteItem: () => {
called++;
},
@@ -122,8 +120,8 @@ module("Unit | Lib | DAG", function (hooks) {
assert.strictEqual(called, 1, "the callback was not called");
});
- test("should replace the value from an item in the map", function (assert) {
- dag = new DAG();
+ test("replaces the value from an item in the map", function (assert) {
+ const dag = new DAG();
dag.add("key1", "value1");
dag.add("key2", "value2");
dag.add("key3", "value3");
@@ -136,7 +134,7 @@ module("Unit | Lib | DAG", function (hooks) {
["value1", "replaced-value2", "value3"],
"replace allows simply replacing the value"
);
- assert.ok(replaced, "replace returns true when the item is replaced");
+ assert.true(replaced, "replace returns true when the item is replaced");
// also changing the position
dag.replace("key2", "replaced-value2-again", { before: "key1" });
@@ -149,13 +147,13 @@ module("Unit | Lib | DAG", function (hooks) {
// replacing an item that doesn't exist
replaced = dag.replace("key4", "replaced-value4");
- assert.notOk(replaced, "replace returns false when the item doesn't exist");
+ assert.false(replaced, "replace returns false when the item doesn't exist");
});
- test("should call the method specified for onReplaceItem callback when an item is replaced", function (assert) {
+ test("calls the method specified for onReplaceItem callback when an item is replaced", function (assert) {
let called = 0;
- dag = new DAG({
+ const dag = new DAG({
onReplaceItem: () => {
called++;
},
@@ -169,14 +167,14 @@ module("Unit | Lib | DAG", function (hooks) {
assert.strictEqual(called, 1, "the callback was not called");
});
- test("should reposition an item in the map", function (assert) {
- dag = new DAG();
+ test("repositions an item in the map", function (assert) {
+ const dag = new DAG();
dag.add("key1", "value1");
dag.add("key2", "value2");
dag.add("key3", "value3");
let repositioned = dag.reposition("key3", { before: "key1" });
- assert.ok(
+ assert.true(
repositioned,
"reposition returns true when the item is repositioned"
);
@@ -188,16 +186,16 @@ module("Unit | Lib | DAG", function (hooks) {
// repositioning an item that doesn't exist
repositioned = dag.reposition("key4", { before: "key1" });
- assert.notOk(
+ assert.false(
repositioned,
"reposition returns false when the item doesn't exist"
);
});
- test("should call the method specified for onRepositionItem callback when an item is repositioned", function (assert) {
+ test("calls the method specified for onRepositionItem callback when an item is repositioned", function (assert) {
let called = 0;
- dag = new DAG({
+ const dag = new DAG({
onRepositionItem: () => {
called++;
},
@@ -211,14 +209,14 @@ module("Unit | Lib | DAG", function (hooks) {
assert.strictEqual(called, 1, "the callback was not called");
});
- test("should return the entries in the map", function (assert) {
+ test("returns the entries in the map", function (assert) {
const entries = [
["key1", "value1", { after: "key2" }],
["key2", "value2", { before: "key3" }],
["key3", "value3", { before: "key1" }],
];
- dag = DAG.from(entries);
+ const dag = DAG.from(entries);
const dagEntries = dag.entries();
entries.forEach((entry, index) => {
@@ -241,8 +239,8 @@ module("Unit | Lib | DAG", function (hooks) {
});
});
- test("should resolve the map in the correct order", function (assert) {
- dag = new DAG();
+ test("resolves the map in the correct order", function (assert) {
+ const dag = new DAG();
dag.add("key1", "value1");
dag.add("key2", "value2");
dag.add("key3", "value3");
@@ -254,7 +252,7 @@ module("Unit | Lib | DAG", function (hooks) {
});
test("allows for custom before and after default positioning", function (assert) {
- dag = new DAG({ defaultPosition: { before: "key3", after: "key2" } });
+ const dag = new DAG({ defaultPosition: { before: "key3", after: "key2" } });
dag.add("key1", "value1", {});
dag.add("key2", "value2", { after: "key1" });
dag.add("key3", "value3", { after: "key2" });
@@ -277,8 +275,8 @@ module("Unit | Lib | DAG", function (hooks) {
);
});
- test("should resolve only existing keys", function (assert) {
- dag = new DAG();
+ test("resolves only existing keys", function (assert) {
+ const dag = new DAG();
dag.add("key1", "value1");
dag.add("key2", "value2", { before: "key1" });
dag.add("key3", "value3");
@@ -292,7 +290,7 @@ module("Unit | Lib | DAG", function (hooks) {
});
test("throws on bad positioning", function (assert) {
- dag = new DAG();
+ const dag = new DAG();
assert.throws(
() => dag.add("key1", "value1", { before: "key1" }),
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/download-calendar-test.js b/app/assets/javascripts/discourse/tests/unit/lib/download-calendar-test.js
index 28ad1797d14..b9d94a7acb9 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/download-calendar-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/download-calendar-test.js
@@ -102,7 +102,7 @@ END:VCALENDAR`
endsAt: "2021-10-12T16:00:00.000Z",
},
]);
- assert.ok(
+ assert.true(
window.open.calledWith(
"https://www.google.com/calendar/event?action=TEMPLATE&text=event&dates=20211012T150000Z%2F20211012T160000Z",
"_blank",
@@ -123,7 +123,7 @@ END:VCALENDAR`
],
{ recurrenceRule: "FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR" }
);
- assert.ok(
+ assert.true(
window.open.calledWith(
"https://www.google.com/calendar/event?action=TEMPLATE&text=event&dates=20211012T150000Z%2F20211012T160000Z&recur=RRULE%3AFREQ%3DDAILY%3BBYDAY%3DMO%2CTU%2CWE%2CTH%2CFR",
"_blank",
@@ -144,7 +144,7 @@ END:VCALENDAR`
],
{ location: "Paris" }
);
- assert.ok(
+ assert.true(
window.open.calledWith(
"https://www.google.com/calendar/event?action=TEMPLATE&text=event&dates=20211012T150000Z%2F20211012T160000Z&location=Paris",
"_blank",
@@ -165,7 +165,7 @@ END:VCALENDAR`
],
{ details: "Cool" }
);
- assert.ok(
+ assert.true(
window.open.calledWith(
"https://www.google.com/calendar/event?action=TEMPLATE&text=event&dates=20211012T150000Z%2F20211012T160000Z&details=Cool",
"_blank",
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/emoji-test.js b/app/assets/javascripts/discourse/tests/unit/lib/emoji-test.js
index 43296396de4..fcbcedd268e 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/emoji-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/emoji-test.js
@@ -172,7 +172,7 @@ module("Unit | Utility | emoji", function (hooks) {
test("search does partial-match on emoji aliases", function (assert) {
const matches = emojiSearch("instru");
- assert.ok(matches.includes("woman_teacher"));
- assert.ok(matches.includes("violin"));
+ assert.true(matches.includes("woman_teacher"));
+ assert.true(matches.includes("violin"));
});
});
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/i18n-test.js b/app/assets/javascripts/discourse/tests/unit/lib/i18n-test.js
index 4c2c22d29da..b7416d8fa01 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/i18n-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/i18n-test.js
@@ -117,9 +117,9 @@ module("Unit | Utility | i18n", function (hooks) {
assert.strictEqual(
I18n.defaultLocale,
"en",
- "it has English as default locale"
+ "has English as default locale"
);
- assert.ok(I18n.pluralizationRules["en"], "it has English pluralizer");
+ assert.true(!!I18n.pluralizationRules["en"], "has English pluralizer");
});
test("translations", function (assert) {
@@ -185,19 +185,19 @@ module("Unit | Utility | i18n", function (hooks) {
assert.strictEqual(
i18n("admin.dashboard.title"),
"Raporty",
- "it uses extra translations when they exists"
+ "uses extra translations when they exists"
);
assert.strictEqual(
i18n("admin.web_hooks.events.incoming", { count: 2 }),
"Istnieją 2 nowe wydarzenia.",
- "it uses pluralized extra translation when it exists"
+ "uses pluralized extra translation when it exists"
);
assert.strictEqual(
i18n("admin.dashboard.backup_count", { count: 2 }),
"2 backups",
- "it falls back to English and uses extra translations when they exists"
+ "falls back to English and uses extra translations when they exists"
);
});
@@ -360,11 +360,11 @@ module("Unit | Utility | i18n", function (hooks) {
});
test("messageFormat", function (assert) {
- assert.ok(
- I18n.messageFormat("posts_likes_MF", { count: 2, ratio: "high" }).match(
- /2 replies/
+ assert.true(
+ /2 replies/.test(
+ I18n.messageFormat("posts_likes_MF", { count: 2, ratio: "high" })
),
- "It works properly"
+ "works properly"
);
I18n._mfMessages = null;
assert.strictEqual(
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/keyboard-shortcuts-test.js b/app/assets/javascripts/discourse/tests/unit/lib/keyboard-shortcuts-test.js
index 2546d61edb2..752ab59540e 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/keyboard-shortcuts-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/keyboard-shortcuts-test.js
@@ -18,20 +18,20 @@ module("Unit | Utility | keyboard-shortcuts", function (hooks) {
});
KeyboardShortcuts.goBack();
- assert.ok(called, "history.back is called");
+ assert.true(called, "history.back is called");
});
test("nextSection calls _changeSection with 1", function (assert) {
let spy = sinon.spy(KeyboardShortcuts, "_changeSection");
KeyboardShortcuts.nextSection();
- assert.ok(spy.calledWith(1), "_changeSection is called with 1");
+ assert.true(spy.calledWith(1), "_changeSection is called with 1");
});
test("prevSection calls _changeSection with -1", function (assert) {
let spy = sinon.spy(KeyboardShortcuts, "_changeSection");
KeyboardShortcuts.prevSection();
- assert.ok(spy.calledWith(-1), "_changeSection is called with -1");
+ assert.true(spy.calledWith(-1), "_changeSection is called with -1");
});
});
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/link-lookup-test.js b/app/assets/javascripts/discourse/tests/unit/lib/link-lookup-test.js
index b5491226a7b..599e07713c6 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/link-lookup-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/link-lookup-test.js
@@ -17,7 +17,7 @@ module("Unit | Utility | link-lookup", function (hooks) {
});
test("works with https", function (assert) {
- assert.ok(
+ assert.true(
this.linkLookup.check(
this.post,
"https://en.wikipedia.org/wiki/handheld_game_console"
@@ -26,7 +26,7 @@ module("Unit | Utility | link-lookup", function (hooks) {
});
test("works with http", function (assert) {
- assert.ok(
+ assert.true(
this.linkLookup.check(
this.post,
"http://en.wikipedia.org/wiki/handheld_game_console"
@@ -35,7 +35,7 @@ module("Unit | Utility | link-lookup", function (hooks) {
});
test("works with trailing slash", function (assert) {
- assert.ok(
+ assert.true(
this.linkLookup.check(
this.post,
"https://en.wikipedia.org/wiki/handheld_game_console/"
@@ -44,7 +44,7 @@ module("Unit | Utility | link-lookup", function (hooks) {
});
test("works with uppercase characters", function (assert) {
- assert.ok(
+ assert.true(
this.linkLookup.check(
this.post,
"https://en.wikipedia.org/wiki/Handheld_game_console"
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.js b/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.js
index b7f06e9b9a3..29dd1d6fa49 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.js
@@ -31,7 +31,7 @@ module("Unit | Utility | oneboxer", function (hooks) {
assert.strictEqual(
loadOnebox(element),
undefined,
- "it returns early for a failed cache"
+ "returns early for a failed cache"
);
});
@@ -41,15 +41,15 @@ module("Unit | Utility | oneboxer", function (hooks) {
await loadOnebox(element);
- assert.ok(
+ assert.true(
localCache["http://somegoodurl.com"].outerHTML.includes(
"Yet another collaboration tool"
),
"stores the html of the onebox in a local cache"
);
- assert.ok(
+ assert.true(
loadOnebox(element).includes("Yet another collaboration tool"),
- "it returns the html from the cache"
+ "returns the html from the cache"
);
});
});
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/preload-store-test.js b/app/assets/javascripts/discourse/tests/unit/lib/preload-store-test.js
index 1337f9aa9ca..a42cf9509e7 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/preload-store-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/preload-store-test.js
@@ -61,7 +61,7 @@ module("Unit | Utility | preload-store", function (hooks) {
test("returns falsy values without calling finder", async function (assert) {
PreloadStore.store("falsy", false);
const result = await PreloadStore.getAndRemove("falsy", () =>
- assert.ok(false)
+ assert.true(false)
);
assert.false(result);
});
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/sanitizer-test.js b/app/assets/javascripts/discourse/tests/unit/lib/sanitizer-test.js
index a420061d694..9e92b50726e 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/sanitizer-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/sanitizer-test.js
@@ -43,7 +43,7 @@ module("Unit | Utility | sanitizer", function (hooks) {
cooked(
"hello<script>alert(42)</script>",
"<p>hello</p>",
- "it sanitizes while cooking"
+ "sanitizes while cooking"
);
cooked(
@@ -52,47 +52,47 @@ module("Unit | Utility | sanitizer", function (hooks) {
"we can embed proper links"
);
- cooked("<center>hello</center>", "hello", "it does not allow centering");
+ cooked("<center>hello</center>", "hello", "does not allow centering");
cooked(
"<blockquote>a\n</blockquote>\n",
"<blockquote>a\n</blockquote>",
- "it does not double sanitize"
+ "does not double sanitize"
);
cooked(
'<iframe src="http://discourse.org" width="100" height="42"></iframe>',
"",
- "it does not allow most iframes"
+ "does not allow most iframes"
);
cooked(
'<iframe src="https://www.google.com/maps/embed?pb=!1m10!1m8!1m3!1d2624.9983685732213!2d2.29432085!3d48.85824149999999!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sen!2s!4v1385737436368" width="100" height="42"></iframe>',
'<iframe src="https://www.google.com/maps/embed?pb=!1m10!1m8!1m3!1d2624.9983685732213!2d2.29432085!3d48.85824149999999!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sen!2s!4v1385737436368" width="100" height="42"></iframe>',
- "it allows iframe to google maps"
+ "allows iframe to google maps"
);
cooked(
'<iframe width="425" height="350" frameborder="0" marginheight="0" marginwidth="0" src="https://www.openstreetmap.org/export/embed.html?bbox=22.49454975128174%2C51.220338322410775%2C22.523088455200195%2C51.23345342732931&amp;layer=mapnik"></iframe>',
'<iframe width="425" height="350" frameborder="0" marginheight="0" marginwidth="0" src="https://www.openstreetmap.org/export/embed.html?bbox=22.49454975128174%2C51.220338322410775%2C22.523088455200195%2C51.23345342732931&amp;layer=mapnik"></iframe>',
- "it allows iframe to OpenStreetMap"
+ "allows iframe to OpenStreetMap"
);
cooked(
`BEFORE\n\n<iframe src=http://example.com>\n\nINSIDE\n\n</iframe>\n\nAFTER`,
`<p>BEFORE</p>\n\n<p>AFTER</p>`,
- "it strips unauthorized iframes - unallowed src"
+ "strips unauthorized iframes - unallowed src"
);
cooked(
`BEFORE\n\n<iframe src=''>\n\nINSIDE\n\n</iframe>\n\nAFTER`,
`<p>BEFORE</p>\n\n<p>AFTER</p>`,
- "it strips unauthorized iframes - empty src"
+ "strips unauthorized iframes - empty src"
);
cooked(
`BEFORE\n\n<iframe src='http://example.com'>\n\nAFTER`,
`<p>BEFORE</p>`,
- "it strips unauthorized partial iframes"
+ "strips unauthorized partial iframes"
);
assert.strictEqual(engine.sanitize("<textarea>hullo</textarea>"), "hullo");
@@ -109,29 +109,29 @@ module("Unit | Utility | sanitizer", function (hooks) {
cooked(
"[the answer](javascript:alert(42))",
"<p>[the answer](javascript:alert(42))</p>",
- "it prevents XSS"
+ "prevents XSS"
);
cooked(
'<i class="fa fa-bug fa-spin" style="font-size:600%"></i>\n<!-- -->',
"<p><i></i></p>",
- "it doesn't circumvent XSS with comments"
+ "doesn't circumvent XSS with comments"
);
cooked(
'<span class="-bbcode-s fa fa-spin">a</span>',
"<p><span>a</span></p>",
- "it sanitizes spans"
+ "sanitizes spans"
);
cooked(
'<span class="fa fa-spin -bbcode-s">a</span>',
"<p><span>a</span></p>",
- "it sanitizes spans"
+ "sanitizes spans"
);
cooked(
'<span class="bbcode-s">a</span>',
'<p><span class="bbcode-s">a</span></p>',
- "it sanitizes spans"
+ "sanitizes spans"
);
cooked(
@@ -216,26 +216,26 @@ module("Unit | Utility | sanitizer", function (hooks) {
test("autoplay videos must be muted", function (assert) {
let engine = build({ siteSettings: {} });
- assert.ok(
- engine
- .sanitize(
+ assert.true(
+ /muted/.test(
+ engine.sanitize(
`<p>Hey</p><video autoplay src="http://example.com/music.mp4"/>`
)
- .match(/muted/)
+ )
);
- assert.ok(
- engine
- .sanitize(
+ assert.true(
+ /muted/.test(
+ engine.sanitize(
`<p>Hey</p><video autoplay><source src="http://example.com/music.mp4" type="audio/mpeg"></video>`
)
- .match(/muted/)
+ )
);
- assert.ok(
- engine
- .sanitize(
+ assert.true(
+ /muted/.test(
+ engine.sanitize(
`<p>Hey</p><video autoplay muted><source src="http://example.com/music.mp4" type="audio/mpeg"></video>`
)
- .match(/muted/)
+ )
);
assert.false(
/muted/.test(
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/time-shortcut-test.js b/app/assets/javascripts/discourse/tests/unit/lib/time-shortcut-test.js
index 5efc3a54912..0615afa76ce 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/time-shortcut-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/time-shortcut-test.js
@@ -9,9 +9,7 @@ module(
"Unit | Lib | time-shortcut | hideDynamicTimeShortcuts",
function (hooks) {
hooks.afterEach(function () {
- if (this.clock) {
- this.clock.restore();
- }
+ this.clock?.restore();
});
test("hides 'Later Today' at the end of the day", function (assert) {
@@ -20,7 +18,7 @@ module(
this.clock = fakeTime("2100-04-19 08:00:00", timezone, true); // morning
let result = hideDynamicTimeShortcuts(shortcuts, timezone).mapBy("id");
- assert.ok(
+ assert.true(
result.includes("later_today"),
"shows later_today in the morning"
);
@@ -37,7 +35,7 @@ module(
this.clock = fakeTime("2100-04-21 18:00:00", timezone, true); // Wednesday
let result = hideDynamicTimeShortcuts(shortcuts, timezone).mapBy("id");
- assert.ok(
+ assert.true(
result.includes("later_this_week"),
"shows later_this_week on Wednesdays"
);
@@ -70,7 +68,7 @@ module(
timezone,
siteSettings
).mapBy("id");
- assert.ok(
+ assert.true(
result.includes("this_weekend"),
"shows this_weekend on Thursdays"
);
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/uploads-test.js b/app/assets/javascripts/discourse/tests/unit/lib/uploads-test.js
index 94133f0ed3c..ff3d421fe59 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/uploads-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/uploads-test.js
@@ -43,7 +43,7 @@ module("Unit | Utility | uploads", function (hooks) {
assert.false(
validateUploadedFiles([1, 2], { siteSettings: this.siteSettings })
);
- assert.ok(dialog.alert.calledWith(i18n("post.errors.too_many_uploads")));
+ assert.true(dialog.alert.calledWith(i18n("post.errors.too_many_uploads")));
});
test("new user cannot upload images", function (assert) {
@@ -57,7 +57,7 @@ module("Unit | Utility | uploads", function (hooks) {
}),
"the upload is not valid"
);
- assert.ok(
+ assert.true(
dialog.alert.calledWith(
i18n("post.errors.image_upload_not_allowed_for_new_user")
),
@@ -70,7 +70,7 @@ module("Unit | Utility | uploads", function (hooks) {
this.siteSettings.default_trust_level = 0;
sinon.stub(dialog, "alert");
- assert.ok(
+ assert.true(
validateUploadedFiles([{ name: "image.png" }], {
user: this.store.createRecord("user"),
siteSettings: this.siteSettings,
@@ -82,7 +82,7 @@ module("Unit | Utility | uploads", function (hooks) {
this.siteSettings.newuser_max_embedded_media = 0;
sinon.stub(dialog, "alert");
- assert.ok(
+ assert.true(
validateUploadedFiles([{ name: "image.png" }], {
user: this.store.createRecord("user", { trust_level: 1 }),
siteSettings: this.siteSettings,
@@ -100,7 +100,7 @@ module("Unit | Utility | uploads", function (hooks) {
siteSettings: this.siteSettings,
})
);
- assert.ok(
+ assert.true(
dialog.alert.calledWith(
i18n("post.errors.attachment_upload_not_allowed_for_new_user")
)
@@ -114,7 +114,7 @@ module("Unit | Utility | uploads", function (hooks) {
siteSettings: this.siteSettings,
})
);
- assert.ok(
+ assert.true(
dialog.alert.calledWith(
i18n("post.errors.upload_not_authorized", {
authorized_extensions: authorizedExtensions(
@@ -136,7 +136,7 @@ module("Unit | Utility | uploads", function (hooks) {
siteSettings: this.siteSettings,
})
);
- assert.ok(
+ assert.true(
validateUploadedFiles(files, {
skipValidation: true,
siteSettings: this.siteSettings,
@@ -155,7 +155,7 @@ module("Unit | Utility | uploads", function (hooks) {
siteSettings: this.siteSettings,
})
);
- assert.ok(
+ assert.true(
dialog.alert.calledWith(i18n("post.errors.no_uploads_authorized"))
);
});
@@ -171,7 +171,7 @@ module("Unit | Utility | uploads", function (hooks) {
siteSettings: this.siteSettings,
})
);
- assert.ok(
+ assert.true(
dialog.alert.calledWith(i18n("post.errors.no_uploads_authorized"))
);
});
@@ -185,7 +185,7 @@ module("Unit | Utility | uploads", function (hooks) {
assert.false(
validateUploadedFiles(files, { user, siteSettings: this.siteSettings })
);
- assert.ok(
+ assert.true(
validateUploadedFiles(files, {
isPrivateMessage: true,
allowStaffToUploadAnyFileInPm: true,
@@ -219,12 +219,12 @@ module("Unit | Utility | uploads", function (hooks) {
// image
let image = { name: "image.png", size: imageSize };
- assert.ok(
+ assert.true(
validateUploadedFiles([image], { user, siteSettings: this.siteSettings })
);
// pasted image
let pastedImage = dummyBlob();
- assert.ok(
+ assert.true(
validateUploadedFiles([pastedImage], {
user,
siteSettings: this.siteSettings,
@@ -238,8 +238,8 @@ module("Unit | Utility | uploads", function (hooks) {
["png", "webp", "jpg", "jpeg", "gif", "ico", "avif"].forEach(
(extension) => {
let image = "image." + extension;
- assert.ok(isImage(image), image + " is recognized as an image");
- assert.ok(
+ assert.true(isImage(image), image + " is recognized as an image");
+ assert.true(
isImage("http://foo.bar/path/to/" + image),
image + " is recognized as an image"
);
@@ -252,22 +252,22 @@ module("Unit | Utility | uploads", function (hooks) {
test("allowsImages", function (assert) {
this.siteSettings.authorized_extensions = "jpg|jpeg|gif";
- assert.ok(allowsImages(false, this.siteSettings), "works");
+ assert.true(allowsImages(false, this.siteSettings), "works");
this.siteSettings.authorized_extensions = ".jpg|.jpeg|.gif";
- assert.ok(
+ assert.true(
allowsImages(false, this.siteSettings),
"works with old extensions syntax"
);
this.siteSettings.authorized_extensions = "txt|pdf|*";
- assert.ok(
+ assert.true(
allowsImages(false, this.siteSettings),
"images are allowed when all extensions are allowed"
);
this.siteSettings.authorized_extensions = "json|jpg|pdf|txt";
- assert.ok(
+ assert.true(
allowsImages(false, this.siteSettings),
"images are allowed when at least one extension is an image extension"
);
@@ -281,19 +281,19 @@ module("Unit | Utility | uploads", function (hooks) {
);
this.siteSettings.authorized_extensions = "jpg|jpeg|gif|*";
- assert.ok(
+ assert.true(
allowsAttachments(false, this.siteSettings),
"attachments are allowed when all extensions are allowed"
);
this.siteSettings.authorized_extensions = "jpg|jpeg|gif|pdf";
- assert.ok(
+ assert.true(
allowsAttachments(false, this.siteSettings),
"attachments are allowed when at least one extension is not an image extension"
);
this.siteSettings.authorized_extensions = ".jpg|.jpeg|.gif|.pdf";
- assert.ok(
+ assert.true(
allowsAttachments(false, this.siteSettings),
"works with old extensions syntax"
);
@@ -369,7 +369,7 @@ module("Unit | Utility | uploads", function (hooks) {
{ max_attachment_size_kb: 4096, max_image_size_kb: 4096 },
"non-backup-tar-gz-file.tar.gz"
);
- assert.ok(
+ assert.true(
dialog.alert.calledWith(
i18n("post.errors.file_too_large_humanized", {
max_size: I18n.toHumanSize(4096 * 1024),
@@ -391,7 +391,7 @@ module("Unit | Utility | uploads", function (hooks) {
{ max_attachment_size_kb: 4096, max_image_size_kb: 4096 },
"backup-2023-09-07-092329-v20230728055813.tar.gz"
);
- assert.ok(
+ assert.true(
dialog.alert.calledWith(i18n("post.errors.backup_too_large")),
"the alert is called"
);
@@ -406,7 +406,10 @@ module("Unit | Utility | uploads", function (hooks) {
{ max_attachment_size_kb: 1024, max_image_size_kb: 1024 },
"test.png"
);
- assert.ok(dialog.alert.calledWith("upload failed"), "the alert is called");
+ assert.true(
+ dialog.alert.calledWith("upload failed"),
+ "the alert is called"
+ );
});
test("displayErrorForUpload - jquery file upload - jqXHR missing, errors present", function (assert) {
@@ -418,7 +421,10 @@ module("Unit | Utility | uploads", function (hooks) {
{ max_attachment_size_kb: 1024, max_image_size_kb: 1024 },
"test.png"
);
- assert.ok(dialog.alert.calledWith("upload failed"), "the alert is called");
+ assert.true(
+ dialog.alert.calledWith("upload failed"),
+ "the alert is called"
+ );
});
test("displayErrorForUpload - jquery file upload - no errors", function (assert) {
@@ -431,7 +437,7 @@ module("Unit | Utility | uploads", function (hooks) {
},
"test.png"
);
- assert.ok(
+ assert.true(
dialog.alert.calledWith(
i18n("post.errors.upload", { file_name: "test.png" })
),
@@ -449,6 +455,9 @@ module("Unit | Utility | uploads", function (hooks) {
"test.png",
{ max_attachment_size_kb: 1024, max_image_size_kb: 1024 }
);
- assert.ok(dialog.alert.calledWith("upload failed"), "the alert is called");
+ assert.true(
+ dialog.alert.calledWith("upload failed"),
+ "the alert is called"
+ );
});
});
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/url-test.js b/app/assets/javascripts/discourse/tests/unit/lib/url-test.js
index 7c169f29d28..9beedd6c0fd 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/url-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/url-test.js
@@ -108,9 +108,9 @@ module("Unit | Utility | url", function (hooks) {
});
sinon.stub(DiscourseURL, "handleURL");
DiscourseURL.routeTo("/my/messages");
- assert.ok(
+ assert.true(
DiscourseURL.handleURL.calledWith(`/my/messages`),
- "it should navigate to the messages page"
+ "navigates to the messages page"
);
});
@@ -124,33 +124,33 @@ module("Unit | Utility | url", function (hooks) {
});
DiscourseURL.routeTo("http://example.com/foo1");
- assert.ok(
+ assert.true(
DiscourseURL.handleURL.calledWith(`/foo1`),
- "it strips the protocol and domain when http"
+ "strips the protocol and domain when http"
);
DiscourseURL.routeTo("https://example.com/foo2");
- assert.ok(
+ assert.true(
DiscourseURL.handleURL.calledWith(`/foo2`),
- "it strips the protocol and domain when https"
+ "strips the protocol and domain when https"
);
DiscourseURL.routeTo("//example.com/foo3");
- assert.ok(
+ assert.true(
DiscourseURL.handleURL.calledWith(`/foo3`),
- "it strips the protocol and domain when protocol-less"
+ "strips the protocol and domain when protocol-less"
);
DiscourseURL.routeTo("https://example.com/t//1");
- assert.ok(
+ assert.true(
DiscourseURL.handleURL.calledWith(`/t//1`),
- "it does not strip double-slash in the middle of urls"
+ "does not strip double-slash in the middle of urls"
);
DiscourseURL.routeTo("/t//2");
- assert.ok(
+ assert.true(
DiscourseURL.handleURL.calledWith(`/t//2`),
- "it does not strip double-slash in the middle of urls, even without a domain"
+ "does not strip double-slash in the middle of urls, even without a domain"
);
});
@@ -161,9 +161,9 @@ module("Unit | Utility | url", function (hooks) {
});
sinon.stub(DiscourseURL, "handleURL");
DiscourseURL.routeTo("/myfeed");
- assert.ok(
+ assert.true(
DiscourseURL.handleURL.calledWith(`/myfeed`),
- "it should navigate to the unmodified route"
+ "navigates to the unmodified route"
);
});
@@ -224,7 +224,7 @@ module("Unit | Utility | url", function (hooks) {
sinon.stub(DiscourseURL, "redirectTo");
sinon.stub(DiscourseURL, "handleURL");
DiscourseURL.routeTo("/secure-uploads/original/1X/test.pdf");
- assert.ok(
+ assert.true(
DiscourseURL.redirectTo.calledWith("/secure-uploads/original/1X/test.pdf")
);
});
@@ -233,11 +233,11 @@ module("Unit | Utility | url", function (hooks) {
sinon.stub(DiscourseURL, "jumpToElement");
sinon.stub(DiscourseURL, "replaceState");
DiscourseURL.routeTo("#heading1");
- assert.ok(
+ assert.true(
DiscourseURL.jumpToElement.calledWith("heading1"),
"in-page anchors call jumpToElement"
);
- assert.ok(
+ assert.true(
DiscourseURL.replaceState.calledWith("#heading1"),
"in-page anchors call replaceState with the url fragment"
);
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/utilities-test.js b/app/assets/javascripts/discourse/tests/unit/lib/utilities-test.js
index f074439b10a..d3845d98a3f 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/utilities-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/utilities-test.js
@@ -53,11 +53,11 @@ module("Unit | Utilities", function (hooks) {
});
test("emailValid", function (assert) {
- assert.ok(
+ assert.true(
emailValid("[email protected]"),
"allows upper case in the first part of emails"
);
- assert.ok(
+ assert.true(
emailValid("[email protected]"),
"allows upper case in the email domain"
);
diff --git a/app/assets/javascripts/discourse/tests/unit/models/composer-test.js b/app/assets/javascripts/discourse/tests/unit/models/composer-test.js
index 05faa8489a9..820f9e0e7cb 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/composer-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/composer-test.js
@@ -431,7 +431,7 @@ module("Unit | Model | composer", function (hooks) {
"composer.title_or_link_placeholder",
"placeholder invites you to paste a link"
);
- assert.ok(composer.canEditTopicFeaturedLink, "can paste link");
+ assert.true(composer.canEditTopicFeaturedLink, "can paste link");
});
test("targetRecipientsArray contains types", function (assert) {
diff --git a/app/assets/javascripts/discourse/tests/unit/models/email-log-test.js b/app/assets/javascripts/discourse/tests/unit/models/email-log-test.js
index d34347a3a3a..7f2b1c01e19 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/email-log-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/email-log-test.js
@@ -8,9 +8,9 @@ module("Unit | Model | email-log", function (hooks) {
test("create", function (assert) {
const store = getOwner(this).lookup("service:store");
- assert.ok(
- store.createRecord("email-log"),
- "it can be created without arguments"
+ assert.true(
+ !!store.createRecord("email-log"),
+ "can be created without arguments"
);
});
diff --git a/app/assets/javascripts/discourse/tests/unit/models/invite-test.js b/app/assets/javascripts/discourse/tests/unit/models/invite-test.js
index d22b00888a7..ecd5c902ff0 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/invite-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/invite-test.js
@@ -7,9 +7,9 @@ module("Unit | Model | invite", function (hooks) {
test("create", function (assert) {
const store = getOwner(this).lookup("service:store");
- assert.ok(
- store.createRecord("invite"),
- "it can be created without arguments"
+ assert.true(
+ !!store.createRecord("invite"),
+ "can be created without arguments"
);
});
});
diff --git a/app/assets/javascripts/discourse/tests/unit/models/post-test.js b/app/assets/javascripts/discourse/tests/unit/models/post-test.js
index 6221591c5b6..e1e471446d3 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/post-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/post-test.js
@@ -17,7 +17,7 @@ module("Unit | Model | post", function (hooks) {
test("new_user", function (assert) {
const post = this.store.createRecord("post", { trust_level: 0 });
- assert.ok(post.new_user, "post is from a new user");
+ assert.true(post.new_user, "post is from a new user");
post.set("trust_level", 1);
assert.false(post.new_user, "post is no longer from a new user");
diff --git a/app/assets/javascripts/discourse/tests/unit/models/private-message-topic-tracking-state-test.js b/app/assets/javascripts/discourse/tests/unit/models/private-message-topic-tracking-state-test.js
index 0d68d76ac77..4adfb9f40d4 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/private-message-topic-tracking-state-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/private-message-topic-tracking-state-test.js
@@ -39,7 +39,7 @@ module("Unit | Model | private-message-topic-tracking-state", function (hooks) {
pmTopicTrackingState.set("isTracking", true);
pmTopicTrackingState.removeTopics([]);
- assert.ok(callbackCalled);
+ assert.true(callbackCalled);
});
});
diff --git a/app/assets/javascripts/discourse/tests/unit/models/report-test.js b/app/assets/javascripts/discourse/tests/unit/models/report-test.js
index be11324a07a..d138612c0ad 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/report-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/report-test.js
@@ -8,12 +8,10 @@ function reportWithData(data) {
return store.createRecord("report", {
type: "topics",
- data: data.map((val, index) => {
- return {
- x: moment().subtract(index, "days").format("YYYY-MM-DD"),
- y: val,
- };
- }),
+ data: data.map((val, index) => ({
+ x: moment().subtract(index, "days").format("YYYY-MM-DD"),
+ y: val,
+ })),
});
}
@@ -85,8 +83,8 @@ module("Unit | Model | report", function (hooks) {
this,
[6, 8, 5, 2, 1]
).yesterdayCountTitle;
- assert.ok(title.includes("+60%"));
- assert.ok(title.match(/Was 5/));
+ assert.true(title.includes("+60%"));
+ assert.true(/Was 5/.test(title));
});
test("yesterdayCountTitle when two days ago was 0", function (assert) {
@@ -95,7 +93,7 @@ module("Unit | Model | report", function (hooks) {
[6, 8, 0, 2, 1]
).yesterdayCountTitle;
assert.false(title.includes("%"));
- assert.ok(title.match(/Was 0/));
+ assert.true(/Was 0/.test(title));
});
test("sevenDaysCountTitle", function (assert) {
@@ -103,22 +101,22 @@ module("Unit | Model | report", function (hooks) {
this,
[100, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 100, 100]
).sevenDaysCountTitle;
- assert.ok(title.match(/-50%/));
- assert.ok(title.match(/Was 14/));
+ assert.true(/-50%/.test(title));
+ assert.true(/Was 14/.test(title));
});
test("thirtyDaysCountTitle", function (assert) {
const report = reportWithData.call(this, [5, 5, 5, 5]);
report.set("prev30Days", 10);
- assert.ok(report.thirtyDaysCountTitle.includes("+50%"));
- assert.ok(report.thirtyDaysCountTitle.match(/Was 10/));
+ assert.true(report.thirtyDaysCountTitle.includes("+50%"));
+ assert.true(/Was 10/.test(report.thirtyDaysCountTitle));
const report2 = reportWithData.call(this, [5, 5, 5, 5]);
report2.set("prev_period", 20);
- assert.ok(report2.thirtyDaysCountTitle.includes("-25%"));
- assert.ok(report2.thirtyDaysCountTitle.match(/Was 20/));
+ assert.true(report2.thirtyDaysCountTitle.includes("-25%"));
+ assert.true(/Was 20/.test(report2.thirtyDaysCountTitle));
});
test("sevenDaysTrend", function (assert) {
diff --git a/app/assets/javascripts/discourse/tests/unit/models/rest-model-test.js b/app/assets/javascripts/discourse/tests/unit/models/rest-model-test.js
index fd2e4244944..2b998945a38 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/rest-model-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/rest-model-test.js
@@ -20,27 +20,31 @@ module("Unit | Model | rest-model", function (hooks) {
getOwner(this).register("model:grape", Grape);
const g = store.createRecord("grape", { store, percent: 0.4 });
- assert.strictEqual(g.inverse, 0.6, "it runs `munge` on `create`");
+ assert.strictEqual(g.inverse, 0.6, "runs `munge` on `create`");
});
test("update", async function (assert) {
const store = getOwner(this).lookup("service:store");
const widget = await store.find("widget", 123);
assert.strictEqual(widget.name, "Trout Lure");
- assert.false(widget.isSaving, "it is not saving");
+ assert.false(widget.isSaving, "is not saving");
const spyBeforeUpdate = sinon.spy(widget, "beforeUpdate");
const spyAfterUpdate = sinon.spy(widget, "afterUpdate");
const promise = widget.update({ name: "new name" });
- assert.true(widget.isSaving, "it is saving");
+ assert.true(widget.isSaving, "is saving");
assert.true(spyBeforeUpdate.calledOn(widget));
const result = await promise;
assert.true(spyAfterUpdate.calledOn(widget));
- assert.false(widget.isSaving, "it is no longer saving");
+ assert.false(widget.isSaving, "is no longer saving");
assert.strictEqual(widget.name, "new name");
- assert.ok(result.target, "it has a reference to the record");
+ assert.notStrictEqual(
+ result.target,
+ undefined,
+ "has a reference to the record"
+ );
assert.strictEqual(result.target.name, widget.name);
});
@@ -61,25 +65,29 @@ module("Unit | Model | rest-model", function (hooks) {
const store = getOwner(this).lookup("service:store");
const widget = store.createRecord("widget");
- assert.true(widget.isNew, "it is a new record");
- assert.false(widget.isCreated, "it is not created");
- assert.false(widget.isSaving, "it is not saving");
+ assert.true(widget.isNew, "is a new record");
+ assert.false(widget.isCreated, "is not created");
+ assert.false(widget.isSaving, "is not saving");
const spyBeforeCreate = sinon.spy(widget, "beforeCreate");
const spyAfterCreate = sinon.spy(widget, "afterCreate");
const promise = widget.save({ name: "Evil Widget" });
- assert.true(widget.isSaving, "it is not saving");
+ assert.true(widget.isSaving, "is not saving");
assert.true(spyBeforeCreate.calledOn(widget));
const result = await promise;
assert.true(spyAfterCreate.calledOn(widget));
- assert.false(widget.isSaving, "it is no longer saving");
- assert.ok(widget.id, "it has an id");
- assert.ok(widget.name, "Evil Widget");
- assert.true(widget.isCreated, "it is created");
- assert.false(widget.isNew, "it is no longer new");
+ assert.false(widget.isSaving, "is no longer saving");
+ assert.notStrictEqual(widget.id, undefined, "has an id");
+ assert.strictEqual(widget.name, "Evil Widget");
+ assert.true(widget.isCreated, " is created");
+ assert.false(widget.isNew, "is no longer new");
- assert.ok(result.target, "it has a reference to the record");
+ assert.notStrictEqual(
+ result.target,
+ undefined,
+ "has a reference to the record"
+ );
assert.strictEqual(result.target.name, widget.name);
});
@@ -100,7 +108,9 @@ module("Unit | Model | rest-model", function (hooks) {
const store = getOwner(this).lookup("service:store");
const widget = await store.find("widget", 123);
- assert.ok(await widget.destroyRecord());
+ assert.deepEqual(await widget.destroyRecord(), {
+ success: true,
+ });
});
test("custom api name", async function (assert) {
@@ -122,7 +132,7 @@ module("Unit | Model | rest-model", function (hooks) {
// Create
const widget = store.createRecord("my-widget");
await widget.save({ name: "Evil Widget" });
- assert.strictEqual(widget.id, 100, "it saved a new record successfully");
+ assert.strictEqual(widget.id, 100, "saved a new record successfully");
assert.strictEqual(widget.name, "Evil Widget");
// Update
diff --git a/app/assets/javascripts/discourse/tests/unit/models/site-test.js b/app/assets/javascripts/discourse/tests/unit/models/site-test.js
index dd8b5670576..32c274f3845 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/site-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/site-test.js
@@ -8,7 +8,7 @@ module("Unit | Model | site", function (hooks) {
test("create", function (assert) {
const store = getOwner(this).lookup("service:store");
- assert.ok(store.createRecord("site"), "it can create with no parameters");
+ assert.true(!!store.createRecord("site"), "can create with no parameters");
});
test("instance", function (assert) {
diff --git a/app/assets/javascripts/discourse/tests/unit/models/staff-action-log-test.js b/app/assets/javascripts/discourse/tests/unit/models/staff-action-log-test.js
index 0bae105a513..520eb75c219 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/staff-action-log-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/staff-action-log-test.js
@@ -7,9 +7,9 @@ module("Unit | Model | staff-action-log", function (hooks) {
test("create", function (assert) {
const store = getOwner(this).lookup("service:store");
- assert.ok(
- store.createRecord("staff-action-log"),
- "it can be created without arguments"
+ assert.true(
+ !!store.createRecord("staff-action-log"),
+ "can be created without arguments"
);
});
});
diff --git a/app/assets/javascripts/discourse/tests/unit/models/tag-test.js b/app/assets/javascripts/discourse/tests/unit/models/tag-test.js
index ae3941afeab..5f508f5f0e3 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/tag-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/tag-test.js
@@ -26,6 +26,6 @@ module("Unit | Model | tag", function (hooks) {
tag.set("pm_only", true);
- assert.ok(tag.pmOnly);
+ assert.true(tag.pmOnly);
});
});
diff --git a/app/assets/javascripts/discourse/tests/unit/models/theme-test.js b/app/assets/javascripts/discourse/tests/unit/models/theme-test.js
index 264f1bfc162..bd3f27a25d6 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/theme-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/theme-test.js
@@ -16,26 +16,22 @@ module("Unit | Model | theme", function (hooks) {
],
});
- assert.ok(
+ assert.true(
theme.settings[0] instanceof ThemeSettings,
- "should be an instance of ThemeSettings"
+ "is an instance of ThemeSettings"
);
- assert.ok(
+ assert.true(
theme.settings[1] instanceof ThemeSettings,
- "should be an instance of ThemeSettings"
+ "is an instance of ThemeSettings"
);
});
- test("can add an upload correctly", function (assert) {
+ test("adds an upload correctly", function (assert) {
const store = getOwner(this).lookup("service:store");
const theme = store.createRecord("theme");
- assert.strictEqual(
- theme.uploads.length,
- 0,
- "uploads should be an empty array"
- );
+ assert.strictEqual(theme.uploads.length, 0, "uploads are an empty array");
theme.setField("common", "bob", "", 999, 2);
let fields = theme.theme_fields;
diff --git a/app/assets/javascripts/discourse/tests/unit/models/topic-test.js b/app/assets/javascripts/discourse/tests/unit/models/topic-test.js
index bfe5d1b65f5..15b112ee26c 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/topic-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/topic-test.js
@@ -28,10 +28,10 @@ module("Unit | Model | topic", function (hooks) {
assert.false(topic.visited, "not visited unless we've read all the posts");
topic.set("last_read_post_number", 2);
- assert.ok(topic.visited, "is visited once we've read all the posts");
+ assert.true(topic.visited, "is visited once we've read all the posts");
topic.set("last_read_post_number", 3);
- assert.ok(
+ assert.true(
topic.visited,
"is visited if we've read all the posts and some are deleted at the end"
);
diff --git a/app/assets/javascripts/discourse/tests/unit/models/topic-tracking-state-test.js b/app/assets/javascripts/discourse/tests/unit/models/topic-tracking-state-test.js
index b574a7571f1..7753a779952 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/topic-tracking-state-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/topic-tracking-state-test.js
@@ -380,7 +380,7 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
trackingState.loadStates([{ topic_id: 111 }, { topic_id: 222 }]);
trackingState.set("_trackedTopicLimit", 5);
trackingState.sync(list, "unread");
- assert.ok(
+ assert.true(
trackingState.states.has("t111"),
"expect state for topic 111 not to be deleted"
);
@@ -591,7 +591,7 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
1,
"increments message count"
);
- assert.ok(
+ assert.true(
DiscourseURL.redirectTo.calledWith("/"),
"redirect to / because topic is destroyed"
);
diff --git a/app/assets/javascripts/discourse/tests/unit/models/user-badge-test.js b/app/assets/javascripts/discourse/tests/unit/models/user-badge-test.js
index dac19347ced..177ea0741b9 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/user-badge-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/user-badge-test.js
@@ -34,7 +34,7 @@ module("Unit | Model | user-badge", function (hooks) {
const userBadges = UserBadge.createFromJson(
cloneJSON(badgeFixtures["/user-badges/:username"])
);
- assert.ok(Array.isArray(userBadges), "returns an array");
+ assert.true(Array.isArray(userBadges), "returns an array");
assert.strictEqual(
userBadges[0].granted_by,
undefined,
@@ -44,12 +44,12 @@ module("Unit | Model | user-badge", function (hooks) {
test("findByUsername", async function (assert) {
const badges = await UserBadge.findByUsername("anne3");
- assert.ok(Array.isArray(badges), "returns an array");
+ assert.true(Array.isArray(badges), "returns an array");
});
test("findByBadgeId", async function (assert) {
const badges = await UserBadge.findByBadgeId(880);
- assert.ok(Array.isArray(badges), "returns an array");
+ assert.true(Array.isArray(badges), "returns an array");
});
test("grant", async function (assert) {
@@ -70,6 +70,6 @@ module("Unit | Model | user-badge", function (hooks) {
assert.strictEqual(userBadge.is_favorite, undefined);
await userBadge.favorite();
- assert.ok(userBadge.is_favorite);
+ assert.true(userBadge.is_favorite);
});
});
diff --git a/app/assets/javascripts/discourse/tests/unit/models/user-test.js b/app/assets/javascripts/discourse/tests/unit/models/user-test.js
index 64ca4d036f4..f0412ed1996 100644
--- a/app/assets/javascripts/discourse/tests/unit/models/user-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/models/user-test.js
@@ -36,13 +36,13 @@ module("Unit | Model | user", function (hooks) {
test("isAllowedToUploadAFile", function (assert) {
const store = getOwner(this).lookup("service:store");
const user = store.createRecord("user", { trust_level: 0, admin: true });
- assert.ok(
+ assert.true(
user.isAllowedToUploadAFile("image"),
"admin can always upload a file"
);
user.setProperties({ admin: false, moderator: true });
- assert.ok(
+ assert.true(
user.isAllowedToUploadAFile("image"),
"moderator can always upload a file"
);
@@ -111,7 +111,7 @@ module("Unit | Model | user", function (hooks) {
User.createCurrent();
- assert.ok(spyMomentGuess.notCalled);
+ assert.false(spyMomentGuess.called);
});
test("subsequent calls to trackStatus and stopTrackingStatus increase and decrease subscribers counter", function (assert) {
diff --git a/app/assets/javascripts/discourse/tests/unit/services/current-user-test.js b/app/assets/javascripts/discourse/tests/unit/services/current-user-test.js
index f455f2c7e66..60287493be6 100644
--- a/app/assets/javascripts/discourse/tests/unit/services/current-user-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/services/current-user-test.js
@@ -6,6 +6,6 @@ acceptance("current-user", function (needs) {
test("currentUser has appEvents", function (assert) {
let currentUser = this.container.lookup("service:current-user");
- assert.ok(currentUser.appEvents);
+ assert.notStrictEqual(currentUser.appEvents, undefined);
});
});
diff --git a/app/assets/javascripts/discourse/tests/unit/services/header-test.js b/app/assets/javascripts/discourse/tests/unit/services/header-test.js
index e0b7b69aa40..d7accf33cf5 100644
--- a/app/assets/javascripts/discourse/tests/unit/services/header-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/services/header-test.js
@@ -11,8 +11,8 @@ module("Unit | Service | header", function (hooks) {
test("it registers hiders", function (assert) {
this.header.registerHider(this, ["search", "login"]);
- assert.ok(this.header.headerButtonsHidden.includes("search"));
- assert.ok(this.header.headerButtonsHidden.includes("login"));
+ assert.true(this.header.headerButtonsHidden.includes("search"));
+ assert.true(this.header.headerButtonsHidden.includes("login"));
});
test("it does not register invalid buttons for hiders", function (assert) {
diff --git a/app/assets/javascripts/discourse/tests/unit/services/presence-test.js b/app/assets/javascripts/discourse/tests/unit/services/presence-test.js
index f96006d132b..3f00fd87726 100644
--- a/app/assets/javascripts/discourse/tests/unit/services/presence-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/services/presence-test.js
@@ -214,8 +214,8 @@ module("Unit | Service | presence | subscribing", function (hooks) {
await channelDup.subscribe();
assert.true(channelDup.subscribed, "channelDup can subscribe");
- assert.ok(
- channelDup._presenceState,
+ assert.true(
+ !!channelDup._presenceState,
"channelDup has a valid internal state"
);
assert.strictEqual(
diff --git a/app/assets/javascripts/discourse/tests/unit/services/site-settings-test.js b/app/assets/javascripts/discourse/tests/unit/services/site-settings-test.js
index f70090b12aa..21362a7cc44 100644
--- a/app/assets/javascripts/discourse/tests/unit/services/site-settings-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/services/site-settings-test.js
@@ -21,7 +21,7 @@ module("Unit | Service | site-settings", function (hooks) {
});
test("contains settings", function (assert) {
- assert.ok(this.siteSettings.title);
+ assert.strictEqual(typeof this.siteSettings.title, "string");
});
test("notifies getters", function (assert) {
diff --git a/app/assets/javascripts/discourse/tests/unit/services/toasts-test.js b/app/assets/javascripts/discourse/tests/unit/services/toasts-test.js
index 3f93b5f788d..66e0b256655 100644
--- a/app/assets/javascripts/discourse/tests/unit/services/toasts-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/services/toasts-test.js
@@ -16,6 +16,6 @@ module("Unit | Service | Toasts", function (hooks) {
this.toasts.show({ views: ["mobile"], data: { text: "foo" } });
- assert.ok(this.toasts.activeToasts.length < 2);
+ assert.true(this.toasts.activeToasts.length < 2);
});
});
diff --git a/eslint.config.mjs b/eslint.config.mjs
index e2719b865db..84b836f4480 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -7,6 +7,11 @@ export default [
"ember/no-classic-classes": "error",
"discourse/i18n-import-location": "error",
"discourse/i18n-t": "error",
+ "qunit/no-assert-equal-boolean": "error",
+ "qunit/no-assert-equal": "error",
+ "qunit/no-loose-assertions": "error",
+ "qunit/no-negated-ok": "error",
+ "qunit/no-ok-equality": "error",
},
},
{
diff --git a/plugins/chat/test/javascripts/unit/lib/chat-audio-test.js b/plugins/chat/test/javascripts/unit/lib/chat-audio-test.js
index 301b16b4c81..49b82f66f8f 100644
--- a/plugins/chat/test/javascripts/unit/lib/chat-audio-test.js
+++ b/plugins/chat/test/javascripts/unit/lib/chat-audio-test.js
@@ -44,70 +44,70 @@ module("Discourse Chat | Unit | chat-audio", function (hooks) {
});
});
- test("it registers desktop notification handler", function (assert) {
- assert.ok(this.stub.calledOnce);
+ test("registers desktop notification handler", function (assert) {
+ assert.true(this.stub.calledOnce);
});
- test("it plays chat sound", async function (assert) {
+ test("plays chat sound", async function (assert) {
await this.handleNotification();
- assert.ok(this.playStub.calledOnce);
+ assert.true(this.playStub.calledOnce);
});
- test("it skips chat sound for user in DND mode", async function (assert) {
+ test("skips chat sound for user in DND mode", async function (assert) {
this.currentUser.isInDoNotDisturb = () => true;
await this.handleNotification();
- assert.ok(this.playStub.notCalled);
+ assert.true(this.playStub.notCalled);
});
- test("it skips chat sound for user with no chat sound set", async function (assert) {
+ test("skips chat sound for user with no chat sound set", async function (assert) {
this.currentUser.chat_sound = null;
await this.handleNotification();
- assert.ok(this.playStub.notCalled);
+ assert.true(this.playStub.notCalled);
});
- test("it plays a chat sound for mentions", async function (assert) {
+ test("plays a chat sound for mentions", async function (assert) {
this.currentUser.user_option.chat_header_indicator_preference =
"only_mentions";
await this.handleNotification({ notification_type: 29 });
- assert.ok(this.playStub.calledOnce);
+ assert.true(this.playStub.calledOnce);
});
- test("it skips chat sound for non-mentions", async function (assert) {
+ test("skips chat sound for non-mentions", async function (assert) {
this.currentUser.user_option.chat_header_indicator_preference =
"only_mentions";
await this.handleNotification();
- assert.ok(this.playStub.notCalled);
+ assert.true(this.playStub.notCalled);
});
- test("it plays a chat sound for DMs", async function (assert) {
+ test("plays a chat sound for DMs", async function (assert) {
this.currentUser.user_option.chat_header_indicator_preference =
"dm_and_mentions";
await this.handleNotification({ is_direct_message_channel: true });
- assert.ok(this.playStub.calledOnce);
+ assert.true(this.playStub.calledOnce);
});
- test("it skips chat sound for non-DM messages", async function (assert) {
+ test("skips chat sound for non-DM messages", async function (assert) {
this.currentUser.user_option.chat_header_indicator_preference =
"dm_and_mentions";
await this.handleNotification({ is_direct_message_channel: false });
- assert.ok(this.playStub.notCalled);
+ assert.true(this.playStub.notCalled);
});
- test("it skips chat sound when service worker returns false", async function (assert) {
+ test("skips chat sound when service worker returns false", async function (assert) {
chatAudioInitializer.canPlaySound.returns(Promise.resolve(false));
await this.handleNotification();
- assert.ok(this.playStub.notCalled);
+ assert.true(this.playStub.notCalled);
});
});
diff --git a/plugins/chat/test/javascripts/unit/services/chat-emoji-picker-manager-test.js b/plugins/chat/test/javascripts/unit/services/chat-emoji-picker-manager-test.js
index 8020d41a441..435d491ff9b 100644
--- a/plugins/chat/test/javascripts/unit/services/chat-emoji-picker-manager-test.js
+++ b/plugins/chat/test/javascripts/unit/services/chat-emoji-picker-manager-test.js
@@ -50,8 +50,10 @@ module(
test("open", async function (assert) {
this.manager.open({ context: "chat-composer" });
- assert.ok(this.manager.loading);
- assert.ok(this.manager.picker);
+ assert.true(this.manager.loading);
+ assert.deepEqual(this.manager.picker, {
+ context: "chat-composer",
+ });
assert.strictEqual(this.manager.picker.context, "chat-composer");
assert.deepEqual(this.manager.visibleSections, [
"favorites",
@@ -91,14 +93,18 @@ module(
test("close", async function (assert) {
this.manager.open({ context: "channel-composer" });
- assert.ok(this.manager.picker);
+ assert.deepEqual(this.manager.picker, {
+ context: "channel-composer",
+ });
this.manager.addVisibleSections("objects");
this.manager.lastVisibleSection = "objects";
this.manager.close();
- assert.ok(this.manager.closing);
- assert.ok(this.manager.picker);
+ assert.true(this.manager.closing);
+ assert.deepEqual(this.manager.picker, {
+ context: "channel-composer",
+ });
await settled();
diff --git a/plugins/chat/test/javascripts/unit/services/chat-guardian-test.js b/plugins/chat/test/javascripts/unit/services/chat-guardian-test.js
index 9cad263ae26..d2fa1893220 100644
--- a/plugins/chat/test/javascripts/unit/services/chat-guardian-test.js
+++ b/plugins/chat/test/javascripts/unit/services/chat-guardian-test.js
@@ -52,7 +52,7 @@ acceptance("Discourse Chat | Unit | Service | chat-guardian", function (needs) {
set(this.currentUser, "has_chat_enabled", true);
set(this.currentUser, "admin", true);
this.siteSettings.chat_enabled = true;
- assert.ok(this.chatGuardian.canEditChatChannel());
+ assert.true(this.chatGuardian.canEditChatChannel());
});
test("#canUseChat", async function (assert) {
@@ -66,7 +66,7 @@ acceptance("Discourse Chat | Unit | Service | chat-guardian", function (needs) {
set(this.currentUser, "has_chat_enabled", true);
this.siteSettings.chat_enabled = true;
- assert.ok(this.chatGuardian.canUseChat());
+ assert.true(this.chatGuardian.canUseChat());
});
test("#canArchiveChannel", async function (assert) {
@@ -76,7 +76,7 @@ acceptance("Discourse Chat | Unit | Service | chat-guardian", function (needs) {
set(this.currentUser, "admin", true);
this.siteSettings.chat_enabled = true;
this.siteSettings.chat_allow_archiving_channels = true;
- assert.ok(this.chatGuardian.canArchiveChannel(channel));
+ assert.true(this.chatGuardian.canArchiveChannel(channel));
set(this.currentUser, "admin", false);
set(this.currentUser, "moderator", false);
diff --git a/plugins/chat/test/javascripts/unit/services/chat-state-manager-test.js b/plugins/chat/test/javascripts/unit/services/chat-state-manager-test.js
index deb6edd7b68..7a8c896f723 100644
--- a/plugins/chat/test/javascripts/unit/services/chat-state-manager-test.js
+++ b/plugins/chat/test/javascripts/unit/services/chat-state-manager-test.js
@@ -26,7 +26,7 @@ module(
this.subject.prefersFullPage();
- assert.ok(this.subject.isFullPagePreferred);
+ assert.true(this.subject.isFullPagePreferred);
this.subject.prefersDrawer();
@@ -35,11 +35,11 @@ module(
this.subject.prefersDrawer();
Site.currentProp("mobileView", true);
- assert.ok(this.subject.isFullPagePreferred);
+ assert.true(this.subject.isFullPagePreferred);
});
test("isDrawerPreferred", function (assert) {
- assert.ok(this.subject.isDrawerPreferred);
+ assert.true(this.subject.isDrawerPreferred);
this.subject.prefersFullPage();
@@ -47,7 +47,7 @@ module(
this.subject.prefersDrawer();
- assert.ok(this.subject.isDrawerPreferred);
+ assert.true(this.subject.isDrawerPreferred);
});
test("lastKnownChatURL", function (assert) {
@@ -76,7 +76,7 @@ module(
assert.false(this.subject.isFullPageActive);
sinon.stub(this.subject.router, "currentRouteName").value("chat");
- assert.ok(this.subject.isFullPageActive);
+ assert.true(this.subject.isFullPageActive);
});
test("didCollapseDrawer", function (assert) {
diff --git a/plugins/chat/test/javascripts/unit/utility/plugin-api-test.js b/plugins/chat/test/javascripts/unit/utility/plugin-api-test.js
index caca49db3f3..2294c6237e7 100644
--- a/plugins/chat/test/javascripts/unit/utility/plugin-api-test.js
+++ b/plugins/chat/test/javascripts/unit/utility/plugin-api-test.js
@@ -55,7 +55,7 @@ module("Chat | Unit | Utility | plugin-api", function (hooks) {
// assert that the initial secondary actions are present
const secondaryActions = interactor.secondaryActions;
- assert.ok(secondaryActions.length > 0);
+ assert.true(secondaryActions.length > 0);
try {
// remove the first secondary action listed
@@ -64,7 +64,7 @@ module("Chat | Unit | Utility | plugin-api", function (hooks) {
const updatedSecondaryActions = interactor.secondaryActions;
// assert that the secondary action was removed
- assert.ok(
+ assert.true(
updatedSecondaryActions.length < secondaryActions.length,
"the updated secondary actions must contain less items than the original"
);
diff --git a/plugins/discourse-local-dates/test/javascripts/acceptance/local-dates-composer-test.js b/plugins/discourse-local-dates/test/javascripts/acceptance/local-dates-composer-test.js
index 65c9f54a8a0..2a4a0c5fdbf 100644
--- a/plugins/discourse-local-dates/test/javascripts/acceptance/local-dates-composer-test.js
+++ b/plugins/discourse-local-dates/test/javascripts/acceptance/local-dates-composer-test.js
@@ -1,10 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit";
-import {
- acceptance,
- query,
- queryAll,
-} from "discourse/tests/helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
acceptance("Local Dates - composer", function (needs) {
@@ -85,10 +81,9 @@ acceptance("Local Dates - composer", function (needs) {
await timezoneChooser.expand();
await timezoneChooser.selectRowByValue("Asia/Macau");
- assert.ok(
- query(".preview .discourse-local-date").textContent.includes("Macau"),
- "it outputs a preview date in selected timezone"
- );
+ assert
+ .dom(".preview .discourse-local-date")
+ .includesText("Macau", "outputs a preview date in selected timezone");
});
test("date modal - controls", async function (assert) {
@@ -101,38 +96,31 @@ acceptance("Local Dates - composer", function (needs) {
await click('.pika-table td[data-day="5"] > .pika-button');
- assert.ok(
- query("#from-date-time").textContent.includes("5,"),
- "selected FROM date works"
- );
+ assert
+ .dom("#from-date-time")
+ .includesText("5,", "selected FROM date works");
await click(".date-time-control.to .date-time");
- assert.strictEqual(
- queryAll(".pika-table .is-disabled").length,
- 4,
- "date just before selected FROM date is disabled"
- );
+ assert
+ .dom(".pika-table .is-disabled")
+ .exists({ count: 4 }, "date just before selected FROM date is disabled");
await click('.pika-table td[data-day="10"] > .pika-button');
- assert.ok(
- query(".date-time-control.to button").textContent.includes("10,"),
- "selected TO date works"
- );
+ assert
+ .dom(".date-time-control.to button")
+ .includesText("10,", "selected TO date works");
- assert.strictEqual(
- query(".pika-table .is-selected").textContent,
- "10",
- "selected date is the 10th"
- );
+ assert
+ .dom(".pika-table .is-selected")
+ .hasText("10", "selected date is the 10th");
await click(".delete-to-date");
- assert.notOk(
- query(".date-time-control.to.is-selected"),
- "deleting selected TO date works"
- );
+ assert
+ .dom(".date-time-control.to.is-selected")
+ .doesNotExist("deleting selected TO date works");
await click(".advanced-mode-btn");
diff --git a/plugins/discourse-local-dates/test/javascripts/lib/date-with-zone-helper-test.js b/plugins/discourse-local-dates/test/javascripts/lib/date-with-zone-helper-test.js
index 79d2602bb8a..a1d2bc39c27 100644
--- a/plugins/discourse-local-dates/test/javascripts/lib/date-with-zone-helper-test.js
+++ b/plugins/discourse-local-dates/test/javascripts/lib/date-with-zone-helper-test.js
@@ -124,9 +124,9 @@ module("lib:date-with-zone-helper", function () {
minute: 36,
timezone: PARIS,
});
- assert.ok(date.isDST());
+ assert.true(date.isDST());
futureLocalDate = date.add(1, "year");
- assert.ok(futureLocalDate.isDST());
+ assert.true(futureLocalDate.isDST());
assert.strictEqual(
futureLocalDate.format(),
"2021-04-25T15:36:00.000+02:00",
@@ -142,7 +142,7 @@ module("lib:date-with-zone-helper", function () {
});
assert.false(date.isDST());
futureLocalDate = date.add(1, "week");
- assert.ok(futureLocalDate.isDST());
+ assert.true(futureLocalDate.isDST());
assert.strictEqual(
futureLocalDate.format(),
"2020-04-01T15:36:00.000+02:00",
@@ -157,7 +157,7 @@ module("lib:date-with-zone-helper", function () {
timezone: PARIS,
});
- assert.ok(date.isDST());
+ assert.true(date.isDST());
futureLocalDate = date.add(8, "months");
assert.false(futureLocalDate.isDST());
assert.strictEqual(
diff --git a/plugins/poll/test/javascripts/acceptance/poll-breakdown-test.js b/plugins/poll/test/javascripts/acceptance/poll-breakdown-test.js
index 5d7a325c383..81c88e636c7 100644
--- a/plugins/poll/test/javascripts/acceptance/poll-breakdown-test.js
+++ b/plugins/poll/test/javascripts/acceptance/poll-breakdown-test.js
@@ -1,6 +1,6 @@
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
-import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Poll breakdown", function (needs) {
needs.user();
@@ -80,9 +80,10 @@ acceptance("Poll breakdown", function (needs) {
"renders a chart for each of the groups in group_results response"
);
- assert.ok(
- query(".poll-breakdown-chart-container > canvas").$chartjs,
- "$chartjs is defined on the pie charts"
+ assert.notStrictEqual(
+ document.querySelector(".poll-breakdown-chart-container > canvas")
+ .$chartjs,
+ undefined
);
});
@@ -92,26 +93,20 @@ acceptance("Poll breakdown", function (needs) {
await click("button.show-breakdown");
- assert.strictEqual(
- query(".poll-breakdown-option-count").textContent.trim(),
- "40.0%",
- "displays the correct vote percentage"
- );
+ assert
+ .dom(".poll-breakdown-option-count")
+ .hasText("40.0%", "displays the correct vote percentage");
await click(".modal-tabs .count");
- assert.strictEqual(
- query(".poll-breakdown-option-count").textContent.trim(),
- "2",
- "displays the correct vote count"
- );
+ assert
+ .dom(".poll-breakdown-option-count")
+ .hasText("2", "displays the correct vote count");
await click(".modal-tabs .percentage");
- assert.strictEqual(
- query(".poll-breakdown-option-count").textContent.trim(),
- "40.0%",
- "displays the percentage again"
- );
+ assert
+ .dom(".poll-breakdown-option-count")
+ .hasText("40.0%", "displays the percentage again");
});
});
diff --git a/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-desktop.js b/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-desktop.js
index 7cef705fc73..0e8be798ef8 100644
--- a/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-desktop.js
+++ b/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-desktop.js
@@ -1,6 +1,6 @@
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
-import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Rendering polls with bar charts - desktop", function (needs) {
needs.user();
@@ -41,71 +41,55 @@ acceptance("Rendering polls with bar charts - desktop", function (needs) {
test("Polls", async function (assert) {
await visit("/t/-/15");
- const polls = queryAll(".poll");
+ assert.dom(".poll").exists({ count: 2 }, "renders the polls correctly");
- assert.strictEqual(polls.length, 2, "it should render the polls correctly");
+ const polls = document.querySelectorAll(".poll");
+ assert
+ .dom(".info-number", polls[0])
+ .hasText("2", "displays the right number of votes");
- assert.strictEqual(
- queryAll(".info-number", polls[0]).text(),
- "2",
- "it should display the right number of votes"
- );
-
- assert.strictEqual(
- queryAll(".info-number", polls[1]).text(),
- "3",
- "it should display the right number of votes"
- );
+ assert
+ .dom(".info-number", polls[1])
+ .hasText("3", "displays the right number of votes");
});
test("Public poll", async function (assert) {
await visit("/t/-/14");
- const polls = queryAll(".poll");
- assert.strictEqual(polls.length, 1, "it should render the poll correctly");
+ assert.dom(".poll").exists({ count: 1 }, "renders the poll correctly");
await click("button.toggle-results");
- assert.strictEqual(
- queryAll(".poll-voters:nth-of-type(1) li").length,
- 25,
- "it should display the right number of voters"
- );
+ assert
+ .dom(".poll-voters:nth-of-type(1) li")
+ .exists({ count: 25 }, "displays the right number of voters");
await click(".poll-voters-toggle-expand:nth-of-type(1) a");
- assert.strictEqual(
- queryAll(".poll-voters:nth-of-type(1) li").length,
- 26,
- "it should display the right number of voters"
- );
+ assert
+ .dom(".poll-voters:nth-of-type(1) li")
+ .exists({ count: 26 }, "displays the right number of voters");
});
test("Public number poll", async function (assert) {
await visit("/t/-/13");
- const polls = queryAll(".poll");
- assert.strictEqual(polls.length, 1, "it should render the poll correctly");
+ assert.dom(".poll").exists({ count: 1 }, "renders the poll correctly");
await click("button.toggle-results");
- assert.strictEqual(
- queryAll(".poll-voters:nth-of-type(1) li").length,
- 25,
- "it should display the right number of voters"
- );
+ assert
+ .dom(".poll-voters:nth-of-type(1) li")
+ .exists({ count: 25 }, "displays the right number of voters");
- assert.notOk(
- queryAll(".poll-voters:nth-of-type(1) li:nth-of-type(1) a").attr("href"),
- "user URL does not exist"
- );
+ assert
+ .dom(".poll-voters:nth-of-type(1) li:nth-of-type(1) a")
+ .doesNotHaveAttribute("href", "user URL does not exist");
await click(".poll-voters-toggle-expand:nth-of-type(1) a");
- assert.strictEqual(
- queryAll(".poll-voters:nth-of-type(1) li").length,
- 30,
- "it should display the right number of voters"
- );
+ assert
+ .dom(".poll-voters:nth-of-type(1) li")
+ .exists({ count: 30 }, "displays the right number of voters");
});
});
diff --git a/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-mobile.js b/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-mobile.js
index 07f4f85d5a9..5e7e932d3b6 100644
--- a/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-mobile.js
+++ b/plugins/poll/test/javascripts/acceptance/polls-bar-chart-test-mobile.js
@@ -1,6 +1,6 @@
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
-import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Rendering polls with bar charts - mobile", function (needs) {
needs.user();
@@ -22,28 +22,22 @@ acceptance("Rendering polls with bar charts - mobile", function (needs) {
test("Public number poll", async function (assert) {
await visit("/t/-/13");
- const polls = queryAll(".poll");
- assert.strictEqual(polls.length, 1, "it should render the poll correctly");
+ assert.dom(".poll").exists({ count: 1 }, "renders the poll correctly");
await click("button.toggle-results");
- assert.strictEqual(
- queryAll(".poll-voters:nth-of-type(1) li").length,
- 25,
- "it should display the right number of voters"
- );
+ assert
+ .dom(".poll-voters:nth-of-type(1) li")
+ .exists({ count: 25 }, "displays the right number of voters");
- assert.notOk(
- queryAll(".poll-voters:nth-of-type(1) li:nth-of-type(1) a").attr("href"),
- "user URL does not exist"
- );
+ assert
+ .dom(".poll-voters:nth-of-type(1) li:nth-of-type(1) a")
+ .doesNotHaveAttribute("href", "user URL does not exist");
await click(".poll-voters-toggle-expand:nth-of-type(1) a");
- assert.strictEqual(
- queryAll(".poll-voters:nth-of-type(1) li").length,
- 35,
- "it should display the right number of voters"
- );
+ assert
+ .dom(".poll-voters:nth-of-type(1) li")
+ .exists({ count: 35 }, "displays the right number of voters");
});
});