DEV: Use the new `hasHtml`/`includesHtml` from qunit-dom (#29680)

This commit is contained in:
Jarek Radosz 2024-11-11 13:06:12 +01:00 committed by GitHub
parent 95fa997e4b
commit e68905510d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
35 changed files with 404 additions and 495 deletions

View File

@ -481,10 +481,9 @@ acceptance("Prioritize Full Name", function (needs) {
await visit("/t/short-topic-with-two-posts/54079"); await visit("/t/short-topic-with-two-posts/54079");
await click("article#post_3 button.reply"); await click("article#post_3 button.reply");
assert.strictEqual( assert
query(".action-title .user-link").innerHTML.trim(), .dom(".action-title .user-link")
"<h1>Tim Stone</h1>" .hasHtml("<h1>Tim Stone</h1>");
);
}); });
test("Quotes use full name", async function (assert) { test("Quotes use full name", async function (assert) {

View File

@ -44,13 +44,11 @@ acceptance("Composer - Messages", function (needs) {
assert.dom(".composer-popup").exists("shows composer warning message"); assert.dom(".composer-popup").exists("shows composer warning message");
assert.true( assert.dom(".composer-popup").includesHtml(
query(".composer-popup").innerHTML.includes( I18n.t("composer.user_not_seen_in_a_while.single", {
I18n.t("composer.user_not_seen_in_a_while.single", { usernames: ['<a class="mention" href="/u/charlie">@charlie</a>'],
usernames: ['<a class="mention" href="/u/charlie">@charlie</a>'], time_ago: "1 year ago",
time_ago: "1 year ago", }),
})
),
"warning message has correct body" "warning message has correct body"
); );
@ -96,12 +94,10 @@ acceptance("Composer - Messages - Cannot see group", function (needs) {
await fillIn(".d-editor-input", "Mention @staff"); await fillIn(".d-editor-input", "Mention @staff");
assert.dom(".composer-popup").exists("shows composer warning message"); assert.dom(".composer-popup").exists("shows composer warning message");
assert.true( assert.dom(".composer-popup").includesHtml(
query(".composer-popup").innerHTML.includes( I18n.t("composer.cannot_see_group_mention.not_allowed", {
I18n.t("composer.cannot_see_group_mention.not_allowed", { group: "staff",
group: "staff", }),
})
),
"warning message has correct body" "warning message has correct body"
); );
}); });
@ -115,13 +111,11 @@ acceptance("Composer - Messages - Cannot see group", function (needs) {
await fillIn(".d-editor-input", "Mention @staff2"); await fillIn(".d-editor-input", "Mention @staff2");
assert.dom(".composer-popup").exists("shows composer warning message"); assert.dom(".composer-popup").exists("shows composer warning message");
assert.true( assert.dom(".composer-popup").includesHtml(
query(".composer-popup").innerHTML.includes( I18n.t("composer.cannot_see_group_mention.some_not_allowed", {
I18n.t("composer.cannot_see_group_mention.some_not_allowed", { group: "staff2",
group: "staff2", count: 10,
count: 10, }),
})
),
"warning message has correct body" "warning message has correct body"
); );
}); });
@ -237,18 +231,18 @@ acceptance("Composer - Messages - Private Messages", function (needs) {
await triggerKeyEvent(".d-editor-input", "keyup", "Space"); await triggerKeyEvent(".d-editor-input", "keyup", "Space");
assert.dom(".composer-popup").exists("shows composer warning message"); assert.dom(".composer-popup").exists("shows composer warning message");
assert.true( assert
query(".composer-popup").innerHTML.includes( .dom(".composer-popup")
I18n.t("composer.yourself_confirm.title") .includesHtml(
), I18n.t("composer.yourself_confirm.title"),
"warning message has correct title" "warning message has correct title"
); );
assert.true( assert
query(".composer-popup").innerHTML.includes( .dom(".composer-popup")
I18n.t("composer.yourself_confirm.body") .includesHtml(
), I18n.t("composer.yourself_confirm.body"),
"warning message has correct body" "warning message has correct body"
); );
}); });
test("Does not show a warning in the composer if the message is sent to other users", async function (assert) { test("Does not show a warning in the composer if the message is sent to other users", async function (assert) {

View File

@ -1,6 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Composer - Onebox", function (needs) { acceptance("Composer - Onebox", function (needs) {
needs.user(); needs.user();
@ -29,17 +29,13 @@ http://www.example.com/has-title.html
); );
assert.dom(".d-editor-preview").exists(); assert.dom(".d-editor-preview").exists();
assert.strictEqual( assert.dom(".d-editor-preview").hasHtml(`
query(".d-editor-preview").innerHTML.trim(),
`
<p><aside class=\"onebox\"><article class=\"onebox-body\"><h3><a href=\"http://www.example.com/article.html\" tabindex=\"-1\">An interesting article</a></h3></article></aside><br> <p><aside class=\"onebox\"><article class=\"onebox-body\"><h3><a href=\"http://www.example.com/article.html\" tabindex=\"-1\">An interesting article</a></h3></article></aside><br>
This is another test <a href=\"http://www.example.com/has-title.html\" class=\"inline-onebox\" tabindex=\"-1\">This is a great title</a></p> This is another test <a href=\"http://www.example.com/has-title.html\" class=\"inline-onebox\" tabindex=\"-1\">This is a great title</a></p>
<p><a href=\"http://www.example.com/no-title.html\" class=\"onebox\" target=\"_blank\" tabindex=\"-1\">http://www.example.com/no-title.html</a></p> <p><a href=\"http://www.example.com/no-title.html\" class=\"onebox\" target=\"_blank\" tabindex=\"-1\">http://www.example.com/no-title.html</a></p>
<p>This is another test <a href=\"http://www.example.com/no-title.html\" class=\"\" tabindex=\"-1\">http://www.example.com/no-title.html</a><br> <p>This is another test <a href=\"http://www.example.com/no-title.html\" class=\"\" tabindex=\"-1\">http://www.example.com/no-title.html</a><br>
This is another test <a href=\"http://www.example.com/has-title.html\" class=\"inline-onebox\" tabindex=\"-1\">This is a great title</a></p> This is another test <a href=\"http://www.example.com/has-title.html\" class=\"inline-onebox\" tabindex=\"-1\">This is a great title</a></p>
<p><aside class=\"onebox\"><article class=\"onebox-body\"><h3><a href=\"http://www.example.com/article.html\" tabindex=\"-1\">An interesting article</a></h3></article></aside></p> <p><aside class=\"onebox\"><article class=\"onebox-body\"><h3><a href=\"http://www.example.com/article.html\" tabindex=\"-1\">An interesting article</a></h3></article></aside></p>`);
`.trim()
);
}); });
}); });
@ -68,16 +64,18 @@ acceptance("Composer - Inline Onebox", function (needs) {
await fillIn(".d-editor-input", `Test www.example.com/page`); await fillIn(".d-editor-input", `Test www.example.com/page`);
assert.strictEqual(requestsCount, 1); assert.strictEqual(requestsCount, 1);
assert.strictEqual( assert
query(".d-editor-preview").innerHTML.trim(), .dom(".d-editor-preview")
'<p>Test <a href="http://www.example.com/page" class="inline-onebox-loading" tabindex="-1">www.example.com/page</a></p>' .hasHtml(
); '<p>Test <a href="http://www.example.com/page" class="inline-onebox-loading" tabindex="-1">www.example.com/page</a></p>'
);
await fillIn(".d-editor-input", `Test www.example.com/page Test`); await fillIn(".d-editor-input", `Test www.example.com/page Test`);
assert.strictEqual(requestsCount, 1); assert.strictEqual(requestsCount, 1);
assert.strictEqual( assert
query(".d-editor-preview").innerHTML.trim(), .dom(".d-editor-preview")
'<p>Test <a href="http://www.example.com/page" tabindex="-1">www.example.com/page</a> Test</p>' .hasHtml(
); '<p>Test <a href="http://www.example.com/page" tabindex="-1">www.example.com/page</a> Test</p>'
);
}); });
}); });

View File

@ -195,11 +195,12 @@ acceptance("Composer", function (needs) {
.exists("body error is dismissed via keyboard"); .exists("body error is dismissed via keyboard");
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
query(".d-editor-preview").innerHTML.trim(), .dom(".d-editor-preview")
"<p>this is the <em>content</em> of a post</p>", .hasHtml(
"it previews content" "<p>this is the <em>content</em> of a post</p>",
); "previews content"
);
assert assert
.dom(".d-editor-textarea-wrapper .popup-tip.good") .dom(".d-editor-textarea-wrapper .popup-tip.good")
.exists("the body is now good"); .exists("the body is now good");

View File

@ -14,10 +14,9 @@ acceptance("Composer topic featured links", function (needs) {
await visit("/"); await visit("/");
await click("#create-topic"); await click("#create-topic");
await fillIn("#reply-title", "http://www.example.com/has-title.html"); await fillIn("#reply-title", "http://www.example.com/has-title.html");
assert.ok( assert
query(".d-editor-preview").innerHTML.trim().includes("onebox"), .dom(".d-editor-preview")
"it pastes the link into the body and previews it" .includesHtml("onebox", "pastes the link into the body and previews it");
);
assert assert
.dom(".d-editor-textarea-wrapper .popup-tip.good") .dom(".d-editor-textarea-wrapper .popup-tip.good")
.exists("the body is now good"); .exists("the body is now good");
@ -32,10 +31,9 @@ acceptance("Composer topic featured links", function (needs) {
await visit("/"); await visit("/");
await click("#create-topic"); await click("#create-topic");
await fillIn("#reply-title", "http://www.example.com/no-title.html"); await fillIn("#reply-title", "http://www.example.com/no-title.html");
assert.ok( assert
query(".d-editor-preview").innerHTML.trim().includes("onebox"), .dom(".d-editor-preview")
"it pastes the link into the body and previews it" .includesHtml("onebox", "pastes the link into the body and previews it");
);
assert assert
.dom(".d-editor-textarea-wrapper .popup-tip.good") .dom(".d-editor-textarea-wrapper .popup-tip.good")
.exists("the body is now good"); .exists("the body is now good");
@ -61,10 +59,9 @@ acceptance("Composer topic featured links", function (needs) {
await visit("/"); await visit("/");
await click("#create-topic"); await click("#create-topic");
await fillIn("#reply-title", "http://www.example.com/nope-onebox.html"); await fillIn("#reply-title", "http://www.example.com/nope-onebox.html");
assert.ok( assert
query(".d-editor-preview").innerHTML.trim().includes("onebox"), .dom(".d-editor-preview")
"it pastes the link into the body and previews it" .includesHtml("onebox", "pastes the link into the body and previews it");
);
assert assert
.dom(".d-editor-textarea-wrapper .popup-tip.good") .dom(".d-editor-textarea-wrapper .popup-tip.good")
.exists("link is pasted into body"); .exists("link is pasted into body");
@ -80,10 +77,9 @@ acceptance("Composer topic featured links", function (needs) {
await click("#create-topic"); await click("#create-topic");
const title = "http://" + window.location.hostname + "/internal-page.html"; const title = "http://" + window.location.hostname + "/internal-page.html";
await fillIn("#reply-title", title); await fillIn("#reply-title", title);
assert.ok( assert
!query(".d-editor-preview").innerHTML.trim().includes("onebox"), .dom(".d-editor-preview")
"onebox preview doesn't show" .doesNotIncludeHtml("onebox", "onebox preview doesn't show");
);
assert.strictEqual( assert.strictEqual(
query(".d-editor-input").value.length, query(".d-editor-input").value.length,
0, 0,
@ -103,10 +99,9 @@ acceptance("Composer topic featured links", function (needs) {
"#reply-title", "#reply-title",
"http://www.example.com/has-title-and-a-url-that-is-more-than-80-characters-because-thats-good-for-seo-i-guess.html" "http://www.example.com/has-title-and-a-url-that-is-more-than-80-characters-because-thats-good-for-seo-i-guess.html"
); );
assert.ok( assert
query(".d-editor-preview").innerHTML.trim().includes("onebox"), .dom(".d-editor-preview")
"it pastes the link into the body and previews it" .includesHtml("onebox", "pastes the link into the body and previews it");
);
assert assert
.dom(".d-editor-textarea-wrapper .popup-tip.good") .dom(".d-editor-textarea-wrapper .popup-tip.good")
.exists("the body is now good"); .exists("the body is now good");
@ -121,10 +116,9 @@ acceptance("Composer topic featured links", function (needs) {
await visit("/"); await visit("/");
await click("#create-topic"); await click("#create-topic");
await fillIn("#reply-title", "http://www.example.com/has-title.html test"); await fillIn("#reply-title", "http://www.example.com/has-title.html test");
assert.ok( assert
!query(".d-editor-preview").innerHTML.trim().includes("onebox"), .dom(".d-editor-preview")
"onebox preview doesn't show" .doesNotIncludeHtml("onebox", "onebox preview doesn't show");
);
assert.strictEqual( assert.strictEqual(
query(".d-editor-input").value.length, query(".d-editor-input").value.length,
0, 0,
@ -144,10 +138,9 @@ acceptance("Composer topic featured links", function (needs) {
"#reply-title", "#reply-title",
"https://twitter.com/discourse/status/1357664660724482048" "https://twitter.com/discourse/status/1357664660724482048"
); );
assert.ok( assert
query(".d-editor-preview").innerHTML.trim().includes("onebox"), .dom(".d-editor-preview")
"it pastes the link into the body and previews it" .includesHtml("onebox", "pastes the link into the body and previews it");
);
assert assert
.dom(".d-editor-textarea-wrapper .popup-tip.good") .dom(".d-editor-textarea-wrapper .popup-tip.good")
.exists("the body is now good"); .exists("the body is now good");
@ -173,10 +166,12 @@ acceptance(
.dom(".d-editor-textarea-wrapper.disabled") .dom(".d-editor-textarea-wrapper.disabled")
.exists("textarea is disabled"); .exists("textarea is disabled");
await fillIn("#reply-title", "http://www.example.com/has-title.html"); await fillIn("#reply-title", "http://www.example.com/has-title.html");
assert.ok( assert
query(".d-editor-preview").innerHTML.trim().includes("onebox"), .dom(".d-editor-preview")
"it pastes the link into the body and previews it" .includesHtml(
); "onebox",
"pastes the link into the body and previews it"
);
assert assert
.dom(".d-editor-textarea-wrapper .popup-tip.good") .dom(".d-editor-textarea-wrapper .popup-tip.good")
.exists("the body is now good"); .exists("the body is now good");

View File

@ -61,10 +61,16 @@ acceptance("DStyles - category backgrounds", function (needs) {
test("CSS classes are generated", async function (assert) { test("CSS classes are generated", async function (assert) {
await visit("/"); await visit("/");
const css = assert
"body.category-foo { background-image: url(/uploads/default/original/1X/c5c84b16ebf745ab848d1498267c541facbf1ff0.png); }\n" + .dom("#d-styles")
"body.category-foo-baz { background-image: url(/uploads/default/original/1X/684c104edc18a7e9cef1fa31f41215f3eec5d92b.png); }"; .includesHtml(
assert.ok(document.querySelector("#d-styles").innerHTML.includes(css)); "body.category-foo { background-image: url(/uploads/default/original/1X/c5c84b16ebf745ab848d1498267c541facbf1ff0.png); }"
);
assert
.dom("#d-styles")
.includesHtml(
"body.category-foo-baz { background-image: url(/uploads/default/original/1X/684c104edc18a7e9cef1fa31f41215f3eec5d92b.png); }"
);
}); });
}); });
@ -87,14 +93,15 @@ acceptance("DStyles - category backgrounds (dark)", function (needs) {
test("CSS classes are generated", async function (assert) { test("CSS classes are generated", async function (assert) {
await visit("/"); await visit("/");
const css = const css = [
"body.category-foo { background-image: url(/uploads/default/original/1X/c5c84b16ebf745ab848d1498267c541facbf1ff0.png); }\n" + "body.category-foo { background-image: url(/uploads/default/original/1X/c5c84b16ebf745ab848d1498267c541facbf1ff0.png); }",
"body.category-foo-baz { background-image: url(/uploads/default/original/1X/684c104edc18a7e9cef1fa31f41215f3eec5d92b.png); }\n" + "body.category-foo-baz { background-image: url(/uploads/default/original/1X/684c104edc18a7e9cef1fa31f41215f3eec5d92b.png); }",
"@media (prefers-color-scheme: dark) {\n" + "@media (prefers-color-scheme: dark) {",
"body.category-bar { background-image: url(/uploads/default/original/1X/f9fdb0ad108f2aed178c40f351bbb2c7cb2571e3.png); }\n" + "body.category-bar { background-image: url(/uploads/default/original/1X/f9fdb0ad108f2aed178c40f351bbb2c7cb2571e3.png); }",
"body.category-foo-baz { background-image: url(/uploads/default/original/1X/89b1a2641e91604c32b21db496be11dba7a253e6.png); }\n" + "body.category-foo-baz { background-image: url(/uploads/default/original/1X/89b1a2641e91604c32b21db496be11dba7a253e6.png); }",
"}"; "}",
assert.ok(document.querySelector("#d-styles").innerHTML.includes(css)); ].join(" ");
assert.dom("#d-styles").includesHtml(css);
}); });
}); });
@ -119,11 +126,12 @@ acceptance(
test("CSS classes are generated", async function (assert) { test("CSS classes are generated", async function (assert) {
await visit("/"); await visit("/");
const css = const css = [
"body.category-foo { background-image: url(/uploads/default/original/1X/c5c84b16ebf745ab848d1498267c541facbf1ff0.png); }\n" + "body.category-foo { background-image: url(/uploads/default/original/1X/c5c84b16ebf745ab848d1498267c541facbf1ff0.png); }",
"body.category-bar { background-image: url(/uploads/default/original/1X/f9fdb0ad108f2aed178c40f351bbb2c7cb2571e3.png); }\n" + "body.category-bar { background-image: url(/uploads/default/original/1X/f9fdb0ad108f2aed178c40f351bbb2c7cb2571e3.png); }",
"body.category-foo-baz { background-image: url(/uploads/default/original/1X/89b1a2641e91604c32b21db496be11dba7a253e6.png); }"; "body.category-foo-baz { background-image: url(/uploads/default/original/1X/89b1a2641e91604c32b21db496be11dba7a253e6.png); }",
assert.ok(document.querySelector("#d-styles").innerHTML.includes(css)); ].join(" ");
assert.dom("#d-styles").includesHtml(css);
}); });
} }
); );
@ -148,23 +156,25 @@ acceptance("DStyles - category badges", function (needs) {
test("category CSS variables are generated", async function (assert) { test("category CSS variables are generated", async function (assert) {
await visit("/"); await visit("/");
const css = const css = [
":root {\n" + ":root {",
"--category-1-color: #ff0000;\n" + "--category-1-color: #ff0000;",
"--category-2-color: #333;\n" + "--category-2-color: #333;",
"--category-4-color: #2B81AF;\n" + "--category-4-color: #2B81AF;",
"}"; "}",
assert.ok(document.querySelector("style#d-styles").innerHTML.includes(css)); ].join(" ");
assert.dom("style#d-styles").includesHtml(css);
}); });
test("category badge CSS variables are generated", async function (assert) { test("category badge CSS variables are generated", async function (assert) {
await visit("/"); await visit("/");
const css = const css = [
'.badge-category[data-category-id="1"] { --category-badge-color: var(--category-1-color); --category-badge-text-color: #ffffff; }\n' + '.badge-category[data-category-id="1"] { --category-badge-color: var(--category-1-color); --category-badge-text-color: #ffffff; }',
'.badge-category[data-parent-category-id="1"] { --parent-category-badge-color: var(--category-1-color); }\n' + '.badge-category[data-parent-category-id="1"] { --parent-category-badge-color: var(--category-1-color); }',
'.badge-category[data-category-id="2"] { --category-badge-color: var(--category-2-color); --category-badge-text-color: #ffffff; }\n' + '.badge-category[data-category-id="2"] { --category-badge-color: var(--category-2-color); --category-badge-text-color: #ffffff; }',
'.badge-category[data-category-id="4"] { --category-badge-color: var(--category-4-color); --category-badge-text-color: #ffffff; }'; '.badge-category[data-category-id="4"] { --category-badge-color: var(--category-4-color); --category-badge-text-color: #ffffff; }',
assert.ok(document.querySelector("style#d-styles").innerHTML.includes(css)); ].join(" ");
assert.dom("style#d-styles").includesHtml(css);
}); });
}); });

View File

@ -3,7 +3,6 @@ import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
import { test } from "qunit"; import { test } from "qunit";
import { import {
acceptance, acceptance,
normalizeHtml,
query, query,
simulateKey, simulateKey,
simulateKeys, simulateKeys,
@ -18,12 +17,11 @@ acceptance("Emoji", function (needs) {
await simulateKeys(".d-editor-input", "a :blonde_wo\t"); await simulateKeys(".d-editor-input", "a :blonde_wo\t");
assert.strictEqual( assert
normalizeHtml(query(".d-editor-preview").innerHTML.trim()), .dom(".d-editor-preview")
normalizeHtml( .hasHtml(
`<p>a <img src="/images/emoji/twitter/blonde_woman.png?v=${v}" title=":blonde_woman:" class="emoji" alt=":blonde_woman:" loading="lazy" width="20" height="20" style="aspect-ratio: 20 / 20;"></p>` `<p>a <img src="/images/emoji/twitter/blonde_woman.png?v=${v}" title=":blonde_woman:" class="emoji" alt=":blonde_woman:" loading="lazy" width="20" height="20" style="aspect-ratio: 20 / 20;"></p>`
) );
);
}); });
test("emoji can be picked from the emoji-picker using the mouse", async function (assert) { test("emoji can be picked from the emoji-picker using the mouse", async function (assert) {
@ -37,12 +35,11 @@ acceptance("Emoji", function (needs) {
assert.dom(".emoji-picker.opened.has-filter").exists(); assert.dom(".emoji-picker.opened.has-filter").exists();
await click(".emoji-picker .results img:first-of-type"); await click(".emoji-picker .results img:first-of-type");
assert.strictEqual( assert
normalizeHtml(query(".d-editor-preview").innerHTML.trim()), .dom(".d-editor-preview")
normalizeHtml( .hasHtml(
`<p>an <img src="/images/emoji/twitter/arrow_backward.png?v=${v}" title=":arrow_backward:" class="emoji" alt=":arrow_backward:" loading="lazy" width="20" height="20" style="aspect-ratio: 20 / 20;"></p>` `<p>an <img src="/images/emoji/twitter/arrow_backward.png?v=${v}" title=":arrow_backward:" class="emoji" alt=":arrow_backward:" loading="lazy" width="20" height="20" style="aspect-ratio: 20 / 20;"></p>`
) );
);
}); });
test("skin toned emoji is cooked properly", async function (assert) { test("skin toned emoji is cooked properly", async function (assert) {
@ -51,12 +48,11 @@ acceptance("Emoji", function (needs) {
await fillIn(".d-editor-input", "a :blonde_woman:t5:"); await fillIn(".d-editor-input", "a :blonde_woman:t5:");
assert.strictEqual( assert
normalizeHtml(query(".d-editor-preview").innerHTML.trim()), .dom(".d-editor-preview")
normalizeHtml( .hasHtml(
`<p>a <img src="/images/emoji/twitter/blonde_woman/5.png?v=${v}" title=":blonde_woman:t5:" class="emoji" alt=":blonde_woman:t5:" loading="lazy" width="20" height="20" style="aspect-ratio: 20 / 20;"></p>` `<p>a <img src="/images/emoji/twitter/blonde_woman/5.png?v=${v}" title=":blonde_woman:t5:" class="emoji" alt=":blonde_woman:t5:" loading="lazy" width="20" height="20" style="aspect-ratio: 20 / 20;"></p>`
) );
);
}); });
needs.settings({ emoji_autocomplete_min_chars: 2 }); needs.settings({ emoji_autocomplete_min_chars: 2 });

View File

@ -1,6 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
let userFound = false; let userFound = false;
@ -26,23 +26,21 @@ acceptance("Forgot password", function (needs) {
await fillIn("#username-or-email", "someuser"); await fillIn("#username-or-email", "someuser");
await click(".forgot-password-reset"); await click(".forgot-password-reset");
assert.strictEqual( assert.dom(".alert-error").hasHtml(
query(".alert-error").innerHTML.trim(),
I18n.t("forgot_password.complete_username_not_found", { I18n.t("forgot_password.complete_username_not_found", {
username: "someuser", username: "someuser",
}), }),
"it should display an error for an invalid username" "displays an error for an invalid username"
); );
await fillIn("#username-or-email", "someuser@gmail.com"); await fillIn("#username-or-email", "someuser@gmail.com");
await click(".forgot-password-reset"); await click(".forgot-password-reset");
assert.strictEqual( assert.dom(".alert-error").hasHtml(
query(".alert-error").innerHTML.trim(),
I18n.t("forgot_password.complete_email_not_found", { I18n.t("forgot_password.complete_email_not_found", {
email: "someuser@gmail.com", email: "someuser@gmail.com",
}), }),
"it should display an error for an invalid email" "displays an error for an invalid email"
); );
await fillIn("#username-or-email", "someuser"); await fillIn("#username-or-email", "someuser");
@ -55,12 +53,11 @@ acceptance("Forgot password", function (needs) {
.dom(".alert-error") .dom(".alert-error")
.doesNotExist("it should remove the flash error when succeeding"); .doesNotExist("it should remove the flash error when succeeding");
assert.strictEqual( assert.dom(".d-modal__body").hasHtml(
query(".d-modal__body").innerHTML.trim(),
I18n.t("forgot_password.complete_username_found", { I18n.t("forgot_password.complete_username_found", {
username: "someuser", username: "someuser",
}), }),
"it should display a success message for a valid username" "displays a success message for a valid username"
); );
await visit("/"); await visit("/");
@ -69,12 +66,11 @@ acceptance("Forgot password", function (needs) {
await fillIn("#username-or-email", "someuser@gmail.com"); await fillIn("#username-or-email", "someuser@gmail.com");
await click(".forgot-password-reset"); await click(".forgot-password-reset");
assert.strictEqual( assert.dom(".d-modal__body").hasHtml(
query(".d-modal__body").innerHTML.trim(),
I18n.t("forgot_password.complete_email_found", { I18n.t("forgot_password.complete_email_found", {
email: "someuser@gmail.com", email: "someuser@gmail.com",
}), }),
"it should display a success message for a valid email" "displays a success message for a valid email"
); );
}); });
}); });
@ -100,12 +96,11 @@ acceptance(
await fillIn("#username-or-email", "someuser"); await fillIn("#username-or-email", "someuser");
await click(".forgot-password-reset"); await click(".forgot-password-reset");
assert.strictEqual( assert.dom(".d-modal__body").hasHtml(
query(".d-modal__body").innerHTML.trim(),
I18n.t("forgot_password.complete_username", { I18n.t("forgot_password.complete_username", {
username: "someuser", username: "someuser",
}), }),
"it should display a success message" "displays a success message"
); );
}); });
} }

View File

@ -22,12 +22,13 @@ acceptance("Hashtag CSS Generator", function (needs) {
test("classes are generated", async function (assert) { test("classes are generated", async function (assert) {
await visit("/"); await visit("/");
const cssTag = document.querySelector("style#hashtag-css-generator"); const cssTag = document.querySelector("style#hashtag-css-generator");
assert.equal( assert
cssTag.innerHTML, .dom(cssTag)
".hashtag-category-badge { background-color: var(--primary-medium); }\n" + .hasHtml(
".hashtag-color--category-1 { background-color: #ff0000; }\n" + ".hashtag-category-badge { background-color: var(--primary-medium); }\n" +
".hashtag-color--category-2 { background-color: #333; }\n" + ".hashtag-color--category-1 { background-color: #ff0000; }\n" +
".hashtag-color--category-4 { background: linear-gradient(-90deg, #2B81AF 50%, #ff0000 50%); }" ".hashtag-color--category-2 { background-color: #333; }\n" +
); ".hashtag-color--category-4 { background: linear-gradient(-90deg, #2B81AF 50%, #ff0000 50%); }"
);
}); });
}); });

View File

@ -1,6 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
acceptance("Login with email - hide email address taken", function (needs) { acceptance("Login with email - hide email address taken", function (needs) {
@ -21,12 +21,11 @@ acceptance("Login with email - hide email address taken", function (needs) {
await fillIn("#login-account-name", "someuser@example.com"); await fillIn("#login-account-name", "someuser@example.com");
await click("#email-login-link"); await click("#email-login-link");
assert.strictEqual( assert.dom(".alert-success").hasHtml(
query(".alert-success").innerHTML.trim(),
I18n.t("email_login.complete_email_found", { I18n.t("email_login.complete_email_found", {
email: "someuser@example.com", email: "someuser@example.com",
}), }),
"it should display the success message for any email address" "displays the success message for any email address"
); );
}); });
}); });

View File

@ -2,7 +2,7 @@ import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import sinon from "sinon"; import sinon from "sinon";
import DiscourseURL from "discourse/lib/url"; import DiscourseURL from "discourse/lib/url";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
const TOKEN = "sometoken"; const TOKEN = "sometoken";
@ -49,23 +49,21 @@ acceptance("Login with email", function (needs) {
await fillIn("#login-account-name", "someuser"); await fillIn("#login-account-name", "someuser");
await click("#email-login-link"); await click("#email-login-link");
assert.strictEqual( assert.dom("#modal-alert").hasHtml(
query("#modal-alert").innerHTML.trim(),
I18n.t("email_login.complete_username_not_found", { I18n.t("email_login.complete_username_not_found", {
username: "someuser", username: "someuser",
}), }),
"it should display an error for an invalid username" "displays an error for an invalid username"
); );
await fillIn("#login-account-name", "someuser@gmail.com"); await fillIn("#login-account-name", "someuser@gmail.com");
await click("#email-login-link"); await click("#email-login-link");
assert.strictEqual( assert.dom("#modal-alert").hasHtml(
query("#modal-alert").innerHTML.trim(),
I18n.t("email_login.complete_email_not_found", { I18n.t("email_login.complete_email_not_found", {
email: "someuser@gmail.com", email: "someuser@gmail.com",
}), }),
"it should display an error for an invalid email" "displays an error for an invalid email"
); );
await fillIn("#login-account-name", "someuser"); await fillIn("#login-account-name", "someuser");
@ -74,23 +72,23 @@ acceptance("Login with email", function (needs) {
await click("#email-login-link"); await click("#email-login-link");
assert.strictEqual( assert
query(".alert-success").innerHTML.trim(), .dom(".alert-success")
I18n.t("email_login.complete_username_found", { username: "someuser" }), .hasHtml(
"it should display a success message for a valid username" I18n.t("email_login.complete_username_found", { username: "someuser" }),
); "displays a success message for a valid username"
);
await visit("/"); await visit("/");
await click("header .login-button"); await click("header .login-button");
await fillIn("#login-account-name", "someuser@gmail.com"); await fillIn("#login-account-name", "someuser@gmail.com");
await click("#email-login-link"); await click("#email-login-link");
assert.strictEqual( assert.dom(".alert-success").hasHtml(
query(".alert-success").innerHTML.trim(),
I18n.t("email_login.complete_email_found", { I18n.t("email_login.complete_email_found", {
email: "someuser@gmail.com", email: "someuser@gmail.com",
}), }),
"it should display a success message for a valid email" "displays a success message for a valid email"
); );
userFound = false; userFound = false;

View File

@ -4,7 +4,7 @@ import sinon from "sinon";
import PreloadStore from "discourse/lib/preload-store"; import PreloadStore from "discourse/lib/preload-store";
import DiscourseURL from "discourse/lib/url"; import DiscourseURL from "discourse/lib/url";
import { parsePostData } from "discourse/tests/helpers/create-pretender"; import { parsePostData } from "discourse/tests/helpers/create-pretender";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
acceptance("Password Reset", function (needs) { acceptance("Password Reset", function (needs) {
@ -72,24 +72,22 @@ acceptance("Password Reset", function (needs) {
await fillIn(".password-reset input", "123"); await fillIn(".password-reset input", "123");
assert.dom(".password-reset .tip.bad").exists("input is not valid"); assert.dom(".password-reset .tip.bad").exists("input is not valid");
assert.ok( assert.dom(".password-reset .tip.bad").includesHtml(
query(".password-reset .tip.bad").innerHTML.includes( I18n.t("user.password.too_short", {
I18n.t("user.password.too_short", { count: this.siteSettings.min_password_length,
count: this.siteSettings.min_password_length, }),
})
),
"password too short" "password too short"
); );
await fillIn(".password-reset input", "jonesyAlienSlayer"); await fillIn(".password-reset input", "jonesyAlienSlayer");
await click(".password-reset form button[type='submit']"); await click(".password-reset form button[type='submit']");
assert.dom(".password-reset .tip.bad").exists("input is not valid"); assert.dom(".password-reset .tip.bad").exists("input is not valid");
assert.ok( assert
query(".password-reset .tip.bad").innerHTML.includes( .dom(".password-reset .tip.bad")
"Password is the name of your cat" .includesHtml(
), "Password is the name of your cat",
"server validation error message shows" "server validation error message shows"
); );
assert assert
.dom("#new-account-password[type='password']") .dom("#new-account-password[type='password']")
@ -121,10 +119,9 @@ acceptance("Password Reset", function (needs) {
assert.dom(".alert-error").exists("shows 2FA error"); assert.dom(".alert-error").exists("shows 2FA error");
assert.ok( assert
query(".alert-error").innerHTML.includes("invalid token"), .dom(".alert-error")
"shows server validation error message" .includesHtml("invalid token", "shows server validation error message");
);
await fillIn("input#second-factor", "123123"); await fillIn("input#second-factor", "123123");
await click(".password-reset form button"); await click(".password-reset form button");

View File

@ -1,6 +1,6 @@
import { visit } from "@ember/test-helpers"; import { visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Reports", function (needs) { acceptance("Reports", function (needs) {
needs.user(); needs.user();
@ -10,21 +10,15 @@ acceptance("Reports", function (needs) {
assert.dom(".admin-reports-list__report").exists({ count: 1 }); assert.dom(".admin-reports-list__report").exists({ count: 1 });
const report = query(".admin-reports-list__report:first-child"); assert
.dom(".admin-reports-list__report .admin-reports-list__report-title")
.hasHtml("My report");
assert.strictEqual( assert
report .dom(
.querySelector(".admin-reports-list__report-title") ".admin-reports-list__report .admin-reports-list__report-description"
.innerHTML.trim(), )
"My report" .hasHtml("List of my activities");
);
assert.strictEqual(
report
.querySelector(".admin-reports-list__report-description")
.innerHTML.trim(),
"List of my activities"
);
}); });
test("Visit report page", async function (assert) { test("Visit report page", async function (assert) {

View File

@ -62,24 +62,24 @@ acceptance("Review", function (needs) {
await reviewableActionDropdown.selectRowByValue("reject_user_delete"); await reviewableActionDropdown.selectRowByValue("reject_user_delete");
assert.dom(".reject-reason-reviewable-modal").exists(); assert.dom(".reject-reason-reviewable-modal").exists();
assert.ok( assert
query( .dom(".reject-reason-reviewable-modal .d-modal__title")
".reject-reason-reviewable-modal .d-modal__title" .includesHtml(
).innerHTML.includes(I18n.t("review.reject_reason.title")), I18n.t("review.reject_reason.title"),
"it opens reject reason modal when user is rejected" "opens reject reason modal when user is rejected"
); );
await click(".d-modal__footer .cancel"); await click(".d-modal__footer .cancel");
await reviewableActionDropdown.expand(); await reviewableActionDropdown.expand();
await reviewableActionDropdown.selectRowByValue("reject_user_block"); await reviewableActionDropdown.selectRowByValue("reject_user_block");
assert.dom(".reject-reason-reviewable-modal").exists(); assert.dom(".reject-reason-reviewable-modal").exists();
assert.ok( assert
query( .dom(".reject-reason-reviewable-modal .d-modal__title")
".reject-reason-reviewable-modal .d-modal__title" .includesHtml(
).innerHTML.includes(I18n.t("review.reject_reason.title")), I18n.t("review.reject_reason.title"),
"it opens reject reason modal when user is rejected and blocked" "opens reject reason modal when user is rejected and blocked"
); );
}); });
test("Settings", async function (assert) { test("Settings", async function (assert) {
@ -104,10 +104,9 @@ acceptance("Review", function (needs) {
.dom(".reviewable-flagged-post .post-contents .username a[href]") .dom(".reviewable-flagged-post .post-contents .username a[href]")
.exists("it has a link to the user"); .exists("it has a link to the user");
assert.strictEqual( assert
query(".reviewable-flagged-post .post-body").innerHTML.trim(), .dom(".reviewable-flagged-post .post-body")
"<b>cooked content</b>" .hasHtml("<b>cooked content</b>");
);
assert assert
.dom(".reviewable-flagged-post .reviewable-score") .dom(".reviewable-flagged-post .reviewable-score")

View File

@ -1,6 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers"; import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
acceptance("Topic move posts", function (needs) { acceptance("Topic move posts", function (needs) {
@ -28,33 +28,30 @@ acceptance("Topic move posts", function (needs) {
await click(".selected-posts .move-to-topic"); await click(".selected-posts .move-to-topic");
assert.ok( assert
query(".choose-topic-modal .d-modal__title").innerHTML.includes( .dom(".choose-topic-modal .d-modal__title")
I18n.t("topic.move_to.title") .includesHtml(I18n.t("topic.move_to.title"), "opens move to modal");
),
"it opens move to modal"
);
assert.ok( assert
query(".choose-topic-modal .radios").innerHTML.includes( .dom(".choose-topic-modal .radios")
I18n.t("topic.split_topic.radio_label") .includesHtml(
), I18n.t("topic.split_topic.radio_label"),
"it shows an option to move to new topic" "shows an option to move to new topic"
); );
assert.ok( assert
query(".choose-topic-modal .radios").innerHTML.includes( .dom(".choose-topic-modal .radios")
I18n.t("topic.merge_topic.radio_label") .includesHtml(
), I18n.t("topic.merge_topic.radio_label"),
"it shows an option to move to existing topic" "shows an option to move to existing topic"
); );
assert.ok( assert
query(".choose-topic-modal .radios").innerHTML.includes( .dom(".choose-topic-modal .radios")
I18n.t("topic.move_to_new_message.radio_label") .includesHtml(
), I18n.t("topic.move_to_new_message.radio_label"),
"it shows an option to move to new message" "shows an option to move to new message"
); );
}); });
test("display error when new topic has invalid title", async function (assert) { test("display error when new topic has invalid title", async function (assert) {
@ -75,33 +72,30 @@ acceptance("Topic move posts", function (needs) {
await click(".select-all"); await click(".select-all");
await click(".selected-posts .move-to-topic"); await click(".selected-posts .move-to-topic");
assert.ok( assert
query(".choose-topic-modal .d-modal__title").innerHTML.includes( .dom(".choose-topic-modal .d-modal__title")
I18n.t("topic.move_to.title") .includesHtml(I18n.t("topic.move_to.title"), "opens move to modal");
),
"it opens move to modal"
);
assert.notOk( assert
query(".choose-topic-modal .radios").innerHTML.includes( .dom(".choose-topic-modal .radios")
I18n.t("topic.split_topic.radio_label") .doesNotIncludeHtml(
), I18n.t("topic.split_topic.radio_label"),
"it does not show an option to move to new topic" "does not show an option to move to new topic"
); );
assert.ok( assert
query(".choose-topic-modal .radios").innerHTML.includes( .dom(".choose-topic-modal .radios")
I18n.t("topic.merge_topic.radio_label") .includesHtml(
), I18n.t("topic.merge_topic.radio_label"),
"it shows an option to move to existing topic" "shows an option to move to existing topic"
); );
assert.notOk( assert
query(".choose-topic-modal .radios").innerHTML.includes( .dom(".choose-topic-modal .radios")
I18n.t("topic.move_to_new_message.radio_label") .doesNotIncludeHtml(
), I18n.t("topic.move_to_new_message.radio_label"),
"it does not show an option to move to new message" "does not show an option to move to new message"
); );
}); });
test("moving posts to existing topic", async function (assert) { test("moving posts to existing topic", async function (assert) {
@ -112,12 +106,12 @@ acceptance("Topic move posts", function (needs) {
await click(".selected-posts .move-to-topic"); await click(".selected-posts .move-to-topic");
assert.ok( assert
query(".choose-topic-modal .radios").innerHTML.includes( .dom(".choose-topic-modal .radios")
I18n.t("topic.merge_topic.radio_label") .includesHtml(
), I18n.t("topic.merge_topic.radio_label"),
"it shows an option to move to an existing topic" "shows an option to move to an existing topic"
); );
await click(".choose-topic-modal .radios #move-to-existing-topic"); await click(".choose-topic-modal .radios #move-to-existing-topic");
@ -131,12 +125,12 @@ acceptance("Topic move posts", function (needs) {
await click(".choose-topic-list .existing-topic:first-child input"); await click(".choose-topic-list .existing-topic:first-child input");
assert.ok( assert
query(".choose-topic-modal .checkbox-label").innerHTML.includes( .dom(".choose-topic-modal .checkbox-label")
I18n.t("topic.merge_topic.chronological_order") .includesHtml(
), I18n.t("topic.merge_topic.chronological_order"),
"it shows a checkbox to merge posts in chronological order" "shows a checkbox to merge posts in chronological order"
); );
}); });
test("moving posts from personal message", async function (assert) { test("moving posts from personal message", async function (assert) {
@ -154,26 +148,23 @@ acceptance("Topic move posts", function (needs) {
await click(".selected-posts .move-to-topic"); await click(".selected-posts .move-to-topic");
assert.ok( assert
query(".choose-topic-modal .d-modal__title").innerHTML.includes( .dom(".choose-topic-modal .d-modal__title")
I18n.t("topic.move_to.title") .includesHtml(I18n.t("topic.move_to.title"), "opens move to modal");
),
"it opens move to modal"
);
assert.ok( assert
query(".choose-topic-modal .radios").innerHTML.includes( .dom(".choose-topic-modal .radios")
I18n.t("topic.move_to_new_message.radio_label") .includesHtml(
), I18n.t("topic.move_to_new_message.radio_label"),
"it shows an option to move to new message" "shows an option to move to new message"
); );
assert.ok( assert
query(".choose-topic-modal .radios").innerHTML.includes( .dom(".choose-topic-modal .radios")
I18n.t("topic.move_to_existing_message.radio_label") .includesHtml(
), I18n.t("topic.move_to_existing_message.radio_label"),
"it shows an option to move to existing message" "shows an option to move to existing message"
); );
}); });
test("group moderator moving posts", async function (assert) { test("group moderator moving posts", async function (assert) {
@ -191,12 +182,9 @@ acceptance("Topic move posts", function (needs) {
await click(".selected-posts .move-to-topic"); await click(".selected-posts .move-to-topic");
assert.ok( assert
query(".choose-topic-modal .d-modal__title").innerHTML.includes( .dom(".choose-topic-modal .d-modal__title")
I18n.t("topic.move_to.title") .includesHtml(I18n.t("topic.move_to.title"), "opens move to modal");
),
"it opens move to modal"
);
}); });
test("moving posts from personal message to existing message", async function (assert) { test("moving posts from personal message to existing message", async function (assert) {
@ -207,12 +195,12 @@ acceptance("Topic move posts", function (needs) {
await click(".selected-posts .move-to-topic"); await click(".selected-posts .move-to-topic");
assert.ok( assert
query(".choose-topic-modal .radios").innerHTML.includes( .dom(".choose-topic-modal .radios")
I18n.t("topic.move_to_existing_message.radio_label") .includesHtml(
), I18n.t("topic.move_to_existing_message.radio_label"),
"it shows an option to move to an existing message" "shows an option to move to an existing message"
); );
await click(".choose-topic-modal .radios #move-to-existing-message"); await click(".choose-topic-modal .radios #move-to-existing-message");
@ -226,11 +214,11 @@ acceptance("Topic move posts", function (needs) {
await click(".choose-topic-modal .existing-message:first-of-type input"); await click(".choose-topic-modal .existing-message:first-of-type input");
assert.ok( assert
query(".choose-topic-modal .checkbox-label").innerHTML.includes( .dom(".choose-topic-modal .checkbox-label")
I18n.t("topic.merge_topic.chronological_order") .includesHtml(
), I18n.t("topic.merge_topic.chronological_order"),
"it shows a checkbox to merge posts in chronological order" "shows a checkbox to merge posts in chronological order"
); );
}); });
}); });

View File

@ -168,10 +168,9 @@ acceptance("Topic", function (needs) {
await click("#topic-title .submit-edit"); await click("#topic-title .submit-edit");
assert.ok( assert
query(".fancy-title").innerHTML.trim().includes("bike.png"), .dom(".fancy-title")
"it displays the new title with emojis" .includesHtml("bike.png", "displays the new title with emojis");
);
}); });
test("Updating the topic title with unicode emojis", async function (assert) { test("Updating the topic title with unicode emojis", async function (assert) {
@ -182,10 +181,9 @@ acceptance("Topic", function (needs) {
await click("#topic-title .submit-edit"); await click("#topic-title .submit-edit");
assert.ok( assert
query(".fancy-title").innerHTML.trim().includes("man_farmer.png"), .dom(".fancy-title")
"it displays the new title with emojis" .includesHtml("man_farmer.png", "displays the new title with emojis");
);
}); });
test("Updating the topic title with unicode emojis without whitespace", async function (assert) { test("Updating the topic title with unicode emojis without whitespace", async function (assert) {
@ -197,12 +195,12 @@ acceptance("Topic", function (needs) {
await click("#topic-title .submit-edit"); await click("#topic-title .submit-edit");
assert.ok( assert
query(".fancy-title") .dom(".fancy-title")
.innerHTML.trim() .includesHtml(
.includes("slightly_smiling_face.png"), "slightly_smiling_face.png",
"it displays the new title with emojis" "displays the new title with emojis"
); );
}); });
test("Suggested topics", async function (assert) { test("Suggested topics", async function (assert) {
@ -346,21 +344,21 @@ acceptance("Topic featured links", function (needs) {
await click(".topic-admin-multi-select .btn"); await click(".topic-admin-multi-select .btn");
await click("#post_3 .select-below"); await click("#post_3 .select-below");
assert.ok( assert
query(".selected-posts").innerHTML.includes( .dom(".selected-posts")
I18n.t("topic.multi_select.description", { count: 18 }) .includesHtml(
), I18n.t("topic.multi_select.description", { count: 18 }),
"it should select the right number of posts" "selects the right number of posts"
); );
await click("#post_2 .select-below"); await click("#post_2 .select-below");
assert.ok( assert
query(".selected-posts").innerHTML.includes( .dom(".selected-posts")
I18n.t("topic.multi_select.description", { count: 19 }) .includesHtml(
), I18n.t("topic.multi_select.description", { count: 19 }),
"it should select the right number of posts" "selects the right number of posts"
); );
}); });
test("View Hidden Replies", async function (assert) { test("View Hidden Replies", async function (assert) {

View File

@ -1,11 +1,7 @@
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { IMAGE_VERSION } from "pretty-text/emoji/version"; import { IMAGE_VERSION } from "pretty-text/emoji/version";
import { test } from "qunit"; import { test } from "qunit";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
normalizeHtml,
query,
} from "discourse/tests/helpers/qunit-helpers";
acceptance("User Drafts", function (needs) { acceptance("User Drafts", function (needs) {
needs.user(); needs.user();
@ -47,15 +43,12 @@ acceptance("User Drafts", function (needs) {
query(".user-stream-item:nth-child(3) .category").textContent, query(".user-stream-item:nth-child(3) .category").textContent,
"meta" "meta"
); );
assert.strictEqual( assert
normalizeHtml( .dom(".user-stream-item:nth-child(3) .excerpt")
query(".user-stream-item:nth-child(3) .excerpt").innerHTML.trim() .hasHtml(
), `here goes a reply to a PM <img src="/images/emoji/twitter/slight_smile.png?v=${IMAGE_VERSION}" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20" style="aspect-ratio: 20 / 20;">`,
normalizeHtml( "shows the excerpt"
`here goes a reply to a PM <img src="/images/emoji/twitter/slight_smile.png?v=${IMAGE_VERSION}" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20" style="aspect-ratio: 20 / 20;">` );
),
"shows the excerpt"
);
assert assert
.dom(".user-stream-item:nth-child(2) a.avatar-link") .dom(".user-stream-item:nth-child(2) a.avatar-link")

View File

@ -121,22 +121,19 @@ acceptance("User Preferences - Account", function (needs) {
.dom(".pref-associated-accounts") .dom(".pref-associated-accounts")
.exists("it has the connected accounts section"); .exists("it has the connected accounts section");
assert.ok( assert
query( .dom(
".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"), )
"it lists facebook" .includesHtml("Facebook", "lists facebook");
);
await click( await click(
".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"
); );
assert.ok( assert
query( .dom(".pref-associated-accounts table tr:nth-of-type(1) td:last-of-type")
".pref-associated-accounts table tr:nth-of-type(1) td:last-of-type" .includesHtml("Connect");
).innerHTML.includes("Connect")
);
}); });
test("avatars are selectable for staff user when `selectable_avatars_mode` site setting is set to `staff`", async function (assert) { test("avatars are selectable for staff user when `selectable_avatars_mode` site setting is set to `staff`", async function (assert) {

View File

@ -8,7 +8,6 @@ import {
import { test } from "qunit"; import { test } from "qunit";
import { import {
acceptance, acceptance,
query,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -74,10 +73,12 @@ acceptance("User Preferences - Second Factor", function (needs) {
.exists("displays second factor key"); .exists("displays second factor key");
await click(".add-totp"); await click(".add-totp");
assert.ok( assert
query(".alert-error").innerHTML.includes("provide a name and the code"), .dom(".alert-error")
"shows name/token missing error message" .includesHtml(
); "provide a name and the code",
"shows name/token missing error message"
);
}); });
test("second factor security keys", async function (assert) { test("second factor security keys", async function (assert) {
@ -93,10 +94,9 @@ acceptance("User Preferences - Second Factor", function (needs) {
if (typeof PublicKeyCredential !== "undefined") { if (typeof PublicKeyCredential !== "undefined") {
await click(".add-security-key"); await click(".add-security-key");
assert.ok( assert
query(".alert-error").innerHTML.includes("provide a name"), .dom(".alert-error")
"shows name missing error message" .includesHtml("provide a name", "shows name missing error message");
);
} }
}); });

View File

@ -3,7 +3,6 @@ import { module, test } from "qunit";
import ComposerEditor from "discourse/components/composer-editor"; import ComposerEditor from "discourse/components/composer-editor";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import pretender, { response } from "discourse/tests/helpers/create-pretender"; import pretender, { response } from "discourse/tests/helpers/create-pretender";
import { query } from "discourse/tests/helpers/qunit-helpers";
module("Integration | Component | ComposerEditor", function (hooks) { module("Integration | Component | ComposerEditor", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -52,9 +51,6 @@ module("Integration | Component | ComposerEditor", function (hooks) {
</template>); </template>);
await fillIn(".d-editor-input", `"><svg onload="prompt(/xss/)"></svg>`); await fillIn(".d-editor-input", `"><svg onload="prompt(/xss/)"></svg>`);
assert.strictEqual( assert.dom(".d-editor-preview").hasHtml('<p>"&gt;<svg></svg></p>');
query(".d-editor-preview").innerHTML.trim(),
'<p>"&gt;<svg></svg></p>'
);
}); });
}); });

View File

@ -4,7 +4,6 @@ import { resetCache } from "pretty-text/upload-short-url";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import pretender, { response } from "discourse/tests/helpers/create-pretender"; import pretender, { response } from "discourse/tests/helpers/create-pretender";
import { query } from "discourse/tests/helpers/qunit-helpers";
module("Integration | Component | cook-text", function (hooks) { module("Integration | Component | cook-text", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -16,8 +15,7 @@ module("Integration | Component | cook-text", function (hooks) {
test("renders markdown", async function (assert) { test("renders markdown", async function (assert) {
await render(hbs`<CookText @rawText="_foo_" class="post-body" />`); await render(hbs`<CookText @rawText="_foo_" class="post-body" />`);
const html = query(".post-body").innerHTML.trim(); assert.dom(".post-body").hasHtml("<p><em>foo</em></p>");
assert.strictEqual(html, "<p><em>foo</em></p>");
}); });
test("resolves short URLs", async function (assert) { test("resolves short URLs", async function (assert) {
@ -35,10 +33,8 @@ module("Integration | Component | cook-text", function (hooks) {
hbs`<CookText @rawText="![an image](upload://a.png)" class="post-body" />` hbs`<CookText @rawText="![an image](upload://a.png)" class="post-body" />`
); );
const html = query(".post-body").innerHTML.trim(); assert
assert.strictEqual( .dom(".post-body")
html, .hasHtml('<p><img src="/images/avatar.png" alt="an image"></p>');
'<p><img src="/images/avatar.png" alt="an image"></p>'
);
}); });
}); });

View File

@ -30,10 +30,9 @@ module("Integration | Component | d-editor", function (hooks) {
await fillIn(".d-editor-input", "hello **world**"); await fillIn(".d-editor-input", "hello **world**");
assert.strictEqual(this.value, "hello **world**"); assert.strictEqual(this.value, "hello **world**");
assert.strictEqual( assert
query(".d-editor-preview").innerHTML.trim(), .dom(".d-editor-preview")
"<p>hello <strong>world</strong></p>" .hasHtml("<p>hello <strong>world</strong></p>");
);
}); });
test("links in preview are not tabbable", async function (assert) { test("links in preview are not tabbable", async function (assert) {
@ -41,10 +40,11 @@ module("Integration | Component | d-editor", function (hooks) {
await fillIn(".d-editor-input", "[discourse](https://www.discourse.org)"); await fillIn(".d-editor-input", "[discourse](https://www.discourse.org)");
assert.strictEqual( assert
query(".d-editor-preview").innerHTML.trim(), .dom(".d-editor-preview")
'<p><a href="https://www.discourse.org" tabindex="-1">discourse</a></p>' .hasHtml(
); '<p><a href="https://www.discourse.org" tabindex="-1">discourse</a></p>'
);
}); });
test("updating the value refreshes the preview", async function (assert) { test("updating the value refreshes the preview", async function (assert) {
@ -52,18 +52,12 @@ module("Integration | Component | d-editor", function (hooks) {
await render(hbs`<DEditor @value={{this.value}} />`); await render(hbs`<DEditor @value={{this.value}} />`);
assert.strictEqual( assert.dom(".d-editor-preview").hasHtml("<p>evil trout</p>");
query(".d-editor-preview").innerHTML.trim(),
"<p>evil trout</p>"
);
this.set("value", "zogstrip"); this.set("value", "zogstrip");
await settled(); await settled();
assert.strictEqual( assert.dom(".d-editor-preview").hasHtml("<p>zogstrip</p>");
query(".d-editor-preview").innerHTML.trim(),
"<p>zogstrip</p>"
);
}); });
function jumpEnd(textarea) { function jumpEnd(textarea) {

View File

@ -192,9 +192,9 @@ module("Integration | Component | Widget | widget-dropdown", function (hooks) {
this.setProperties(DEFAULT_CONTENT); this.setProperties(DEFAULT_CONTENT);
await render(TEMPLATE); await render(TEMPLATE);
await toggle(); await toggle();
assert.strictEqual(rowById(4).innerHTML.trim(), "<span><b>baz</b></span>");
assert.dom(rowById(4)).hasHtml("<span><b>baz</b></span>");
}); });
test("separator", async function (assert) { test("separator", async function (assert) {

View File

@ -2,7 +2,6 @@ import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
module("Integration | Helper | d-icon", function (hooks) { module("Integration | Helper | d-icon", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -10,20 +9,20 @@ module("Integration | Helper | d-icon", function (hooks) {
test("default", async function (assert) { test("default", async function (assert) {
await render(hbs`<div class="test">{{d-icon "bars"}}</div>`); await render(hbs`<div class="test">{{d-icon "bars"}}</div>`);
const html = query(".test").innerHTML.trim(); assert
assert.strictEqual( .dom(".test")
html, .hasHtml(
'<svg class="fa d-icon d-icon-bars svg-icon svg-string" xmlns="http://www.w3.org/2000/svg"><use href="#bars"></use></svg>' '<svg class="fa d-icon d-icon-bars svg-icon svg-string" xmlns="http://www.w3.org/2000/svg"><use href="#bars"></use></svg>'
); );
}); });
test("with replacement", async function (assert) { test("with replacement", async function (assert) {
await render(hbs`<div class="test">{{d-icon "d-watching"}}</div>`); await render(hbs`<div class="test">{{d-icon "d-watching"}}</div>`);
const html = query(".test").innerHTML.trim(); assert
assert.strictEqual( .dom(".test")
html, .hasHtml(
'<svg class="fa d-icon d-icon-d-watching svg-icon svg-string" xmlns="http://www.w3.org/2000/svg"><use href="#discourse-bell-exclamation"></use></svg>' '<svg class="fa d-icon d-icon-d-watching svg-icon svg-string" xmlns="http://www.w3.org/2000/svg"><use href="#discourse-bell-exclamation"></use></svg>'
); );
}); });
}); });

View File

@ -18,8 +18,7 @@ function generateClickEventOn(selector) {
function badgeClickCount(assert, id, expected) { function badgeClickCount(assert, id, expected) {
track(generateClickEventOn(`#${id}`)); track(generateClickEventOn(`#${id}`));
const badge = fixture(`#${id}`).querySelector("span.badge"); assert.dom("span.badge", fixture(`#${id}`)).hasHtml(String(expected));
assert.strictEqual(parseInt(badge.innerHTML, 10), expected);
} }
function testOpenInANewTab(description, clickEventModifier) { function testOpenInANewTab(description, clickEventModifier) {

View File

@ -250,16 +250,16 @@ module("Unit | Utility | formatter", function (hooks) {
assert.strictEqual(elem.dataset.format, "medium-with-ago"); assert.strictEqual(elem.dataset.format, "medium-with-ago");
assert.strictEqual(elem.dataset.time, d.getTime().toString()); assert.strictEqual(elem.dataset.time, d.getTime().toString());
assert.dom(elem).hasAttribute("title", longDate(d)); assert.dom(elem).hasAttribute("title", longDate(d));
assert.strictEqual(elem.innerHTML, "1 day ago"); assert.dom(elem).hasHtml("1 day ago");
elem = domFromString(autoUpdatingRelativeAge(d, { format: "medium" }))[0]; elem = domFromString(autoUpdatingRelativeAge(d, { format: "medium" }))[0];
assert.strictEqual(elem.dataset.format, "medium"); assert.strictEqual(elem.dataset.format, "medium");
assert.strictEqual(elem.dataset.time, d.getTime().toString()); assert.strictEqual(elem.dataset.time, d.getTime().toString());
assert.dom(elem).doesNotHaveAttribute("title"); assert.dom(elem).doesNotHaveAttribute("title");
assert.strictEqual(elem.innerHTML, "1 day"); assert.dom(elem).hasHtml("1 day");
elem = domFromString(autoUpdatingRelativeAge(d, { prefix: "test" }))[0]; elem = domFromString(autoUpdatingRelativeAge(d, { prefix: "test" }))[0];
assert.strictEqual(elem.innerHTML, "test 1d"); assert.dom(elem).hasHtml("test 1d");
}); });
test("updateRelativeAge", function (assert) { test("updateRelativeAge", function (assert) {
@ -269,7 +269,7 @@ module("Unit | Utility | formatter", function (hooks) {
updateRelativeAge(elem); updateRelativeAge(elem);
assert.strictEqual(elem.innerHTML, "2m"); assert.dom(elem).hasHtml("2m");
d = new Date(); d = new Date();
elem = domFromString( elem = domFromString(
@ -279,7 +279,7 @@ module("Unit | Utility | formatter", function (hooks) {
updateRelativeAge(elem); updateRelativeAge(elem);
assert.strictEqual(elem.innerHTML, "2 mins ago"); assert.dom(elem).hasHtml("2 mins ago");
}); });
test("number", function (assert) { test("number", function (assert) {

View File

@ -44,9 +44,6 @@ module("Unit | Utility | link-mentions", function (hooks) {
root.querySelector("a[data-mentionable-user-count]").innerText, root.querySelector("a[data-mentionable-user-count]").innerText,
"@mentionable_group" "@mentionable_group"
); );
assert.strictEqual( assert.dom("span.mention", root).hasHtml("@invalid");
root.querySelector("span.mention").innerHTML,
"@invalid"
);
}); });
}); });

View File

@ -65,13 +65,13 @@ acceptance("Chat | Hashtag CSS Generator", function (needs) {
test("hashtag CSS classes are generated", async function (assert) { test("hashtag CSS classes are generated", async function (assert) {
await visit("/"); await visit("/");
const cssTag = document.querySelector("style#hashtag-css-generator"); assert
assert.equal( .dom("style#hashtag-css-generator", document.head)
cssTag.innerHTML, .hasHtml(
".hashtag-category-badge { background-color: var(--primary-medium); }\n" + ".hashtag-category-badge { background-color: var(--primary-medium); }\n" +
".hashtag-color--category-1 { background-color: #ff0000; }\n" + ".hashtag-color--category-1 { background-color: #ff0000; }\n" +
".hashtag-color--category-2 { background-color: #333; }\n" + ".hashtag-color--category-2 { background-color: #333; }\n" +
".hashtag-color--category-4 { background: linear-gradient(-90deg, #2B81AF 50%, #ff0000 50%); }" ".hashtag-color--category-4 { background: linear-gradient(-90deg, #2B81AF 50%, #ff0000 50%); }"
); );
}); });
}); });

View File

@ -53,11 +53,9 @@ module("Discourse Chat | Component | chat message collapser", function (hooks) {
this.set("uploads", [{ original_filename: evilString }]); this.set("uploads", [{ original_filename: evilString }]);
await render(hbs`<ChatMessageCollapser @uploads={{this.uploads}} />`); await render(hbs`<ChatMessageCollapser @uploads={{this.uploads}} />`);
assert.true( assert
query(".chat-message-collapser-link-small").innerHTML.includes( .dom(".chat-message-collapser-link-small")
evilStringEscaped .includesHtml(evilStringEscaped);
)
);
}); });
}); });
@ -399,16 +397,14 @@ module(
); );
await render(hbs`<ChatMessageCollapser @cooked={{this.cooked}} />`); await render(hbs`<ChatMessageCollapser @cooked={{this.cooked}} />`);
assert.true( const links = [
queryAll(".chat-message-collapser-link-small")[0].innerHTML.includes( ...document.querySelectorAll(".chat-message-collapser-link-small"),
evilStringEscaped ];
)
); assert.dom(links[0]).includesHtml(evilStringEscaped);
assert.true( assert
queryAll(".chat-message-collapser-link-small")[1].innerHTML.includes( .dom(links[1])
"&lt;script&gt;someeviltitle&lt;/script&gt;" .includesHtml("&lt;script&gt;someeviltitle&lt;/script&gt;");
)
);
}); });
test("shows alt or links (if no alt) for linked image", async function (assert) { test("shows alt or links (if no alt) for linked image", async function (assert) {
@ -511,10 +507,7 @@ module(
assert assert
.dom(".chat-message-collapser-link-small") .dom(".chat-message-collapser-link-small")
.hasProperty("href", /%3Cscript%3Esomeeviltitle%3C\/script%3E$/); .hasProperty("href", /%3Cscript%3Esomeeviltitle%3C\/script%3E$/);
assert.strictEqual( assert.dom(".chat-message-collapser-link-small").hasHtml("someeviltitle");
query(".chat-message-collapser-link-small").innerHTML.trim(),
"someeviltitle"
);
}); });
test("removes album title overlay", async function (assert) { test("removes album title overlay", async function (assert) {

View File

@ -4,7 +4,6 @@ import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit"; import { module, test } from "qunit";
import CoreFabricators from "discourse/lib/fabricators"; import CoreFabricators from "discourse/lib/fabricators";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators"; import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
module("Discourse Chat | Component | chat-message", function (hooks) { module("Discourse Chat | Component | chat-message", function (hooks) {
@ -64,11 +63,9 @@ module("Discourse Chat | Component | chat-message", function (hooks) {
await this.message.cook(); await this.message.cook();
await render(template); await render(template);
assert.true( assert
query(".chat-message-text") .dom(".chat-message-text")
.innerHTML.trim() .includesHtml("<p>what <mark>test</mark></p>");
.includes("<p>what <mark>test</mark></p>")
);
}); });
test("Message with reply", async function (assert) { test("Message with reply", async function (assert) {

View File

@ -3,7 +3,6 @@ import { render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators"; import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
module( module(
@ -20,11 +19,9 @@ module(
hbs`<Chat::Modal::ArchiveChannel @inline={{true}} @model={{hash channel=this.channel}} />` hbs`<Chat::Modal::ArchiveChannel @inline={{true}} @model={{hash channel=this.channel}} />`
); );
assert.true( assert
query(".chat-modal-archive-channel").innerHTML.includes( .dom(".chat-modal-archive-channel")
"&lt;script&gt;someeviltitle&lt;/script&gt;" .includesHtml("&lt;script&gt;someeviltitle&lt;/script&gt;");
)
);
}); });
} }
); );

View File

@ -3,7 +3,6 @@ import { render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators"; import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
module( module(
@ -20,11 +19,9 @@ module(
hbs`<Chat::Modal::DeleteChannel @inline={{true}} @model={{hash channel=this.channel}} />` hbs`<Chat::Modal::DeleteChannel @inline={{true}} @model={{hash channel=this.channel}} />`
); );
assert.true( assert
query(".chat-modal-delete-channel__instructions").innerHTML.includes( .dom(".chat-modal-delete-channel__instructions")
"&lt;script&gt;someeviltitle&lt;/script&gt;" .includesHtml("&lt;script&gt;someeviltitle&lt;/script&gt;");
)
);
}); });
} }
); );

View File

@ -3,7 +3,6 @@ import { render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators"; import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
module( module(
@ -24,11 +23,9 @@ module(
/> />
`); `);
assert.true( assert
query(".chat-modal-move-message-to-channel").innerHTML.includes( .dom(".chat-modal-move-message-to-channel")
"&lt;script&gt;someeviltitle&lt;/script&gt;" .includesHtml("&lt;script&gt;someeviltitle&lt;/script&gt;");
)
);
}); });
} }
); );

View File

@ -3,7 +3,6 @@ import { render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators"; import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
module("Discourse Chat | Component | chat-thread-header", function (hooks) { module("Discourse Chat | Component | chat-thread-header", function (hooks) {
@ -17,10 +16,8 @@ module("Discourse Chat | Component | chat-thread-header", function (hooks) {
<Chat::Thread::Header @thread={{this.thread}} @channel={{this.thread.channel}} /> <Chat::Thread::Header @thread={{this.thread}} @channel={{this.thread.channel}} />
`); `);
assert.ok( assert
query(".c-navbar__title") .dom(".c-navbar__title")
.innerHTML.trim() .includesHtml("&lt;style&gt;body { background: red;}&lt;/style&gt;");
.includes("&lt;style&gt;body { background: red;}&lt;/style&gt;")
);
}); });
}); });

View File

@ -3,7 +3,6 @@ import { render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators"; import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
module("Discourse Chat | Component | chat-thread-list-item", function (hooks) { module("Discourse Chat | Component | chat-thread-list-item", function (hooks) {
@ -17,9 +16,8 @@ module("Discourse Chat | Component | chat-thread-list-item", function (hooks) {
<Chat::ThreadList::Item @thread={{this.thread}} /> <Chat::ThreadList::Item @thread={{this.thread}} />
`); `);
assert.equal( assert
query(".chat-thread-list-item__title").innerHTML.trim(), .dom(".chat-thread-list-item__title")
"&lt;style&gt;body { background: red;}&lt;/style&gt;" .hasHtml("&lt;style&gt;body { background: red;}&lt;/style&gt;");
);
}); });
}); });