DEV: Reduce jQuery usage in acceptance tests (#17406)

This commit is contained in:
Jarek Radosz 2022-07-10 10:52:02 +02:00 committed by GitHub
parent 06ae9229e8
commit 0f01cc7df2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 419 additions and 425 deletions

View File

@ -1,7 +1,7 @@
import { import {
acceptance, acceptance,
exists, exists,
queryAll, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, currentRouteName, fillIn, visit } from "@ember/test-helpers"; import { click, currentRouteName, fillIn, visit } from "@ember/test-helpers";
import PreloadStore from "discourse/lib/preload-store"; import PreloadStore from "discourse/lib/preload-store";
@ -16,7 +16,7 @@ acceptance("Account Created", function () {
assert.ok(exists(".account-created")); assert.ok(exists(".account-created"));
assert.strictEqual( assert.strictEqual(
queryAll(".account-created .ac-message").text().trim(), query(".account-created .ac-message").innerText.trim(),
"Hello World", "Hello World",
"it displays the message" "it displays the message"
); );
@ -35,7 +35,7 @@ acceptance("Account Created", function () {
assert.ok(exists(".account-created")); assert.ok(exists(".account-created"));
assert.strictEqual( assert.strictEqual(
queryAll(".account-created .ac-message").text().trim(), query(".account-created .ac-message").innerText.trim(),
"Hello World", "Hello World",
"it displays the message" "it displays the message"
); );
@ -43,7 +43,7 @@ acceptance("Account Created", function () {
await click(".activation-controls .resend"); await click(".activation-controls .resend");
assert.strictEqual(currentRouteName(), "account-created.resent"); assert.strictEqual(currentRouteName(), "account-created.resent");
const email = queryAll(".account-created .ac-message b").text(); const email = query(".account-created .ac-message b").innerText;
assert.strictEqual(email, "eviltrout@example.com"); assert.strictEqual(email, "eviltrout@example.com");
}); });
@ -88,7 +88,7 @@ acceptance("Account Created", function () {
await click(".activation-controls .btn-primary"); await click(".activation-controls .btn-primary");
assert.strictEqual(currentRouteName(), "account-created.resent"); assert.strictEqual(currentRouteName(), "account-created.resent");
const email = queryAll(".account-created .ac-message b").text(); const email = query(".account-created .ac-message b").innerText;
assert.strictEqual(email, "newemail@example.com"); assert.strictEqual(email, "newemail@example.com");
}); });
}); });

View File

@ -1,7 +1,7 @@
import { import {
acceptance, acceptance,
exists, exists,
queryAll, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, currentURL, fillIn, visit } from "@ember/test-helpers"; import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
@ -37,7 +37,7 @@ acceptance("Admin - Site Texts", function (needs) {
test("edit and revert a site text by key", async function (assert) { test("edit and revert a site text by key", async function (assert) {
await visit("/admin/customize/site_texts/site.test?locale=en"); await visit("/admin/customize/site_texts/site.test?locale=en");
assert.strictEqual(queryAll(".title h3").text(), "site.test"); assert.strictEqual(query(".title h3").innerText, "site.test");
assert.ok(!exists(".saved")); assert.ok(!exists(".saved"));
assert.ok(!exists(".revert-site-text")); assert.ok(!exists(".revert-site-text"));

View File

@ -1,17 +1,17 @@
import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers"; import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import I18n from "I18n"; import I18n from "I18n";
import { test } from "qunit"; import { test } from "qunit";
function assertNoSecondary(assert) { function assertNoSecondary(assert) {
assert.strictEqual( assert.strictEqual(
queryAll(".display-row.email .value a").text(), query(".display-row.email .value a").innerText,
"eviltrout@example.com", "eviltrout@example.com",
"it should display the primary email" "it should display the primary email"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".display-row.secondary-emails .value").text().trim(), query(".display-row.secondary-emails .value").innerText.trim(),
I18n.t("user.email.no_secondary"), I18n.t("user.email.no_secondary"),
"it should not display secondary emails" "it should not display secondary emails"
); );
@ -19,13 +19,13 @@ function assertNoSecondary(assert) {
function assertMultipleSecondary(assert, firstEmail, secondEmail) { function assertMultipleSecondary(assert, firstEmail, secondEmail) {
assert.strictEqual( assert.strictEqual(
queryAll(".display-row.secondary-emails .value li:first-of-type a").text(), query(".display-row.secondary-emails .value li:first-of-type a").innerText,
firstEmail, firstEmail,
"it should display the first secondary email" "it should display the first secondary email"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".display-row.secondary-emails .value li:last-of-type a").text(), query(".display-row.secondary-emails .value li:last-of-type a").innerText,
secondEmail, secondEmail,
"it should display the second secondary email" "it should display the second secondary email"
); );
@ -44,7 +44,7 @@ acceptance("Admin - User Emails", function (needs) {
await visit("/admin/users/3/markvanlan"); await visit("/admin/users/3/markvanlan");
assert.strictEqual( assert.strictEqual(
queryAll(".display-row.email .value a").text(), query(".display-row.email .value a").innerText,
"markvanlan@example.com", "markvanlan@example.com",
"it should display the user's primary email" "it should display the user's primary email"
); );

View File

@ -2,7 +2,6 @@ import {
acceptance, acceptance,
exists, exists,
query, query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, currentURL, fillIn, visit } from "@ember/test-helpers"; import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
@ -86,7 +85,7 @@ acceptance("Admin - User Index", function (needs) {
server.put("/admin/users/4/grant_admin", () => { server.put("/admin/users/4/grant_admin", () => {
return helper.response(403, { return helper.response(403, {
second_factor_challenge_nonce: "somenonce", second_factor_challenge_nonce: "some-nonce",
}); });
}); });
@ -104,7 +103,7 @@ acceptance("Admin - User Index", function (needs) {
await visit("/admin/users/2/sam"); await visit("/admin/users/2/sam");
assert.strictEqual( assert.strictEqual(
queryAll(".display-row.username .value").text().trim(), query(".display-row.username .value").innerText.trim(),
"sam" "sam"
); );
@ -113,7 +112,7 @@ acceptance("Admin - User Index", function (needs) {
await fillIn(".display-row.username .value input", "new-sam"); await fillIn(".display-row.username .value input", "new-sam");
await click(".display-row.username a"); await click(".display-row.username a");
assert.strictEqual( assert.strictEqual(
queryAll(".display-row.username .value").text().trim(), query(".display-row.username .value").innerText.trim(),
"sam" "sam"
); );
@ -122,7 +121,7 @@ acceptance("Admin - User Index", function (needs) {
await fillIn(".display-row.username .value input", "new-sam"); await fillIn(".display-row.username .value input", "new-sam");
await click(".display-row.username button"); await click(".display-row.username button");
assert.strictEqual( assert.strictEqual(
queryAll(".display-row.username .value").text().trim(), query(".display-row.username .value").innerText.trim(),
"new-sam" "new-sam"
); );
}); });
@ -130,7 +129,7 @@ acceptance("Admin - User Index", function (needs) {
test("shows the number of post edits", async function (assert) { test("shows the number of post edits", async function (assert) {
await visit("/admin/users/1/eviltrout"); await visit("/admin/users/1/eviltrout");
assert.strictEqual(queryAll(".post-edits-count .value").text().trim(), "6"); assert.strictEqual(query(".post-edits-count .value").innerText.trim(), "6");
assert.ok( assert.ok(
exists(".post-edits-count .controls .btn.btn-icon"), exists(".post-edits-count .controls .btn.btn-icon"),
@ -165,7 +164,7 @@ acceptance("Admin - User Index", function (needs) {
await visit("/admin/users/2/sam"); await visit("/admin/users/2/sam");
assert.strictEqual( assert.strictEqual(
queryAll(".display-row.username .value").text().trim(), query(".display-row.username .value").innerText.trim(),
"sam", "sam",
"the name should be correct" "the name should be correct"
); );
@ -182,7 +181,7 @@ acceptance("Admin - User Index", function (needs) {
await visit("/admin/users/1/eviltrout"); await visit("/admin/users/1/eviltrout");
assert.strictEqual( assert.strictEqual(
queryAll(".display-row.username .value").text().trim(), query(".display-row.username .value").innerText.trim(),
"eviltrout", "eviltrout",
"the name should be correct" "the name should be correct"
); );
@ -209,7 +208,7 @@ acceptance("Admin - User Index", function (needs) {
await click(".grant-admin"); await click(".grant-admin");
assert.equal( assert.equal(
currentURL(), currentURL(),
"/session/2fa?nonce=somenonce", "/session/2fa?nonce=some-nonce",
"user is redirected to the 2FA page" "user is redirected to the 2FA page"
); );
}); });

View File

@ -1,7 +1,7 @@
import { import {
acceptance, acceptance,
exists, exists,
queryAll, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import I18n from "I18n"; import I18n from "I18n";
@ -25,18 +25,18 @@ acceptance("Admin - Users List", function (needs) {
await click(".users-list .sortable:nth-child(1)"); await click(".users-list .sortable:nth-child(1)");
assert.ok( assert.ok(
queryAll(".users-list .user:nth-child(1) .username") query(".users-list .user:nth-child(1) .username").innerText.includes(
.text() "eviltrout"
.includes("eviltrout"), ),
"list should be sorted by username" "list should be sorted by username"
); );
await click(".users-list .sortable:nth-child(1)"); await click(".users-list .sortable:nth-child(1)");
assert.ok( assert.ok(
queryAll(".users-list .user:nth-child(1) .username") query(".users-list .user:nth-child(1) .username").innerText.includes(
.text() "discobot"
.includes("discobot"), ),
"list should be sorted ascending by username" "list should be sorted ascending by username"
); );
}); });
@ -49,7 +49,7 @@ acceptance("Admin - Users List", function (needs) {
await click(".show-emails"); await click(".show-emails");
assert.strictEqual( assert.strictEqual(
queryAll(".users-list .user:nth-child(1) .email").text(), query(".users-list .user:nth-child(1) .email").innerText,
"<small>eviltrout@example.com</small>", "<small>eviltrout@example.com</small>",
"shows the emails" "shows the emails"
); );
@ -57,7 +57,7 @@ acceptance("Admin - Users List", function (needs) {
await click(".hide-emails"); await click(".hide-emails");
assert.strictEqual( assert.strictEqual(
queryAll(".users-list .user:nth-child(1) .email").text(), query(".users-list .user:nth-child(1) .email").innerText,
"", "",
"hides the emails" "hides the emails"
); );
@ -71,38 +71,38 @@ acceptance("Admin - Users List", function (needs) {
await visit("/admin/users/list/active"); await visit("/admin/users/list/active");
assert.strictEqual(queryAll(".admin-title h2").text(), activeTitle); assert.strictEqual(query(".admin-title h2").innerText, activeTitle);
assert.ok( assert.ok(
queryAll(".users-list .user:nth-child(1) .username") query(".users-list .user:nth-child(1) .username").innerText.includes(
.text() activeUser
.includes(activeUser) )
); );
await click('a[href="/admin/users/list/new"]'); await click('a[href="/admin/users/list/new"]');
assert.strictEqual(queryAll(".admin-title h2").text(), suspectTitle); assert.strictEqual(query(".admin-title h2").innerText, suspectTitle);
assert.ok( assert.ok(
queryAll(".users-list .user:nth-child(1) .username") query(".users-list .user:nth-child(1) .username").innerText.includes(
.text() suspectUser
.includes(suspectUser) )
); );
await click(".users-list .sortable:nth-child(4)"); await click(".users-list .sortable:nth-child(4)");
assert.strictEqual(queryAll(".admin-title h2").text(), suspectTitle); assert.strictEqual(query(".admin-title h2").innerText, suspectTitle);
assert.ok( assert.ok(
queryAll(".users-list .user:nth-child(1) .username") query(".users-list .user:nth-child(1) .username").innerText.includes(
.text() suspectUser
.includes(suspectUser) )
); );
await click('a[href="/admin/users/list/active"]'); await click('a[href="/admin/users/list/active"]');
assert.strictEqual(queryAll(".admin-title h2").text(), activeTitle); assert.strictEqual(query(".admin-title h2").innerText, activeTitle);
assert.ok( assert.ok(
queryAll(".users-list .user:nth-child(1) .username") query(".users-list .user:nth-child(1) .username").innerText.includes(
.text() activeUser
.includes(activeUser) )
); );
}); });
}); });

View File

@ -63,8 +63,8 @@ acceptance("Admin - Watched Words", function (needs) {
await click(".watched-word-form button"); await click(".watched-word-form button");
let found = []; let found = [];
$.each(queryAll(".watched-words-list .watched-word"), (index, elem) => { [...queryAll(".watched-words-list .watched-word")].forEach((elem) => {
if ($(elem).text().trim() === "poutine") { if (elem.innerText.trim() === "poutine") {
found.push(true); found.push(true);
} }
}); });
@ -75,15 +75,15 @@ acceptance("Admin - Watched Words", function (needs) {
await visit("/admin/customize/watched_words/action/block"); await visit("/admin/customize/watched_words/action/block");
await click(".show-words-checkbox"); await click(".show-words-checkbox");
let word = null; let wordId = null;
$.each(queryAll(".watched-words-list .watched-word"), (index, elem) => { [...queryAll(".watched-words-list .watched-word")].forEach((elem) => {
if ($(elem).text().trim() === "anise") { if (elem.innerText.trim() === "anise") {
word = elem; wordId = elem.getAttribute("id");
} }
}); });
await click(`#${$(word).attr("id")} .delete-word-record`); await click(`#${wordId} .delete-word-record`);
assert.strictEqual(count(".watched-words-list .watched-word"), 2); assert.strictEqual(count(".watched-words-list .watched-word"), 2);
}); });

View File

@ -3,7 +3,6 @@ import {
exists, exists,
loggedInUser, loggedInUser,
query, query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import I18n from "I18n"; import I18n from "I18n";
@ -218,9 +217,9 @@ acceptance("Bookmarking", function (needs) {
assert.ok(exists(".bootbox.modal"), "it asks for delete confirmation"); assert.ok(exists(".bootbox.modal"), "it asks for delete confirmation");
assert.ok( assert.ok(
queryAll(".bootbox.modal") query(".bootbox.modal").innerText.includes(
.text() I18n.t("bookmarks.confirm_delete")
.includes(I18n.t("bookmarks.confirm_delete")), ),
"it shows delete confirmation message" "it shows delete confirmation message"
); );
@ -252,17 +251,17 @@ acceptance("Bookmarking", function (needs) {
await openEditBookmarkModal(); await openEditBookmarkModal();
assert.strictEqual( assert.strictEqual(
queryAll("#bookmark-name").val(), query("#bookmark-name").value,
"Test name", "Test name",
"it should prefill the bookmark name" "it should prefill the bookmark name"
); );
assert.strictEqual( assert.strictEqual(
queryAll("#custom-date > input").val(), query("#custom-date > input").value,
tomorrow, tomorrow,
"it should prefill the bookmark date" "it should prefill the bookmark date"
); );
assert.strictEqual( assert.strictEqual(
queryAll("#custom-time").val(), query("#custom-time").value,
"08:00", "08:00",
"it should prefill the bookmark time" "it should prefill the bookmark time"
); );
@ -278,17 +277,17 @@ acceptance("Bookmarking", function (needs) {
await openEditBookmarkModal(); await openEditBookmarkModal();
assert.strictEqual( assert.strictEqual(
queryAll("#bookmark-name").val(), query("#bookmark-name").value,
"Test name", "Test name",
"it should prefill the bookmark name" "it should prefill the bookmark name"
); );
assert.strictEqual( assert.strictEqual(
queryAll("#custom-date > input").val(), query("#custom-date > input").value,
postDateFormatted, postDateFormatted,
"it should prefill the bookmark date" "it should prefill the bookmark date"
); );
assert.strictEqual( assert.strictEqual(
queryAll("#custom-time").val(), query("#custom-time").value,
"10:35", "10:35",
"it should prefill the bookmark time" "it should prefill the bookmark time"
); );
@ -446,9 +445,9 @@ acceptance("Bookmarking", function (needs) {
assert.ok(exists(".bootbox.modal"), "it asks for delete confirmation"); assert.ok(exists(".bootbox.modal"), "it asks for delete confirmation");
assert.ok( assert.ok(
queryAll(".bootbox.modal") query(".bootbox.modal").innerText.includes(
.text() I18n.t("bookmarks.confirm_delete")
.includes(I18n.t("bookmarks.confirm_delete")), ),
"it shows delete confirmation message" "it shows delete confirmation message"
); );

View File

@ -2,7 +2,7 @@ import {
acceptance, acceptance,
count, count,
exists, exists,
queryAll, query,
visible, visible,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, currentURL, fillIn, visit } from "@ember/test-helpers"; import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
@ -27,16 +27,16 @@ acceptance("Category Edit", function (needs) {
); );
assert.strictEqual( assert.strictEqual(
queryAll(".category-breadcrumb .badge-category").text(), query(".category-breadcrumb .badge-category").innerText,
"bug" "bug"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".category-color-editor .badge-category").text(), query(".category-color-editor .badge-category").innerText,
"bug" "bug"
); );
await fillIn("input.category-name", "testing"); await fillIn("input.category-name", "testing");
assert.strictEqual( assert.strictEqual(
queryAll(".category-color-editor .badge-category").text(), query(".category-color-editor .badge-category").innerText,
"testing" "testing"
); );
@ -156,7 +156,7 @@ acceptance("Category Edit", function (needs) {
"/c/1-category/edit/general", "/c/1-category/edit/general",
"it goes to the general tab" "it goes to the general tab"
); );
assert.strictEqual(queryAll("input.category-name").val(), "bug"); assert.strictEqual(query("input.category-name").value, "bug");
}); });
test("Error Saving", async function (assert) { test("Error Saving", async function (assert) {
@ -166,7 +166,7 @@ acceptance("Category Edit", function (needs) {
assert.ok(visible(".bootbox")); assert.ok(visible(".bootbox"));
assert.strictEqual( assert.strictEqual(
queryAll(".bootbox .modal-body").html(), query(".bootbox .modal-body").innerHTML,
"duplicate email" "duplicate email"
); );

View File

@ -1,7 +1,7 @@
import { import {
acceptance, acceptance,
exists, exists,
queryAll, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, currentURL, fillIn, visit } from "@ember/test-helpers"; import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
import DiscourseURL from "discourse/lib/url"; import DiscourseURL from "discourse/lib/url";
@ -15,11 +15,11 @@ acceptance("Category New", function (needs) {
test("Creating a new category", async function (assert) { test("Creating a new category", async function (assert) {
await visit("/new-category"); await visit("/new-category");
assert.ok(queryAll(".badge-category")); assert.ok(exists(".badge-category"));
assert.notOk(exists(".category-breadcrumb")); assert.notOk(exists(".category-breadcrumb"));
await fillIn("input.category-name", "testing"); await fillIn("input.category-name", "testing");
assert.strictEqual(queryAll(".badge-category").text(), "testing"); assert.strictEqual(query(".badge-category").innerText, "testing");
await click("#save-category"); await click("#save-category");
@ -30,7 +30,7 @@ acceptance("Category New", function (needs) {
); );
assert.strictEqual( assert.strictEqual(
queryAll(".edit-category-title h2").text(), query(".edit-category-title h2").innerText,
I18n.t("category.edit_dialog_title", { I18n.t("category.edit_dialog_title", {
categoryName: "testing", categoryName: "testing",
}) })
@ -38,13 +38,13 @@ acceptance("Category New", function (needs) {
await click(".edit-category-security a"); await click(".edit-category-security a");
assert.ok( assert.ok(
queryAll("button.edit-permission"), exists(".permission-row button.reply-toggle"),
"it can switch to the security tab" "it can switch to the security tab"
); );
await click(".edit-category-settings a"); await click(".edit-category-settings a");
assert.ok( assert.ok(
queryAll("#category-search-priority"), exists("#category-search-priority"),
"it can switch to the settings tab" "it can switch to the settings tab"
); );

View File

@ -2,7 +2,7 @@ import {
acceptance, acceptance,
count, count,
exists, exists,
queryAll, query,
selectText, selectText,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -69,15 +69,15 @@ acceptance("Composer Actions", function (needs) {
await composerActions.selectRowByValue("reply_to_topic"); await composerActions.selectRowByValue("reply_to_topic");
assert.strictEqual( assert.strictEqual(
queryAll(".action-title .topic-link").text().trim(), query(".action-title .topic-link").innerText.trim(),
"Internationalization / localization" "Internationalization / localization"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".action-title .topic-link").attr("href"), query(".action-title .topic-link").getAttribute("href"),
"/t/internationalization-localization/280" "/t/internationalization-localization/280"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val(), query(".d-editor-input").value,
"test replying to topic when initially replied to post" "test replying to topic when initially replied to post"
); );
}); });
@ -141,10 +141,10 @@ acceptance("Composer Actions", function (needs) {
assert.strictEqual(categoryChooserReplyArea.header().name(), "faq"); assert.strictEqual(categoryChooserReplyArea.header().name(), "faq");
assert.strictEqual( assert.strictEqual(
queryAll(".action-title").text().trim(), query(".action-title").innerText.trim(),
I18n.t("topic.create_long") I18n.t("topic.create_long")
); );
assert.ok(queryAll(".d-editor-input").val().includes(quote)); assert.ok(query(".d-editor-input").value.includes(quote));
sinon.restore(); sinon.restore();
}); });
@ -179,10 +179,10 @@ acceptance("Composer Actions", function (needs) {
await composerActions.selectRowByValue("reply_to_topic"); await composerActions.selectRowByValue("reply_to_topic");
assert.strictEqual( assert.strictEqual(
queryAll(".action-title").text().trim(), query(".action-title").innerText.trim(),
"Short topic with two posts" "Short topic with two posts"
); );
assert.strictEqual(queryAll(".d-editor-input").val(), quote); assert.strictEqual(query(".d-editor-input").value, quote);
await composerActions.expand(); await composerActions.expand();
@ -203,10 +203,10 @@ acceptance("Composer Actions", function (needs) {
assert.ok(exists(".action-title img.avatar")); assert.ok(exists(".action-title img.avatar"));
assert.strictEqual( assert.strictEqual(
queryAll(".action-title .user-link").text().trim(), query(".action-title .user-link").innerText.trim(),
"tms" "tms"
); );
assert.strictEqual(queryAll(".d-editor-input").val(), quote); assert.strictEqual(query(".d-editor-input").value, quote);
assert.strictEqual( assert.strictEqual(
composerActions.rowByIndex(0).value(), composerActions.rowByIndex(0).value(),
"reply_as_new_topic" "reply_as_new_topic"
@ -223,10 +223,10 @@ acceptance("Composer Actions", function (needs) {
await composerActions.expand(); await composerActions.expand();
assert.strictEqual( assert.strictEqual(
queryAll(".action-title").text().trim(), query(".action-title").innerText.trim(),
I18n.t("topic.create_long") I18n.t("topic.create_long")
); );
assert.ok(queryAll(".d-editor-input").val().includes(quote)); assert.ok(query(".d-editor-input").value.includes(quote));
assert.strictEqual(composerActions.rowByIndex(0).value(), "reply_to_post"); assert.strictEqual(composerActions.rowByIndex(0).value(), "reply_to_post");
assert.strictEqual(composerActions.rowByIndex(1).value(), "reply_to_topic"); assert.strictEqual(composerActions.rowByIndex(1).value(), "reply_to_topic");
assert.strictEqual(composerActions.rowByIndex(2).value(), "shared_draft"); assert.strictEqual(composerActions.rowByIndex(2).value(), "shared_draft");
@ -242,7 +242,7 @@ acceptance("Composer Actions", function (needs) {
await composerActions.expand(); await composerActions.expand();
assert.strictEqual( assert.strictEqual(
queryAll(".action-title").text().trim(), query(".action-title").innerText.trim(),
I18n.t("topic.private_message") I18n.t("topic.private_message")
); );
assert.strictEqual(composerActions.rowByIndex(0).value(), "create_topic"); assert.strictEqual(composerActions.rowByIndex(0).value(), "create_topic");
@ -452,12 +452,12 @@ acceptance("Composer Actions With New Topic Draft", function (needs) {
assert.strictEqual(tags.header().value(), "monkey", "tags are not reset"); assert.strictEqual(tags.header().value(), "monkey", "tags are not reset");
assert.strictEqual( assert.strictEqual(
queryAll("#reply-title").val(), query("#reply-title").value,
"This is the new text for the title using 'quotes'" "This is the new text for the title using 'quotes'"
); );
assert.strictEqual( assert.strictEqual(
queryAll("#reply-control .btn-primary.create .d-button-label").text(), query("#reply-control .btn-primary.create .d-button-label").innerText,
I18n.t("composer.create_shared_draft") I18n.t("composer.create_shared_draft")
); );
assert.strictEqual( assert.strictEqual(
@ -482,7 +482,7 @@ acceptance("Composer Actions With New Topic Draft", function (needs) {
stubDraftResponse(); stubDraftResponse();
await composerActions.selectRowByValue("reply_as_new_topic"); await composerActions.selectRowByValue("reply_as_new_topic");
assert.strictEqual( assert.strictEqual(
queryAll(".bootbox .modal-body").text(), query(".bootbox .modal-body").innerText,
I18n.t("composer.composer_actions.reply_as_new_topic.confirm") I18n.t("composer.composer_actions.reply_as_new_topic.confirm")
); );
await click(".modal-footer .btn.btn-default"); await click(".modal-footer .btn.btn-default");
@ -502,7 +502,7 @@ acceptance("Prioritize Username", function (needs) {
await click("article#post_2 button.reply"); await click("article#post_2 button.reply");
assert.strictEqual( assert.strictEqual(
queryAll(".action-title .user-link").text().trim(), query(".action-title .user-link").innerText.trim(),
"james_john" "james_john"
); );
}); });
@ -512,7 +512,7 @@ acceptance("Prioritize Username", function (needs) {
await selectText("#post_2 p"); await selectText("#post_2 p");
await click(".insert-quote"); await click(".insert-quote");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val().trim(), query(".d-editor-input").value.trim(),
'[quote="james_john, post:2, topic:54079, full:true"]\nThis is a short topic.\n[/quote]' '[quote="james_john, post:2, topic:54079, full:true"]\nThis is a short topic.\n[/quote]'
); );
}); });
@ -530,7 +530,7 @@ acceptance("Prioritize Full Name", function (needs) {
await click("article#post_2 button.reply"); await click("article#post_2 button.reply");
assert.strictEqual( assert.strictEqual(
queryAll(".action-title .user-link").text().trim(), query(".action-title .user-link").innerText.trim(),
"james, john, the third" "james, john, the third"
); );
}); });
@ -540,7 +540,7 @@ acceptance("Prioritize Full Name", function (needs) {
await selectText("#post_2 p"); await selectText("#post_2 p");
await click(".insert-quote"); await click(".insert-quote");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val().trim(), query(".d-editor-input").value.trim(),
'[quote="james, john, the third, post:2, topic:54079, full:true, username:james_john"]\nThis is a short topic.\n[/quote]' '[quote="james, john, the third, post:2, topic:54079, full:true, username:james_john"]\nThis is a short topic.\n[/quote]'
); );
}); });
@ -550,7 +550,7 @@ acceptance("Prioritize Full Name", function (needs) {
await selectText("#post_4 p"); await selectText("#post_4 p");
await click(".insert-quote"); await click(".insert-quote");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val().trim(), query(".d-editor-input").value.trim(),
'[quote="james_john, post:2, topic:54079"]\nThis is a short topic.\n[/quote]' '[quote="james_john, post:2, topic:54079"]\nThis is a short topic.\n[/quote]'
); );
}); });
@ -569,7 +569,7 @@ acceptance("Prioritizing Name fall back", function (needs) {
await selectText("#post_1 p"); await selectText("#post_1 p");
await click(".insert-quote"); await click(".insert-quote");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val().trim(), query(".d-editor-input").value.trim(),
'[quote="bianca, post:1, topic:130, full:true"]\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas a varius ipsum. Nunc euismod, metus non vulputate malesuada, ligula metus pharetra tortor, vel sodales arcu lacus sed mauris. Nam semper, orci vitae fringilla placerat, dui tellus convallis felis, ultricies laoreet sapien mi et metus. Mauris facilisis, mi fermentum rhoncus feugiat, dolor est vehicula leo, id porta leo ex non enim. In a ligula vel tellus commodo scelerisque non in ex. Pellentesque semper leo quam, nec varius est viverra eget. Donec vehicula sem et massa faucibus tempus.\n[/quote]' '[quote="bianca, post:1, topic:130, full:true"]\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas a varius ipsum. Nunc euismod, metus non vulputate malesuada, ligula metus pharetra tortor, vel sodales arcu lacus sed mauris. Nam semper, orci vitae fringilla placerat, dui tellus convallis felis, ultricies laoreet sapien mi et metus. Mauris facilisis, mi fermentum rhoncus feugiat, dolor est vehicula leo, id porta leo ex non enim. In a ligula vel tellus commodo scelerisque non in ex. Pellentesque semper leo quam, nec varius est viverra eget. Donec vehicula sem et massa faucibus tempus.\n[/quote]'
); );
}); });

View File

@ -1,6 +1,6 @@
import { import {
acceptance, acceptance,
queryAll, query,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import I18n from "I18n"; import I18n from "I18n";
@ -53,7 +53,7 @@ acceptance("Composer - Tags", function (needs) {
await click("#reply-control button.create"); await click("#reply-control button.create");
assert.strictEqual(currentURL(), "/"); assert.strictEqual(currentURL(), "/");
assert.strictEqual( assert.strictEqual(
queryAll(".popup-tip.bad").text().trim(), query(".popup-tip.bad").innerText.trim(),
I18n.t("composer.error.tags_missing", { count: 1 }), I18n.t("composer.error.tags_missing", { count: 1 }),
"it should display the right alert" "it should display the right alert"
); );
@ -86,7 +86,7 @@ acceptance("Composer - Tags", function (needs) {
await click("#reply-control button.create"); await click("#reply-control button.create");
assert.strictEqual(currentURL(), "/"); assert.strictEqual(currentURL(), "/");
assert.strictEqual( assert.strictEqual(
queryAll(".popup-tip.bad").text().trim(), query(".popup-tip.bad").innerText.trim(),
I18n.t("composer.error.tags_missing", { count: 1 }), I18n.t("composer.error.tags_missing", { count: 1 }),
"it should display the right alert" "it should display the right alert"
); );

View File

@ -15,7 +15,6 @@ import {
exists, exists,
invisible, invisible,
query, query,
queryAll,
updateCurrentUser, updateCurrentUser,
visible, visible,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -100,7 +99,7 @@ acceptance("Composer", function (needs) {
await fillIn(".d-editor-input", "this is the *content* of a post"); await fillIn(".d-editor-input", "this is the *content* of a post");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-preview").html().trim(), query(".d-editor-preview").innerHTML.trim(),
"<p>this is the <em>content</em> of a post</p>", "<p>this is the <em>content</em> of a post</p>",
"it previews content" "it previews content"
); );
@ -126,7 +125,7 @@ acceptance("Composer", function (needs) {
const example = I18n.t(`composer.bold_text`); const example = I18n.t(`composer.bold_text`);
assert.strictEqual( assert.strictEqual(
queryAll("#reply-control .d-editor-input").val().trim(), query("#reply-control .d-editor-input").value.trim(),
`this is the *content* of a post**${example}**`, `this is the *content* of a post**${example}**`,
"it supports keyboard shortcuts" "it supports keyboard shortcuts"
); );
@ -186,7 +185,7 @@ acceptance("Composer", function (needs) {
await fillIn(".d-editor-input", "custom message"); await fillIn(".d-editor-input", "custom message");
await click("#reply-control button.create"); await click("#reply-control button.create");
assert.strictEqual( assert.strictEqual(
queryAll(".bootbox .modal-body").text(), query(".bootbox .modal-body").innerText,
"This is a custom response" "This is a custom response"
); );
assert.strictEqual(currentURL(), "/", "it doesn't change routes"); assert.strictEqual(currentURL(), "/", "it doesn't change routes");
@ -217,7 +216,7 @@ acceptance("Composer", function (needs) {
await fillIn(".d-editor-input", "this is the content of my reply"); await fillIn(".d-editor-input", "this is the content of my reply");
await click("#reply-control button.create"); await click("#reply-control button.create");
assert.strictEqual( assert.strictEqual(
queryAll(".cooked:last p").text(), query(".topic-post:last-of-type .cooked p").innerText,
"this is the content of my reply" "this is the content of my reply"
); );
}); });
@ -234,7 +233,7 @@ acceptance("Composer", function (needs) {
await click(".modal-footer button.keep-editing"); await click(".modal-footer button.keep-editing");
assert.ok(invisible(".discard-draft-modal.modal")); assert.ok(invisible(".discard-draft-modal.modal"));
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val(), query(".d-editor-input").value,
"this is the content of my reply", "this is the content of my reply",
"composer does not switch when using Keep Editing button" "composer does not switch when using Keep Editing button"
); );
@ -244,8 +243,8 @@ acceptance("Composer", function (needs) {
assert.ok(invisible(".discard-draft-modal.modal")); assert.ok(invisible(".discard-draft-modal.modal"));
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val(), query(".d-editor-input").value,
queryAll(".topic-post:nth-of-type(1) .cooked > p").text(), query(".topic-post:nth-of-type(1) .cooked > p").innerText,
"composer has contents of post to be edited" "composer has contents of post to be edited"
); );
}); });
@ -268,7 +267,7 @@ acceptance("Composer", function (needs) {
await click(".btn-reply-here"); await click(".btn-reply-here");
assert.strictEqual( assert.strictEqual(
queryAll(".cooked:last p").text(), query(".topic-post:last-of-type .cooked p").innerText,
"If you use gettext format you could leverage Launchpad 13 translations and the community behind it." "If you use gettext format you could leverage Launchpad 13 translations and the community behind it."
); );
}); });
@ -298,7 +297,7 @@ acceptance("Composer", function (needs) {
await click(".modal-footer button.discard-draft"); await click(".modal-footer button.discard-draft");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val(), query(".d-editor-input").value,
"", "",
"discards draft and reset composer textarea" "discards draft and reset composer textarea"
); );
@ -319,7 +318,8 @@ acceptance("Composer", function (needs) {
await fillIn(".d-editor-input", "enqueue this content please"); await fillIn(".d-editor-input", "enqueue this content please");
await click("#reply-control button.create"); await click("#reply-control button.create");
assert.ok( assert.ok(
queryAll(".cooked:last p").text() !== "enqueue this content please", query(".topic-post:last-of-type .cooked p").innerText !==
"enqueue this content please",
"it doesn't insert the post" "it doesn't insert the post"
); );
@ -342,7 +342,7 @@ 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.show-more-actions");
await click(".topic-post:nth-of-type(1) button.edit"); await click(".topic-post:nth-of-type(1) button.edit");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val().indexOf("Any plans to support"), query(".d-editor-input").value.indexOf("Any plans to support"),
0, 0,
"it populates the input with the post text" "it populates the input with the post text"
); );
@ -356,15 +356,15 @@ acceptance("Composer", function (needs) {
"it has the edits icon" "it has the edits icon"
); );
assert.ok( assert.ok(
queryAll("#topic-title h1") query("#topic-title h1").innerText.indexOf(
.text() "This is the new text for the title"
.indexOf("This is the new text for the title") !== -1, ) !== -1,
"it shows the new title" "it shows the new title"
); );
assert.ok( assert.ok(
queryAll(".topic-post:nth-of-type(1) .cooked") query(".topic-post:nth-of-type(1) .cooked").innerText.indexOf(
.text() "This is the new text for the post"
.indexOf("This is the new text for the post") !== -1, ) !== -1,
"it updates the post" "it updates the post"
); );
}); });
@ -407,13 +407,13 @@ acceptance("Composer", function (needs) {
await click(".topic-post:nth-of-type(1) button.edit"); await click(".topic-post:nth-of-type(1) button.edit");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val().indexOf("This is the first post."), query(".d-editor-input").value.indexOf("This is the first post."),
0, 0,
"it populates the input with the post text" "it populates the input with the post text"
); );
await click(".topic-post:nth-of-type(2) button.edit"); await click(".topic-post:nth-of-type(2) button.edit");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val().indexOf("This is the second post."), query(".d-editor-input").value.indexOf("This is the second post."),
0, 0,
"it populates the input with the post text" "it populates the input with the post text"
); );
@ -432,7 +432,7 @@ acceptance("Composer", function (needs) {
await click(".modal-footer button.discard-draft"); await click(".modal-footer button.discard-draft");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val().indexOf("This is the second post."), query(".d-editor-input").value.indexOf("This is the second post."),
0, 0,
"it populates the input with the post text" "it populates the input with the post text"
); );
@ -443,19 +443,19 @@ acceptance("Composer", function (needs) {
await click(".topic-post:nth-of-type(1) button.edit"); await click(".topic-post:nth-of-type(1) button.edit");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val().indexOf("This is the first post."), query(".d-editor-input").value.indexOf("This is the first post."),
0, 0,
"it populates the input with the post text" "it populates the input with the post text"
); );
await click(".topic-post:nth-of-type(1) button.reply"); await click(".topic-post:nth-of-type(1) button.reply");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val(), query(".d-editor-input").value,
"", "",
"it clears the input" "it clears the input"
); );
await click(".topic-post:nth-of-type(1) button.edit"); await click(".topic-post:nth-of-type(1) button.edit");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val().indexOf("This is the first post."), query(".d-editor-input").value.indexOf("This is the first post."),
0, 0,
"it populates the input with the post text" "it populates the input with the post text"
); );
@ -628,7 +628,7 @@ acceptance("Composer", function (needs) {
); );
await click(".modal-footer button.discard-draft"); await click(".modal-footer button.discard-draft");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val().indexOf("This is the first post."), query(".d-editor-input").value.indexOf("This is the first post."),
0, 0,
"it populates the input with the post text" "it populates the input with the post text"
); );
@ -646,18 +646,18 @@ acceptance("Composer", function (needs) {
"it pops up a confirmation dialog" "it pops up a confirmation dialog"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".modal-footer button.save-draft").text().trim(), query(".modal-footer button.save-draft").innerText.trim(),
I18n.t("post.cancel_composer.save_draft"), I18n.t("post.cancel_composer.save_draft"),
"has save draft button" "has save draft button"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".modal-footer button.keep-editing").text().trim(), query(".modal-footer button.keep-editing").innerText.trim(),
I18n.t("post.cancel_composer.keep_editing"), I18n.t("post.cancel_composer.keep_editing"),
"has keep editing button" "has keep editing button"
); );
await click(".modal-footer button.save-draft"); await click(".modal-footer button.save-draft");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val().indexOf("This is the second post."), query(".d-editor-input").value.indexOf("This is the second post."),
0, 0,
"it populates the input with the post text" "it populates the input with the post text"
); );
@ -677,18 +677,18 @@ acceptance("Composer", function (needs) {
"it pops up a confirmation dialog" "it pops up a confirmation dialog"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".modal-footer button.save-draft").text().trim(), query(".modal-footer button.save-draft").innerText.trim(),
I18n.t("post.cancel_composer.save_draft"), I18n.t("post.cancel_composer.save_draft"),
"has save draft button" "has save draft button"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".modal-footer button.keep-editing").text().trim(), query(".modal-footer button.keep-editing").innerText.trim(),
I18n.t("post.cancel_composer.keep_editing"), I18n.t("post.cancel_composer.keep_editing"),
"has keep editing button" "has keep editing button"
); );
await click(".modal-footer button.save-draft"); await click(".modal-footer button.save-draft");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val(), query(".d-editor-input").value,
"", "",
"it clears the composer input" "it clears the composer input"
); );
@ -704,7 +704,7 @@ acceptance("Composer", function (needs) {
await click(".topic-post:nth-of-type(1) button.edit"); await click(".topic-post:nth-of-type(1) button.edit");
assert.strictEqual( assert.strictEqual(
queryAll(".modal-body").text(), query(".modal-body").innerText,
I18n.t("drafts.abandon.confirm") I18n.t("drafts.abandon.confirm")
); );
@ -749,7 +749,7 @@ acceptance("Composer", function (needs) {
assert.ok(!exists(".modal-body"), "abandon popup shouldn't come"); assert.ok(!exists(".modal-body"), "abandon popup shouldn't come");
assert.ok( assert.ok(
queryAll(".d-editor-input").val().includes(longText), query(".d-editor-input").value.includes(longText),
"entered text should still be there" "entered text should still be there"
); );
@ -802,7 +802,7 @@ acceptance("Composer", function (needs) {
await visit("/latest"); await visit("/latest");
assert.strictEqual( assert.strictEqual(
queryAll("#create-topic").text().trim(), query("#create-topic").innerText.trim(),
I18n.t("topic.open_draft") I18n.t("topic.open_draft")
); );
@ -818,13 +818,11 @@ acceptance("Composer", function (needs) {
await visit("/t/34"); await visit("/t/34");
await click("#post_1 .d-icon-ellipsis-h"); await click("#post_1 .d-icon-ellipsis-h");
await click("#post_1 .d-icon-pencil-alt"); await click("#post_1 .d-icon-pencil-alt");
await fillIn(".d-editor-input", ""); await fillIn(".d-editor-input", "");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-container textarea").attr("placeholder"), query(".d-editor-container textarea").getAttribute("placeholder"),
I18n.t("composer.reply_placeholder"), I18n.t("composer.reply_placeholder"),
"it should not block because of missing category" "it should not block because of missing category"
); );
@ -834,7 +832,7 @@ acceptance("Composer", function (needs) {
await visit("/t/34"); await visit("/t/34");
await click("article#post_3 button.reply"); await click("article#post_3 button.reply");
assert.strictEqual( assert.strictEqual(
queryAll(".save-or-cancel button.create").text().trim(), query(".save-or-cancel button.create").innerText.trim(),
I18n.t("composer.create_pm"), I18n.t("composer.create_pm"),
"reply button says Message" "reply button says Message"
); );
@ -851,7 +849,7 @@ acceptance("Composer", function (needs) {
await click("article#post_3 button.edit"); await click("article#post_3 button.edit");
assert.strictEqual( assert.strictEqual(
queryAll(".save-or-cancel button.create").text().trim(), query(".save-or-cancel button.create").innerText.trim(),
I18n.t("composer.save_edit"), I18n.t("composer.save_edit"),
"save button says Save Edit" "save button says Save Edit"
); );

View File

@ -1,7 +1,7 @@
import { import {
acceptance, acceptance,
exists, exists,
queryAll, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import PreloadStore from "discourse/lib/preload-store"; import PreloadStore from "discourse/lib/preload-store";
import { setCustomHTML } from "discourse/helpers/custom-html"; import { setCustomHTML } from "discourse/helpers/custom-html";
@ -19,7 +19,7 @@ acceptance("CustomHTML set", function () {
await visit("/static/faq"); await visit("/static/faq");
assert.strictEqual( assert.strictEqual(
queryAll("span.custom-html-test").text(), query("span.custom-html-test").innerText,
"HTML", "HTML",
"it inserted the markup" "it inserted the markup"
); );
@ -32,7 +32,7 @@ acceptance("CustomHTML set", function () {
await visit("/static/faq"); await visit("/static/faq");
assert.strictEqual( assert.strictEqual(
queryAll("span.cookie").text(), query("span.cookie").innerText,
"monster", "monster",
"it inserted the markup" "it inserted the markup"
); );

View File

@ -1,4 +1,4 @@
import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers"; import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
import { test } from "qunit"; import { test } from "qunit";
import { visit } from "@ember/test-helpers"; import { visit } from "@ember/test-helpers";
@ -17,7 +17,7 @@ acceptance("CustomHTML template", function (needs) {
test("renders custom template", async function (assert) { test("renders custom template", async function (assert) {
await visit("/static/faq"); await visit("/static/faq");
assert.strictEqual( assert.strictEqual(
queryAll("span.top-span").text(), query("span.top-span").innerText,
"TOP", "TOP",
"it inserted the template" "it inserted the template"
); );

View File

@ -1,9 +1,8 @@
import { import {
acceptance, acceptance,
queryAll,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, settled, visit } from "@ember/test-helpers"; import { click, currentRouteName, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
async function catchAbortedTransition() { async function catchAbortedTransition() {
@ -14,7 +13,6 @@ async function catchAbortedTransition() {
throw e; throw e;
} }
} }
await settled();
} }
acceptance("Enforce Second Factor", function (needs) { acceptance("Enforce Second Factor", function (needs) {
@ -35,8 +33,8 @@ acceptance("Enforce Second Factor", function (needs) {
await catchAbortedTransition(); await catchAbortedTransition();
assert.strictEqual( assert.strictEqual(
queryAll(".control-label").text(), currentRouteName(),
"Password", "preferences.second-factor",
"it will not transition from second-factor preferences" "it will not transition from second-factor preferences"
); );
@ -44,8 +42,8 @@ acceptance("Enforce Second Factor", function (needs) {
await click("a.admin-link"); await click("a.admin-link");
assert.strictEqual( assert.strictEqual(
queryAll(".control-label").text(), currentRouteName(),
"Password", "preferences.second-factor",
"it stays at second-factor preferences" "it stays at second-factor preferences"
); );
}); });
@ -59,8 +57,8 @@ acceptance("Enforce Second Factor", function (needs) {
await catchAbortedTransition(); await catchAbortedTransition();
assert.strictEqual( assert.strictEqual(
queryAll(".control-label").text(), currentRouteName(),
"Password", "preferences.second-factor",
"it will not transition from second-factor preferences" "it will not transition from second-factor preferences"
); );
@ -68,8 +66,8 @@ acceptance("Enforce Second Factor", function (needs) {
await click("a.about-link"); await click("a.about-link");
assert.strictEqual( assert.strictEqual(
queryAll(".control-label").text(), currentRouteName(),
"Password", "preferences.second-factor",
"it stays at second-factor preferences" "it stays at second-factor preferences"
); );
}); });
@ -83,18 +81,18 @@ acceptance("Enforce Second Factor", function (needs) {
await catchAbortedTransition(); await catchAbortedTransition();
assert.notStrictEqual( assert.strictEqual(
queryAll(".control-label").text(), currentRouteName(),
"Password", "user.summary",
"it will transition from second-factor preferences" "it will transition from second-factor preferences"
); );
await click("#toggle-hamburger-menu"); await click("#toggle-hamburger-menu");
await click("a.about-link"); await click("a.about-link");
assert.notStrictEqual( assert.strictEqual(
queryAll(".control-label").text(), currentRouteName(),
"Password", "about",
"it is possible to navigate to other pages" "it is possible to navigate to other pages"
); );
}); });

View File

@ -1,7 +1,7 @@
import { import {
acceptance, acceptance,
count, count,
queryAll, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
@ -91,37 +91,35 @@ acceptance("Group Requests", function (needs) {
assert.strictEqual(count(".group-members tr"), 2); assert.strictEqual(count(".group-members tr"), 2);
assert.strictEqual( assert.strictEqual(
queryAll(".group-members tr:first-child td:nth-child(1)") query(".group-members tr:first-child td:nth-child(1)")
.text() .innerText.trim()
.trim()
.replace(/\s+/g, " "), .replace(/\s+/g, " "),
"Robin Ward eviltrout" "Robin Ward eviltrout"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".group-members tr:first-child td:nth-child(3)").text().trim(), query(".group-members tr:first-child td:nth-child(3)").innerText.trim(),
"Please accept my membership request." "Please accept my membership request."
); );
assert.strictEqual( assert.strictEqual(
queryAll(".group-members tr:first-child .btn-primary").text().trim(), query(".group-members tr:first-child .btn-primary").innerText.trim(),
"Accept" "Accept"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".group-members tr:first-child .btn-danger").text().trim(), query(".group-members tr:first-child .btn-danger").innerText.trim(),
"Deny" "Deny"
); );
await click(".group-members tr:first-child .btn-primary"); await click(".group-members tr:first-child .btn-primary");
assert.ok( assert.ok(
queryAll(".group-members tr:first-child td:nth-child(4)") query(".group-members tr:first-child td:nth-child(4)")
.text() .innerText.trim()
.trim() .startsWith("accepted")
.indexOf("accepted") === 0
); );
assert.deepEqual(requests, [["19", "true"]]); assert.deepEqual(requests, [["19", "true"]]);
await click(".group-members tr:last-child .btn-danger"); await click(".group-members tr:last-child .btn-danger");
assert.strictEqual( assert.strictEqual(
queryAll(".group-members tr:last-child td:nth-child(4)").text().trim(), query(".group-members tr:last-child td:nth-child(4)").innerText.trim(),
"denied" "denied"
); );
assert.deepEqual(requests, [ assert.deepEqual(requests, [

View File

@ -3,7 +3,6 @@ import {
count, count,
exists, exists,
query, query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import I18n from "I18n"; import I18n from "I18n";
@ -40,7 +39,7 @@ acceptance("Group - Anonymous", function (needs) {
await click(".activity-nav li a[href='/g/discourse/activity/topics']"); await click(".activity-nav li a[href='/g/discourse/activity/topics']");
assert.ok(queryAll(".topic-list"), "it shows the topic list"); assert.ok(query(".topic-list"), "it shows the topic list");
assert.strictEqual(count(".topic-list-item"), 2, "it lists stream items"); assert.strictEqual(count(".topic-list-item"), 2, "it lists stream items");
await click(".activity-nav li a[href='/g/discourse/activity/mentions']"); await click(".activity-nav li a[href='/g/discourse/activity/mentions']");
@ -192,19 +191,19 @@ acceptance("Group - Authenticated", function (needs) {
await click(".group-index-request"); await click(".group-index-request");
assert.strictEqual( assert.strictEqual(
queryAll(".modal-header .title").text().trim(), query(".modal-header .title").innerText.trim(),
I18n.t("groups.membership_request.title", { group_name: "Macdonald" }) I18n.t("groups.membership_request.title", { group_name: "Macdonald" })
); );
assert.strictEqual( assert.strictEqual(
queryAll(".request-group-membership-form textarea").val(), query(".request-group-membership-form textarea").value,
"Please add me" "Please add me"
); );
await click(".modal-footer .btn-primary"); await click(".modal-footer .btn-primary");
assert.strictEqual( assert.strictEqual(
queryAll(".fancy-title").text().trim(), query(".fancy-title").innerText.trim(),
"Internationalization / localization" "Internationalization / localization"
); );
@ -239,13 +238,13 @@ acceptance("Group - Authenticated", function (needs) {
await click(".nav-pills li a[title='Messages']"); await click(".nav-pills li a[title='Messages']");
assert.strictEqual( assert.strictEqual(
queryAll(".topic-list-item .link-top-line").text().trim(), query(".topic-list-item .link-top-line").innerText.trim(),
"This is a private message 1", "This is a private message 1",
"it should display the list of group topics" "it should display the list of group topics"
); );
await click("#search-button"); await click("#search-button");
await fillIn("#search-term", "smth"); await fillIn("#search-term", "something");
assert.ok( assert.ok(
query(".search-menu .btn.search-context"), query(".search-menu .btn.search-context"),
@ -268,7 +267,7 @@ acceptance("Group - Authenticated", function (needs) {
"it displays show group message button" "it displays show group message button"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".group-info-name").text(), query(".group-info-name").innerText,
"Awesome Team", "Awesome Team",
"it should display the group name" "it should display the group name"
); );
@ -276,7 +275,7 @@ acceptance("Group - Authenticated", function (needs) {
await click(".group-details-button button.btn-danger"); await click(".group-details-button button.btn-danger");
assert.strictEqual( assert.strictEqual(
queryAll(".bootbox .modal-body").html(), query(".bootbox .modal-body").innerHTML,
I18n.t("admin.groups.delete_with_messages_confirm", { I18n.t("admin.groups.delete_with_messages_confirm", {
count: 2, count: 2,
}), }),

View File

@ -3,7 +3,7 @@ import {
count, count,
exists, exists,
invisible, invisible,
queryAll, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
@ -11,11 +11,9 @@ import { test } from "qunit";
acceptance("Groups", function () { acceptance("Groups", function () {
test("Browsing Groups", async function (assert) { test("Browsing Groups", async function (assert) {
await visit("/g?username=eviltrout"); await visit("/g?username=eviltrout");
assert.strictEqual(count(".group-box"), 1, "it displays user's groups"); assert.strictEqual(count(".group-box"), 1, "it displays user's groups");
await visit("/g"); await visit("/g");
assert.strictEqual(count(".group-box"), 2, "it displays visible groups"); assert.strictEqual(count(".group-box"), 2, "it displays visible groups");
assert.strictEqual( assert.strictEqual(
count(".group-index-join"), count(".group-index-join"),
@ -29,27 +27,22 @@ acceptance("Groups", function () {
); );
await click(".group-index-join"); await click(".group-index-join");
assert.ok(exists(".modal.login-modal"), "it shows the login modal"); assert.ok(exists(".modal.login-modal"), "it shows the login modal");
await click(".login-modal .close"); await click(".login-modal .close");
assert.ok(invisible(".modal.login-modal"), "it closes the login modal"); assert.ok(invisible(".modal.login-modal"), "it closes the login modal");
await click(".group-index-request"); await click(".group-index-request");
assert.ok(exists(".modal.login-modal"), "it shows the login modal"); assert.ok(exists(".modal.login-modal"), "it shows the login modal");
await click("a[href='/g/discourse/members']"); await click("a[href='/g/discourse/members']");
assert.strictEqual( assert.strictEqual(
queryAll(".group-info-name").text().trim(), query(".group-info-name").innerText.trim(),
"Awesome Team", "Awesome Team",
"it displays the group page" "it displays the group page"
); );
await click(".group-index-join"); await click(".group-index-join");
assert.ok(exists(".modal.login-modal"), "it shows the login modal"); assert.ok(exists(".modal.login-modal"), "it shows the login modal");
}); });
}); });

View File

@ -2,7 +2,7 @@ import {
acceptance, acceptance,
count, count,
exists, exists,
queryAll, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import I18n from "I18n"; import I18n from "I18n";
@ -21,6 +21,7 @@ acceptance("New Group - Anonymous", function () {
acceptance("New Group - Authenticated", function (needs) { acceptance("New Group - Authenticated", function (needs) {
needs.user(); needs.user();
test("Creating a new group", async function (assert) { test("Creating a new group", async function (assert) {
await visit("/g"); await visit("/g");
await click(".groups-header-new"); await click(".groups-header-new");
@ -34,7 +35,7 @@ acceptance("New Group - Authenticated", function (needs) {
await fillIn("input[name='name']", "1"); await fillIn("input[name='name']", "1");
assert.strictEqual( assert.strictEqual(
queryAll(".tip.bad").text().trim(), query(".tip.bad").innerText.trim(),
I18n.t("admin.groups.new.name.too_short"), I18n.t("admin.groups.new.name.too_short"),
"it should show the right validation tooltip" "it should show the right validation tooltip"
); );
@ -51,7 +52,7 @@ acceptance("New Group - Authenticated", function (needs) {
); );
assert.strictEqual( assert.strictEqual(
queryAll(".tip.bad").text().trim(), query(".tip.bad").innerText.trim(),
I18n.t("admin.groups.new.name.too_long"), I18n.t("admin.groups.new.name.too_long"),
"it should show the right validation tooltip" "it should show the right validation tooltip"
); );
@ -59,15 +60,15 @@ acceptance("New Group - Authenticated", function (needs) {
await fillIn("input[name='name']", ""); await fillIn("input[name='name']", "");
assert.strictEqual( assert.strictEqual(
queryAll(".tip.bad").text().trim(), query(".tip.bad").innerText.trim(),
I18n.t("admin.groups.new.name.blank"), I18n.t("admin.groups.new.name.blank"),
"it should show the right validation tooltip" "it should show the right validation tooltip"
); );
await fillIn("input[name='name']", "goodusername"); await fillIn("input[name='name']", "good-username");
assert.strictEqual( assert.strictEqual(
queryAll(".tip.good").text().trim(), query(".tip.good").innerText.trim(),
I18n.t("admin.groups.new.name.available"), I18n.t("admin.groups.new.name.available"),
"it should show the right validation tooltip" "it should show the right validation tooltip"
); );
@ -79,10 +80,11 @@ acceptance("New Group - Authenticated", function (needs) {
"it should disable the membership requests checkbox" "it should disable the membership requests checkbox"
); );
assert.ok( assert.strictEqual(
queryAll(".groups-form-default-notification-level .selected-name .name") query(
.text() ".groups-form-default-notification-level .selected-name .name"
.trim() === I18n.t("groups.notifications.watching.title"), ).innerText.trim(),
I18n.t("groups.notifications.watching.title"),
"it has a default selection for notification level" "it has a default selection for notification level"
); );
}); });

View File

@ -1,6 +1,6 @@
import { import {
acceptance, acceptance,
queryAll, query,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
@ -20,7 +20,7 @@ acceptance(
await click(".hamburger-dropdown"); await click(".hamburger-dropdown");
assert.strictEqual( assert.strictEqual(
queryAll(".review .badge-notification.reviewables").text(), query(".review .badge-notification.reviewables").innerText,
"3" "3"
); );
}); });

View File

@ -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 { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
@ -32,8 +36,9 @@ category vs tag: #bug vs #bug::tag
uppercase hashtag works too #BUG, #BUG::tag` uppercase hashtag works too #BUG, #BUG::tag`
); );
assert.ok(visible(".d-editor-preview"));
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-preview:visible").html().trim(), query(".d-editor-preview").innerHTML.trim(),
`<p>this is a category hashtag <a href="/c/bugs" class="hashtag" tabindex=\"-1\">#<span>bug</span></a></p> `<p>this is a category hashtag <a href="/c/bugs" class="hashtag" tabindex=\"-1\">#<span>bug</span></a></p>
<p>this is a tag hashtag <a href="/tag/monkey" class="hashtag" tabindex=\"-1\">#<span>monkey</span></a></p> <p>this is a tag hashtag <a href="/tag/monkey" class="hashtag" tabindex=\"-1\">#<span>monkey</span></a></p>
<p>category vs tag: <a href="/c/bugs" class="hashtag" tabindex=\"-1\">#<span>bug</span></a> vs <a href="/tag/bug" class="hashtag" tabindex=\"-1\">#<span>bug</span></a></p> <p>category vs tag: <a href="/c/bugs" class="hashtag" tabindex=\"-1\">#<span>bug</span></a> vs <a href="/tag/bug" class="hashtag" tabindex=\"-1\">#<span>bug</span></a></p>

View File

@ -2,7 +2,6 @@ import {
acceptance, acceptance,
exists, exists,
query, query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { fillIn, visit } from "@ember/test-helpers"; import { fillIn, visit } from "@ember/test-helpers";
import PreloadStore from "discourse/lib/preload-store"; import PreloadStore from "discourse/lib/preload-store";
@ -71,12 +70,12 @@ acceptance("Invite accept", function (needs) {
is_invite_link: false, is_invite_link: false,
}); });
await visit("/invites/myvalidinvitetoken"); await visit("/invites/my-valid-invite-token");
assert.ok( assert.ok(
queryAll(".col-form") query(".col-form").innerText.includes(
.text() I18n.t("invites.social_login_available")
.includes(I18n.t("invites.social_login_available")), ),
"shows social login hint" "shows social login hint"
); );
@ -97,11 +96,11 @@ acceptance("Invite accept", function (needs) {
is_invite_link: true, is_invite_link: true,
}); });
await visit("/invites/myvalidinvitetoken"); await visit("/invites/my-valid-invite-token");
assert.ok(exists("#new-account-email"), "shows the email input"); assert.ok(exists("#new-account-email"), "shows the email input");
assert.ok(exists("#new-account-username"), "shows the username input"); assert.ok(exists("#new-account-username"), "shows the username input");
assert.strictEqual( assert.strictEqual(
queryAll("#new-account-username").val(), query("#new-account-username").value,
"invited", "invited",
"username is prefilled" "username is prefilled"
); );
@ -151,7 +150,7 @@ acceptance("Invite accept", function (needs) {
"submit is disabled" "submit is disabled"
); );
await fillIn("#new-account-username", "validname"); await fillIn("#new-account-username", "valid-name");
await fillIn("#new-account-password", "secur3ty4Y0uAndMe"); await fillIn("#new-account-password", "secur3ty4Y0uAndMe");
await fillIn("#new-account-email", "john.doe@example.com"); await fillIn("#new-account-email", "john.doe@example.com");
assert.ok(exists(".username-input .good"), "username is valid"); assert.ok(exists(".username-input .good"), "username is valid");
@ -165,7 +164,7 @@ acceptance("Invite accept", function (needs) {
test("invite name is required only if full name is required", async function (assert) { test("invite name is required only if full name is required", async function (assert) {
preloadInvite(); preloadInvite();
await visit("/invites/myvalidinvitetoken"); await visit("/invites/my-valid-invite-token");
assert.ok(exists(".name-input .required"), "Full name is required"); assert.ok(exists(".name-input .required"), "Full name is required");
}); });
}); });
@ -176,7 +175,7 @@ acceptance("Invite accept when local login is disabled", function (needs) {
test("invite link", async function (assert) { test("invite link", async function (assert) {
preloadInvite({ link: true }); preloadInvite({ link: true });
await visit("/invites/myvalidinvitetoken"); await visit("/invites/my-valid-invite-token");
assert.ok(exists(".btn-social.facebook"), "shows Facebook login button"); assert.ok(exists(".btn-social.facebook"), "shows Facebook login button");
assert.ok(!exists("form"), "does not display the form"); assert.ok(!exists("form"), "does not display the form");
@ -184,7 +183,7 @@ acceptance("Invite accept when local login is disabled", function (needs) {
test("email invite link", async function (assert) { test("email invite link", async function (assert) {
preloadInvite(); preloadInvite();
await visit("/invites/myvalidinvitetoken"); await visit("/invites/my-valid-invite-token");
assert.ok(exists(".btn-social.facebook"), "shows Facebook login button"); assert.ok(exists(".btn-social.facebook"), "shows Facebook login button");
assert.ok(!exists("form"), "does not display the form"); assert.ok(!exists("form"), "does not display the form");
@ -202,7 +201,7 @@ acceptance(
test("invite link", async function (assert) { test("invite link", async function (assert) {
preloadInvite({ link: true }); preloadInvite({ link: true });
await visit("/invites/myvalidinvitetoken"); await visit("/invites/my-valid-invite-token");
assert.ok( assert.ok(
!exists(".btn-social.facebook"), !exists(".btn-social.facebook"),
@ -219,7 +218,7 @@ acceptance(
test("email invite link", async function (assert) { test("email invite link", async function (assert) {
preloadInvite(); preloadInvite();
await visit("/invites/myvalidinvitetoken"); await visit("/invites/my-valid-invite-token");
assert.ok( assert.ok(
!exists(".btn-social.facebook"), !exists(".btn-social.facebook"),
@ -232,7 +231,7 @@ acceptance(
); );
assert.ok(exists(".discourse-connect"), "shows the Continue button"); assert.ok(exists(".discourse-connect"), "shows the Continue button");
assert.ok( assert.ok(
queryAll(".email-message").text().includes("foobar@example.com") query(".email-message").innerText.includes("foobar@example.com")
); );
}); });
} }
@ -249,7 +248,7 @@ acceptance(
test("invite link", async function (assert) { test("invite link", async function (assert) {
preloadInvite({ link: true }); preloadInvite({ link: true });
await visit("/invites/myvalidinvitetoken"); await visit("/invites/my-valid-invite-token");
assert.ok(!exists("form"), "does not display the form"); assert.ok(!exists("form"), "does not display the form");
}); });
} }
@ -269,7 +268,7 @@ acceptance("Invite link with authentication data", function (needs) {
test("form elements and buttons are correct ", async function (assert) { test("form elements and buttons are correct ", async function (assert) {
preloadInvite({ link: true }); preloadInvite({ link: true });
await visit("/invites/myvalidinvitetoken"); await visit("/invites/my-valid-invite-token");
assert.ok( assert.ok(
!exists(".btn-social.facebook"), !exists(".btn-social.facebook"),
@ -284,18 +283,18 @@ acceptance("Invite link with authentication data", function (needs) {
); );
assert.strictEqual( assert.strictEqual(
queryAll("#account-email-validation").text().trim(), query("#account-email-validation").innerText.trim(),
I18n.t("user.email.authenticated", { provider: "Facebook" }) I18n.t("user.email.authenticated", { provider: "Facebook" })
); );
assert.strictEqual( assert.strictEqual(
queryAll("#new-account-username").val(), query("#new-account-username").value,
"foobar", "foobar",
"username is prefilled" "username is prefilled"
); );
assert.strictEqual( assert.strictEqual(
queryAll("#new-account-name").val(), query("#new-account-name").value,
"barfoo", "barfoo",
"name is prefilled" "name is prefilled"
); );
@ -316,10 +315,10 @@ acceptance("Email Invite link with authentication data", function (needs) {
test("email invite link with authentication data when email does not match", async function (assert) { test("email invite link with authentication data when email does not match", async function (assert) {
preloadInvite(); preloadInvite();
await visit("/invites/myvalidinvitetoken"); await visit("/invites/my-valid-invite-token");
assert.strictEqual( assert.strictEqual(
queryAll("#account-email-validation").text().trim(), query("#account-email-validation").innerText.trim(),
I18n.t("user.email.invite_auth_email_invalid", { provider: "Facebook" }) I18n.t("user.email.invite_auth_email_invalid", { provider: "Facebook" })
); );
@ -343,7 +342,7 @@ acceptance(
test("confirm form and buttons", async function (assert) { test("confirm form and buttons", async function (assert) {
preloadInvite(); preloadInvite();
await visit("/invites/myvalidinvitetoken"); await visit("/invites/my-valid-invite-token");
assert.ok( assert.ok(
!exists(".btn-social.facebook"), !exists(".btn-social.facebook"),
@ -357,18 +356,18 @@ acceptance(
assert.ok(!exists("#new-account-email"), "does not show email field"); assert.ok(!exists("#new-account-email"), "does not show email field");
assert.strictEqual( assert.strictEqual(
queryAll("#account-email-validation").text().trim(), query("#account-email-validation").innerText.trim(),
I18n.t("user.email.authenticated", { provider: "Facebook" }) I18n.t("user.email.authenticated", { provider: "Facebook" })
); );
assert.strictEqual( assert.strictEqual(
queryAll("#new-account-username").val(), query("#new-account-username").value,
"foobar", "foobar",
"username is prefilled" "username is prefilled"
); );
assert.strictEqual( assert.strictEqual(
queryAll("#new-account-name").val(), query("#new-account-name").value,
"barfoo", "barfoo",
"name is prefilled" "name is prefilled"
); );
@ -392,7 +391,7 @@ acceptance(
test("display information that email is invalid", async function (assert) { test("display information that email is invalid", async function (assert) {
preloadInvite({ different_external_email: true, hidden_email: true }); preloadInvite({ different_external_email: true, hidden_email: true });
await visit("/invites/myvalidinvitetoken"); await visit("/invites/my-valid-invite-token");
assert.strictEqual( assert.strictEqual(
query(".bad").textContent.trim(), query(".bad").textContent.trim(),
@ -418,12 +417,12 @@ acceptance(
test("confirm form and buttons", async function (assert) { test("confirm form and buttons", async function (assert) {
preloadInvite({ email_verified_by_link: true }); preloadInvite({ email_verified_by_link: true });
await visit("/invites/myvalidinvitetoken"); await visit("/invites/my-valid-invite-token");
assert.ok(!exists("#new-account-email"), "does not show email field"); assert.ok(!exists("#new-account-email"), "does not show email field");
assert.strictEqual( assert.strictEqual(
queryAll("#account-email-validation").text().trim(), query("#account-email-validation").innerText.trim(),
I18n.t("user.email.authenticated_by_invite") I18n.t("user.email.authenticated_by_invite")
); );
}); });
@ -446,12 +445,12 @@ acceptance(
test("confirm form and buttons", async function (assert) { test("confirm form and buttons", async function (assert) {
preloadInvite({ email_verified_by_link: false }); preloadInvite({ email_verified_by_link: false });
await visit("/invites/myvalidinvitetoken"); await visit("/invites/my-valid-invite-token");
assert.ok(!exists("#new-account-email"), "does not show email field"); assert.ok(!exists("#new-account-email"), "does not show email field");
assert.strictEqual( assert.strictEqual(
queryAll("#account-email-validation").text().trim(), query("#account-email-validation").innerText.trim(),
I18n.t("user.email.ok") I18n.t("user.email.ok")
); );
}); });
@ -475,7 +474,7 @@ acceptance(
test("shows the associate link", async function (assert) { test("shows the associate link", async function (assert) {
preloadInvite({ link: true }); preloadInvite({ link: true });
await visit("/invites/myvalidinvitetoken"); await visit("/invites/my-valid-invite-token");
assert.ok( assert.ok(
exists(".create-account-associate-link"), exists(".create-account-associate-link"),

View File

@ -3,7 +3,7 @@ import {
controllerFor, controllerFor,
count, count,
exists, exists,
queryAll, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, settled, triggerKeyEvent, visit } from "@ember/test-helpers"; import { click, settled, triggerKeyEvent, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
@ -90,7 +90,7 @@ acceptance("Modal", function (needs) {
await settled(); await settled();
assert.strictEqual( assert.strictEqual(
queryAll(".d-modal .modal-tab:first-child").text().trim(), query(".d-modal .modal-tab:first-child").innerText.trim(),
"Test 1", "Test 1",
"it should display the raw title" "it should display the raw title"
); );
@ -109,7 +109,7 @@ acceptance("Modal", function (needs) {
showModal("test-title", { title: "test_title" }); showModal("test-title", { title: "test_title" });
await settled(); await settled();
assert.strictEqual( assert.strictEqual(
queryAll(".d-modal .title").text().trim(), query(".d-modal .title").innerText.trim(),
"Test title", "Test title",
"it should display the title" "it should display the title"
); );
@ -119,7 +119,7 @@ acceptance("Modal", function (needs) {
showModal("test-title-with-body", { title: "test_title" }); showModal("test-title-with-body", { title: "test_title" });
await settled(); await settled();
assert.strictEqual( assert.strictEqual(
queryAll(".d-modal .title").text().trim(), query(".d-modal .title").innerText.trim(),
"Test title", "Test title",
"it should display the title when used with d-modal-body" "it should display the title when used with d-modal-body"
); );

View File

@ -1,7 +1,7 @@
import { import {
acceptance, acceptance,
exists, exists,
queryAll, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import I18n from "I18n"; import I18n from "I18n";
import { test } from "qunit"; import { test } from "qunit";
@ -23,7 +23,7 @@ acceptance("Personal Message", function (needs) {
await visit("/t/pm-for-testing/12"); await visit("/t/pm-for-testing/12");
assert.strictEqual( assert.strictEqual(
queryAll("#suggested-topics .suggested-topics-title").text().trim(), query("#suggested-topics .suggested-topics-title").innerText.trim(),
I18n.t("suggested_topics.pm_title") I18n.t("suggested_topics.pm_title")
); );
}); });

View File

@ -2,7 +2,7 @@ import {
acceptance, acceptance,
count, count,
exists, exists,
queryAll, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { action } from "@ember/object"; import { action } from "@ember/object";
@ -88,14 +88,14 @@ acceptance("Plugin Outlet - Connector Class", function (needs) {
await click(".say-hello"); await click(".say-hello");
assert.strictEqual( assert.strictEqual(
queryAll(".hello-result").text(), query(".hello-result").innerText,
"hello!", "hello!",
"actions delegate properly" "actions delegate properly"
); );
await click(".say-hi"); await click(".say-hi");
assert.strictEqual( assert.strictEqual(
queryAll(".hi-result").text(), query(".hi-result").innerText,
"hi!", "hi!",
"actions delegate properly" "actions delegate properly"
); );

View File

@ -1,7 +1,7 @@
import { import {
acceptance, acceptance,
count, count,
queryAll, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { clearCache } from "discourse/lib/plugin-connectors"; import { clearCache } from "discourse/lib/plugin-connectors";
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
@ -42,12 +42,12 @@ acceptance("Plugin Outlet - Multi Template", function (needs) {
"it has class names" "it has class names"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".hello-span").text(), query(".hello-span").innerText,
"Hello", "Hello",
"it renders into the outlet" "it renders into the outlet"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".bye-span").text(), query(".bye-span").innerText,
"Goodbye", "Goodbye",
"it renders into the outlet" "it renders into the outlet"
); );

View File

@ -1,7 +1,7 @@
import { import {
acceptance, acceptance,
count, count,
queryAll, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
import { test } from "qunit"; import { test } from "qunit";
@ -31,7 +31,7 @@ acceptance("Plugin Outlet - Single Template", function (needs) {
"it has class names" "it has class names"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".hello-username").text(), query(".hello-username").innerText,
"eviltrout", "eviltrout",
"it renders into the outlet" "it renders into the outlet"
); );

View File

@ -2,7 +2,7 @@ import {
acceptance, acceptance,
count, count,
exists, exists,
queryAll, query,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { import {
@ -81,7 +81,10 @@ acceptance("User Preferences", function (needs) {
test("update some fields", async function (assert) { test("update some fields", async function (assert) {
await visit("/u/eviltrout/preferences"); await visit("/u/eviltrout/preferences");
assert.ok($("body.user-preferences-page").length, "has the body class"); assert.ok(
document.body.classList.contains("user-preferences-page"),
"has the body class"
);
assert.strictEqual( assert.strictEqual(
currentURL(), currentURL(),
"/u/eviltrout/preferences/account", "/u/eviltrout/preferences/account",
@ -93,7 +96,7 @@ acceptance("User Preferences", function (needs) {
assert.ok(!exists(".saved"), "it hasn't been saved yet"); assert.ok(!exists(".saved"), "it hasn't been saved yet");
await click(".save-changes"); await click(".save-changes");
assert.ok(exists(".saved"), "it displays the saved message"); assert.ok(exists(".saved"), "it displays the saved message");
queryAll(".saved").remove(); query(".saved").remove();
}; };
await fillIn(".pref-name input[type=text]", "Jon Snow"); await fillIn(".pref-name input[type=text]", "Jon Snow");
@ -149,10 +152,10 @@ acceptance("User Preferences", function (needs) {
assert.ok(exists("#change-email"), "it has the input element"); assert.ok(exists("#change-email"), "it has the input element");
await fillIn("#change-email", "invalidemail"); await fillIn("#change-email", "invalid-email");
assert.strictEqual( assert.strictEqual(
queryAll(".tip.bad").text().trim(), query(".tip.bad").innerText.trim(),
I18n.t("user.email.invalid"), I18n.t("user.email.invalid"),
"it should display invalid email tip" "it should display invalid email tip"
); );
@ -180,11 +183,9 @@ acceptance("User Preferences", function (needs) {
"it has the connected accounts section" "it has the connected accounts section"
); );
assert.ok( assert.ok(
queryAll( query(
".pref-associated-accounts table tr:nth-of-type(1) td:nth-of-type(1)" ".pref-associated-accounts table tr:nth-of-type(1) td:nth-of-type(1)"
) ).innerHTML.includes("Facebook"),
.html()
.indexOf("Facebook") > -1,
"it lists facebook" "it lists facebook"
); );
@ -192,9 +193,11 @@ acceptance("User Preferences", function (needs) {
".pref-associated-accounts table tr:nth-of-type(1) td:last-child button" ".pref-associated-accounts table tr:nth-of-type(1) td:last-child button"
); );
queryAll(".pref-associated-accounts table tr:nth-of-type(1) td:last button") assert.ok(
.html() query(
.indexOf("Connect") > -1; ".pref-associated-accounts table tr:nth-of-type(1) td:last-of-type"
).innerHTML.includes("Connect")
);
}); });
test("second factor totp", async function (assert) { test("second factor totp", async function (assert) {
@ -212,8 +215,7 @@ acceptance("User Preferences", function (needs) {
await click(".add-totp"); await click(".add-totp");
assert.ok( assert.ok(
queryAll(".alert-error").html().indexOf("provide a name and the code") > query(".alert-error").innerHTML.includes("provide a name and the code"),
-1,
"shows name/token missing error message" "shows name/token missing error message"
); );
}); });
@ -238,7 +240,7 @@ acceptance("User Preferences", function (needs) {
await click(".add-security-key"); await click(".add-security-key");
assert.ok( assert.ok(
queryAll(".alert-error").html().indexOf("provide a name") > -1, query(".alert-error").innerHTML.indexOf("provide a name") > -1,
"shows name missing error message" "shows name missing error message"
); );
} }
@ -356,7 +358,7 @@ acceptance(
) )
); );
}); });
test("disallow nonstaff", async function (assert) { test("disallow non-staff", async function (assert) {
await visit("/u/eviltrout/preferences"); await visit("/u/eviltrout/preferences");
await updateCurrentUser({ await updateCurrentUser({
trust_level: 3, trust_level: 3,
@ -454,7 +456,10 @@ acceptance("User Preferences when badges are disabled", function (needs) {
test("visit my preferences", async function (assert) { test("visit my preferences", async function (assert) {
await visit("/u/eviltrout/preferences"); await visit("/u/eviltrout/preferences");
assert.ok($("body.user-preferences-page").length, "has the body class"); assert.ok(
document.body.classList.contains("user-preferences-page"),
"has the body class"
);
assert.strictEqual( assert.strictEqual(
currentURL(), currentURL(),
"/u/eviltrout/preferences/account", "/u/eviltrout/preferences/account",
@ -489,9 +494,9 @@ acceptance(
"clear button not present" "clear button not present"
); );
const selectTopicBtn = queryAll( const selectTopicBtn = query(
".feature-topic-on-profile-btn:nth-of-type(1)" ".feature-topic-on-profile-btn:nth-of-type(1)"
)[0]; );
assert.ok(exists(selectTopicBtn), "feature topic button is present"); assert.ok(exists(selectTopicBtn), "feature topic button is present");
await click(selectTopicBtn); await click(selectTopicBtn);
@ -501,9 +506,9 @@ acceptance(
"topic picker modal is open" "topic picker modal is open"
); );
const topicRadioBtn = queryAll( const topicRadioBtn = query(
'input[name="choose_topic_id"]:nth-of-type(1)' 'input[name="choose_topic_id"]:nth-of-type(1)'
)[0]; );
assert.ok(exists(topicRadioBtn), "Topic options are prefilled"); assert.ok(exists(topicRadioBtn), "Topic options are prefilled");
await click(topicRadioBtn); await click(topicRadioBtn);
@ -616,15 +621,15 @@ acceptance("Security", function (needs) {
await visit("/u/eviltrout/preferences/security"); await visit("/u/eviltrout/preferences/security");
assert.strictEqual( assert.strictEqual(
queryAll(".auth-tokens > .auth-token:nth-of-type(1) .auth-token-device") query(
.text() ".auth-tokens > .auth-token:nth-of-type(1) .auth-token-device"
.trim(), ).innerText.trim(),
"Linux Computer", "Linux Computer",
"it should display active token first" "it should display active token first"
); );
assert.strictEqual( assert.strictEqual(
queryAll(".pref-auth-tokens > a:nth-of-type(1)").text().trim(), query(".pref-auth-tokens > a:nth-of-type(1)").innerText.trim(),
I18n.t("user.auth_tokens.show_all", { count: 3 }), I18n.t("user.auth_tokens.show_all", { count: 3 }),
"it should display two tokens" "it should display two tokens"
); );
@ -670,7 +675,10 @@ acceptance(
test("staged user doesn't show category and tag preferences", async function (assert) { test("staged user doesn't show category and tag preferences", async function (assert) {
await visit("/u/staged/preferences"); await visit("/u/staged/preferences");
assert.ok($("body.user-preferences-page").length, "has the body class"); assert.ok(
document.body.classList.contains("user-preferences-page"),
"has the body class"
);
assert.strictEqual( assert.strictEqual(
currentURL(), currentURL(),
"/u/staged/preferences/account", "/u/staged/preferences/account",

View File

@ -4,7 +4,7 @@ import {
exists, exists,
publishToMessageBus, publishToMessageBus,
query, query,
queryAll, visible,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import I18n from "I18n"; import I18n from "I18n";
@ -67,10 +67,11 @@ acceptance("Review", function (needs) {
await reviewableActionDropdown.expand(); await reviewableActionDropdown.expand();
await reviewableActionDropdown.selectRowByValue("reject_user_delete"); await reviewableActionDropdown.selectRowByValue("reject_user_delete");
assert.ok(visible(".reject-reason-reviewable-modal"));
assert.ok( assert.ok(
queryAll(".reject-reason-reviewable-modal:visible .title") query(".reject-reason-reviewable-modal .title").innerHTML.includes(
.html() I18n.t("review.reject_reason.title")
.includes(I18n.t("review.reject_reason.title")), ),
"it opens reject reason modal when user is rejected" "it opens reject reason modal when user is rejected"
); );
@ -78,10 +79,11 @@ acceptance("Review", function (needs) {
await reviewableActionDropdown.expand(); await reviewableActionDropdown.expand();
await reviewableActionDropdown.selectRowByValue("reject_user_block"); await reviewableActionDropdown.selectRowByValue("reject_user_block");
assert.ok(visible(".reject-reason-reviewable-modal"));
assert.ok( assert.ok(
queryAll(".reject-reason-reviewable-modal:visible .title") query(".reject-reason-reviewable-modal .title").innerHTML.includes(
.html() I18n.t("review.reject_reason.title")
.includes(I18n.t("review.reject_reason.title")), ),
"it opens reject reason modal when user is rejected and blocked" "it opens reject reason modal when user is rejected and blocked"
); );
}); });
@ -110,7 +112,7 @@ acceptance("Review", function (needs) {
); );
assert.strictEqual( assert.strictEqual(
queryAll(".reviewable-flagged-post .post-body").html().trim(), query(".reviewable-flagged-post .post-body").innerHTML.trim(),
"<b>cooked content</b>" "<b>cooked content</b>"
); );
@ -135,16 +137,16 @@ acceptance("Review", function (needs) {
assert.ok(exists(`${topic} .reviewable-action.approve`)); assert.ok(exists(`${topic} .reviewable-action.approve`));
assert.ok(!exists(`${topic} .category-name`)); assert.ok(!exists(`${topic} .category-name`));
assert.strictEqual( assert.strictEqual(
queryAll(`${topic} .discourse-tag:nth-of-type(1)`).text(), query(`${topic} .discourse-tag:nth-of-type(1)`).innerText,
"hello" "hello"
); );
assert.strictEqual( assert.strictEqual(
queryAll(`${topic} .discourse-tag:nth-of-type(2)`).text(), query(`${topic} .discourse-tag:nth-of-type(2)`).innerText,
"world" "world"
); );
assert.strictEqual( assert.strictEqual(
queryAll(`${topic} .post-body`).text().trim(), query(`${topic} .post-body`).innerText.trim(),
"existing body" "existing body"
); );
@ -164,7 +166,7 @@ acceptance("Review", function (needs) {
await fillIn(".editable-field.payload-raw textarea", "new raw contents"); await fillIn(".editable-field.payload-raw textarea", "new raw contents");
await click(`${topic} .reviewable-action.cancel-edit`); await click(`${topic} .reviewable-action.cancel-edit`);
assert.strictEqual( assert.strictEqual(
queryAll(`${topic} .post-body`).text().trim(), query(`${topic} .post-body`).innerText.trim(),
"existing body", "existing body",
"cancelling does not update the value" "cancelling does not update the value"
); );
@ -186,24 +188,24 @@ acceptance("Review", function (needs) {
await click(`${topic} .reviewable-action.save-edit`); await click(`${topic} .reviewable-action.save-edit`);
assert.strictEqual( assert.strictEqual(
queryAll(`${topic} .discourse-tag:nth-of-type(1)`).text(), query(`${topic} .discourse-tag:nth-of-type(1)`).innerText,
"hello" "hello"
); );
assert.strictEqual( assert.strictEqual(
queryAll(`${topic} .discourse-tag:nth-of-type(2)`).text(), query(`${topic} .discourse-tag:nth-of-type(2)`).innerText,
"world" "world"
); );
assert.strictEqual( assert.strictEqual(
queryAll(`${topic} .discourse-tag:nth-of-type(3)`).text(), query(`${topic} .discourse-tag:nth-of-type(3)`).innerText,
"monkey" "monkey"
); );
assert.strictEqual( assert.strictEqual(
queryAll(`${topic} .post-body`).text().trim(), query(`${topic} .post-body`).innerText.trim(),
"new raw contents" "new raw contents"
); );
assert.strictEqual( assert.strictEqual(
queryAll(`${topic} .category-name`).text().trim(), query(`${topic} .category-name`).innerText.trim(),
"support" "support"
); );
}); });

View File

@ -2,7 +2,7 @@ import {
acceptance, acceptance,
count, count,
exists, exists,
queryAll, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
@ -41,14 +41,14 @@ acceptance("Signing In", function () {
await fillIn("#login-account-password", "not-activated"); await fillIn("#login-account-password", "not-activated");
await click(".modal-footer .btn-primary"); await click(".modal-footer .btn-primary");
assert.strictEqual( assert.strictEqual(
queryAll(".modal-body b").text(), query(".modal-body b").innerText,
"<small>eviltrout@example.com</small>" "<small>eviltrout@example.com</small>"
); );
assert.ok(!exists(".modal-body small"), "it escapes the email address"); assert.ok(!exists(".modal-body small"), "it escapes the email address");
await click(".modal-footer button.resend"); await click(".modal-footer button.resend");
assert.strictEqual( assert.strictEqual(
queryAll(".modal-body b").text(), query(".modal-body b").innerText,
"<small>current@example.com</small>" "<small>current@example.com</small>"
); );
assert.ok(!exists(".modal-body small"), "it escapes the email address"); assert.ok(!exists(".modal-body small"), "it escapes the email address");
@ -64,7 +64,7 @@ acceptance("Signing In", function () {
await click(".modal-footer .btn-primary"); await click(".modal-footer .btn-primary");
await click(".modal-footer button.edit-email"); await click(".modal-footer button.edit-email");
assert.strictEqual( assert.strictEqual(
queryAll(".activate-new-email").val(), query(".activate-new-email").value,
"current@example.com" "current@example.com"
); );
assert.strictEqual( assert.strictEqual(
@ -76,7 +76,7 @@ acceptance("Signing In", function () {
assert.ok(!exists(".modal-footer .btn-primary:disabled")); assert.ok(!exists(".modal-footer .btn-primary:disabled"));
await click(".modal-footer .btn-primary"); await click(".modal-footer .btn-primary");
assert.strictEqual( assert.strictEqual(
queryAll(".modal-body b").text(), query(".modal-body b").innerText,
"different@example.com" "different@example.com"
); );
}); });
@ -160,7 +160,7 @@ acceptance("Signing In", function () {
); );
await click(".modal-footer .btn-primary"); await click(".modal-footer .btn-primary");
await fillIn("#new-account-username", "goodtuna"); await fillIn("#new-account-username", "good-tuna");
assert.ok( assert.ok(
exists("#username-validation.good"), exists("#username-validation.good"),
"the username validation is good" "the username validation is good"

View File

@ -1,4 +1,8 @@
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers"; import {
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
@ -36,7 +40,7 @@ acceptance("Tags intersection", function (needs) {
assert.ok(exists(".mini-tag-chooser"), "The tag selector appears"); assert.ok(exists(".mini-tag-chooser"), "The tag selector appears");
assert.strictEqual( assert.strictEqual(
$(".composer-fields .mini-tag-chooser").text().trim(), query(".composer-fields .mini-tag-chooser").innerText.trim(),
"first, second", "first, second",
"populates the tags when clicking 'New topic'" "populates the tags when clicking 'New topic'"
); );

View File

@ -107,11 +107,11 @@ acceptance("Tags", function (needs) {
test("list the tags", async function (assert) { test("list the tags", async function (assert) {
await visit("/tags"); await visit("/tags");
assert.ok($("body.tags-page").length, "has the body class");
assert.ok( assert.ok(
$('*[data-tag-name="eviltrout"]').length, document.body.classList.contains("tags-page"),
"shows the eviltrout tag" "has the body class"
); );
assert.ok(exists(`[data-tag-name="eviltrout"]`), "shows the eviltrout tag");
}); });
test("dismiss notifications", async function (assert) { test("dismiss notifications", async function (assert) {
@ -193,40 +193,33 @@ acceptance("Tags listed by group", function (needs) {
test("list the tags in groups", async function (assert) { test("list the tags in groups", async function (assert) {
await visit("/tags"); await visit("/tags");
assert.strictEqual( assert.strictEqual(
$(".tag-list").length, count(".tag-list"),
4, 4,
"shows separate lists for the 3 groups and the ungrouped tags" "shows separate lists for the 3 groups and the ungrouped tags"
); );
assert.deepEqual( assert.deepEqual(
$(".tag-list h3") [...queryAll(".tag-list h3")].map((el) => el.innerText),
.toArray()
.map((i) => {
return $(i).text();
}),
["Ford Cars", "Honda Cars", "Makes", "Other Tags"], ["Ford Cars", "Honda Cars", "Makes", "Other Tags"],
"shown in given order and with tags that are not in a group" "shown in given order and with tags that are not in a group"
); );
assert.deepEqual( assert.deepEqual(
$(".tag-list:nth-of-type(1) .discourse-tag") [...queryAll(".tag-list:nth-of-type(1) .discourse-tag")].map(
.toArray() (el) => el.innerText
.map((i) => { ),
return $(i).text();
}),
["focus", "Escort"], ["focus", "Escort"],
"shows the tags in default sort (by count)" "shows the tags in default sort (by count)"
); );
assert.deepEqual( assert.deepEqual(
$(".tag-list:nth-of-type(1) .discourse-tag") [...queryAll(".tag-list:nth-of-type(1) .discourse-tag")].map((el) =>
.toArray() el.getAttribute("href")
.map((i) => { ),
return $(i).attr("href");
}),
["/tag/focus", "/tag/escort"], ["/tag/focus", "/tag/escort"],
"always uses lowercase URLs for mixed case tags" "always uses lowercase URLs for mixed case tags"
); );
assert.strictEqual( assert.strictEqual(
$("a[data-tag-name='private']").attr("href"), query(`a[data-tag-name="private"]`).getAttribute("href"),
"/u/eviltrout/messages/tags/private", "/u/eviltrout/messages/tags/private",
"links to private messages" "links to private messages"
); );
@ -402,7 +395,7 @@ acceptance("Tag info", function (needs) {
await click("#show-tag-info"); await click("#show-tag-info");
assert.ok(exists(".tag-info .tag-name"), "show tag"); assert.ok(exists(".tag-info .tag-name"), "show tag");
assert.ok( assert.ok(
queryAll(".tag-info .tag-associations").text().indexOf("Gardening") >= 0, query(".tag-info .tag-associations").innerText.includes("Gardening"),
"show tag group names" "show tag group names"
); );
assert.strictEqual( assert.strictEqual(
@ -485,7 +478,7 @@ acceptance("Tag info", function (needs) {
await visit("/tag/planters"); await visit("/tag/planters");
await click(".category-breadcrumb .category-drop-header"); await click(".category-breadcrumb .category-drop-header");
await click('.category-breadcrumb .category-row[data-name="faq"]'); await click(`.category-breadcrumb .category-row[data-name="faq"]`);
assert.strictEqual(currentURL(), "/tags/c/faq/4/planters"); assert.strictEqual(currentURL(), "/tags/c/faq/4/planters");
}); });
@ -494,12 +487,12 @@ acceptance("Tag info", function (needs) {
await visit("/tag/planters"); await visit("/tag/planters");
await click(".category-breadcrumb .category-drop-header"); await click(".category-breadcrumb .category-drop-header");
await click('.category-breadcrumb .category-row[data-name="feature"]'); await click(`.category-breadcrumb .category-row[data-name="feature"]`);
assert.strictEqual(currentURL(), "/tags/c/feature/2/planters"); assert.strictEqual(currentURL(), "/tags/c/feature/2/planters");
await click(".category-breadcrumb li:nth-of-type(2) .category-drop-header"); await click(".category-breadcrumb li:nth-of-type(2) .category-drop-header");
await click( await click(
'.category-breadcrumb li:nth-of-type(2) .category-row[data-value="no-categories"]' `.category-breadcrumb li:nth-of-type(2) .category-row[data-value="no-categories"]`
); );
assert.strictEqual(currentURL(), "/tags/c/feature/2/none/planters"); assert.strictEqual(currentURL(), "/tags/c/feature/2/none/planters");
}); });

View File

@ -3,6 +3,7 @@ import {
exists, exists,
fakeTime, fakeTime,
loggedInUser, loggedInUser,
query,
queryAll, queryAll,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -48,9 +49,9 @@ acceptance("Topic - Edit timer", function (needs) {
await click("#tap_tile_start_of_next_business_week"); await click("#tap_tile_start_of_next_business_week");
const regex = /will automatically close in/g; const regex = /will automatically close in/g;
const html = queryAll(".edit-topic-timer-modal .topic-timer-info") const html = query(
.html() ".edit-topic-timer-modal .topic-timer-info"
.trim(); ).innerHTML.trim();
assert.ok(regex.test(html)); assert.ok(regex.test(html));
}); });
@ -64,18 +65,18 @@ acceptance("Topic - Edit timer", function (needs) {
await click("#tap_tile_start_of_next_business_week"); await click("#tap_tile_start_of_next_business_week");
const regex1 = /will automatically close in/g; const regex1 = /will automatically close in/g;
const html1 = queryAll(".edit-topic-timer-modal .topic-timer-info") const html1 = query(
.html() ".edit-topic-timer-modal .topic-timer-info"
.trim(); ).innerHTML.trim();
assert.ok(regex1.test(html1)); assert.ok(regex1.test(html1));
await click("#tap_tile_custom"); await click("#tap_tile_custom");
await fillIn(".tap-tile-date-input .date-picker", "2100-11-24"); await fillIn(".tap-tile-date-input .date-picker", "2100-11-24");
const regex2 = /will automatically close in/g; const regex2 = /will automatically close in/g;
const html2 = queryAll(".edit-topic-timer-modal .topic-timer-info") const html2 = query(
.html() ".edit-topic-timer-modal .topic-timer-info"
.trim(); ).innerHTML.trim();
assert.ok(regex2.test(html2)); assert.ok(regex2.test(html2));
const timerType = selectKit(".select-kit.timer-type"); const timerType = selectKit(".select-kit.timer-type");
@ -88,7 +89,7 @@ acceptance("Topic - Edit timer", function (needs) {
await fillIn(".relative-time-duration", "2"); await fillIn(".relative-time-duration", "2");
const regex3 = /last post in the topic is already/g; const regex3 = /last post in the topic is already/g;
const html3 = queryAll(".edit-topic-timer-modal .warning").html().trim(); const html3 = query(".edit-topic-timer-modal .warning").innerHTML.trim();
assert.ok(regex3.test(html3)); assert.ok(regex3.test(html3));
}); });
@ -106,18 +107,18 @@ acceptance("Topic - Edit timer", function (needs) {
await click("#tap_tile_start_of_next_business_week"); await click("#tap_tile_start_of_next_business_week");
const regex1 = /will automatically open in/g; const regex1 = /will automatically open in/g;
const html1 = queryAll(".edit-topic-timer-modal .topic-timer-info") const html1 = query(
.html() ".edit-topic-timer-modal .topic-timer-info"
.trim(); ).innerHTML.trim();
assert.ok(regex1.test(html1)); assert.ok(regex1.test(html1));
await click("#tap_tile_custom"); await click("#tap_tile_custom");
await fillIn(".tap-tile-date-input .date-picker", "2100-11-24"); await fillIn(".tap-tile-date-input .date-picker", "2100-11-24");
const regex2 = /will automatically open in/g; const regex2 = /will automatically open in/g;
const html2 = queryAll(".edit-topic-timer-modal .topic-timer-info") const html2 = query(
.html() ".edit-topic-timer-modal .topic-timer-info"
.trim(); ).innerHTML.trim();
assert.ok(regex2.test(html2)); assert.ok(regex2.test(html2));
}); });
@ -141,9 +142,9 @@ acceptance("Topic - Edit timer", function (needs) {
await click("#tap_tile_start_of_next_business_week"); await click("#tap_tile_start_of_next_business_week");
const text = queryAll(".edit-topic-timer-modal .topic-timer-info") const text = query(
.text() ".edit-topic-timer-modal .topic-timer-info"
.trim(); ).innerText.trim();
// this needs to be done because there is no simple way to get the // this needs to be done because there is no simple way to get the
// plain text version of a translation with HTML // plain text version of a translation with HTML
@ -181,9 +182,9 @@ acceptance("Topic - Edit timer", function (needs) {
await click("#tap_tile_start_of_next_business_week"); await click("#tap_tile_start_of_next_business_week");
const text = queryAll(".edit-topic-timer-modal .topic-timer-info") const text = query(
.text() ".edit-topic-timer-modal .topic-timer-info"
.trim(); ).innerText.trim();
// this needs to be done because there is no simple way to get the // this needs to be done because there is no simple way to get the
// plain text version of a translation with HTML // plain text version of a translation with HTML
@ -225,9 +226,9 @@ acceptance("Topic - Edit timer", function (needs) {
await click("#tap_tile_start_of_next_business_week"); await click("#tap_tile_start_of_next_business_week");
const text = queryAll(".edit-topic-timer-modal .topic-timer-info") const text = query(
.text() ".edit-topic-timer-modal .topic-timer-info"
.trim(); ).innerText.trim();
// this needs to be done because there is no simple way to get the // this needs to be done because there is no simple way to get the
// plain text version of a translation with HTML // plain text version of a translation with HTML
@ -274,7 +275,7 @@ acceptance("Topic - Edit timer", function (needs) {
exists("#tap_tile_last_custom"), exists("#tap_tile_last_custom"),
"it show last custom because the custom date and time was valid" "it show last custom because the custom date and time was valid"
); );
const text = queryAll("#tap_tile_last_custom").text().trim(); const text = query("#tap_tile_last_custom").innerText.trim();
const regex = /Nov 24, 10:30 am/g; const regex = /Nov 24, 10:30 am/g;
assert.ok(regex.test(text)); assert.ok(regex.test(text));
}); });
@ -322,9 +323,9 @@ acceptance("Topic - Edit timer", function (needs) {
await click("#tap_tile_two_weeks"); await click("#tap_tile_two_weeks");
const regex = /will be automatically deleted/g; const regex = /will be automatically deleted/g;
const html = queryAll(".edit-topic-timer-modal .topic-timer-info") const html = query(
.html() ".edit-topic-timer-modal .topic-timer-info"
.trim(); ).innerHTML.trim();
assert.ok(regex.test(html)); assert.ok(regex.test(html));
}); });
@ -337,12 +338,11 @@ acceptance("Topic - Edit timer", function (needs) {
await click("#tap_tile_start_of_next_business_week"); await click("#tap_tile_start_of_next_business_week");
await click(".edit-topic-timer-buttons button.btn-primary"); await click(".edit-topic-timer-buttons button.btn-primary");
const removeTimerButton = queryAll(".topic-timer-info .topic-timer-remove"); const removeTimerButton = query(".topic-timer-info .topic-timer-remove");
assert.strictEqual(removeTimerButton.attr("title"), "remove timer"); assert.strictEqual(removeTimerButton.getAttribute("title"), "remove timer");
await click(".topic-timer-info .topic-timer-remove"); await click(".topic-timer-info .topic-timer-remove");
const topicTimerInfo = queryAll(".topic-timer-info .topic-timer-remove"); assert.ok(!exists(".topic-timer-info .topic-timer-remove"));
assert.strictEqual(topicTimerInfo.length, 0);
}); });
test("Shows correct time frame options", async function (assert) { test("Shows correct time frame options", async function (assert) {
@ -353,23 +353,20 @@ acceptance("Topic - Edit timer", function (needs) {
await click(".toggle-admin-menu"); await click(".toggle-admin-menu");
await click(".admin-topic-timer-update button"); await click(".admin-topic-timer-update button");
const expected = [ assert.deepEqual(
I18n.t("time_shortcut.tomorrow"), [...queryAll("div.tap-tile-grid div.tap-tile-title")].map((el) =>
I18n.t("time_shortcut.this_weekend"), el.innerText.trim()
I18n.t("time_shortcut.start_of_next_business_week"), ),
I18n.t("time_shortcut.two_weeks"), [
I18n.t("time_shortcut.next_month"), I18n.t("time_shortcut.tomorrow"),
I18n.t("time_shortcut.six_months"), I18n.t("time_shortcut.this_weekend"),
I18n.t("time_shortcut.custom"), I18n.t("time_shortcut.start_of_next_business_week"),
]; I18n.t("time_shortcut.two_weeks"),
I18n.t("time_shortcut.next_month"),
const options = Array.from( I18n.t("time_shortcut.six_months"),
queryAll("div.tap-tile-grid div.tap-tile-title").map((_, div) => I18n.t("time_shortcut.custom"),
div.innerText.trim() ]
)
); );
assert.deepEqual(options, expected);
}); });
test("Does not show timer notice unless timer set", async function (assert) { test("Does not show timer notice unless timer set", async function (assert) {

View File

@ -1,4 +1,4 @@
import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers"; import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import I18n from "I18n"; import I18n from "I18n";
import { test } from "qunit"; import { test } from "qunit";
@ -13,7 +13,7 @@ acceptance("Topic move posts", function (needs) {
await click("#post_11 .select-below"); await click("#post_11 .select-below");
assert.strictEqual( assert.strictEqual(
queryAll(".selected-posts .move-to-topic").text().trim(), query(".selected-posts .move-to-topic").innerText.trim(),
I18n.t("topic.move_to.action"), I18n.t("topic.move_to.action"),
"it should show the move to button" "it should show the move to button"
); );
@ -21,30 +21,30 @@ acceptance("Topic move posts", function (needs) {
await click(".selected-posts .move-to-topic"); await click(".selected-posts .move-to-topic");
assert.ok( assert.ok(
queryAll(".choose-topic-modal .title") query(".choose-topic-modal .title").innerHTML.includes(
.html() I18n.t("topic.move_to.title")
.includes(I18n.t("topic.move_to.title")), ),
"it opens move to modal" "it opens move to modal"
); );
assert.ok( assert.ok(
queryAll(".choose-topic-modal .radios") query(".choose-topic-modal .radios").innerHTML.includes(
.html() I18n.t("topic.split_topic.radio_label")
.includes(I18n.t("topic.split_topic.radio_label")), ),
"it shows an option to move to new topic" "it shows an option to move to new topic"
); );
assert.ok( assert.ok(
queryAll(".choose-topic-modal .radios") query(".choose-topic-modal .radios").innerHTML.includes(
.html() I18n.t("topic.merge_topic.radio_label")
.includes(I18n.t("topic.merge_topic.radio_label")), ),
"it shows an option to move to existing topic" "it shows an option to move to existing topic"
); );
assert.ok( assert.ok(
queryAll(".choose-topic-modal .radios") query(".choose-topic-modal .radios").innerHTML.includes(
.html() I18n.t("topic.move_to_new_message.radio_label")
.includes(I18n.t("topic.move_to_new_message.radio_label")), ),
"it shows an option to move to new message" "it shows an option to move to new message"
); );
}); });
@ -57,30 +57,30 @@ acceptance("Topic move posts", function (needs) {
await click(".selected-posts .move-to-topic"); await click(".selected-posts .move-to-topic");
assert.ok( assert.ok(
queryAll(".choose-topic-modal .title") query(".choose-topic-modal .title").innerHTML.includes(
.html() I18n.t("topic.move_to.title")
.includes(I18n.t("topic.move_to.title")), ),
"it opens move to modal" "it opens move to modal"
); );
assert.notOk( assert.notOk(
queryAll(".choose-topic-modal .radios") query(".choose-topic-modal .radios").innerHTML.includes(
.html() I18n.t("topic.split_topic.radio_label")
.includes(I18n.t("topic.split_topic.radio_label")), ),
"it does not show an option to move to new topic" "it does not show an option to move to new topic"
); );
assert.ok( assert.ok(
queryAll(".choose-topic-modal .radios") query(".choose-topic-modal .radios").innerHTML.includes(
.html() I18n.t("topic.merge_topic.radio_label")
.includes(I18n.t("topic.merge_topic.radio_label")), ),
"it shows an option to move to existing topic" "it shows an option to move to existing topic"
); );
assert.notOk( assert.notOk(
queryAll(".choose-topic-modal .radios") query(".choose-topic-modal .radios").innerHTML.includes(
.html() I18n.t("topic.move_to_new_message.radio_label")
.includes(I18n.t("topic.move_to_new_message.radio_label")), ),
"it does not show an option to move to new message" "it does not show an option to move to new message"
); );
}); });
@ -92,7 +92,7 @@ acceptance("Topic move posts", function (needs) {
await click("#post_1 .select-post"); await click("#post_1 .select-post");
assert.strictEqual( assert.strictEqual(
queryAll(".selected-posts .move-to-topic").text().trim(), query(".selected-posts .move-to-topic").innerText.trim(),
I18n.t("topic.move_to.action"), I18n.t("topic.move_to.action"),
"it should show the move to button" "it should show the move to button"
); );
@ -100,23 +100,23 @@ acceptance("Topic move posts", function (needs) {
await click(".selected-posts .move-to-topic"); await click(".selected-posts .move-to-topic");
assert.ok( assert.ok(
queryAll(".choose-topic-modal .title") query(".choose-topic-modal .title").innerHTML.includes(
.html() I18n.t("topic.move_to.title")
.includes(I18n.t("topic.move_to.title")), ),
"it opens move to modal" "it opens move to modal"
); );
assert.ok( assert.ok(
queryAll(".choose-topic-modal .radios") query(".choose-topic-modal .radios").innerHTML.includes(
.html() I18n.t("topic.move_to_new_message.radio_label")
.includes(I18n.t("topic.move_to_new_message.radio_label")), ),
"it shows an option to move to new message" "it shows an option to move to new message"
); );
assert.ok( assert.ok(
queryAll(".choose-topic-modal .radios") query(".choose-topic-modal .radios").innerHTML.includes(
.html() I18n.t("topic.move_to_existing_message.radio_label")
.includes(I18n.t("topic.move_to_existing_message.radio_label")), ),
"it shows an option to move to existing message" "it shows an option to move to existing message"
); );
}); });
@ -128,7 +128,7 @@ acceptance("Topic move posts", function (needs) {
await click("#post_2 .select-below"); await click("#post_2 .select-below");
assert.strictEqual( assert.strictEqual(
queryAll(".selected-posts .move-to-topic").text().trim(), query(".selected-posts .move-to-topic").innerText.trim(),
I18n.t("topic.move_to.action"), I18n.t("topic.move_to.action"),
"it should show the move to button" "it should show the move to button"
); );
@ -136,9 +136,9 @@ acceptance("Topic move posts", function (needs) {
await click(".selected-posts .move-to-topic"); await click(".selected-posts .move-to-topic");
assert.ok( assert.ok(
queryAll(".choose-topic-modal .title") query(".choose-topic-modal .title").innerHTML.includes(
.html() I18n.t("topic.move_to.title")
.includes(I18n.t("topic.move_to.title")), ),
"it opens move to modal" "it opens move to modal"
); );
}); });

View File

@ -2,7 +2,7 @@ import {
acceptance, acceptance,
count, count,
exists, exists,
queryAll, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import { click, currentURL, fillIn, visit } from "@ember/test-helpers"; import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
@ -116,8 +116,8 @@ acceptance("Discourse Presence Plugin", function (needs) {
await click(".topic-post:nth-of-type(1) button.edit"); await click(".topic-post:nth-of-type(1) button.edit");
assert.strictEqual( assert.strictEqual(
queryAll(".d-editor-input").val(), query(".d-editor-input").value,
queryAll(".topic-post:nth-of-type(1) .cooked > p").text(), query(".topic-post:nth-of-type(1) .cooked > p").innerText,
"composer has contents of post to be edited" "composer has contents of post to be edited"
); );
@ -162,7 +162,7 @@ acceptance("Discourse Presence Plugin", function (needs) {
await joinChannel("/discourse-presence/reply/280", { await joinChannel("/discourse-presence/reply/280", {
id: 123, id: 123,
avatar_template: "/a/b/c.jpg", avatar_template: "/a/b/c.jpg",
username: "myusername", username: "my-username",
}); });
assert.strictEqual(count(avatarSelector), 1, "avatar displayed"); assert.strictEqual(count(avatarSelector), 1, "avatar displayed");
@ -170,7 +170,7 @@ acceptance("Discourse Presence Plugin", function (needs) {
await joinChannel("/discourse-presence/whisper/280", { await joinChannel("/discourse-presence/whisper/280", {
id: 124, id: 124,
avatar_template: "/a/b/c.jpg", avatar_template: "/a/b/c.jpg",
username: "myusername2", username: "my-username2",
}); });
assert.strictEqual(count(avatarSelector), 2, "whisper avatar displayed"); assert.strictEqual(count(avatarSelector), 2, "whisper avatar displayed");
@ -199,7 +199,7 @@ acceptance("Discourse Presence Plugin", function (needs) {
await joinChannel("/discourse-presence/reply/280", { await joinChannel("/discourse-presence/reply/280", {
id: 123, id: 123,
avatar_template: "/a/b/c.jpg", avatar_template: "/a/b/c.jpg",
username: "myusername", username: "my-username",
}); });
assert.strictEqual(count(avatarSelector), 1, "avatar displayed"); assert.strictEqual(count(avatarSelector), 1, "avatar displayed");
@ -207,7 +207,7 @@ acceptance("Discourse Presence Plugin", function (needs) {
await joinChannel("/discourse-presence/whisper/280", { await joinChannel("/discourse-presence/whisper/280", {
id: 124, id: 124,
avatar_template: "/a/b/c.jpg", avatar_template: "/a/b/c.jpg",
username: "myusername2", username: "my-username2",
}); });
assert.strictEqual(count(avatarSelector), 2, "whisper avatar displayed"); assert.strictEqual(count(avatarSelector), 2, "whisper avatar displayed");