A platform for community discussion. Free, open, simple.
DEV: Remove most of jQuery usage from tests (#17474)
Jarek Radosz7b6cd44c3225
diff --git a/app/assets/javascripts/discourse/tests/acceptance/about-test.js b/app/assets/javascripts/discourse/tests/acceptance/about-test.jsindex b51cd5a5721..f0817e09264 100644--- a/app/assets/javascripts/discourse/tests/acceptance/about-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/about-test.js@@ -6,7 +6,7 @@ acceptance("About", function () {test("viewing", async function (assert) {await visit("/about");- assert.ok($("body.about-page").length, "has body class");+ assert.ok(document.body.classList.contains("about-page"), "has body class");assert.ok(exists(".about.admins .user-info"), "has admins");assert.ok(exists(".about.moderators .user-info"), "has moderators");assert.ok(exists(".about.stats tr td"), "has stats");diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.jsindex c931fa082e4..64ccfc7f5b0 100644--- a/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js@@ -2,7 +2,7 @@ import {acceptance,count,exists,- queryAll,+ query,} from "discourse/tests/helpers/qunit-helpers";import {click,@@ -58,7 +58,7 @@ acceptance("Admin - Site Settings", function (needs) {await visit("/admin/site_settings");assert.strictEqual(- queryAll(".row.setting .setting-label h3 a").attr("href"),+ query(".row.setting .setting-label h3 a").getAttribute("href"),"/admin/logs/staff_action_logs?filters=%7B%22subject%22%3A%22title%22%2C%22action_name%22%3A%22change_site_setting%22%7D&force_refresh=true","it links to the staff action log");diff --git a/app/assets/javascripts/discourse/tests/acceptance/badges-test.js b/app/assets/javascripts/discourse/tests/acceptance/badges-test.jsindex 6eaaf10431b..394f82655e5 100644--- a/app/assets/javascripts/discourse/tests/acceptance/badges-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/badges-test.js@@ -9,7 +9,10 @@ acceptance("Badges", function (needs) {test("Visit Badge Pages", async function (assert) {await visit("/badges");- assert.ok($("body.badges-page").length, "has body class");+ assert.ok(+ document.body.classList.contains("badges-page"),+ "has body class"+ );assert.ok(exists(".badge-groups .badge-card"), "has a list of badges");await visit("/badges/9/autobiographer");@@ -23,6 +26,9 @@ acceptance("Badges", function (needs) {const availableBadgeTitles = selectKit(".select-kit");await visit("/badges/50/custombadge");await availableBadgeTitles.expand();- assert.ok(availableBadgeTitles.rowByIndex(1).name() === "CustomBadge");+ assert.strictEqual(+ availableBadgeTitles.rowByIndex(1).name(),+ "CustomBadge"+ );});});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.jsindex c09719d96eb..200d5b05ddd 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@@ -10,14 +10,14 @@ import I18n from "I18n";import selectKit from "discourse/tests/helpers/select-kit-helper";import { test } from "qunit";-acceptance("Category Edit - security", function (needs) {+acceptance("Category Edit - Security", function (needs) {needs.user();test("default", async function (assert) {await visit("/c/bug/edit/security");- const firstRow = queryAll(".row-body").first();- const badgeName = firstRow.find(".group-name-label").text();+ const firstRow = query(".row-body");+ const badgeName = firstRow.querySelector(".group-name-label").innerText;assert.strictEqual(badgeName, "everyone");assert.strictEqual(count(".d-icon-check-square"), 3);@@ -56,11 +56,14 @@ acceptance("Category Edit - security", function (needs) {await availableGroups.expand();await availableGroups.selectRowByValue("staff");- const addedRow = queryAll(".row-body").last();+ const addedRow = [...queryAll(".row-body")].at(-1);- assert.strictEqual(addedRow.find(".group-name-label").text(), "staff");assert.strictEqual(- addedRow.find(".d-icon-check-square").length,+ addedRow.querySelector(".group-name-label").innerText,+ "staff"+ );+ assert.strictEqual(+ addedRow.querySelectorAll(".d-icon-check-square").length,3,"new row permissions match default 'everyone' permissions");@@ -70,7 +73,6 @@ acceptance("Category Edit - security", function (needs) {const availableGroups = selectKit(".available-groups");await visit("/c/bug/edit/security");-await click(".row-body .remove-permission");assert.ok(!exists(".row-body"), "removes the permission from the list");@@ -84,11 +86,14 @@ acceptance("Category Edit - security", function (needs) {"adds back the permission tp the list");- const firstRow = queryAll(".row-body").first();+ const firstRow = query(".row-body");- assert.strictEqual(firstRow.find(".group-name-label").text(), "everyone");assert.strictEqual(- firstRow.find(".d-icon-check-square").length,+ firstRow.querySelector(".group-name-label").innerText,+ "everyone"+ );+ assert.strictEqual(+ firstRow.querySelectorAll(".d-icon-check-square").length,1,"adds only 'See' permission for a new row");@@ -99,10 +104,10 @@ acceptance("Category Edit - security", function (needs) {await visit("/c/bug/edit/security");- const everyoneRow = queryAll(".row-body").first();+ const everyoneRow = query(".row-body");assert.strictEqual(- everyoneRow.find(".reply-granted, .create-granted").length,+ everyoneRow.querySelectorAll(".reply-granted, .create-granted").length,2,"everyone has full permissions by default");@@ -110,58 +115,58 @@ acceptance("Category Edit - security", function (needs) {await availableGroups.expand();await availableGroups.selectRowByValue("staff");- const staffRow = queryAll(".row-body").last();+ const staffRow = [...queryAll(".row-body")].at(-1);assert.strictEqual(- staffRow.find(".reply-granted, .create-granted").length,+ staffRow.querySelectorAll(".reply-granted, .create-granted").length,2,"staff group also has full permissions");- await click(everyoneRow.find(".reply-toggle")[0]);+ await click(everyoneRow.querySelector(".reply-toggle"));assert.strictEqual(- everyoneRow.find(".reply-granted, .create-granted").length,+ everyoneRow.querySelectorAll(".reply-granted, .create-granted").length,0,"everyone does not have reply or create");assert.strictEqual(- staffRow.find(".reply-granted, .create-granted").length,+ staffRow.querySelectorAll(".reply-granted, .create-granted").length,2,"staff group still has full permissions");- await click(staffRow.find(".reply-toggle")[0]);+ await click(staffRow.querySelector(".reply-toggle"));assert.strictEqual(- everyoneRow.find(".reply-granted, .create-granted").length,+ everyoneRow.querySelectorAll(".reply-granted, .create-granted").length,0,"everyone permission unchanged");assert.strictEqual(- staffRow.find(".reply-granted").length,+ staffRow.querySelectorAll(".reply-granted").length,0,"staff does not have reply permission");assert.strictEqual(- staffRow.find(".create-granted").length,+ staffRow.querySelectorAll(".create-granted").length,0,"staff does not have create permission");- await click(everyoneRow.find(".create-toggle")[0]);+ await click(everyoneRow.querySelector(".create-toggle"));assert.strictEqual(- everyoneRow.find(".reply-granted, .create-granted").length,+ everyoneRow.querySelectorAll(".reply-granted, .create-granted").length,2,"everyone has full permissions");assert.strictEqual(- staffRow.find(".reply-granted, .create-granted").length,+ staffRow.querySelectorAll(".reply-granted, .create-granted").length,2,"staff group has full permissions (inherited from everyone)");diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-edit-conflict-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-edit-conflict-test.jsindex 312a2954894..51f33213f15 100644--- a/app/assets/javascripts/discourse/tests/acceptance/composer-edit-conflict-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-edit-conflict-test.js@@ -20,7 +20,7 @@ acceptance("Composer - Edit conflict", function (needs) {".d-editor-input","hello world hello world hello world hello world hello world");- assert.ok(lastBody.indexOf("originalText") === -1);+ assert.ok(!lastBody.includes("originalText"));});test("Should send originalText when editing a reply", async function (assert) {@@ -31,6 +31,6 @@ acceptance("Composer - Edit conflict", function (needs) {".d-editor-input","hello world hello world hello world hello world hello world");- assert.ok(lastBody.indexOf("originalText") > -1);+ assert.ok(lastBody.includes("originalText"));});});diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.jsindex 507641d7228..6c4cd9b003c 100644--- a/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-hyperlink-test.js@@ -2,7 +2,6 @@ import {acceptance,exists,query,- queryAll,} from "discourse/tests/helpers/qunit-helpers";import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers";import { test } from "qunit";@@ -28,7 +27,7 @@ acceptance("Composer - Hyperlink", function (needs) {await click(".modal-footer button.btn-primary");assert.strictEqual(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,"This is a link to [Google](https://google.com)","adds link with url and text, prepends 'https://'");@@ -46,7 +45,7 @@ acceptance("Composer - Hyperlink", function (needs) {await click(".modal-footer button.btn-danger");assert.strictEqual(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,"Reset textarea contents.","doesn’t insert anything after cancelling");@@ -65,7 +64,7 @@ acceptance("Composer - Hyperlink", function (needs) {await click(".modal-footer button.btn-primary");assert.strictEqual(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,"[Reset](https://somelink.com) textarea contents.","adds link to a selected text");@@ -96,7 +95,7 @@ acceptance("Composer - Hyperlink", function (needs) {);assert.ok(- queryAll(".link-url").val().includes("http"),+ query(".link-url").value.includes("http"),"replaces link url field with internal link");});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.jsindex b5148fa888d..c81b0fdde2e 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@@ -5,7 +5,6 @@ import {exists,invisible,query,- queryAll,visible,} from "discourse/tests/helpers/qunit-helpers";import { test } from "qunit";@@ -34,7 +33,7 @@ acceptance("Composer - Image Preview", function (needs) {const assertImageResized = (assert, uploads) => {assert.strictEqual(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,uploads.join("\n"),"it resizes uploaded image");@@ -84,9 +83,7 @@ acceptance("Composer - Image Preview", function (needs) {uploads[0] ="<a href='https://example.com'></a>";await click(- queryAll(- ".button-wrapper[data-image-index='0'] .scale-btn[data-scale='50']"- )[0]+ ".button-wrapper[data-image-index='0'] .scale-btn[data-scale='50']");assertImageResized(assert, uploads);@@ -94,9 +91,7 @@ acceptance("Composer - Image Preview", function (needs) {uploads[6] =" ";await click(- queryAll(- ".button-wrapper[data-image-index='3'] .scale-btn[data-scale='50']"- )[0]+ ".button-wrapper[data-image-index='3'] .scale-btn[data-scale='50']");assertImageResized(assert, uploads);@@ -104,45 +99,35 @@ acceptance("Composer - Image Preview", function (needs) {uploads[6] =" ";await click(- queryAll(- ".button-wrapper[data-image-index='4'] .scale-btn[data-scale='75']"- )[0]+ ".button-wrapper[data-image-index='4'] .scale-btn[data-scale='75']");assertImageResized(assert, uploads);// Make sure we target the correct image if there are duplicatesuploads[7] = "";await click(- queryAll(- ".button-wrapper[data-image-index='5'] .scale-btn[data-scale='50']"- )[0]+ ".button-wrapper[data-image-index='5'] .scale-btn[data-scale='50']");assertImageResized(assert, uploads);// Try the other dupeuploads[8] = "";await click(- queryAll(- ".button-wrapper[data-image-index='6'] .scale-btn[data-scale='75']"- )[0]+ ".button-wrapper[data-image-index='6'] .scale-btn[data-scale='75']");assertImageResized(assert, uploads);// Don't mess with image titlesuploads[10] = ``;await click(- queryAll(- ".button-wrapper[data-image-index='8'] .scale-btn[data-scale='75']"- )[0]+ ".button-wrapper[data-image-index='8'] .scale-btn[data-scale='75']");assertImageResized(assert, uploads);// Keep data attributesuploads[12] = ``;await click(- queryAll(- ".button-wrapper[data-image-index='9'] .scale-btn[data-scale='75']"- )[0]+ ".button-wrapper[data-image-index='9'] .scale-btn[data-scale='75']");assertImageResized(assert, uploads);@@ -192,24 +177,20 @@ acceptance("Composer - Image Preview", function (needs) {assert.ok(visible(altTextEditOk), "alt text edit ok button is visible");assert.ok(visible(altTextEditCancel), "alt text edit cancel is hidden");assert.equal(- queryAll(altTextInput).val(),+ query(altTextInput).value,"zorro","correct alt text in input");await triggerKeyEvent(altTextInput, "keypress", "[".charCodeAt(0));await triggerKeyEvent(altTextInput, "keypress", "]".charCodeAt(0));- assert.equal(- queryAll(altTextInput).val(),- "zorro",- "does not input [ ] keys"- );+ assert.equal(query(altTextInput).value, "zorro", "does not input [ ] keys");await fillIn(altTextInput, "steak");await triggerKeyEvent(altTextInput, "keypress", 13);assert.equal(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,"","alt text updated");@@ -246,7 +227,7 @@ acceptance("Composer - Image Preview", function (needs) {await click(altTextEditOk);assert.equal(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,"","alt text updated");@@ -285,7 +266,7 @@ acceptance("Composer - Image Preview", function (needs) {await click(altTextEditCancel);assert.equal(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,"","alt text not updated");@@ -320,7 +301,7 @@ acceptance("Composer - Image Preview", function (needs) {await triggerKeyEvent(altTextInput, "keypress", 13);assert.equal(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,` `,"the correct image's alt text updated");@@ -342,7 +323,7 @@ acceptance("Composer - Image Preview", function (needs) {await triggerKeyEvent(altTextInput, "keypress", 13);assert.equal(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,"","alt text updated");@@ -354,7 +335,7 @@ acceptance("Composer - Image Preview", function (needs) {await triggerKeyEvent(altTextInput, "keypress", 13);assert.equal(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,"","alt text updated");diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-onebox-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-onebox-test.jsindex 7a875def554..ee5b26898f5 100644--- a/app/assets/javascripts/discourse/tests/acceptance/composer-onebox-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-onebox-test.js@@ -1,4 +1,8 @@-import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";+import {+ acceptance,+ query,+ visible,+} from "discourse/tests/helpers/qunit-helpers";import { click, fillIn, visit } from "@ember/test-helpers";import { test } from "qunit";@@ -28,8 +32,9 @@ http://www.example.com/has-title.html`);+ assert.ok(visible(".d-editor-preview"));assert.strictEqual(- queryAll(".d-editor-preview:visible").html().trim(),+ query(".d-editor-preview").innerHTML.trim(),`<p><aside class=\"onebox\"><article class=\"onebox-body\"><h3><a href=\"http://www.example.com/article.html\" tabindex=\"-1\">An interesting article</a></h3></article></aside><br>This is another test <a href=\"http://www.example.com/has-title.html\" class=\"inline-onebox\" tabindex=\"-1\">This is a great title</a></p>@@ -68,14 +73,14 @@ acceptance("Composer - Inline Onebox", function (needs) {await fillIn(".d-editor-input", `Test www.example.com/page`);assert.strictEqual(requestsCount, 1);assert.strictEqual(- queryAll(".d-editor-preview").html().trim(),+ query(".d-editor-preview").innerHTML.trim(),'<p>Test <a href="http://www.example.com/page" class="inline-onebox-loading" tabindex="-1">www.example.com/page</a></p>');await fillIn(".d-editor-input", `Test www.example.com/page Test`);assert.strictEqual(requestsCount, 1);assert.strictEqual(- queryAll(".d-editor-preview").html().trim(),+ query(".d-editor-preview").innerHTML.trim(),'<p>Test <a href="http://www.example.com/page" tabindex="-1">www.example.com/page</a> Test</p>');});diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-test.jsindex 19bf983d76f..62690a7ef37 100644--- a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js@@ -341,9 +341,8 @@ acceptance("Composer", function (needs) {await click(".topic-post:nth-of-type(1) button.show-more-actions");await click(".topic-post:nth-of-type(1) button.edit");- assert.strictEqual(- query(".d-editor-input").value.indexOf("Any plans to support"),- 0,+ assert.ok(+ query(".d-editor-input").value.startsWith("Any plans to support"),"it populates the input with the post text");@@ -356,15 +355,15 @@ acceptance("Composer", function (needs) {"it has the edits icon");assert.ok(- query("#topic-title h1").innerText.indexOf(+ query("#topic-title h1").innerText.includes("This is the new text for the title"- ) !== -1,+ ),"it shows the new title");assert.ok(- query(".topic-post:nth-of-type(1) .cooked").innerText.indexOf(+ query(".topic-post:nth-of-type(1) .cooked").innerText.includes("This is the new text for the post"- ) !== -1,+ ),"it updates the post");});@@ -406,15 +405,13 @@ acceptance("Composer", function (needs) {await visit("/t/this-is-a-test-topic/9");await click(".topic-post:nth-of-type(1) button.edit");- assert.strictEqual(- query(".d-editor-input").value.indexOf("This is the first post."),- 0,+ assert.ok(+ query(".d-editor-input").value.startsWith("This is the first post."),"it populates the input with the post text");await click(".topic-post:nth-of-type(2) button.edit");- assert.strictEqual(- query(".d-editor-input").value.indexOf("This is the second post."),- 0,+ assert.ok(+ query(".d-editor-input").value.startsWith("This is the second post."),"it populates the input with the post text");});@@ -431,9 +428,8 @@ acceptance("Composer", function (needs) {);await click(".modal-footer button.discard-draft");- assert.strictEqual(- query(".d-editor-input").value.indexOf("This is the second post."),- 0,+ assert.ok(+ query(".d-editor-input").value.startsWith("This is the second post."),"it populates the input with the post text");});@@ -442,9 +438,8 @@ acceptance("Composer", function (needs) {await visit("/t/this-is-a-test-topic/9");await click(".topic-post:nth-of-type(1) button.edit");- assert.strictEqual(- query(".d-editor-input").value.indexOf("This is the first post."),- 0,+ assert.ok(+ query(".d-editor-input").value.startsWith("This is the first post."),"it populates the input with the post text");await click(".topic-post:nth-of-type(1) button.reply");@@ -454,9 +449,8 @@ acceptance("Composer", function (needs) {"it clears the input");await click(".topic-post:nth-of-type(1) button.edit");- assert.strictEqual(- query(".d-editor-input").value.indexOf("This is the first post."),- 0,+ assert.ok(+ query(".d-editor-input").value.startsWith("This is the first post."),"it populates the input with the post text");});@@ -627,9 +621,8 @@ acceptance("Composer", function (needs) {"it pops up a confirmation dialog");await click(".modal-footer button.discard-draft");- assert.strictEqual(- query(".d-editor-input").value.indexOf("This is the first post."),- 0,+ assert.ok(+ query(".d-editor-input").value.startsWith("This is the first post."),"it populates the input with the post text");});@@ -656,9 +649,8 @@ acceptance("Composer", function (needs) {"has keep editing button");await click(".modal-footer button.save-draft");- assert.strictEqual(- query(".d-editor-input").value.indexOf("This is the second post."),- 0,+ assert.ok(+ query(".d-editor-input").value.startsWith("This is the second post."),"it populates the input with the post text");});@@ -928,7 +920,7 @@ acceptance("Composer - Customizations", function (needs) {function customComposerAction(composer) {return (- (composer.tags || []).indexOf("monkey") !== -1 &&+ (composer.tags || []).includes("monkey") &&composer.action === CREATE_TOPIC);}diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.jsindex ce2e1468813..e8e0127b591 100644--- a/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-topic-links-test.js@@ -1,7 +1,7 @@import {acceptance,exists,- queryAll,+ query,} from "discourse/tests/helpers/qunit-helpers";import { click, fillIn, visit } from "@ember/test-helpers";import { test } from "qunit";@@ -19,7 +19,7 @@ acceptance("Composer topic featured links", function (needs) {await click("#create-topic");await fillIn("#reply-title", "http://www.example.com/has-title.html");assert.ok(- queryAll(".d-editor-preview").html().trim().indexOf("onebox") > 0,+ query(".d-editor-preview").innerHTML.trim().includes("onebox"),"it pastes the link into the body and previews it");assert.ok(@@ -27,7 +27,7 @@ acceptance("Composer topic featured links", function (needs) {"the body is now good");assert.strictEqual(- queryAll(".title-input input").val(),+ query(".title-input input").value,"An interesting article","title is from the oneboxed article");@@ -38,7 +38,7 @@ acceptance("Composer topic featured links", function (needs) {await click("#create-topic");await fillIn("#reply-title", "http://www.example.com/no-title.html");assert.ok(- queryAll(".d-editor-preview").html().trim().indexOf("onebox") > 0,+ query(".d-editor-preview").innerHTML.trim().includes("onebox"),"it pastes the link into the body and previews it");assert.ok(@@ -46,7 +46,7 @@ acceptance("Composer topic featured links", function (needs) {"the body is now good");assert.strictEqual(- queryAll(".title-input input").val(),+ query(".title-input input").value,"http://www.example.com/no-title.html","title is unchanged");@@ -57,7 +57,7 @@ acceptance("Composer topic featured links", function (needs) {await click("#create-topic");await fillIn("#reply-title", "https://www.youtube.com/watch?v=dQw4w9WgXcQ");assert.strictEqual(- queryAll(".title-input input").val(),+ query(".title-input input").value,"Rick Astley - Never Gonna Give You Up (Video)","title is from the oneboxed article");@@ -68,7 +68,7 @@ acceptance("Composer topic featured links", function (needs) {await click("#create-topic");await fillIn("#reply-title", "http://www.example.com/nope-onebox.html");assert.ok(- queryAll(".d-editor-preview").html().trim().indexOf("onebox") > 0,+ query(".d-editor-preview").innerHTML.trim().includes("onebox"),"it pastes the link into the body and previews it");assert.ok(@@ -76,7 +76,7 @@ acceptance("Composer topic featured links", function (needs) {"link is pasted into body");assert.strictEqual(- queryAll(".title-input input").val(),+ query(".title-input input").value,"http://www.example.com/nope-onebox.html","title is unchanged");@@ -87,18 +87,17 @@ acceptance("Composer topic featured links", function (needs) {await click("#create-topic");const title = "http://" + window.location.hostname + "/internal-page.html";await fillIn("#reply-title", title);- assert.strictEqual(- queryAll(".d-editor-preview").html().trim().indexOf("onebox"),- -1,+ assert.ok(+ !query(".d-editor-preview").innerHTML.trim().includes("onebox"),"onebox preview doesn't show");assert.strictEqual(- queryAll(".d-editor-input").val().length,+ query(".d-editor-input").value.length,0,"link isn't put into the post");assert.strictEqual(- queryAll(".title-input input").val(),+ query(".title-input input").value,title,"title is unchanged");@@ -112,7 +111,7 @@ acceptance("Composer topic featured links", function (needs) {"http://www.example.com/has-title-and-a-url-that-is-more-than-80-characters-because-thats-good-for-seo-i-guess.html");assert.ok(- queryAll(".d-editor-preview").html().trim().indexOf("onebox") > 0,+ query(".d-editor-preview").innerHTML.trim().includes("onebox"),"it pastes the link into the body and previews it");assert.ok(@@ -120,7 +119,7 @@ acceptance("Composer topic featured links", function (needs) {"the body is now good");assert.strictEqual(- queryAll(".title-input input").val(),+ query(".title-input input").value,"An interesting article","title is from the oneboxed article");@@ -130,18 +129,17 @@ acceptance("Composer topic featured links", function (needs) {await visit("/");await click("#create-topic");await fillIn("#reply-title", "http://www.example.com/has-title.html test");- assert.strictEqual(- queryAll(".d-editor-preview").html().trim().indexOf("onebox"),- -1,+ assert.ok(+ !query(".d-editor-preview").innerHTML.trim().includes("onebox"),"onebox preview doesn't show");assert.strictEqual(- queryAll(".d-editor-input").val().length,+ query(".d-editor-input").value.length,0,"link isn't put into the post");assert.strictEqual(- queryAll(".title-input input").val(),+ query(".title-input input").value,"http://www.example.com/has-title.html test","title is unchanged");@@ -155,14 +153,14 @@ acceptance("Composer topic featured links", function (needs) {"https://twitter.com/discourse/status/1357664660724482048");assert.ok(- queryAll(".d-editor-preview").html().trim().indexOf("onebox") > 0,+ query(".d-editor-preview").innerHTML.trim().includes("onebox"),"it pastes the link into the body and previews it");assert.ok(exists(".d-editor-textarea-wrapper .popup-tip.good"),"the body is now good");- assert.blank(queryAll(".title-input input").val(), "title is blank");+ assert.blank(query(".title-input input").value, "title is blank");});});@@ -186,7 +184,7 @@ acceptance();await fillIn("#reply-title", "http://www.example.com/has-title.html");assert.ok(- queryAll(".d-editor-preview").html().trim().indexOf("onebox") > 0,+ query(".d-editor-preview").innerHTML.trim().includes("onebox"),"it pastes the link into the body and previews it");assert.ok(@@ -194,7 +192,7 @@ acceptance("the body is now good");assert.strictEqual(- queryAll(".title-input input").val(),+ query(".title-input input").value,"An interesting article","title is from the oneboxed article");diff --git a/app/assets/javascripts/discourse/tests/acceptance/create-invite-modal-test.js b/app/assets/javascripts/discourse/tests/acceptance/create-invite-modal-test.jsindex cf08b5a8ae2..b534b80ec56 100644--- a/app/assets/javascripts/discourse/tests/acceptance/create-invite-modal-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/create-invite-modal-test.js@@ -151,7 +151,7 @@ acceptance("Invites - Email Invites", function (needs) {assert.ok(exists(".save-invite"), "shows save without email button");await click(".save-invite");assert.ok(- lastRequest.requestBody.indexOf("skip_email=true") !== -1,+ lastRequest.requestBody.includes("skip_email=true"),"sends skip_email to server");@@ -159,7 +159,7 @@ acceptance("Invites - Email Invites", function (needs) {assert.ok(exists(".send-invite"), "shows save and send email button");await click(".send-invite");assert.ok(- lastRequest.requestBody.indexOf("send_email=true") !== -1,+ lastRequest.requestBody.includes("send_email=true"),"sends send_email to server");});diff --git a/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js b/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.jsindex fac3c52d7ea..30e9487d804 100644--- a/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/dashboard-test.js@@ -1,7 +1,8 @@import {acceptance,+ count,exists,- queryAll,+ query,} from "discourse/tests/helpers/qunit-helpers";import { click, fillIn, visit } from "@ember/test-helpers";import selectKit from "discourse/tests/helpers/select-kit-helper";@@ -46,6 +47,7 @@ acceptance("Dashboard", function (needs) {test("general tab", async function (assert) {await visit("/admin");+assert.ok(exists(".admin-report.signups"), "signups report");assert.ok(exists(".admin-report.posts"), "posts report");assert.ok(exists(".admin-report.dau-by-mau"), "dau-by-mau report");@@ -57,11 +59,10 @@ acceptance("Dashboard", function (needs) {exists(".admin-report.new-contributors"),"new-contributors report");-assert.strictEqual(- $(".section.dashboard-problems .problem-messages ul li:first-child")- .html()- .trim(),+ query(+ ".section.dashboard-problems .problem-messages ul li:first-child"+ ).innerHTML.trim(),"Houston...","displays problems");@@ -81,16 +82,14 @@ acceptance("Dashboard", function (needs) {await click(".dashboard .navigation-item.reports .navigation-link");assert.strictEqual(- queryAll(".dashboard .reports-index.section .reports-list .report")- .length,+ count(".dashboard .reports-index.section .reports-list .report"),1);await fillIn(".dashboard .filter-reports-input", "flags");assert.strictEqual(- queryAll(".dashboard .reports-index.section .reports-list .report")- .length,+ count(".dashboard .reports-index.section .reports-list .report"),0);@@ -98,8 +97,7 @@ acceptance("Dashboard", function (needs) {await click(".dashboard .navigation-item.reports .navigation-link");assert.strictEqual(- queryAll(".dashboard .reports-index.section .reports-list .report")- .length,+ count(".dashboard .reports-index.section .reports-list .report"),1,"navigating back and forth resets filter");@@ -107,8 +105,7 @@ acceptance("Dashboard", function (needs) {await fillIn(".dashboard .filter-reports-input", "activities");assert.strictEqual(- queryAll(".dashboard .reports-index.section .reports-list .report")- .length,+ count(".dashboard .reports-index.section .reports-list .report"),1,"filter is case insensitive");diff --git a/app/assets/javascripts/discourse/tests/acceptance/do-not-disturb-test.js b/app/assets/javascripts/discourse/tests/acceptance/do-not-disturb-test.jsindex e2e368d27d3..c9dcae0a36a 100644--- a/app/assets/javascripts/discourse/tests/acceptance/do-not-disturb-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/do-not-disturb-test.js@@ -1,5 +1,6 @@import {acceptance,+ count,exists,query,queryAll,@@ -56,7 +57,7 @@ acceptance("Do not disturb", function (needs) {assert.ok(exists(".do-not-disturb-modal"), "DND modal is displayed");assert.strictEqual(- queryAll(".do-not-disturb-tile").length,+ count(".do-not-disturb-tile"),4,"There are 4 duration choices");diff --git a/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js b/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.jsindex 5c8af7a4ee2..5faac2f7dc1 100644--- a/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js@@ -1,5 +1,6 @@import {acceptance,+ count,exists,query,queryAll,@@ -45,7 +46,7 @@ acceptance("EmojiPicker", function (needs) {await click(".emoji-picker-emoji-area img.emoji[title='grinning']");assert.strictEqual(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,":grinning:","it adds the emoji code in the editor when selected");@@ -60,7 +61,7 @@ acceptance("EmojiPicker", function (needs) {await click("button.emoji.btn");await click(".emoji-picker-emoji-area img.emoji[title='grinning']");assert.strictEqual(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,"This is a test input :grinning:","it adds the emoji code and a leading whitespace when there is text");@@ -70,7 +71,7 @@ acceptance("EmojiPicker", function (needs) {await click(".emoji-picker-emoji-area img.emoji[title='grinning']");assert.strictEqual(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,"This is a test input :grinning:","it adds the emoji code and no leading whitespace when user already entered whitespace");@@ -122,15 +123,14 @@ acceptance("EmojiPicker", function (needs) {await click(".emoji-picker-emoji-area img.emoji[title='grinning']");assert.strictEqual(- queryAll('.section[data-section="recent"] .section-group img.emoji')- .length,+ count('.section[data-section="recent"] .section-group img.emoji'),2,"it has multiple recent emojis");assert.strictEqual(/grinning/.test(- queryAll(".section.recent .section-group img.emoji").first().attr("src")+ query(".section.recent .section-group img.emoji").getAttribute("src")),true,"it puts the last used emoji in first"diff --git a/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js b/app/assets/javascripts/discourse/tests/acceptance/emoji-test.jsindex eb551cf2a82..de2b5716010 100644--- a/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/emoji-test.js@@ -2,7 +2,8 @@ import {acceptance,exists,normalizeHtml,- queryAll,+ query,+ visible,} from "discourse/tests/helpers/qunit-helpers";import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers";import { test } from "qunit";@@ -16,8 +17,9 @@ acceptance("Emoji", function (needs) {await click("#topic-footer-buttons .btn.create");await fillIn(".d-editor-input", "this is an emoji :blonde_woman:");+ assert.ok(visible(".d-editor-preview"));assert.strictEqual(- normalizeHtml(queryAll(".d-editor-preview:visible").html().trim()),+ normalizeHtml(query(".d-editor-preview").innerHTML.trim()),normalizeHtml(`<p>this is an emoji <img src="/images/emoji/google_classic/blonde_woman.png?v=${v}" title=":blonde_woman:" class="emoji" alt=":blonde_woman:" loading="lazy" width="20" height="20" style="aspect-ratio: 20 / 20;"></p>`)@@ -30,8 +32,9 @@ acceptance("Emoji", function (needs) {await fillIn(".d-editor-input", "this is an emoji :blonde_woman:t5:");+ assert.ok(visible(".d-editor-preview"));assert.strictEqual(- normalizeHtml(queryAll(".d-editor-preview:visible").html().trim()),+ normalizeHtml(query(".d-editor-preview").innerHTML.trim()),normalizeHtml(`<p>this is an emoji <img src="/images/emoji/google_classic/blonde_woman/5.png?v=${v}" title=":blonde_woman:t5:" class="emoji" alt=":blonde_woman:t5:" loading="lazy" width="20" height="20" style="aspect-ratio: 20 / 20;"></p>`)diff --git a/app/assets/javascripts/discourse/tests/acceptance/encoded-category-test.js b/app/assets/javascripts/discourse/tests/acceptance/encoded-category-test.jsindex 9e5a80bead9..092d4875b34 100644--- a/app/assets/javascripts/discourse/tests/acceptance/encoded-category-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/encoded-category-test.js@@ -43,15 +43,22 @@ acceptance("Encoded Sub Category Discovery", function (needs) {});test("Visit subcategory by slug", async function (assert) {- let bodySelector =- "body.category-\\%E6\\%BC\\%A2\\%E5\\%AD\\%97-parent-\\%E6\\%BC\\%A2\\%E5\\%AD\\%97-subcategory";+ const bodyClass =+ "category-%E6%BC%A2%E5%AD%97-parent-%E6%BC%A2%E5%AD%97-subcategory";+await visit("/c/%E6%BC%A2%E5%AD%97-parent/%E6%BC%A2%E5%AD%97-subcategory");- assert.ok($(bodySelector).length, "has the default navigation");+ assert.ok(+ document.body.classList.contains(bodyClass),+ "has the default navigation"+ );assert.ok(exists(".topic-list"), "The list of topics was rendered");assert.ok(exists(".topic-list .topic-list-item"), "has topics");await visit("/c/漢字-parent/漢字-subcategory");- assert.ok($(bodySelector).length, "has the default navigation");+ assert.ok(+ document.body.classList.contains(bodyClass),+ "has the default navigation"+ );assert.ok(exists(".topic-list"), "The list of topics was rendered");assert.ok(exists(".topic-list .topic-list-item"), "has topics");});diff --git a/app/assets/javascripts/discourse/tests/acceptance/forgot-password-test.js b/app/assets/javascripts/discourse/tests/acceptance/forgot-password-test.jsindex e675c72ffa2..7d2f7af63b7 100644--- a/app/assets/javascripts/discourse/tests/acceptance/forgot-password-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/forgot-password-test.js@@ -1,7 +1,7 @@import {acceptance,exists,- queryAll,+ query,} from "discourse/tests/helpers/qunit-helpers";import { click, fillIn, visit } from "@ember/test-helpers";import I18n from "I18n";@@ -23,9 +23,8 @@ acceptance("Forgot password", function (needs) {await click("header .login-button");await click("#forgot-password-link");- assert.strictEqual(- queryAll(".forgot-password-reset").attr("disabled"),- "disabled",+ assert.ok(+ query(".forgot-password-reset").disabled,"it should disable the button until the field is filled");@@ -33,7 +32,7 @@ acceptance("Forgot password", function (needs) {await click(".forgot-password-reset");assert.strictEqual(- queryAll(".alert-error").html().trim(),+ query(".alert-error").innerHTML.trim(),I18n.t("forgot_password.complete_username_not_found", {username: "someuser",}),@@ -44,7 +43,7 @@ acceptance("Forgot password", function (needs) {await click(".forgot-password-reset");assert.strictEqual(- queryAll(".alert-error").html().trim(),+ query(".alert-error").innerHTML.trim(),I18n.t("forgot_password.complete_email_not_found", {email: "[email protected]",}),@@ -63,7 +62,7 @@ acceptance("Forgot password", function (needs) {);assert.strictEqual(- queryAll(".modal-body").html().trim(),+ query(".modal-body").innerHTML.trim(),I18n.t("forgot_password.complete_username_found", {username: "someuser",}),@@ -77,7 +76,7 @@ acceptance("Forgot password", function (needs) {await click(".forgot-password-reset");assert.strictEqual(- queryAll(".modal-body").html().trim(),+ query(".modal-body").innerHTML.trim(),I18n.t("forgot_password.complete_email_found", {email: "[email protected]",}),@@ -100,9 +99,8 @@ acceptance(await click("header .login-button");await click("#forgot-password-link");- assert.strictEqual(- queryAll(".forgot-password-reset").attr("disabled"),- "disabled",+ assert.ok(+ query(".forgot-password-reset").disabled,"it should disable the button until the field is filled");@@ -110,7 +108,7 @@ acceptance(await click(".forgot-password-reset");assert.strictEqual(- queryAll(".modal-body").html().trim(),+ query(".modal-body").innerHTML.trim(),I18n.t("forgot_password.complete_username", {username: "someuser",}),diff --git a/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-index-test.jsindex 0aa2399c4f4..2c5538aede1 100644--- a/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/group-index-test.js@@ -2,6 +2,7 @@ import {acceptance,count,exists,+ query,queryAll,updateCurrentUser,} from "discourse/tests/helpers/qunit-helpers";@@ -14,8 +15,9 @@ acceptance("Group Members - Anonymous", function () {test("Viewing Members as anon user", async function (assert) {await visit("/g/discourse");- assert.ok(- count(".avatar-flair .d-icon-adjust") === 1,+ assert.strictEqual(+ count(".avatar-flair .d-icon-adjust"),+ 1,"it displays the group's avatar flair");assert.ok(exists(".group-members tr"), "it lists group members");@@ -26,7 +28,7 @@ acceptance("Group Members - Anonymous", function () {);assert.strictEqual(- queryAll(".group-username-filter").attr("placeholder"),+ query(".group-username-filter").getAttribute("placeholder"),I18n.t("groups.members.filter_placeholder"),"it should display the right filter placeholder");@@ -64,7 +66,7 @@ acceptance("Group Members", function (needs) {);assert.strictEqual(- queryAll(".group-username-filter").attr("placeholder"),+ query(".group-username-filter").getAttribute("placeholder"),I18n.t("groups.members.filter_placeholder_admin"),"it should display the right filter placeholder");diff --git a/app/assets/javascripts/discourse/tests/acceptance/login-with-email-and-hide-email-address-taken-test.js b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-and-hide-email-address-taken-test.jsindex f2264fd98b1..2c81e94fd4d 100644--- a/app/assets/javascripts/discourse/tests/acceptance/login-with-email-and-hide-email-address-taken-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-and-hide-email-address-taken-test.js@@ -1,4 +1,4 @@-import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers";+import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";import { click, fillIn, visit } from "@ember/test-helpers";import I18n from "I18n";import { test } from "qunit";@@ -22,7 +22,7 @@ acceptance("Login with email - hide email address taken", function (needs) {await click("#email-login-link");assert.strictEqual(- queryAll(".alert-success").html().trim(),+ query(".alert-success").innerHTML.trim(),I18n.t("email_login.complete_email_found", {email: "[email protected]",}),diff --git a/app/assets/javascripts/discourse/tests/acceptance/login-with-email-test.js b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-test.jsindex b009495530d..ee9718f0fa4 100644--- a/app/assets/javascripts/discourse/tests/acceptance/login-with-email-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/login-with-email-test.js@@ -1,7 +1,7 @@import {acceptance,exists,- queryAll,+ query,} from "discourse/tests/helpers/qunit-helpers";import { click, fillIn, visit } from "@ember/test-helpers";import I18n from "I18n";@@ -38,7 +38,7 @@ acceptance("Login with email", function (needs) {await click("#email-login-link");assert.strictEqual(- queryAll(".alert-error").html(),+ query(".alert-error").innerHTML,I18n.t("email_login.complete_username_not_found", {username: "someuser",}),@@ -49,7 +49,7 @@ acceptance("Login with email", function (needs) {await click("#email-login-link");assert.strictEqual(- queryAll(".alert-error").html(),+ query(".alert-error").innerHTML,I18n.t("email_login.complete_email_not_found", {email: "[email protected]",}),@@ -63,7 +63,7 @@ acceptance("Login with email", function (needs) {await click("#email-login-link");assert.strictEqual(- queryAll(".alert-success").html().trim(),+ query(".alert-success").innerHTML.trim(),I18n.t("email_login.complete_username_found", { username: "someuser" }),"it should display a success message for a valid username");@@ -74,7 +74,7 @@ acceptance("Login with email", function (needs) {await click("#email-login-link");assert.strictEqual(- queryAll(".alert-success").html().trim(),+ query(".alert-success").innerHTML.trim(),I18n.t("email_login.complete_email_found", {email: "[email protected]",}),diff --git a/app/assets/javascripts/discourse/tests/acceptance/mobile-discovery-test.js b/app/assets/javascripts/discourse/tests/acceptance/mobile-discovery-test.jsindex 43be07e2f92..05bcd0b0d7b 100644--- a/app/assets/javascripts/discourse/tests/acceptance/mobile-discovery-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/mobile-discovery-test.js@@ -1,7 +1,7 @@import {acceptance,exists,- queryAll,+ query,} from "discourse/tests/helpers/qunit-helpers";import { test } from "qunit";import { visit } from "@ember/test-helpers";@@ -14,7 +14,9 @@ acceptance("Topic Discovery - Mobile", function (needs) {assert.ok(exists(".topic-list .topic-list-item"), "has topics");assert.strictEqual(- queryAll("a[data-user-card=codinghorror] img.avatar").attr("loading"),+ query("a[data-user-card=codinghorror] img.avatar").getAttribute(+ "loading"+ ),"lazy","it adds loading=`lazy` to topic list avatars");diff --git a/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js b/app/assets/javascripts/discourse/tests/acceptance/new-message-test.jsindex 185850c5117..81cd8ef1122 100644--- a/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/new-message-test.js@@ -2,7 +2,7 @@ import selectKit from "discourse/tests/helpers/select-kit-helper";import {acceptance,exists,- queryAll,+ query,} from "discourse/tests/helpers/qunit-helpers";import { test } from "qunit";import { visit } from "@ember/test-helpers";@@ -27,12 +27,12 @@ acceptance("New Message - Authenticated", function (needs) {assert.ok(exists(".composer-fields"), "it opens composer");assert.strictEqual(- queryAll("#reply-title").val().trim(),+ query("#reply-title").value.trim(),"message title","it pre-fills message title");assert.strictEqual(- queryAll(".d-editor-input").val().trim(),+ query(".d-editor-input").value.trim(),"message body","it pre-fills message body");diff --git a/app/assets/javascripts/discourse/tests/acceptance/new-topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/new-topic-test.jsindex 311a91837d3..18daaab0a5a 100644--- a/app/assets/javascripts/discourse/tests/acceptance/new-topic-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/new-topic-test.js@@ -1,7 +1,7 @@import {acceptance,exists,- queryAll,+ query,} from "discourse/tests/helpers/qunit-helpers";import selectKit from "discourse/tests/helpers/select-kit-helper";import { test } from "qunit";@@ -24,12 +24,12 @@ acceptance("New Topic - Authenticated", function (needs) {assert.ok(exists(".composer-fields"), "it opens composer");assert.strictEqual(- queryAll("#reply-title").val().trim(),+ query("#reply-title").value.trim(),"topic title","it pre-fills topic title");assert.strictEqual(- queryAll(".d-editor-input").val().trim(),+ query(".d-editor-input").value.trim(),"topic body","it pre-fills topic body");diff --git a/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js b/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.jsindex 9ddee1bee92..ce8f1069e8e 100644--- a/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/password-reset-test.js@@ -1,7 +1,7 @@import {acceptance,exists,- queryAll,+ query,} from "discourse/tests/helpers/qunit-helpers";import { click, fillIn, visit } from "@ember/test-helpers";import DiscourseURL from "discourse/lib/url";@@ -73,9 +73,9 @@ acceptance("Password Reset", function (needs) {await fillIn(".password-reset input", "123");assert.ok(exists(".password-reset .tip.bad"), "input is not valid");assert.ok(- queryAll(".password-reset .tip.bad")- .html()- .indexOf(I18n.t("user.password.too_short")) > -1,+ query(".password-reset .tip.bad").innerHTML.includes(+ I18n.t("user.password.too_short")+ ),"password too short");@@ -83,9 +83,9 @@ acceptance("Password Reset", function (needs) {await click(".password-reset form button");assert.ok(exists(".password-reset .tip.bad"), "input is not valid");assert.ok(- queryAll(".password-reset .tip.bad")- .html()- .indexOf("is the name of your cat") > -1,+ query(".password-reset .tip.bad").innerHTML.includes(+ "is the name of your cat"+ ),"server validation error message shows");@@ -112,7 +112,7 @@ acceptance("Password Reset", function (needs) {assert.ok(exists(".alert-error"), "shows 2 factor error");assert.ok(- queryAll(".alert-error").html().indexOf("invalid token") > -1,+ query(".alert-error").innerHTML.includes("invalid token"),"shows server validation error message");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.jsindex fe8811ab7dd..d6512769d29 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@@ -18,17 +18,17 @@ acceptance("Plugin Keyboard Shortcuts - Logged In", function (needs) {withPluginApi("0.8.38", (api) => {api.addKeyboardShortcut("]", () => {- $("#qunit-fixture").html(- "<div id='added-element'>Test adding plugin shortcut</div>"- );+ document.querySelector(+ "#qunit-fixture"+ ).innerHTML = `<div id="added-element">Test adding plugin shortcut</div>`;});});await visit("/t/this-is-a-test-topic/9");await triggerKeyEvent(document, "keypress", "]".charCodeAt(0));- assert.strictEqual(- $("#added-element").length,- 1,++ assert.ok(+ document.querySelector("#added-element"),"the keyboard shortcut callback fires successfully");});@@ -70,6 +70,7 @@ acceptance("Plugin Keyboard Shortcuts - Anonymous", function () {});await visit("/");await triggerKeyEvent(document, "keypress", "?".charCodeAt(0));+assert.ok(exists(".shortcut-category-new_category"));assert.strictEqual(count(".shortcut-category-new_category li"), 1);});diff --git a/app/assets/javascripts/discourse/tests/acceptance/post-controls-test.js b/app/assets/javascripts/discourse/tests/acceptance/post-controls-test.jsindex 8acc304c605..ac7f357eefb 100644--- a/app/assets/javascripts/discourse/tests/acceptance/post-controls-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/post-controls-test.js@@ -41,9 +41,15 @@ acceptance("Post controls", function () {I18n.t("post.actions.people.sr_post_likers_list_description"),"likes container has aria-label");- const likesAvatars = Array.from(- likesContainer.querySelectorAll("a.trigger-user-card")+ assert.equal(+ likesContainer+ .querySelector(".list-description")+ .getAttribute("aria-hidden"),+ "true",+ "list description is aria-hidden");++ const likesAvatars = likesContainer.querySelectorAll("a.trigger-user-card");assert.ok(likesAvatars.length > 0, "avatars are rendered");likesAvatars.forEach((avatar) => {assert.equal(@@ -57,13 +63,6 @@ acceptance("Post controls", function () {"avatars have listitem role");});- assert.equal(- likesContainer- .querySelector(".list-description")- .getAttribute("aria-hidden"),- "true",- "list description is aria-hidden"- );});test("accessibility of the embedded replies below the post", async function (assert) {diff --git a/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js b/app/assets/javascripts/discourse/tests/acceptance/preferences-test.jsindex e7426d4cce9..84125f6bddd 100644--- a/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js@@ -240,7 +240,7 @@ acceptance("User Preferences", function (needs) {await click(".add-security-key");assert.ok(- query(".alert-error").innerHTML.indexOf("provide a name") > -1,+ query(".alert-error").innerHTML.includes("provide a name"),"shows name missing error message");}diff --git a/app/assets/javascripts/discourse/tests/acceptance/reports-test.js b/app/assets/javascripts/discourse/tests/acceptance/reports-test.jsindex 38d766f14cb..4189c8add2c 100644--- a/app/assets/javascripts/discourse/tests/acceptance/reports-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/reports-test.js@@ -1,4 +1,9 @@-import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";+import {+ acceptance,+ count,+ exists,+ query,+} from "discourse/tests/helpers/qunit-helpers";import { test } from "qunit";import { visit } from "@ember/test-helpers";@@ -8,17 +13,17 @@ acceptance("Reports", function (needs) {test("Visit reports page", async function (assert) {await visit("/admin/reports");- assert.strictEqual($(".reports-list .report").length, 1);+ assert.strictEqual(count(".reports-list .report"), 1);- const $report = $(".reports-list .report:first-child");+ const report = query(".reports-list .report:first-child");assert.strictEqual(- $report.find(".report-title").html().trim(),+ report.querySelector(".report-title").innerHTML.trim(),"My report");assert.strictEqual(- $report.find(".report-description").html().trim(),+ report.querySelector(".report-description").innerHTML.trim(),"List of my activities");});diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-full-test.jsindex a133d104e1b..7dca56837ce 100644--- a/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/search-full-test.js@@ -2,7 +2,7 @@ import {acceptance,count,exists,- queryAll,+ query,selectDate,visible,} from "discourse/tests/helpers/qunit-helpers";@@ -112,7 +112,10 @@ acceptance("Search - Full Page", function (needs) {test("perform various searches", async function (assert) {await visit("/search");- assert.ok($("body.search-page").length, "has body class");+ assert.ok(+ document.body.classList.contains("search-page"),+ "has body class"+ );assert.ok(exists(".search-container"), "has container class");assert.ok(exists(".search-query"));assert.ok(!exists(".fps-topic"));@@ -177,7 +180,7 @@ acceptance("Search - Full Page", function (needs) {'has "faq" populated');assert.strictEqual(- queryAll(".search-query").val(),+ query(".search-query").value,"none #faq",'has updated search term to "none #faq"');@@ -201,7 +204,7 @@ acceptance("Search - Full Page", function (needs) {'has "快乐的" populated');assert.strictEqual(- queryAll(".search-query").val(),+ query(".search-query").value,"none category:240",'has updated search term to "none category:240"');@@ -217,7 +220,7 @@ acceptance("Search - Full Page", function (needs) {'has "in title" populated');assert.strictEqual(- queryAll(".search-query").val(),+ query(".search-query").value,"none in:title",'has updated search term to "none in:title"');@@ -240,7 +243,7 @@ acceptance("Search - Full Page", function (needs) {'has "I liked" populated');assert.strictEqual(- queryAll(".search-query").val(),+ query(".search-query").value,"none in:likes",'has updated search term to "none in:likes"');@@ -257,7 +260,7 @@ acceptance("Search - Full Page", function (needs) {);assert.strictEqual(- queryAll(".search-query").val(),+ query(".search-query").value,"none in:messages",'has updated search term to "none in:messages"');@@ -281,7 +284,7 @@ acceptance("Search - Full Page", function (needs) {);assert.strictEqual(- queryAll(".search-query").val(),+ query(".search-query").value,"none in:seen","it should update the search term");@@ -310,7 +313,7 @@ acceptance("Search - Full Page", function (needs) {'has "I bookmarked" populated');assert.strictEqual(- queryAll(".search-query").val(),+ query(".search-query").value,"none in:bookmarks",'has updated search term to "none in:bookmarks"');@@ -334,7 +337,7 @@ acceptance("Search - Full Page", function (needs) {'has "are closed" populated');assert.strictEqual(- queryAll(".search-query").val(),+ query(".search-query").value,"none status:closed",'has updated search term to "none status:closed"');@@ -376,7 +379,7 @@ acceptance("Search - Full Page", function (needs) {await visit("/search?expanded=true&q=after:2018-08-22");assert.strictEqual(- queryAll(".search-query").val(),+ query(".search-query").value,"after:2018-08-22","it should update the search term correctly");@@ -400,7 +403,7 @@ acceptance("Search - Full Page", function (needs) {);assert.strictEqual(- queryAll(".search-query").val(),+ query(".search-query").value,"none after:2016-10-05",'has updated search term to "none after:2016-10-05"');@@ -413,14 +416,12 @@ acceptance("Search - Full Page", function (needs) {await fillIn("#search-min-post-count", "5");assert.strictEqual(- queryAll(- ".search-advanced-additional-options #search-min-post-count"- ).val(),+ query(".search-advanced-additional-options #search-min-post-count").value,"5",'has "5" populated');assert.strictEqual(- queryAll(".search-query").val(),+ query(".search-query").value,"none min_posts:5",'has updated search term to "none min_posts:5"');@@ -433,14 +434,12 @@ acceptance("Search - Full Page", function (needs) {await fillIn("#search-max-post-count", "5");assert.strictEqual(- queryAll(- ".search-advanced-additional-options #search-max-post-count"- ).val(),+ query(".search-advanced-additional-options #search-max-post-count").value,"5",'has "5" populated');assert.strictEqual(- queryAll(".search-query").val(),+ query(".search-query").value,"none max_posts:5",'has updated search term to "none max_posts:5"');@@ -456,7 +455,7 @@ acceptance("Search - Full Page", function (needs) {);assert.strictEqual(- queryAll(".search-query").val(),+ query(".search-query").value,"in:likes",'has updated search term to "in:likes"');@@ -583,11 +582,11 @@ acceptance("Search - Full Page", function (needs) {await fillIn(".search-query", "discourse");await click(".search-cta");- assert.equal(queryAll(".visited").length, 0);+ assert.equal(count(".visited"), 0);await fillIn(".search-query", "discourse visited");await click(".search-cta");- assert.equal(queryAll(".visited").length, 1);+ assert.equal(count(".visited"), 1);});test("result link click tracking is invoked", async function (assert) {diff --git a/app/assets/javascripts/discourse/tests/acceptance/search-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/search-mobile-test.jsindex b27985a0da1..2452d1ea8b6 100644--- a/app/assets/javascripts/discourse/tests/acceptance/search-mobile-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/search-mobile-test.js@@ -2,7 +2,7 @@ import {acceptance,count,exists,- queryAll,+ query,} from "discourse/tests/helpers/qunit-helpers";import { click, fillIn, visit } from "@ember/test-helpers";import { test } from "qunit";@@ -42,7 +42,7 @@ acceptance("Search - Mobile", function (needs) {await click("#search-button");assert.strictEqual(- queryAll("input.full-page-search").val(),+ query("input.full-page-search").value,"discourse","it does not reset input when hitting search icon again");diff --git a/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.jsindex c18f96508d9..be66565f7a4 100644--- a/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js@@ -5,7 +5,6 @@ import {acceptance,exists,query,- queryAll,} from "discourse/tests/helpers/qunit-helpers";import selectKit from "discourse/tests/helpers/select-kit-helper";import { test } from "qunit";@@ -45,9 +44,9 @@ acceptance("Share and Invite modal", function (needs) {);assert.ok(- queryAll("input.invite-link")- .val()- .includes("/t/internationalization-localization/280?u=eviltrout"),+ query("input.invite-link").value.includes(+ "/t/internationalization-localization/280?u=eviltrout"+ ),"it shows the topic sharing url");@@ -135,7 +134,7 @@ acceptance("Share url with badges disabled - desktop", function (needs) {await click("#topic-footer-button-share-and-invite");assert.notOk(- queryAll("input.invite-link").val().includes("?u=eviltrout"),+ query("input.invite-link").value.includes("?u=eviltrout"),"it doesn't add the username param when badges are disabled");});diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-categories-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-categories-section-test.jsindex e771afdc213..0552c9d149c 100644--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-categories-section-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-categories-section-test.js@@ -1,13 +1,11 @@import { test } from "qunit";-import { click, currentURL, settled, visit } from "@ember/test-helpers";-import {acceptance,+ count,exists,publishToMessageBus,query,- queryAll,updateCurrentUser,} from "discourse/tests/helpers/qunit-helpers";import Site from "discourse/models/site";@@ -39,7 +37,7 @@ acceptance(await visit("/");assert.strictEqual(- queryAll(".sidebar-section-categories .sidebar-section-link").length,+ count(".sidebar-section-categories .sidebar-section-link"),1,"there should only be one section link under the section");@@ -161,7 +159,7 @@ acceptance("Sidebar - Categories Section", function (needs) {await visit("/");assert.strictEqual(- queryAll(".sidebar-section-categories .sidebar-section-link").length,+ count(".sidebar-section-categories .sidebar-section-link"),2,"there should only be two section link under the section");@@ -186,8 +184,7 @@ acceptance("Sidebar - Categories Section", function (needs) {);assert.strictEqual(- queryAll(".sidebar-section-categories .sidebar-section-link.active")- .length,+ count(".sidebar-section-categories .sidebar-section-link.active"),1,"only one link is marked as active");@@ -206,8 +203,7 @@ acceptance("Sidebar - Categories Section", function (needs) {);assert.strictEqual(- queryAll(".sidebar-section-categories .sidebar-section-link.active")- .length,+ count(".sidebar-section-categories .sidebar-section-link.active"),1,"only one link is marked as active");@@ -224,8 +220,7 @@ acceptance("Sidebar - Categories Section", function (needs) {await visit(`/c/${category1.slug}/${category1.id}/l/new`);assert.strictEqual(- queryAll(".sidebar-section-categories .sidebar-section-link.active")- .length,+ count(".sidebar-section-categories .sidebar-section-link.active"),1,"only one link is marked as active");@@ -242,8 +237,7 @@ acceptance("Sidebar - Categories Section", function (needs) {await visit(`/c/${category1.slug}/${category1.id}/l/unread`);assert.strictEqual(- queryAll(".sidebar-section-categories .sidebar-section-link.active")- .length,+ count(".sidebar-section-categories .sidebar-section-link.active"),1,"only one link is marked as active");@@ -260,8 +254,7 @@ acceptance("Sidebar - Categories Section", function (needs) {await visit(`/c/${category1.slug}/${category1.id}/l/top`);assert.strictEqual(- queryAll(".sidebar-section-categories .sidebar-section-link.active")- .length,+ count(".sidebar-section-categories .sidebar-section-link.active"),1,"only one link is marked as active");diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-messages-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-messages-section-test.jsindex 4d6770a665d..bdbec2db140 100644--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-messages-section-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-messages-section-test.js@@ -1,14 +1,12 @@import { test } from "qunit";import I18n from "I18n";-import { click, currentURL, settled, visit } from "@ember/test-helpers";-import {acceptance,+ count,exists,publishToMessageBus,query,- queryAll,updateCurrentUser,} from "discourse/tests/helpers/qunit-helpers";import { NotificationLevels } from "discourse/lib/notification-levels";@@ -71,7 +69,6 @@ acceptance(test("clicking on section header button", async function (assert) {await visit("/");-await click(".sidebar-section-messages .sidebar-section-header-button");assert.ok(@@ -87,7 +84,7 @@ acceptance(assert.strictEqual(currentURL(),`/u/eviltrout/messages`,- "it should transistion to the user's messages"+ "it should transition to the user's messages");});@@ -102,7 +99,7 @@ acceptance();assert.strictEqual(- queryAll(".sidebar-section-messages .sidebar-section-link").length,+ count(".sidebar-section-messages .sidebar-section-link"),1,"only displays the personal message inbox link");@@ -119,7 +116,7 @@ acceptance();assert.strictEqual(- queryAll(".sidebar-section-messages .sidebar-section-link").length,+ count(".sidebar-section-messages .sidebar-section-link"),5,"expands and displays the links for personal messages");@@ -144,8 +141,7 @@ acceptance();assert.strictEqual(- queryAll(".sidebar-section-messages .sidebar-section-link.active")- .length,+ count(".sidebar-section-messages .sidebar-section-link.active"),2,"only two links are marked as active in the sidebar");@@ -203,14 +199,13 @@ acceptance(await visit("/u/eviltrout/messages/group/GrOuP1");assert.strictEqual(- queryAll(".sidebar-section-messages .sidebar-section-link").length,+ count(".sidebar-section-messages .sidebar-section-link"),6,"expands and displays the links for group1 group messages");assert.strictEqual(- queryAll(".sidebar-section-messages .sidebar-section-link.group1")- .length,+ count(".sidebar-section-messages .sidebar-section-link.group1"),4,"expands the links for group1 group messages");@@ -220,15 +215,13 @@ acceptance();assert.strictEqual(- queryAll(".sidebar-section-messages .sidebar-section-link.group1")- .length,+ count(".sidebar-section-messages .sidebar-section-link.group1"),1,"collapses the links for group1 group messages");assert.strictEqual(- queryAll(".sidebar-section-messages .sidebar-section-link.group3")- .length,+ count(".sidebar-section-messages .sidebar-section-link.group3"),4,"expands the links for group3 group messages");@@ -270,8 +263,7 @@ acceptance();assert.strictEqual(- queryAll(".sidebar-section-messages .sidebar-section-link.active")- .length,+ count(".sidebar-section-messages .sidebar-section-link.active"),2,"only two links are marked as active in the sidebar");@@ -305,22 +297,21 @@ acceptance(await visit("/t/130");assert.strictEqual(- queryAll(".sidebar-section-messages .sidebar-section-link").length,+ count(".sidebar-section-messages .sidebar-section-link"),5,"5 section links are displayed");assert.strictEqual(- queryAll(+ count(".sidebar-section-messages .sidebar-section-link.personal-messages"- ).length,+ ),1,"personal messages inbox filter links are not shown");assert.strictEqual(- queryAll(".sidebar-section-messages .sidebar-section-link.foo_group")- .length,+ count(".sidebar-section-messages .sidebar-section-link.foo_group"),4,"foo_group messages inbox filter links are shown");@@ -339,22 +330,21 @@ acceptance(await visit("/t/34");assert.strictEqual(- queryAll(".sidebar-section-messages .sidebar-section-link").length,+ count(".sidebar-section-messages .sidebar-section-link"),6,"6 section links are displayed");assert.strictEqual(- queryAll(+ count(".sidebar-section-messages .sidebar-section-link.personal-messages"- ).length,+ ),5,"personal messages inbox filter links are shown");assert.strictEqual(- queryAll(".sidebar-section-messages .sidebar-section-link.foo_group")- .length,+ count(".sidebar-section-messages .sidebar-section-link.foo_group"),1,"foo_group messages inbox filter links are not shown");diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-mobile-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-mobile-test.jsindex 8c06a9e7d27..738592bf05e 100644--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-mobile-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-mobile-test.js@@ -1,5 +1,4 @@import { test } from "qunit";-import { click, visit } from "@ember/test-helpers";import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-tags-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-tags-section-test.jsindex 2b545979c21..8743ea4443c 100644--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-tags-section-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-tags-section-test.js@@ -1,14 +1,12 @@import I18n from "I18n";import { test } from "qunit";-import { click, currentURL, settled, visit } from "@ember/test-helpers";-import {acceptance,+ count,exists,publishToMessageBus,query,- queryAll,updateCurrentUser,} from "discourse/tests/helpers/qunit-helpers";import discoveryFixture from "discourse/tests/fixtures/discovery-fixtures";@@ -104,7 +102,7 @@ acceptance("Sidebar - Tags section", function (needs) {await visit("/");assert.strictEqual(- queryAll(".sidebar-section-tags .sidebar-section-link").length,+ count(".sidebar-section-tags .sidebar-section-link"),3,"3 section links under the section");@@ -136,7 +134,7 @@ acceptance("Sidebar - Tags section", function (needs) {);assert.strictEqual(- queryAll(".sidebar-section-tags .sidebar-section-link.active").length,+ count(".sidebar-section-tags .sidebar-section-link.active"),1,"only one link is marked as active");@@ -155,7 +153,7 @@ acceptance("Sidebar - Tags section", function (needs) {);assert.strictEqual(- queryAll(".sidebar-section-tags .sidebar-section-link.active").length,+ count(".sidebar-section-tags .sidebar-section-link.active"),1,"only one link is marked as active");@@ -170,7 +168,7 @@ acceptance("Sidebar - Tags section", function (needs) {await visit(`/tag/tag1/l/top`);assert.strictEqual(- queryAll(".sidebar-section-tags .sidebar-section-link.active").length,+ count(".sidebar-section-tags .sidebar-section-link.active"),1,"only one link is marked as active");@@ -185,7 +183,7 @@ acceptance("Sidebar - Tags section", function (needs) {await visit(`/tag/tag1/l/new`);assert.strictEqual(- queryAll(".sidebar-section-tags .sidebar-section-link.active").length,+ count(".sidebar-section-tags .sidebar-section-link.active"),1,"only one link is marked as active");@@ -200,7 +198,7 @@ acceptance("Sidebar - Tags section", function (needs) {await visit(`/tag/tag1/l/unread`);assert.strictEqual(- queryAll(".sidebar-section-tags .sidebar-section-link.active").length,+ count(".sidebar-section-tags .sidebar-section-link.active"),1,"only one link is marked as active");diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-test.jsindex 7f74dc66738..c324ac0e8bc 100644--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-test.js@@ -1,5 +1,4 @@import { test } from "qunit";-import { click, visit } from "@ember/test-helpers";import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";@@ -8,9 +7,8 @@ acceptance("Sidebar - Anon User", function () {test("sidebar is not displayed", async function (assert) {await visit("/");- assert.strictEqual(- document.querySelectorAll("body.has-sidebar-page").length,- 0,+ assert.ok(+ !document.body.classList.contains("has-sidebar-page"),"does not add sidebar utility class to body");@@ -24,9 +22,8 @@ acceptance("Sidebar - User with sidebar disabled", function (needs) {test("sidebar is not displayed", async function (assert) {await visit("/");- assert.strictEqual(- document.querySelectorAll("body.has-sidebar-page").length,- 0,+ assert.ok(+ !document.body.classList.contains("has-sidebar-page"),"does not add sidebar utility class to body");@@ -40,9 +37,8 @@ acceptance("Sidebar - User with sidebar enabled", function (needs) {test("hiding and displaying sidebar", async function (assert) {await visit("/");- assert.strictEqual(- document.querySelectorAll("body.has-sidebar-page").length,- 1,+ assert.ok(+ document.body.classList.contains("has-sidebar-page"),"adds sidebar utility class to body");@@ -50,9 +46,8 @@ acceptance("Sidebar - User with sidebar enabled", function (needs) {await click(".header-sidebar-toggle .btn");- assert.strictEqual(- document.querySelectorAll("body.has-sidebar-page").length,- 0,+ assert.ok(+ !document.body.classList.contains("has-sidebar-page"),"removes sidebar utility class to body");diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-topics-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-topics-section-test.jsindex 3d6eedfd48d..f393a7d5eee 100644--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-topics-section-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-topics-section-test.js@@ -1,14 +1,12 @@import { test } from "qunit";-import { click, currentURL, settled, visit } from "@ember/test-helpers";-import {acceptance,+ count,exists,loggedInUser,publishToMessageBus,query,- queryAll,} from "discourse/tests/helpers/qunit-helpers";import topicFixtures from "discourse/tests/fixtures/discovery-fixtures";import { cloneJSON } from "discourse-common/lib/object";@@ -88,11 +86,11 @@ acceptance("Sidebar - Topics Section", function (needs) {assert.strictEqual(currentURL(),"/latest",- "it should transistion to the homepage"+ "it should transition to the homepage");assert.strictEqual(- queryAll(".sidebar-section-topics .sidebar-section-link.active").length,+ count(".sidebar-section-topics .sidebar-section-link.active"),1,"only one link is marked as active");@@ -110,11 +108,11 @@ acceptance("Sidebar - Topics Section", function (needs) {assert.strictEqual(currentURL(),"/latest",- "it should transistion to the latest page"+ "it should transition to the latest page");assert.strictEqual(- queryAll(".sidebar-section-topics .sidebar-section-link.active").length,+ count(".sidebar-section-topics .sidebar-section-link.active"),1,"only one link is marked as active");@@ -132,11 +130,11 @@ acceptance("Sidebar - Topics Section", function (needs) {assert.strictEqual(currentURL(),"/latest?f=tracked",- "it should transistion to the tracked url"+ "it should transition to the tracked url");assert.strictEqual(- queryAll(".sidebar-section-topics .sidebar-section-link.active").length,+ count(".sidebar-section-topics .sidebar-section-link.active"),1,"only one link is marked as active");@@ -154,11 +152,11 @@ acceptance("Sidebar - Topics Section", function (needs) {assert.strictEqual(currentURL(),`/u/${loggedInUser().username}/activity/bookmarks`,- "it should transistion to the bookmarked url"+ "it should transition to the bookmarked url");assert.strictEqual(- queryAll(".sidebar-section-topics .sidebar-section-link.active").length,+ count(".sidebar-section-topics .sidebar-section-link.active"),1,"only one link is marked as active");@@ -176,11 +174,11 @@ acceptance("Sidebar - Topics Section", function (needs) {assert.strictEqual(currentURL(),`/u/${loggedInUser().username}/activity`,- "it should transistion to the user's activity url"+ "it should transition to the user's activity url");assert.strictEqual(- queryAll(".sidebar-section-topics .sidebar-section-link.active").length,+ count(".sidebar-section-topics .sidebar-section-link.active"),1,"only one link is marked as active");@@ -212,11 +210,11 @@ acceptance("Sidebar - Topics Section", function (needs) {assert.strictEqual(currentURL(),`/u/${loggedInUser().username}/activity/drafts`,- "it transistions to the user's activity drafts url"+ "it transitions to the user's activity drafts url");assert.strictEqual(- queryAll(".sidebar-section-topics .sidebar-section-link.active").length,+ count(".sidebar-section-topics .sidebar-section-link.active"),1,"only one link is marked as active");@@ -238,7 +236,7 @@ acceptance("Sidebar - Topics Section", function (needs) {await visit("/top");assert.strictEqual(- queryAll(".sidebar-section-topics .sidebar-section-link.active").length,+ count(".sidebar-section-topics .sidebar-section-link.active"),1,"only one link is marked as active");@@ -253,7 +251,7 @@ acceptance("Sidebar - Topics Section", function (needs) {await visit("/unread");assert.strictEqual(- queryAll(".sidebar-section-topics .sidebar-section-link.active").length,+ count(".sidebar-section-topics .sidebar-section-link.active"),1,"only one link is marked as active");@@ -268,7 +266,7 @@ acceptance("Sidebar - Topics Section", function (needs) {await visit("/new");assert.strictEqual(- queryAll(".sidebar-section-topics .sidebar-section-link.active").length,+ count(".sidebar-section-topics .sidebar-section-link.active"),1,"only one link is marked as active");@@ -429,7 +427,7 @@ acceptance("Sidebar - Topics Section", function (needs) {await visit("/top?f=tracked");assert.strictEqual(- queryAll(".sidebar-section-topics .sidebar-section-link.active").length,+ count(".sidebar-section-topics .sidebar-section-link.active"),1,"only one link is marked as active");@@ -444,7 +442,7 @@ acceptance("Sidebar - Topics Section", function (needs) {await visit("/unread?f=tracked");assert.strictEqual(- queryAll(".sidebar-section-topics .sidebar-section-link.active").length,+ count(".sidebar-section-topics .sidebar-section-link.active"),1,"only one link is marked as active");@@ -459,7 +457,7 @@ acceptance("Sidebar - Topics Section", function (needs) {await visit("/new?f=tracked");assert.strictEqual(- queryAll(".sidebar-section-topics .sidebar-section-link.active").length,+ count(".sidebar-section-topics .sidebar-section-link.active"),1,"only one link is marked as active");diff --git a/app/assets/javascripts/discourse/tests/acceptance/static-test.js b/app/assets/javascripts/discourse/tests/acceptance/static-test.jsindex 4071f1b6204..92a7125128b 100644--- a/app/assets/javascripts/discourse/tests/acceptance/static-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/static-test.js@@ -5,19 +5,31 @@ import { test } from "qunit";acceptance("Static", function () {test("Static Pages", async function (assert) {await visit("/faq");- assert.ok($("body.static-faq").length, "has the body class");+ assert.ok(+ document.body.classList.contains("static-faq"),+ "has the body class"+ );assert.ok(exists(".body-page"), "The content is present");await visit("/guidelines");- assert.ok($("body.static-guidelines").length, "has the body class");+ assert.ok(+ document.body.classList.contains("static-guidelines"),+ "has the body class"+ );assert.ok(exists(".body-page"), "The content is present");await visit("/tos");- assert.ok($("body.static-tos").length, "has the body class");+ assert.ok(+ document.body.classList.contains("static-tos"),+ "has the body class"+ );assert.ok(exists(".body-page"), "The content is present");await visit("/privacy");- assert.ok($("body.static-privacy").length, "has the body class");+ assert.ok(+ document.body.classList.contains("static-privacy"),+ "has the body class"+ );assert.ok(exists(".body-page"), "The content is present");await visit("/login");diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-bulk-actions-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-bulk-actions-test.jsindex dc41baeeb72..e929567609d 100644--- a/app/assets/javascripts/discourse/tests/acceptance/topic-bulk-actions-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-bulk-actions-test.js@@ -1,6 +1,8 @@import {acceptance,+ count,invisible,+ query,queryAll,updateCurrentUser,} from "discourse/tests/helpers/qunit-helpers";@@ -30,82 +32,82 @@ acceptance("Topic - Bulk Actions", function (needs) {await click(".bulk-select-actions");assert.ok(- queryAll("#discourse-modal-title")- .html()- .includes(I18n.t("topics.bulk.actions")),+ query("#discourse-modal-title").innerHTML.includes(+ I18n.t("topics.bulk.actions")+ ),"it opens bulk-select modal");assert.ok(- queryAll(".bulk-buttons")- .html()- .includes(I18n.t("topics.bulk.change_category")),+ query(".bulk-buttons").innerHTML.includes(+ I18n.t("topics.bulk.change_category")+ ),"it shows an option to change category");assert.ok(- queryAll(".bulk-buttons")- .html()- .includes(I18n.t("topics.bulk.close_topics")),+ query(".bulk-buttons").innerHTML.includes(+ I18n.t("topics.bulk.close_topics")+ ),"it shows an option to close topics");assert.ok(- queryAll(".bulk-buttons")- .html()- .includes(I18n.t("topics.bulk.archive_topics")),+ query(".bulk-buttons").innerHTML.includes(+ I18n.t("topics.bulk.archive_topics")+ ),"it shows an option to archive topics");assert.ok(- queryAll(".bulk-buttons")- .html()- .includes(I18n.t("topics.bulk.notification_level")),+ query(".bulk-buttons").innerHTML.includes(+ I18n.t("topics.bulk.notification_level")+ ),"it shows an option to update notification level");assert.ok(- queryAll(".bulk-buttons").html().includes(I18n.t("topics.bulk.defer")),+ query(".bulk-buttons").innerHTML.includes(I18n.t("topics.bulk.defer")),"it shows an option to reset read");assert.ok(- queryAll(".bulk-buttons")- .html()- .includes(I18n.t("topics.bulk.unlist_topics")),+ query(".bulk-buttons").innerHTML.includes(+ I18n.t("topics.bulk.unlist_topics")+ ),"it shows an option to unlist topics");assert.ok(- queryAll(".bulk-buttons")- .html()- .includes(I18n.t("topics.bulk.reset_bump_dates")),+ query(".bulk-buttons").innerHTML.includes(+ I18n.t("topics.bulk.reset_bump_dates")+ ),"it shows an option to reset bump dates");assert.ok(- queryAll(".bulk-buttons")- .html()- .includes(I18n.t("topics.bulk.change_tags")),+ query(".bulk-buttons").innerHTML.includes(+ I18n.t("topics.bulk.change_tags")+ ),"it shows an option to replace tags");assert.ok(- queryAll(".bulk-buttons")- .html()- .includes(I18n.t("topics.bulk.append_tags")),+ query(".bulk-buttons").innerHTML.includes(+ I18n.t("topics.bulk.append_tags")+ ),"it shows an option to append tags");assert.ok(- queryAll(".bulk-buttons")- .html()- .includes(I18n.t("topics.bulk.remove_tags")),+ query(".bulk-buttons").innerHTML.includes(+ I18n.t("topics.bulk.remove_tags")+ ),"it shows an option to remove all tags");assert.ok(- queryAll(".bulk-buttons").html().includes(I18n.t("topics.bulk.delete")),+ query(".bulk-buttons").innerHTML.includes(I18n.t("topics.bulk.delete")),"it shows an option to delete topics");});@@ -136,8 +138,8 @@ acceptance("Topic - Bulk Actions", function (needs) {await triggerEvent(queryAll("input.bulk-select")[3], "click", {shiftKey: true,});- assert.equal(- queryAll("input.bulk-select:checked").length,+ assert.strictEqual(+ count("input.bulk-select:checked"),4,"Shift click selects a range");@@ -148,8 +150,8 @@ acceptance("Topic - Bulk Actions", function (needs) {await triggerEvent(queryAll("input.bulk-select")[1], "click", {shiftKey: true,});- assert.equal(- queryAll("input.bulk-select:checked").length,+ assert.strictEqual(+ count("input.bulk-select:checked"),5,"Bottom-up Shift click range selection works");diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-test.jsindex 0cb9b0687ab..63c1bcf397e 100644--- a/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-test.js@@ -22,7 +22,7 @@ acceptance("Topic Discovery", function (needs) {test("Visit Discovery Pages", async function (assert) {await visit("/");assert.ok(- document.querySelectorAll("body.navigation-topics").length,+ document.body.classList.contains("navigation-topics"),"has the default navigation");assert.ok(exists(".topic-list"), "The list of topics was rendered");@@ -45,28 +45,28 @@ acceptance("Topic Discovery", function (needs) {assert.ok(exists(".topic-list .topic-list-item"), "has topics");assert.ok(!exists(".category-list"), "doesn't render subcategories");assert.ok(- document.querySelectorAll("body.category-bug").length,+ document.body.classList.contains("category-bug"),"has a custom css class for the category id on the body");await visit("/categories");assert.ok(- document.querySelectorAll("body.navigation-categories").length,+ document.body.classList.contains("navigation-categories"),"has the body class");assert.ok(- document.querySelectorAll("body.category-bug").length === 0,+ !document.body.classList.contains("category-bug"),"removes the custom category class");assert.ok(exists(".category"), "has a list of categories");assert.ok(- document.querySelectorAll("body.categories-list").length,+ document.body.classList.contains("categories-list"),"has a custom class to indicate categories");await visit("/top");assert.ok(- document.querySelectorAll("body.categories-list").length === 0,+ !document.body.classList.contains("categories-list"),"removes the `categories-list` class");assert.ok(exists(".topic-list .topic-list-item"), "has topics");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.jsindex 6c9c7bb9c25..e761909e912 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@@ -2,6 +2,7 @@ import {acceptance,chromeTest,exists,+ query,queryAll,selectText,} from "discourse/tests/helpers/qunit-helpers";@@ -55,7 +56,7 @@ acceptance("Topic - Quote button - logged in", function (needs) {await click(".insert-quote");assert.strictEqual(- queryAll(".d-editor-input").val().trim(),+ query(".d-editor-input").value.trim(),'[quote="group_moderator, post:3, topic:2480"]\nhttps://example.com/57350945\n[/quote]',"quote only contains a link");@@ -135,7 +136,7 @@ acceptance("Topic - Quote button - keyboard shortcut", function (needs) {assert.ok(exists(".d-editor-input"), "the editor is open");assert.ok(- queryAll(".d-editor-input").val().includes("Any plans to support"),+ query(".d-editor-input").value.includes("Any plans to support"),"editor includes selected text");});diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-anonymous-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-anonymous-test.jsindex e6696e68a05..a4e42661168 100644--- a/app/assets/javascripts/discourse/tests/acceptance/user-anonymous-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/user-anonymous-test.js@@ -5,7 +5,11 @@ import { test } from "qunit";acceptance("User Anonymous", function () {test("Root URL", async function (assert) {await visit("/u/eviltrout");- assert.ok($("body.user-summary-page").length, "has the body class");++ assert.ok(+ document.body.classList.contains("user-summary-page"),+ "has the body class"+ );assert.strictEqual(currentRouteName(),"user.summary",@@ -15,7 +19,10 @@ acceptance("User Anonymous", function () {test("Filters", async function (assert) {await visit("/u/eviltrout/activity");- assert.ok($("body.user-activity-page").length, "has the body class");+ assert.ok(+ document.body.classList.contains("user-activity-page"),+ "has the body class"+ );assert.ok(exists(".user-main .about"), "it has the about section");assert.ok(exists(".user-stream .item"), "it has stream items");@@ -32,7 +39,11 @@ acceptance("User Anonymous", function () {test("Badges", async function (assert) {await visit("/u/eviltrout/badges");- assert.ok($("body.user-badges-page").length, "has the body class");++ assert.ok(+ document.body.classList.contains("user-badges-page"),+ "has the body class"+ );assert.ok(exists(".badge-group-list .badge-card"), "shows a badge");});diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-bookmarks-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-bookmarks-test.jsindex 4c379d80b9e..691ecd9ef59 100644--- a/app/assets/javascripts/discourse/tests/acceptance/user-bookmarks-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/user-bookmarks-test.js@@ -1,7 +1,7 @@import {acceptance,+ count,exists,- queryAll,} from "discourse/tests/helpers/qunit-helpers";import { click, visit } from "@ember/test-helpers";import { cloneJSON } from "discourse-common/lib/object";@@ -60,13 +60,13 @@ acceptance("User's bookmarks - reminder", function (needs) {test("bookmarks with reminders have a clear reminder option", async function (assert) {await visit("/u/eviltrout/activity/bookmarks");- assert.strictEqual(queryAll(".bookmark-reminder").length, 2);+ assert.strictEqual(count(".bookmark-reminder"), 2);const dropdown = selectKit(".bookmark-actions-dropdown");await dropdown.expand();await dropdown.selectRowByValue("clear_reminder");- assert.strictEqual(queryAll(".bookmark-reminder").length, 1);+ assert.strictEqual(count(".bookmark-reminder"), 1);});});diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.jsindex a0602c737a9..2ea3fb5b54c 100644--- a/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js@@ -4,7 +4,6 @@ import {exists,normalizeHtml,query,- queryAll,visible,} from "discourse/tests/helpers/qunit-helpers";import { click, visit } from "@ember/test-helpers";@@ -42,7 +41,7 @@ acceptance("User Drafts", function (needs) {await click(".user-stream-item .resume-draft");assert.strictEqual(- queryAll(".d-editor-input").val().trim(),+ query(".d-editor-input").value.trim(),"A fun new topic for testing drafts.");});diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.jsindex 3737937f10c..50cf773d120 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@@ -2,7 +2,7 @@ import {acceptance,count,exists,- queryAll,+ query,} from "discourse/tests/helpers/qunit-helpers";import { click, visit } from "@ember/test-helpers";import cookie, { removeCookie } from "discourse/lib/cookie";@@ -22,7 +22,7 @@ acceptance("User Preferences - Interface", function (needs) {assert.ok(!exists(".saved"), "it hasn't been saved yet");await click(".save-changes");assert.ok(exists(".saved"), "it displays the saved message");- queryAll(".saved").remove();+ query(".saved").remove();};await visit("/u/eviltrout/preferences/interface");@@ -187,8 +187,8 @@ acceptance(await visit("/u/eviltrout/preferences/interface");assert.ok(exists(".light-color-scheme"), "has light scheme dropdown");assert.strictEqual(- queryAll(".light-color-scheme .selected-name").data("value"),- session.userColorSchemeId,+ query(".light-color-scheme .selected-name").dataset.value,+ session.userColorSchemeId.toString(),"user's selected color scheme is selected value in light scheme dropdown");});@@ -237,15 +237,15 @@ acceptance(assert.ok(!exists(".saved"), "it hasn't been saved yet");await click(".save-changes");assert.ok(exists(".saved"), "it displays the saved message");- queryAll(".saved").remove();+ query(".saved").remove();};await visit("/u/eviltrout/preferences/interface");assert.ok(exists(".light-color-scheme"), "has regular dropdown");assert.ok(exists(".dark-color-scheme"), "has dark color scheme dropdown");assert.strictEqual(- queryAll(".dark-color-scheme .selected-name").data("value"),- session.userDarkSchemeId,+ query(".dark-color-scheme .selected-name").dataset.value,+ session.userDarkSchemeId.toString(),"sets site default as selected dark scheme");assert.ok(diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-test.jsindex 214229c25ca..e8ae776aa2a 100644--- a/app/assets/javascripts/discourse/tests/acceptance/user-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/user-test.js@@ -43,12 +43,18 @@ acceptance("User Routes", function (needs) {test("Invites", async function (assert) {await visit("/u/eviltrout/invited/pending");- assert.ok($("body.user-invites-page").length, "has the body class");+ assert.ok(+ document.body.classList.contains("user-invites-page"),+ "has the body class"+ );});test("Notifications", async function (assert) {await visit("/u/eviltrout/notifications");- assert.ok($("body.user-notifications-page").length, "has the body class");+ assert.ok(+ document.body.classList.contains("user-notifications-page"),+ "has the body class"+ );const $links = queryAll(".item.notification a");@@ -75,7 +81,10 @@ acceptance("User Routes", function (needs) {test("Root URL - Viewing Self", async function (assert) {await visit("/u/eviltrout");- assert.ok($("body.user-activity-page").length, "has the body class");+ assert.ok(+ document.body.classList.contains("user-activity-page"),+ "has the body class"+ );assert.strictEqual(currentRouteName(),"userActivity.index",@@ -209,8 +218,11 @@ acceptance("User Routes - Moderator viewing warnings", function (needs) {test("Messages - Warnings", async function (assert) {await visit("/u/eviltrout/messages/warnings");- assert.ok($("body.user-messages-page").length, "has the body class");- assert.ok($("div.alert-info").length, "has the permissions alert");+ assert.ok(+ document.body.classList.contains("user-messages-page"),+ "has the body class"+ );+ assert.ok(exists("div.alert-info"), "has the permissions alert");});});diff --git a/app/assets/javascripts/discourse/tests/acceptance/users-test.js b/app/assets/javascripts/discourse/tests/acceptance/users-test.jsindex a9d65bc643a..4f6eb96d495 100644--- a/app/assets/javascripts/discourse/tests/acceptance/users-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/users-test.js@@ -10,7 +10,10 @@ import { click, triggerKeyEvent, visit } from "@ember/test-helpers";acceptance("User Directory", function () {test("Visit Page", async function (assert) {await visit("/u");- assert.ok($("body.users-page").length, "has the body class");+ assert.ok(+ document.body.classList.contains("users-page"),+ "has the body class"+ );assert.ok(exists(".directory table tr"), "has a list of users");});@@ -21,13 +24,19 @@ acceptance("User Directory", function () {test("Visit Without Usernames", async function (assert) {await visit("/u?exclude_usernames=system");- assert.ok($("body.users-page").length, "has the body class");+ assert.ok(+ document.body.classList.contains("users-page"),+ "has the body class"+ );assert.ok(exists(".directory table tr"), "has a list of users");});test("Visit With Group Filter", async function (assert) {await visit("/u?group=trust_level_0");- assert.ok($("body.users-page").length, "has the body class");+ assert.ok(+ document.body.classList.contains("users-page"),+ "has the body class"+ );assert.ok(exists(".directory table tr"), "has a list of users");});diff --git a/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js b/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.jsindex a603d206758..417c412eaf2 100644--- a/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js+++ b/app/assets/javascripts/discourse/tests/integration/components/d-editor-test.js@@ -656,18 +656,14 @@ third line`testCase(`doesn't jump to bottom with long text`,async function (assert, textarea) {- let longText = "hello world.";- for (let i = 0; i < 8; i++) {- longText = longText + longText;- }- this.set("value", longText);+ this.set("value", "hello world.".repeat(8));- $(textarea).scrollTop(0);+ textarea.scrollTop = 0;textarea.selectionStart = 3;textarea.selectionEnd = 3;await click("button.bold");- assert.strictEqual($(textarea).scrollTop(), 0, "it stays scrolled up");+ assert.strictEqual(textarea.scrollTop, 0, "it stays scrolled up");});@@ -1021,7 +1017,7 @@ third line`for (let i = 0; i < CASES.length; i++) {const CASE = CASES[i];// prettier-ignore- composerTestCase(`replace-text event: ${CASE.description}`, async function( // eslint-disable-line no-loop-func+ composerTestCase(`replace-text event: ${CASE.description}`, async function(assert,textarea) {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.jsindex 35b858ef4d5..2056cd43fe1 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@@ -56,9 +56,8 @@ discourseModule("Unit | Utility | category-badge", function () {const store = createStore();const category = store.createRecord("category", { name: "hello", id: 123 });- assert.strictEqual(- categoryBadgeHTML(category).indexOf("topic-count"),- -1,+ assert.ok(+ !categoryBadgeHTML(category).includes("topic-count"),"it does not include topic count by default");assert.ok(@@ -136,41 +135,21 @@ discourseModule("Unit | Utility | category-badge", function () {});this.siteSettings.max_category_nesting = 0;- assert.ok(- categoryBadgeHTML(baz, { recursive: true }).indexOf("baz") !== -1- );- assert.ok(- categoryBadgeHTML(baz, { recursive: true }).indexOf("bar") === -1- );+ assert.ok(categoryBadgeHTML(baz, { recursive: true }).includes("baz"));+ assert.ok(!categoryBadgeHTML(baz, { recursive: true }).includes("bar"));this.siteSettings.max_category_nesting = 1;- assert.ok(- categoryBadgeHTML(baz, { recursive: true }).indexOf("baz") !== -1- );- assert.ok(- categoryBadgeHTML(baz, { recursive: true }).indexOf("bar") === -1- );+ assert.ok(categoryBadgeHTML(baz, { recursive: true }).includes("baz"));+ assert.ok(!categoryBadgeHTML(baz, { recursive: true }).includes("bar"));this.siteSettings.max_category_nesting = 2;- assert.ok(- categoryBadgeHTML(baz, { recursive: true }).indexOf("baz") !== -1- );- assert.ok(- categoryBadgeHTML(baz, { recursive: true }).indexOf("bar") !== -1- );- assert.ok(- categoryBadgeHTML(baz, { recursive: true }).indexOf("foo") === -1- );+ assert.ok(categoryBadgeHTML(baz, { recursive: true }).includes("baz"));+ assert.ok(categoryBadgeHTML(baz, { recursive: true }).includes("bar"));+ assert.ok(!categoryBadgeHTML(baz, { recursive: true }).includes("foo"));this.siteSettings.max_category_nesting = 3;- assert.ok(- categoryBadgeHTML(baz, { recursive: true }).indexOf("baz") !== -1- );- assert.ok(- categoryBadgeHTML(baz, { recursive: true }).indexOf("bar") !== -1- );- assert.ok(- categoryBadgeHTML(baz, { recursive: true }).indexOf("foo") !== -1- );+ assert.ok(categoryBadgeHTML(baz, { recursive: true }).includes("baz"));+ assert.ok(categoryBadgeHTML(baz, { recursive: true }).includes("bar"));+ assert.ok(categoryBadgeHTML(baz, { recursive: true }).includes("foo"));});});diff --git a/app/assets/javascripts/discourse/tests/unit/lib/icon-library-test.js b/app/assets/javascripts/discourse/tests/unit/lib/icon-library-test.jsindex be710f4207c..c69e3021cd9 100644--- a/app/assets/javascripts/discourse/tests/unit/lib/icon-library-test.js+++ b/app/assets/javascripts/discourse/tests/unit/lib/icon-library-test.js@@ -7,7 +7,7 @@ import { module, test } from "qunit";module("Unit | Utility | icon-library", function () {test("return icon markup", function (assert) {- assert.ok(iconHTML("bars").indexOf('use href="#bars"') > -1);+ assert.ok(iconHTML("bars").includes('use href="#bars"'));const nodeIcon = iconNode("bars");assert.strictEqual(nodeIcon.tagName, "svg");@@ -19,10 +19,10 @@ module("Unit | Utility | icon-library", function () {test("convert icon names", function (assert) {const fa5Icon = convertIconClass("fab fa-facebook");- assert.ok(iconHTML(fa5Icon).indexOf("fab-facebook") > -1, "FA 5 syntax");+ assert.ok(iconHTML(fa5Icon).includes("fab-facebook"), "FA 5 syntax");const iconC = convertIconClass(" fab fa-facebook ");- assert.ok(iconHTML(iconC).indexOf(" ") === -1, "trims whitespace");+ assert.ok(!iconHTML(iconC).includes(" "), "trims whitespace");});test("escape icon names, classes and titles", function (assert) {diff --git a/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.js b/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.jsindex dcc6d4a2e60..3f15e065173 100644--- a/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.js+++ b/app/assets/javascripts/discourse/tests/unit/lib/oneboxer-test.js@@ -40,13 +40,13 @@ module("Unit | Utility | oneboxer", function () {await loadOnebox(element);assert.ok(- localCache["http://somegoodurl.com"].outerHTML.indexOf(+ localCache["http://somegoodurl.com"].outerHTML.includes("Yet another collaboration tool"- ) !== -1,+ ),"stores the html of the onebox in a local cache");assert.ok(- loadOnebox(element).indexOf("Yet another collaboration tool") !== -1,+ loadOnebox(element).includes("Yet another collaboration tool"),"it returns the html from the cache");});diff --git a/app/assets/javascripts/discourse/tests/unit/lib/search-test.js b/app/assets/javascripts/discourse/tests/unit/lib/search-test.jsindex 7ac7ee75dac..d3f94fe55d6 100644--- a/app/assets/javascripts/discourse/tests/unit/lib/search-test.js+++ b/app/assets/javascripts/discourse/tests/unit/lib/search-test.js@@ -31,9 +31,9 @@ module("Unit | Utility | search", function () {const results = await translateResults(source);const blurb = results.posts[0].get("blurb");- assert.ok(blurb.indexOf("thinking.png"));- assert.ok(blurb.indexOf('<img width="20" height="20" src') === 0);- assert.ok(blurb.indexOf(":thinking:") === -1);+ assert.ok(blurb.includes("thinking.png"));+ assert.ok(blurb.startsWith('<img width="20" height="20" src'));+ assert.ok(!blurb.includes(":thinking:"));});test("searchContextDescription", function (assert) {diff --git a/app/assets/javascripts/discourse/tests/unit/lib/upload-short-url-test.js b/app/assets/javascripts/discourse/tests/unit/lib/upload-short-url-test.jsindex 4b4f12f34fd..79520604a8e 100644--- a/app/assets/javascripts/discourse/tests/unit/lib/upload-short-url-test.js+++ b/app/assets/javascripts/discourse/tests/unit/lib/upload-short-url-test.js@@ -75,7 +75,7 @@ function stubUrls(imageSrcs, attachmentSrcs, otherMediaSrcs) {`<div class="scoped-area"><img data-orig-src="${imageSrcs[2].url}"></div>` +otherMediaSrcs.map((src) => {- if (src.short_url.indexOf("mp3") > -1) {+ if (src.short_url.includes("mp3")) {return `<audio controls><source data-orig-src="${src.short_url}"></audio>`;} else {return `<video controls><source data-orig-src="${src.short_url}"></video>`;diff --git a/app/assets/javascripts/discourse/tests/unit/models/report-test.js b/app/assets/javascripts/discourse/tests/unit/models/report-test.jsindex e5e7706de93..4807d1691bd 100644--- a/app/assets/javascripts/discourse/tests/unit/models/report-test.js+++ b/app/assets/javascripts/discourse/tests/unit/models/report-test.js@@ -74,13 +74,13 @@ module("Unit | Model | report", function () {test("yesterdayCountTitle with valid values", function (assert) {const title = reportWithData([6, 8, 5, 2, 1]).get("yesterdayCountTitle");- assert.ok(title.indexOf("+60%") !== -1);+ assert.ok(title.includes("+60%"));assert.ok(title.match(/Was 5/));});test("yesterdayCountTitle when two days ago was 0", function (assert) {const title = reportWithData([6, 8, 0, 2, 1]).get("yesterdayCountTitle");- assert.strictEqual(title.indexOf("%"), -1);+ assert.ok(!title.includes("%"));assert.ok(title.match(/Was 0/));});@@ -97,14 +97,14 @@ module("Unit | Model | report", function () {report.set("prev30Days", 10);let title = report.get("thirtyDaysCountTitle");- assert.ok(title.indexOf("+50%") !== -1);+ assert.ok(title.includes("+50%"));assert.ok(title.match(/Was 10/));report = reportWithData([5, 5, 5, 5]);report.set("prev_period", 20);title = report.get("thirtyDaysCountTitle");- assert.ok(title.indexOf("-25%") !== -1);+ assert.ok(title.includes("-25%"));assert.ok(title.match(/Was 20/));});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.jsindex 173035392b9..c79036fe797 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@@ -254,7 +254,7 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {}}- if (topic.tags && topic.tags.indexOf("random") > -1) {+ if (topic.tags?.includes("random")) {if (isNew) {randomNew += 1;}diff --git a/plugins/discourse-details/test/javascripts/acceptance/details-button-test.js b/plugins/discourse-details/test/javascripts/acceptance/details-button-test.jsindex 1f092621040..a0897f6c422 100644--- a/plugins/discourse-details/test/javascripts/acceptance/details-button-test.js+++ b/plugins/discourse-details/test/javascripts/acceptance/details-button-test.js@@ -1,8 +1,4 @@-import {- acceptance,- query,- queryAll,-} from "discourse/tests/helpers/qunit-helpers";+import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";import I18n from "I18n";import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer";import selectKit from "discourse/tests/helpers/select-kit-helper";@@ -23,7 +19,7 @@ acceptance("Details Button", function (needs) {await popupMenu.selectRowByValue("insertDetails");assert.strictEqual(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,`\n[details="${I18n.t("composer.details_title")}"]\n${I18n.t("composer.details_text")}\n[/details]\n`,@@ -40,7 +36,7 @@ acceptance("Details Button", function (needs) {await popupMenu.selectRowByValue("insertDetails");assert.strictEqual(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,`\n[details="${I18n.t("composer.details_title")}"]\nThis is my title\n[/details]\n`,@@ -67,7 +63,7 @@ acceptance("Details Button", function (needs) {await popupMenu.selectRowByValue("insertDetails");assert.strictEqual(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,`Before \n[details="${I18n.t("composer.details_title")}"]\nsome text in between\n[/details]\n After`,@@ -94,7 +90,7 @@ acceptance("Details Button", function (needs) {await popupMenu.selectRowByValue("insertDetails");assert.strictEqual(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,`Before \n\n[details="${I18n.t("composer.details_title")}"]\nsome text in between\n[/details]\n\n After`,@@ -129,7 +125,7 @@ acceptance("Details Button", function (needs) {await popupMenu.selectRowByValue("insertDetails");assert.strictEqual(- queryAll(".d-editor-input").val(),+ query(".d-editor-input").value,`\n[details="${I18n.t("composer.details_title")}"]\n${multilineInput}\n[/details]\n`,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.jsindex 5c54bc937a8..e9a3ff1d489 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,8 +1,4 @@-import {- acceptance,- query,- queryAll,-} from "discourse/tests/helpers/qunit-helpers";+import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";import { test } from "qunit";import { click, fillIn, visit } from "@ember/test-helpers";import selectKit from "discourse/tests/helpers/select-kit-helper";@@ -13,9 +9,9 @@ acceptance("Local Dates - composer", function (needs) {test("composer bbcode", async function (assert) {const getAttr = (attr) => {- return queryAll(+ return query(".d-editor-preview .discourse-local-date.cooked-date"- ).attr(`data-${attr}`);+ ).getAttribute(`data-${attr}`);};await visit("/");diff --git a/plugins/discourse-local-dates/test/javascripts/acceptance/local-dates-quoting-test.js b/plugins/discourse-local-dates/test/javascripts/acceptance/local-dates-quoting-test.jsindex c568cf584b6..265cf349401 100644--- a/plugins/discourse-local-dates/test/javascripts/acceptance/local-dates-quoting-test.js+++ b/plugins/discourse-local-dates/test/javascripts/acceptance/local-dates-quoting-test.js@@ -2,7 +2,7 @@ import { cloneJSON } from "discourse-common/lib/object";import topicFixtures from "discourse/tests/fixtures/topic";import {acceptance,- queryAll,+ query,selectText,} from "discourse/tests/helpers/qunit-helpers";import { test } from "qunit";@@ -15,17 +15,17 @@ acceptance("Local Dates - quoting", function (needs) {needs.pretender((server, helper) => {const topicResponse = cloneJSON(topicFixtures["/t/280/1.json"]);const firstPost = topicResponse.post_stream.posts[0];- firstPost.cooked += `<div class='select-local-date-test'>This is a test <span data-date="2022-06-17" data-time="10:00:00" class="discourse-local-date cooked-date past" data-displayed-timezone="Australia/Perth" data-timezone="Australia/Brisbane" data-email-preview="2022-06-17T00:00:00Z UTC" aria-label="Brisbane Friday, June 17, 2022+ firstPost.cooked += `<div class='select-local-date-test'>This is a test <span data-date="2022-06-17" data-time="10:00:00" class="discourse-local-date cooked-date past" data-displayed-timezone="Australia/Perth" data-timezone="Australia/Brisbane" data-email-preview="2022-06-17T00:00:00Z UTC" aria-label="Brisbane Friday, June 17, 2022<br /><svg class='fa d-icon d-icon-clock svg-icon svg-string'xmlns="http://www.w3.org/2000/svg"><use href="#clock" />- </svg> 10:00 AM, Paris Friday, June 17, 2022+ </svg> 10:00 AM, Paris Friday, June 17, 2022<br /><svg class='fa d-icon d-icon-clock svg-icon svg-string'xmlns="http://www.w3.org/2000/svg"><use href="#clock" />- </svg> 2:00 AM, Los Angeles Thursday, June 16, 2022+ </svg> 2:00 AM, Los Angeles Thursday, June 16, 2022<br /><svg class='fa d-icon d-icon-clock svg-icon svg-string'xmlns="http://www.w3.org/2000/svg">@@ -48,7 +48,7 @@ acceptance("Local Dates - quoting", function (needs) {await selectText("#post_1 .select-local-date-test");await click(".insert-quote");assert.strictEqual(- queryAll(".d-editor-input").val().trim(),+ query(".d-editor-input").value.trim(),`[quote=\"Uwe Keim, post:1, topic:280, username:uwe_keim\"]This is a test [date=2022-06-17 time=10:00:00 timezone="Australia/Brisbane" displayedTimezone="Australia/Perth"][/quote]`,@@ -87,7 +87,7 @@ acceptance("Local Dates - quoting range", function (needs) {await selectText("#post_1 .select-local-date-test");await click(".insert-quote");assert.strictEqual(- queryAll(".d-editor-input").val().trim(),+ query(".d-editor-input").value.trim(),`[quote=\"Uwe Keim, post:1, topic:280, username:uwe_keim\"]Some text [date-range from=2022-06-17T09:30:00 to=2022-06-18T10:30:00 format="LL" timezone="Australia/Brisbane" timezones="Africa/Accra|Australia/Brisbane|Europe/Paris"][/quote]`,@@ -129,7 +129,7 @@ acceptance(await selectText("#post_1 .select-local-date-test");await click(".insert-quote");assert.strictEqual(- queryAll(".d-editor-input").val().trim(),+ query(".d-editor-input").value.trim(),`[quote=\"Uwe Keim, post:1, topic:280, username:uwe_keim\"]Testing countdown [date=2022-06-21 time=09:30:00 format="LL" timezone="Australia/Brisbane" countdown="true"]diff --git a/plugins/poll/test/javascripts/acceptance/poll-pie-chart-test.js b/plugins/poll/test/javascripts/acceptance/poll-pie-chart-test.jsindex c36042d49e2..ecf9494d0f4 100644--- a/plugins/poll/test/javascripts/acceptance/poll-pie-chart-test.js+++ b/plugins/poll/test/javascripts/acceptance/poll-pie-chart-test.js@@ -1,7 +1,7 @@import {acceptance,+ count,query,- queryAll,} from "discourse/tests/helpers/qunit-helpers";import { test } from "qunit";import { visit } from "@ember/test-helpers";@@ -25,7 +25,7 @@ acceptance("Rendering polls with pie charts", function (needs) {);assert.strictEqual(- queryAll(".info-number", poll)[1].innerHTML,+ poll.querySelectorAll(".info-number")[1].innerHTML,"5","it should display the right number of votes");@@ -37,7 +37,7 @@ acceptance("Rendering polls with pie charts", function (needs) {);assert.strictEqual(- queryAll(".poll-results-chart", poll).length,+ count(".poll-results-chart", poll),1,"Renders the chart div instead of bar container");diff --git a/plugins/poll/test/javascripts/controllers/poll-ui-builder-test.js b/plugins/poll/test/javascripts/controllers/poll-ui-builder-test.jsindex 2993cb42b94..ea00d305e77 100644--- a/plugins/poll/test/javascripts/controllers/poll-ui-builder-test.js+++ b/plugins/poll/test/javascripts/controllers/poll-ui-builder-test.js@@ -196,8 +196,9 @@ discourseModule("Unit | Controller | poll-ui-builder", function () {controller.currentUser = { staff: false };controller.notifyPropertyChange("pollResults");- assert.ok(- controller.pollResults.filterBy("value", "staff_only").length === 0,+ assert.strictEqual(+ controller.pollResults.filterBy("value", "staff_only").length,+ 0,"staff_only is not present");});@@ -212,8 +213,9 @@ discourseModule("Unit | Controller | poll-ui-builder", function () {controller.currentUser = { staff: true };controller.notifyPropertyChange("pollResults");- assert.ok(- controller.pollResults.filterBy("value", "staff_only").length === 1,+ assert.strictEqual(+ controller.pollResults.filterBy("value", "staff_only").length,+ 1,"staff_only is present");});