Skip to content

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

DEV: Updates all `assert.equal` to qunit-dom or strictEqual (#29945)

Jarek Radoszed73d80cbd22
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 c1d9383fe99..d14648a65ab 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
@@ -270,7 +270,7 @@ acceptance("Admin - User Index", function (needs) {
test("grant admin - redirects to the 2fa page", async function (assert) {
await visit("/admin/users/4/user2");
await click(".grant-admin");
- assert.equal(
+ assert.strictEqual(
currentURL(),
"/session/2fa?nonce=some-nonce",
"user is redirected to the 2FA page"
@@ -293,11 +293,9 @@ acceptance("Admin - User Index", function (needs) {
await visit("/admin/users/5/user5");
await click(".btn-user-delete");
- assert.equal(
- query("#dialog-title").textContent,
- i18n("admin.user.delete_confirm_title"),
- "dialog has a title"
- );
+ assert
+ .dom("#dialog-title")
+ .hasText(i18n("admin.user.delete_confirm_title"), "dialog has a title");
await click(".dialog-footer .btn-primary");
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 43217dd2576..03d66f1e3f9 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/category-new-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/category-new-test.js
@@ -110,7 +110,7 @@ acceptance("New category preview", function (needs) {
.style.getPropertyValue("--category-badge-color")
.trim();
- assert.equal(previewBadgeColor, "#0088CC");
+ assert.strictEqual(previewBadgeColor, "#0088CC");
await fillIn(".hex-input", "FF00FF");
@@ -119,6 +119,6 @@ acceptance("New category preview", function (needs) {
.style.getPropertyValue("--category-badge-color")
.trim();
- assert.equal(previewBadgeColor, "#FF00FF");
+ assert.strictEqual(previewBadgeColor, "#FF00FF");
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-image-preview-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-image-preview-test.js
index 9e26e3aaa9e..8369a3fb9ef 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/composer-image-preview-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-image-preview-test.js
@@ -147,10 +147,8 @@ acceptance("Composer - Image Preview", function (needs) {
test("Editing alt text (with enter key) for single image in preview updates alt text in composer", async function (assert) {
const scaleButtonContainer = ".scale-btn-container";
- const readonlyAltText = ".alt-text";
const editAltTextButton = ".alt-text-edit-btn";
- const altTextInput = ".alt-text-input";
const altTextEditOk = ".alt-text-edit-ok";
const altTextEditCancel = ".alt-text-edit-cancel";
@@ -159,10 +157,10 @@ acceptance("Composer - Image Preview", function (needs) {
await click("#create-topic");
await fillIn(".d-editor-input", `![zorro|200x200](upload://zorro.png)`);
- assert.equal(query(readonlyAltText).innerText, "zorro", "correct alt text");
- assert.dom(readonlyAltText).isVisible("alt text is visible");
+ assert.dom(".alt-text").hasText("zorro", "correct alt text");
+ assert.dom(".alt-text").isVisible("alt text is visible");
assert.dom(editAltTextButton).isVisible("alt text edit button is visible");
- assert.dom(altTextInput).isNotVisible("alt text input is hidden");
+ assert.dom(".alt-text-input").isNotVisible("alt text input is hidden");
assert.dom(altTextEditOk).isNotVisible("alt text edit ok button is hidden");
assert
.dom(altTextEditCancel)
@@ -171,40 +169,32 @@ acceptance("Composer - Image Preview", function (needs) {
await click(editAltTextButton);
assert.dom(scaleButtonContainer).isNotVisible("scale buttons are hidden");
- assert.dom(readonlyAltText).isNotVisible("alt text is hidden");
+ assert.dom(".alt-text").isNotVisible("alt text is hidden");
assert
.dom(editAltTextButton)
.isNotVisible("alt text edit button is hidden");
- assert.dom(altTextInput).isVisible("alt text input is visible");
+ assert.dom(".alt-text-input").isVisible("alt text input is visible");
assert.dom(altTextEditOk).isVisible("alt text edit ok button is visible");
assert.dom(altTextEditCancel).isVisible("alt text edit cancel is hidden");
- assert.equal(
- query(altTextInput).value,
- "zorro",
- "correct alt text in input"
- );
+ assert
+ .dom(".alt-text-input")
+ .hasValue("zorro", "correct alt text in input");
- await triggerKeyEvent(altTextInput, "keypress", "[");
- await triggerKeyEvent(altTextInput, "keypress", "]");
- assert.equal(query(altTextInput).value, "zorro", "does not input [ ] keys");
+ await triggerKeyEvent(".alt-text-input", "keypress", "[");
+ await triggerKeyEvent(".alt-text-input", "keypress", "]");
+ assert.dom(".alt-text-input").hasValue("zorro", "does not input [ ] keys");
- await fillIn(altTextInput, "steak");
- await triggerKeyEvent(altTextInput, "keypress", 13);
+ await fillIn(".alt-text-input", "steak");
+ await triggerKeyEvent(".alt-text-input", "keypress", 13);
- assert.equal(
- query(".d-editor-input").value,
- "![steak|200x200](upload://zorro.png)",
- "alt text updated"
- );
- assert.equal(
- query(readonlyAltText).innerText,
- "steak",
- "shows the alt text"
- );
+ assert
+ .dom(".d-editor-input")
+ .hasValue("![steak|200x200](upload://zorro.png)", "alt text updated");
+ assert.dom(".alt-text").hasText("steak", "shows the alt text");
assert.dom(editAltTextButton).isVisible("alt text edit button is visible");
assert.dom(scaleButtonContainer).isVisible("scale buttons are visible");
assert.dom(editAltTextButton).isVisible("alt text edit button is visible");
- assert.dom(altTextInput).isNotVisible("alt text input is hidden");
+ assert.dom(".alt-text-input").isNotVisible("alt text input is hidden");
assert.dom(altTextEditOk).isNotVisible("alt text edit ok button is hidden");
assert
.dom(altTextEditCancel)
@@ -213,7 +203,6 @@ acceptance("Composer - Image Preview", function (needs) {
test("Editing alt text (with check button) in preview updates alt text in composer", async function (assert) {
const scaleButtonContainer = ".scale-btn-container";
- const readonlyAltText = ".alt-text";
const editAltTextButton = ".alt-text-edit-btn";
const altTextInput = ".alt-text-input";
@@ -230,16 +219,10 @@ acceptance("Composer - Image Preview", function (needs) {
await fillIn(altTextInput, "steak");
await click(altTextEditOk);
- assert.equal(
- query(".d-editor-input").value,
- "![steak|200x200](upload://zorro.png)",
- "alt text updated"
- );
- assert.equal(
- query(readonlyAltText).innerText,
- "steak",
- "shows the alt text"
- );
+ assert
+ .dom(".d-editor-input")
+ .hasValue("![steak|200x200](upload://zorro.png)", "alt text updated");
+ assert.dom(".alt-text").hasText("steak", "shows the alt text");
assert.dom(editAltTextButton).isVisible("alt text edit button is visible");
assert.dom(scaleButtonContainer).isVisible("scale buttons are visible");
@@ -254,7 +237,6 @@ acceptance("Composer - Image Preview", function (needs) {
test("Cancel alt text edit in preview does not update alt text in composer", async function (assert) {
const scaleButtonContainer = ".scale-btn-container";
- const readonlyAltText = ".alt-text";
const editAltTextButton = ".alt-text-edit-btn";
const altTextInput = ".alt-text-input";
@@ -271,16 +253,10 @@ acceptance("Composer - Image Preview", function (needs) {
await fillIn(altTextInput, "steak");
await click(altTextEditCancel);
- assert.equal(
- query(".d-editor-input").value,
- "![zorro|200x200](upload://zorro.png)",
- "alt text not updated"
- );
- assert.equal(
- query(readonlyAltText).innerText,
- "zorro",
- "shows the unedited alt text"
- );
+ assert
+ .dom(".d-editor-input")
+ .hasValue("![zorro|200x200](upload://zorro.png)", "alt text not updated");
+ assert.dom(".alt-text").hasText("zorro", "shows the unedited alt text");
assert.dom(editAltTextButton).isVisible("alt text edit button is visible");
assert.dom(scaleButtonContainer).isVisible("scale buttons are visible");
@@ -308,15 +284,15 @@ acceptance("Composer - Image Preview", function (needs) {
await fillIn(altTextInput, "tomtom");
await triggerKeyEvent(altTextInput, "keypress", "Enter");
- assert.equal(
- query(".d-editor-input").value,
- `![tomtom|200x200](upload://zorro.png) ![not-zorro|200x200](upload://not-zorro.png)`,
- "the correct image's alt text updated"
- );
+ assert
+ .dom(".d-editor-input")
+ .hasValue(
+ `![tomtom|200x200](upload://zorro.png) ![not-zorro|200x200](upload://not-zorro.png)`,
+ "the correct image's alt text updated"
+ );
});
test("Deleting alt text for image empties alt text in composer and allows further modification", async function (assert) {
- const altText = ".alt-text";
const editAltTextButton = ".alt-text-edit-btn";
const altTextInput = ".alt-text-input";
@@ -330,23 +306,19 @@ acceptance("Composer - Image Preview", function (needs) {
await fillIn(altTextInput, "");
await triggerKeyEvent(altTextInput, "keypress", "Enter");
- assert.equal(
- query(".d-editor-input").value,
- "![|200x200](upload://zorro.png)",
- "alt text updated"
- );
- assert.equal(query(altText).innerText, "", "shows the alt text");
+ assert
+ .dom(".d-editor-input")
+ .hasValue("![|200x200](upload://zorro.png)", "alt text updated");
+ assert.dom(".alt-text").hasText("", "shows the alt text");
await click(editAltTextButton);
await fillIn(altTextInput, "tomtom");
await triggerKeyEvent(altTextInput, "keypress", "Enter");
- assert.equal(
- query(".d-editor-input").value,
- "![tomtom|200x200](upload://zorro.png)",
- "alt text updated"
- );
+ assert
+ .dom(".d-editor-input")
+ .hasValue("![tomtom|200x200](upload://zorro.png)", "alt text updated");
});
test("Image delete button", async function (assert) {
@@ -371,17 +343,14 @@ acceptance("Composer - Image Preview", function (needs) {
"Image should be removed from the editor"
);
- assert.equal(
+ assert.false(
query(".d-editor-input").value.includes("image_example_0"),
- false,
- "It shouldn't have the first image"
+ "does not have the first image"
);
- assert.equal(
- query(".d-editor-input").value.includes("image_example_1"),
- true,
- "It should have the second image"
- );
+ assert
+ .dom(".d-editor-input")
+ .hasValue(/image_example_1/, "has the second image");
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-uploads-uppy-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-uploads-uppy-test.js
index 55cf0b015bb..a19d00d7fb9 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/composer-uploads-uppy-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-uploads-uppy-test.js
@@ -436,8 +436,8 @@ acceptance("Uppy Composer Attachment - Upload Placeholder", function (needs) {
// after uploading we have this in the textarea:
// "The image:\n![avatar.PNG|690x320](upload://yoj8pf9DdIeHRRULyw7i57GAYdz.jpeg)\ntext after image"
// cursor should be just before "text after image":
- assert.equal(input.selectionStart, 76);
- assert.equal(input.selectionEnd, 76);
+ assert.strictEqual(input.selectionStart, 76);
+ assert.strictEqual(input.selectionEnd, 76);
done();
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/header-api-test.gjs b/app/assets/javascripts/discourse/tests/acceptance/header-api-test.gjs
index d31f1c8202f..2c06e016380 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/header-api-test.gjs
+++ b/app/assets/javascripts/discourse/tests/acceptance/header-api-test.gjs
@@ -29,7 +29,7 @@ acceptance("Header API - anonymous", function () {
await visit("/");
const testButton = document.querySelector(".test-button");
const authButtons = document.querySelector(".auth-buttons");
- assert.equal(
+ assert.strictEqual(
testButton.compareDocumentPosition(authButtons),
Node.DOCUMENT_POSITION_FOLLOWING,
"Test button is positioned before auth-buttons"
@@ -57,7 +57,7 @@ acceptance("Header API - anonymous", function () {
await visit("/");
const testIcon = document.querySelector(".test-icon");
const search = document.querySelector(".search-dropdown");
- assert.equal(
+ assert.strictEqual(
testIcon.compareDocumentPosition(search),
Node.DOCUMENT_POSITION_FOLLOWING,
"Test icon is positioned before search icon"
@@ -95,7 +95,7 @@ acceptance("Glimmer Header API - authenticated", function (needs) {
await visit("/");
const test1 = document.querySelector(".test1-button");
const test2 = document.querySelector(".test2-button");
- assert.equal(
+ assert.strictEqual(
test2.compareDocumentPosition(test1),
Node.DOCUMENT_POSITION_FOLLOWING,
"Test2 button is positioned before Test1 button"
@@ -129,7 +129,7 @@ acceptance("Glimmer Header API - authenticated", function (needs) {
await visit("/");
const test1 = document.querySelector(".test1-icon");
const test2 = document.querySelector(".test2-icon");
- assert.equal(
+ assert.strictEqual(
test2.compareDocumentPosition(test1),
Node.DOCUMENT_POSITION_FOLLOWING,
"Test2 icon is positioned before Test1 icon"
diff --git a/app/assets/javascripts/discourse/tests/acceptance/lightbox-test.js b/app/assets/javascripts/discourse/tests/acceptance/lightbox-test.js
index fb151886131..9e9730d8cf0 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/lightbox-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/lightbox-test.js
@@ -1,7 +1,7 @@
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
import topicFixtures from "discourse/tests/fixtures/topic";
-import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object";
acceptance("Lightbox", function (needs) {
@@ -30,10 +30,9 @@ acceptance("Lightbox", function (needs) {
await visit("/t/internationalization-localization/280");
await click(".lightbox");
- assert.equal(
- query(".mfp-title").textContent,
- "image · 1500×842 234 KB · download · original image"
- );
+ assert
+ .dom(".mfp-title")
+ .hasText("image · 1500×842 234 KB · download · original image");
assert
.dom(".image-source-link:nth-child(1)")
diff --git a/app/assets/javascripts/discourse/tests/acceptance/post-history-test.js b/app/assets/javascripts/discourse/tests/acceptance/post-history-test.js
index 7091e0e094c..acab345e102 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/post-history-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/post-history-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("Post - History", function (needs) {
needs.user();
@@ -52,8 +52,8 @@ acceptance("Post - History", function (needs) {
await click("article[data-post-id='419'] .edits button");
assert.dom(".discourse-tag").exists({ count: 4 });
assert.dom(".discourse-tag.diff-del").exists({ count: 1 });
- assert.equal(query(".discourse-tag.diff-del").textContent, "tag1");
+ assert.dom(".discourse-tag.diff-del").hasText("tag1");
assert.dom(".discourse-tag.diff-ins").exists({ count: 1 });
- assert.equal(query(".discourse-tag.diff-ins").textContent, "tag3");
+ assert.dom(".discourse-tag.diff-ins").hasText("tag3");
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/review-test.js b/app/assets/javascripts/discourse/tests/acceptance/review-test.js
index 6954402f4de..24a6d1e4338 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/review-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/review-test.js
@@ -185,8 +185,8 @@ acceptance("Review", function (needs) {
let tags = selectKit(`${topic} .payload-tags .mini-tag-chooser`);
requests = [];
await tags.expand();
- assert.equal(requests.length, 1);
- assert.equal(requests[0].queryParams.categoryId, "6");
+ assert.strictEqual(requests.length, 1);
+ assert.strictEqual(requests[0].queryParams.categoryId, "6");
await tags.fillInFilter("monkey");
await tags.selectRowByValue("monkey");
diff --git a/app/assets/javascripts/discourse/tests/acceptance/second-factor-auth-test.js b/app/assets/javascripts/discourse/tests/acceptance/second-factor-auth-test.js
index 628214824fb..8b454813d5a 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/second-factor-auth-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/second-factor-auth-test.js
@@ -1,7 +1,7 @@
import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit";
import { SECOND_FACTOR_METHODS } from "discourse/models/user";
-import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
const { TOTP, BACKUP_CODE, SECURITY_KEY } = SECOND_FACTOR_METHODS;
@@ -93,11 +93,12 @@ acceptance("Second Factor Auth Page", function (needs) {
test("when challenge data fails to load", async function (assert) {
await visit("/session/2fa?nonce=failed");
- assert.equal(
- query(".alert-error").textContent,
- "could not find an active challenge in your session",
- "load error message is shown"
- );
+ assert
+ .dom(".alert-error")
+ .hasText(
+ "could not find an active challenge in your session",
+ "load error message is shown"
+ );
});
test("default 2FA method", async function (assert) {
@@ -241,34 +242,36 @@ acceptance("Second Factor Auth Page", function (needs) {
test("2FA action description", async function (assert) {
await visit("/session/2fa?nonce=ok111111");
- assert.equal(
- query(".action-description").textContent.trim(),
- "This is an additional description that can be customized per action",
- "action description is rendered on the page"
- );
+ assert
+ .dom(".action-description")
+ .hasText(
+ "This is an additional description that can be customized per action",
+ "action description is rendered on the page"
+ );
});
test("error when submitting 2FA form", async function (assert) {
await visit("/session/2fa?nonce=ok110111");
await fillIn("form.totp-token .second-factor-token-input", WRONG_TOTP);
await click('form.totp-token .btn-primary[type="submit"]');
- assert.equal(
- query(".alert-error").textContent.trim(),
- "invalid token man",
- "error message from the server is displayed"
- );
+ assert
+ .dom(".alert-error")
+ .hasText(
+ "invalid token man",
+ "error message from the server is displayed"
+ );
});
test("successful 2FA form submit", async function (assert) {
await visit("/session/2fa?nonce=ok110111");
await fillIn("form.totp-token .second-factor-token-input", "323421");
await click('form.totp-token .btn-primary[type="submit"]');
- assert.equal(
+ assert.strictEqual(
currentURL(),
"/",
"user has been redirected to the redirect_url"
);
- assert.equal(callbackCount, 1, "callback request has been performed");
+ assert.strictEqual(callbackCount, 1, "callback request has been performed");
});
test("sidebar is disabled on 2FA route", async function (assert) {
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 c774bc19358..37a2df464a7 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
@@ -5,7 +5,6 @@ import {
acceptance,
publishToMessageBus,
query,
- queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object";
@@ -32,11 +31,9 @@ acceptance("Topic - User Status", function (needs) {
this.siteSettings.enable_user_status = true;
await visit("/t/-/299/1");
- assert.equal(
- queryAll(".topic-post .user-status-message").length,
- 3,
- "all posts has user status"
- );
+ assert
+ .dom(".topic-post .user-status-message")
+ .exists({ count: 3 }, "all posts has user status");
});
test("shows user status next to avatar on posts when displaying names on posts is enabled", async function (assert) {
@@ -45,11 +42,9 @@ acceptance("Topic - User Status", function (needs) {
await visit("/t/-/299/1");
- assert.equal(
- queryAll(".topic-post .user-status-message").length,
- 3,
- "all posts has user status"
- );
+ assert
+ .dom(".topic-post .user-status-message")
+ .exists({ count: 3 }, "all posts has user status");
});
});
@@ -74,11 +69,9 @@ acceptance("Topic - User Status - live updates", function (needs) {
this.siteSettings.enable_user_status = true;
await visit("/t/-/299/1");
- assert.equal(
- queryAll(".topic-post .user-status-message").length,
- 3,
- "all posts has user status"
- );
+ assert
+ .dom(".topic-post .user-status-message")
+ .exists({ count: 3 }, "all posts has user status");
assert.ok(
query(".topic-post .user-status-message .emoji").src.includes(
status.emoji
@@ -89,11 +82,9 @@ acceptance("Topic - User Status - live updates", function (needs) {
const newStatus = { emoji: "surfing_man", description: "surfing" };
await publishToMessageBus(`/user-status`, { [userId]: newStatus });
- assert.equal(
- queryAll(".topic-post .user-status-message").length,
- 3,
- "all posts has user status"
- );
+ assert
+ .dom(".topic-post .user-status-message")
+ .exists({ count: 3 }, "all posts has user status");
assert.ok(
query(".topic-post .user-status-message .emoji").src.includes(
newStatus.emoji
@@ -106,11 +97,9 @@ acceptance("Topic - User Status - live updates", function (needs) {
this.siteSettings.enable_user_status = true;
await visit("/t/-/299/1");
- assert.equal(
- queryAll(".topic-post .user-status-message").length,
- 3,
- "all posts has user status"
- );
+ assert
+ .dom(".topic-post .user-status-message")
+ .exists({ count: 3 }, "all posts has user status");
assert.ok(
query(".topic-post .user-status-message .emoji").src.includes(
status.emoji
@@ -127,11 +116,9 @@ acceptance("Topic - User Status - live updates", function (needs) {
const newStatus = { emoji: "surfing_man", description: "surfing" };
await publishToMessageBus(`/user-status`, { [userId]: newStatus });
- assert.equal(
- queryAll(".topic-post .user-status-message").length,
- 3,
- "all posts have user status"
- );
+ assert
+ .dom(".topic-post .user-status-message")
+ .exists({ count: 3 }, "all posts have user status");
assert.ok(
query(".topic-post .user-status-message .emoji").src.includes(
newStatus.emoji
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-activity-all-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-activity-all-test.js
index 7f4c150d1be..4c61db9fcc5 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-activity-all-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-activity-all-test.js
@@ -1,7 +1,7 @@
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { i18n } from "discourse-i18n";
-import { acceptance, query } from "../helpers/qunit-helpers";
+import { acceptance } from "../helpers/qunit-helpers";
acceptance("User Activity / All - empty state", function (needs) {
const currentUser = "eviltrout";
@@ -18,17 +18,15 @@ acceptance("User Activity / All - empty state", function (needs) {
test("When looking at own activity page", async function (assert) {
await visit(`/u/${currentUser}/activity`);
- assert.equal(
- query("div.empty-state span.empty-state-title").innerText,
- i18n("user_activity.no_activity_title")
- );
+ assert
+ .dom("div.empty-state span.empty-state-title")
+ .hasText(i18n("user_activity.no_activity_title"));
});
test("When looking at another user's activity page", async function (assert) {
await visit(`/u/${anotherUser}/activity`);
- assert.equal(
- query("div.empty-state span.empty-state-title").innerText,
- i18n("user_activity.no_activity_title")
- ); // the same title as when looking at own page
+ assert
+ .dom("div.empty-state span.empty-state-title")
+ .hasText(i18n("user_activity.no_activity_title")); // the same title as when looking at own page
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-activity-likes-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-activity-likes-test.js
index b5f5a654285..9bfc7adf3bc 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-activity-likes-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-activity-likes-test.js
@@ -1,7 +1,7 @@
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { i18n } from "discourse-i18n";
-import { acceptance, query } from "../helpers/qunit-helpers";
+import { acceptance } from "../helpers/qunit-helpers";
acceptance("User Activity / Likes - empty state", function (needs) {
const currentUser = "eviltrout";
@@ -18,17 +18,17 @@ acceptance("User Activity / Likes - empty state", function (needs) {
test("When looking at own likes page", async function (assert) {
await visit(`/u/${currentUser}/activity/likes-given`);
- assert.equal(
- query("div.empty-state span.empty-state-title").innerText,
- i18n("user_activity.no_likes_title")
- );
+ assert
+ .dom("div.empty-state span.empty-state-title")
+ .hasText(i18n("user_activity.no_likes_title"));
});
test("When looking at another user's likes page", async function (assert) {
await visit(`/u/${anotherUser}/activity/likes-given`);
- assert.equal(
- query("div.empty-state span.empty-state-title").innerText,
- i18n("user_activity.no_likes_title_others", { username: anotherUser })
- );
+ assert
+ .dom("div.empty-state span.empty-state-title")
+ .hasText(
+ i18n("user_activity.no_likes_title_others", { username: anotherUser })
+ );
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-activity-replies-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-activity-replies-test.js
index a84771523ac..3342d847167 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-activity-replies-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-activity-replies-test.js
@@ -1,7 +1,7 @@
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { i18n } from "discourse-i18n";
-import { acceptance, query } from "../helpers/qunit-helpers";
+import { acceptance } from "../helpers/qunit-helpers";
acceptance("User Activity / Replies - empty state", function (needs) {
const currentUser = "eviltrout";
@@ -19,17 +19,17 @@ acceptance("User Activity / Replies - empty state", function (needs) {
test("When looking at own replies page", async function (assert) {
await visit(`/u/${currentUser}/activity/replies`);
- assert.equal(
- query("div.empty-state span.empty-state-title").innerText,
- i18n("user_activity.no_replies_title")
- );
+ assert
+ .dom("div.empty-state span.empty-state-title")
+ .hasText(i18n("user_activity.no_replies_title"));
});
test("When looking at another user's replies page", async function (assert) {
await visit(`/u/${anotherUser}/activity/replies`);
- assert.equal(
- query("div.empty-state span.empty-state-title").innerText,
- i18n("user_activity.no_replies_title_others", { username: anotherUser })
- );
+ assert
+ .dom("div.empty-state span.empty-state-title")
+ .hasText(
+ i18n("user_activity.no_replies_title_others", { username: anotherUser })
+ );
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-activity-topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-activity-topic-test.js
index 1380f51241a..00bb4d2e7be 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-activity-topic-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-activity-topic-test.js
@@ -2,7 +2,7 @@ import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
import { i18n } from "discourse-i18n";
import userFixtures from "../fixtures/user-fixtures";
-import { acceptance, query, queryAll } from "../helpers/qunit-helpers";
+import { acceptance, queryAll } from "../helpers/qunit-helpers";
acceptance("User Activity / Topics - bulk actions", function (needs) {
const currentUser = "eviltrout";
@@ -58,17 +58,17 @@ acceptance("User Activity / Topics - empty state", function (needs) {
test("When looking at the own activity page", async function (assert) {
await visit(`/u/${currentUser}/activity/topics`);
- assert.equal(
- query("div.empty-state span.empty-state-title").innerText,
- i18n("user_activity.no_topics_title")
- );
+ assert
+ .dom("div.empty-state span.empty-state-title")
+ .hasText(i18n("user_activity.no_topics_title"));
});
test("When looking at another user's activity page", async function (assert) {
await visit(`/u/${anotherUser}/activity/topics`);
- assert.equal(
- query("div.empty-state span.empty-state-title").innerText,
- i18n("user_activity.no_topics_title_others", { username: anotherUser })
- );
+ assert
+ .dom("div.empty-state span.empty-state-title")
+ .hasText(
+ i18n("user_activity.no_topics_title_others", { username: anotherUser })
+ );
});
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-user-status-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-user-status-test.js
index 3957302d04a..25953c2c239 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-user-status-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-user-status-test.js
@@ -2,7 +2,6 @@ import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit";
import {
acceptance,
- query,
updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers";
@@ -49,13 +48,9 @@ acceptance("User Profile - Account - User Status", function (needs) {
assert
.dom(`.pref-user-status .emoji[alt='${status.emoji}']`)
.exists("status emoji is correct");
- assert.equal(
- query(
- `.pref-user-status .user-status-message-description`
- ).innerText.trim(),
- status.description,
- "status description is correct"
- );
+ assert
+ .dom(`.pref-user-status .user-status-message-description`)
+ .hasText(status.description, "status description is correct");
});
test("doesn't show the pause notifications control group on the user status modal", async function (assert) {
@@ -84,13 +79,9 @@ acceptance("User Profile - Account - User Status", function (needs) {
assert
.dom(`.pref-user-status .emoji[alt='${status.emoji}']`)
.exists("status emoji is correct");
- assert.equal(
- query(
- `.pref-user-status .user-status-message-description`
- ).innerText.trim(),
- status.description,
- "status description is correct"
- );
+ assert
+ .dom(`.pref-user-status .user-status-message-description`)
+ .hasText(status.description, "status description is correct");
});
test("the status modal updates status", async function (assert) {
@@ -106,13 +97,9 @@ acceptance("User Profile - Account - User Status", function (needs) {
assert
.dom(`.pref-user-status .emoji[alt='${newStatus.emoji}']`)
.exists("status emoji is correct");
- assert.equal(
- query(
- `.pref-user-status .user-status-message-description`
- ).innerText.trim(),
- newStatus.description,
- "status description is correct"
- );
+ assert
+ .dom(`.pref-user-status .user-status-message-description`)
+ .hasText(newStatus.description, "status description is correct");
});
test("the status modal clears status", async function (assert) {
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 f0e4f1e14db..8b805b179b4 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
@@ -1,7 +1,7 @@
import { click, currentURL, visit } from "@ember/test-helpers";
import { test } from "qunit";
import userFixtures from "discourse/tests/fixtures/user-fixtures";
-import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
+import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object";
import { i18n } from "discourse-i18n";
@@ -106,7 +106,7 @@ acceptance("User Profile - Summary - Stats", function (needs) {
test("Summary Read Times", async function (assert) {
await visit("/u/eviltrout/summary");
- assert.equal(query(".stats-time-read span").textContent.trim(), "1d");
+ assert.dom(".stats-time-read span").hasText("1d");
assert
.dom(".stats-time-read span")
.hasAttribute(
@@ -114,7 +114,7 @@ acceptance("User Profile - Summary - Stats", function (needs) {
i18n("user.summary.time_read_title", { duration: "1 day" })
);
- assert.equal(query(".stats-recent-read span").textContent.trim(), "17m");
+ assert.dom(".stats-recent-read span").hasText("17m");
assert
.dom(".stats-recent-read span")
.hasAttribute(
@@ -168,11 +168,9 @@ acceptance("User Profile - Summary - Admin", function (needs) {
await visit("/u/charlie/summary");
await click(".btn-delete-user");
- assert.equal(
- query("#dialog-title").textContent,
- i18n("admin.user.delete_confirm_title"),
- "dialog has a title"
- );
+ assert
+ .dom("#dialog-title")
+ .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");
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-status-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-status-test.js
index 5b694f33c3c..fe386169d69 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-status-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-status-test.js
@@ -3,7 +3,6 @@ import { test } from "qunit";
import {
acceptance,
publishToMessageBus,
- query,
updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers";
@@ -58,25 +57,25 @@ acceptance("User Status", function (needs) {
await click(".header-dropdown-toggle.current-user button");
await click("#user-menu-button-profile");
- assert.equal(
- query(
- "div.quick-access-panel li.set-user-status span.item-label"
- ).textContent.trim(),
- userStatus,
- "shows user status description on the menu"
- );
+ assert
+ .dom("div.quick-access-panel li.set-user-status span.item-label")
+ .hasText(userStatus, "shows user status description on the menu");
- assert.equal(
- query("div.quick-access-panel li.set-user-status img.emoji").alt,
- `${userStatusEmoji}`,
- "shows user status emoji on the menu"
- );
+ assert
+ .dom("div.quick-access-panel li.set-user-status img.emoji")
+ .hasAttribute(
+ "alt",
+ `${userStatusEmoji}`,
+ "shows user status emoji on the menu"
+ );
- assert.equal(
- query(".header-dropdown-toggle .user-status-background img.emoji").alt,
- `:${userStatusEmoji}:`,
- "shows user status emoji on the user avatar in the header"
- );
+ assert
+ .dom(".header-dropdown-toggle .user-status-background img.emoji")
+ .hasAttribute(
+ "alt",
+ `:${userStatusEmoji}:`,
+ "shows user status emoji on the user avatar in the header"
+ );
});
test("shows user status on the user status modal", async function (assert) {
@@ -96,21 +95,15 @@ acceptance("User Status", function (needs) {
assert
.dom(".btn-emoji img.emoji")
.hasAttribute("title", userStatusEmoji, "status emoji is shown");
- assert.equal(
- query(".user-status-description").value,
- userStatus,
- "status description is shown"
- );
- assert.equal(
- query(".date-picker").value,
- "2100-02-01",
- "date of auto removing of status is shown"
- );
- assert.equal(
- query(".time-input").value,
- "09:35",
- "time of auto removing of status is shown"
- );
+ assert
+ .dom(".user-status-description")
+ .hasValue(userStatus, "status description is shown");
+ assert
+ .dom(".date-picker")
+ .hasValue("2100-02-01", "date of auto removing of status is shown");
+ assert
+ .dom(".time-input")
+ .hasValue("09:35", "time of auto removing of status is shown");
});
test("emoji picking", async function (assert) {
@@ -144,27 +137,27 @@ acceptance("User Status", function (needs) {
.exists("chosen status emoji is shown");
await click(".btn-primary"); // save
- assert.equal(
- query(".header-dropdown-toggle .user-status-background img.emoji").alt,
- `:${userStatusEmoji}:`,
- "shows user status emoji on the user avatar in the header"
- );
+ assert
+ .dom(".header-dropdown-toggle .user-status-background img.emoji")
+ .hasAttribute(
+ "alt",
+ `:${userStatusEmoji}:`,
+ "shows user status emoji on the user avatar in the header"
+ );
await click(".header-dropdown-toggle.current-user button");
await click("#user-menu-button-profile");
- assert.equal(
- query(
- "div.quick-access-panel li.set-user-status span.item-label"
- ).textContent.trim(),
- userStatus,
- "shows user status description on the menu"
- );
+ assert
+ .dom("div.quick-access-panel li.set-user-status span.item-label")
+ .hasText(userStatus, "shows user status description on the menu");
- assert.equal(
- query("div.quick-access-panel li.set-user-status img.emoji").alt,
- `${userStatusEmoji}`,
- "shows user status emoji on the menu"
- );
+ assert
+ .dom("div.quick-access-panel li.set-user-status img.emoji")
+ .hasAttribute(
+ "alt",
+ `${userStatusEmoji}`,
+ "shows user status emoji on the menu"
+ );
});
test("updating user status", async function (assert) {
@@ -181,18 +174,16 @@ acceptance("User Status", function (needs) {
await click(".header-dropdown-toggle.current-user button");
await click("#user-menu-button-profile");
- assert.equal(
- query(
- "div.quick-access-panel li.set-user-status span.item-label"
- ).textContent.trim(),
- updatedStatus,
- "shows user status description on the menu"
- );
- assert.equal(
- query("div.quick-access-panel li.set-user-status img.emoji").alt,
- `${userStatusEmoji}`,
- "shows user status emoji on the menu"
- );
+ assert
+ .dom("div.quick-access-panel li.set-user-status span.item-label")
+ .hasText(updatedStatus, "shows user status description on the menu");
+ assert
+ .dom("div.quick-access-panel li.set-user-status img.emoji")
+ .hasAttribute(
+ "alt",
+ `${userStatusEmoji}`,
+ "shows user status emoji on the menu"
+ );
});
test("clearing user status", async function (assert) {
@@ -230,13 +221,9 @@ acceptance("User Status", function (needs) {
await click(".header-dropdown-toggle.current-user button");
await click("#user-menu-button-profile");
- assert.equal(
- query(
- "div.quick-access-panel li.set-user-status span.relative-date"
- ).textContent.trim(),
- "1h",
- "shows user status timer on the menu"
- );
+ assert
+ .dom("div.quick-access-panel li.set-user-status span.relative-date")
+ .hasText("1h", "shows user status timer on the menu");
});
test("it's impossible to set status without description", async function (assert) {
@@ -283,11 +270,9 @@ acceptance("User Status", function (needs) {
userStatusEmoji,
"the actual status emoji is shown"
);
- assert.equal(
- query(".user-status-description").value,
- userStatus,
- "the actual status description is shown"
- );
+ assert
+ .dom(".user-status-description")
+ .hasValue(userStatus, "the actual status description is shown");
});
test("shows the trash button when editing status that was set before", async function (assert) {
@@ -323,11 +308,9 @@ acceptance("User Status", function (needs) {
await openUserStatusModal();
assert.dom(".d-icon-discourse-emojis").exists("empty status icon is shown");
- assert.equal(
- query(".user-status-description").value,
- "",
- "no status description is shown"
- );
+ assert
+ .dom(".user-status-description")
+ .hasValue("", "no status description is shown");
});
});
@@ -511,23 +494,25 @@ acceptance("User Status - user menu", function (needs) {
await click(".header-dropdown-toggle.current-user button");
await click("#user-menu-button-profile");
- assert.equal(
- query("li.set-user-status .item-label").textContent.trim(),
- userStatus,
- "shows user status description on the menu"
- );
+ assert
+ .dom("li.set-user-status .item-label")
+ .hasText(userStatus, "shows user status description on the menu");
- assert.equal(
- query("li.set-user-status .emoji").alt,
- `${userStatusEmoji}`,
- "shows user status emoji on the menu"
- );
+ assert
+ .dom("li.set-user-status .emoji")
+ .hasAttribute(
+ "alt",
+ `${userStatusEmoji}`,
+ "shows user status emoji on the menu"
+ );
- assert.equal(
- query(".header-dropdown-toggle .user-status-background img.emoji").alt,
- `:${userStatusEmoji}:`,
- "shows user status emoji on the user avatar in the header"
- );
+ assert
+ .dom(".header-dropdown-toggle .user-status-background img.emoji")
+ .hasAttribute(
+ "alt",
+ `:${userStatusEmoji}:`,
+ "shows user status emoji on the user avatar in the header"
+ );
});
test("user menu gets closed when the user status modal is opened", async function (assert) {
diff --git a/app/assets/javascripts/discourse/tests/integration/components/date-time-input-range-test.js b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-range-test.js
index 6112ecdc186..6c185d4109a 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/date-time-input-range-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/date-time-input-range-test.js
@@ -43,15 +43,15 @@ module("Integration | Component | date-time-input-range", function (hooks) {
const toTimeSelectKit = selectKit(".to .d-time-input .select-kit");
await toTimeSelectKit.expand();
let rows = toTimeSelectKit.rows();
- assert.equal(rows[0].dataset.name, "14:45");
- assert.equal(rows[rows.length - 1].dataset.name, "23:45");
+ assert.dom(rows[0]).hasAttribute("data-name", "14:45");
+ assert.dom(rows[rows.length - 1]).hasAttribute("data-name", "23:45");
await toTimeSelectKit.collapse();
await fillIn(toDateInput(), "2019-01-30");
await toTimeSelectKit.expand();
rows = toTimeSelectKit.rows();
- assert.equal(rows[0].dataset.name, "00:00");
- assert.equal(rows[rows.length - 1].dataset.name, "23:45");
+ assert.dom(rows[0]).hasAttribute("data-name", "00:00");
+ assert.dom(rows[rows.length - 1]).hasAttribute("data-name", "23:45");
});
test("setting relativeDate results in correct intervals (4x 15m then 30m)", async function (assert) {
@@ -65,8 +65,8 @@ module("Integration | Component | date-time-input-range", function (hooks) {
const toTimeSelectKit = selectKit(".to .d-time-input .select-kit");
await toTimeSelectKit.expand();
let rows = toTimeSelectKit.rows();
- assert.equal(rows[4].dataset.name, "15:45");
- assert.equal(rows[5].dataset.name, "16:15");
+ assert.dom(rows[4]).hasAttribute("data-name", "15:45");
+ assert.dom(rows[5]).hasAttribute("data-name", "16:15");
});
test("timezone support", async function (assert) {
@@ -91,6 +91,9 @@ module("Integration | Component | date-time-input-range", function (hooks) {
await toTimeSelectKit.expand();
await toTimeSelectKit.selectRowByName("19:15");
- assert.equal(this.state.to.toString(), "Tue Jan 29 2019 19:15:00 GMT+0100");
+ assert.strictEqual(
+ this.state.to.toString(),
+ "Tue Jan 29 2019 19:15:00 GMT+0100"
+ );
});
});
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 198e1c2593a..c944d2a57be 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/dag-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/dag-test.js
@@ -80,11 +80,11 @@ module("Unit | Lib | DAG", function (hooks) {
},
});
dag.add("key1", "value1");
- assert.equal(called, 1, "the callback was called");
+ assert.strictEqual(called, 1, "the callback was called");
// it doesn't call the callback when the item already exists
dag.add("key1", "value1");
- assert.equal(called, 1, "the callback was not called");
+ assert.strictEqual(called, 1, "the callback was not called");
});
test("should remove an item from the map", function (assert) {
@@ -115,11 +115,11 @@ module("Unit | Lib | DAG", function (hooks) {
});
dag.add("key1", "value1");
dag.delete("key1");
- assert.equal(called, 1, "the callback was called");
+ assert.strictEqual(called, 1, "the callback was called");
// it doesn't call the callback when the item doesn't exist
dag.delete("key1");
- assert.equal(called, 1, "the callback was not called");
+ assert.strictEqual(called, 1, "the callback was not called");
});
test("should replace the value from an item in the map", function (assert) {
@@ -162,11 +162,11 @@ module("Unit | Lib | DAG", function (hooks) {
});
dag.add("key1", "value1");
dag.replace("key1", "replaced-value1");
- assert.equal(called, 1, "the callback was called");
+ assert.strictEqual(called, 1, "the callback was called");
// it doesn't call the callback when the item doesn't exist
dag.replace("key2", "replaced-value2");
- assert.equal(called, 1, "the callback was not called");
+ assert.strictEqual(called, 1, "the callback was not called");
});
test("should reposition an item in the map", function (assert) {
@@ -204,11 +204,11 @@ module("Unit | Lib | DAG", function (hooks) {
});
dag.add("key1", "value1");
dag.reposition("key1", { before: "key2" });
- assert.equal(called, 1, "the callback was called");
+ assert.strictEqual(called, 1, "the callback was called");
// it doesn't call the callback when the item doesn't exist
dag.reposition("key2", { before: "key1" });
- assert.equal(called, 1, "the callback was not called");
+ assert.strictEqual(called, 1, "the callback was not called");
});
test("should return the entries in the map", function (assert) {
@@ -222,14 +222,18 @@ module("Unit | Lib | DAG", function (hooks) {
const dagEntries = dag.entries();
entries.forEach((entry, index) => {
- assert.equal(dagEntries[index][0], entry[0], "the key is correct");
- assert.equal(dagEntries[index][1], entry[1], "the value is correct");
- assert.equal(
+ assert.strictEqual(dagEntries[index][0], entry[0], "the key is correct");
+ assert.strictEqual(
+ dagEntries[index][1],
+ entry[1],
+ "the value is correct"
+ );
+ assert.strictEqual(
dagEntries[index][2]["before"],
entry[2]["before"],
"the before position is correct"
);
- assert.equal(
+ assert.strictEqual(
dagEntries[index][2]["after"],
entry[2]["after"],
"the after position is correct"