DEV: Use qunit-dom instead of raw href/title comparisons (#29678)

This commit is contained in:
Jarek Radosz
2024-11-11 11:44:54 +01:00
committed by GitHub
parent 429b6a4e4e
commit 2272b1340b
31 changed files with 391 additions and 316 deletions

View File

@ -8,7 +8,7 @@ import {
import { test } from "qunit"; import { test } from "qunit";
import siteSettingFixture from "discourse/tests/fixtures/site-settings"; import siteSettingFixture from "discourse/tests/fixtures/site-settings";
import pretender from "discourse/tests/helpers/create-pretender"; import pretender from "discourse/tests/helpers/create-pretender";
import { acceptance, queryAll } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Admin - Site Settings", function (needs) { acceptance("Admin - Site Settings", function (needs) {
let updatedTitle; let updatedTitle;
@ -192,14 +192,18 @@ acceptance("Admin - Site Settings", function (needs) {
test("nav menu items have titles", async (assert) => { test("nav menu items have titles", async (assert) => {
await visit("/admin/site_settings"); await visit("/admin/site_settings");
const navItems = queryAll(".admin-nav .nav-stacked li a"); const navItems = [
navItems.each((_, item) => { ...document.querySelectorAll(".admin-nav .nav-stacked li a"),
assert.strictEqual( ];
item.title, for (const item of navItems) {
item.innerText, assert
"menu item has title, and the title is equal to menu item's label" .dom(item)
); .hasAttribute(
}); "title",
item.innerText,
"menu item has title, and the title is equal to menu item's label"
);
}
}); });
test("can perform fuzzy search", async function (assert) { test("can perform fuzzy search", async function (assert) {

View File

@ -2,13 +2,14 @@ import { visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import PreloadStore from "discourse/lib/preload-store"; import PreloadStore from "discourse/lib/preload-store";
import discoveryFixtures from "discourse/tests/fixtures/discovery-fixtures"; import discoveryFixtures from "discourse/tests/fixtures/discovery-fixtures";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { cloneJSON } from "discourse-common/lib/object"; import { cloneJSON } from "discourse-common/lib/object";
acceptance("Categories - 'categories_only'", function (needs) { acceptance("Categories - 'categories_only'", function (needs) {
needs.settings({ needs.settings({
desktop_category_page_style: "categories_only", desktop_category_page_style: "categories_only",
}); });
test("basic functionality", async function (assert) { test("basic functionality", async function (assert) {
await visit("/categories"); await visit("/categories");
assert assert
@ -21,6 +22,7 @@ acceptance("Categories - 'categories_and_latest_topics'", function (needs) {
needs.settings({ needs.settings({
desktop_category_page_style: "categories_and_latest_topics", desktop_category_page_style: "categories_and_latest_topics",
}); });
test("basic functionality", async function (assert) { test("basic functionality", async function (assert) {
await visit("/categories"); await visit("/categories");
assert assert
@ -29,10 +31,13 @@ acceptance("Categories - 'categories_and_latest_topics'", function (needs) {
assert assert
.dom("div.latest-topic-list div[data-topic-id='8']") .dom("div.latest-topic-list div[data-topic-id='8']")
.exists("shows the topic list"); .exists("shows the topic list");
assert.notOk( assert
query(".more-topics a").href.endsWith("?order=created"), .dom(".more-topics a")
"the load more button doesn't include the order=created param" .hasAttribute(
); "href",
"/latest",
"the load more button doesn't include the order=created param"
);
}); });
}); });
@ -42,13 +47,17 @@ acceptance(
needs.settings({ needs.settings({
desktop_category_page_style: "categories_and_latest_topics_created_date", desktop_category_page_style: "categories_and_latest_topics_created_date",
}); });
test("order topics by", async function (assert) { test("order topics by", async function (assert) {
await visit("/categories"); await visit("/categories");
assert.ok( assert
query(".more-topics a").href.endsWith("?order=created"), .dom(".more-topics a")
"the load more button includes the order=created param" .hasAttribute(
); "href",
"/latest?order=created",
"the load more button includes the order=created param"
);
}); });
} }
); );
@ -57,6 +66,7 @@ acceptance("Categories - 'categories_with_featured_topics'", function (needs) {
needs.settings({ needs.settings({
desktop_category_page_style: "categories_with_featured_topics", desktop_category_page_style: "categories_with_featured_topics",
}); });
test("basic functionality", async function (assert) { test("basic functionality", async function (assert) {
await visit("/categories"); await visit("/categories");
assert assert
@ -74,6 +84,7 @@ acceptance(
needs.settings({ needs.settings({
desktop_category_page_style: "subcategories_with_featured_topics", desktop_category_page_style: "subcategories_with_featured_topics",
}); });
test("basic functionality", async function (assert) { test("basic functionality", async function (assert) {
await visit("/categories"); await visit("/categories");
assert assert
@ -98,6 +109,7 @@ acceptance(
needs.settings({ needs.settings({
desktop_category_page_style: "subcategories_with_featured_topics", desktop_category_page_style: "subcategories_with_featured_topics",
}); });
test("basic functionality", async function (assert) { test("basic functionality", async function (assert) {
await visit("/categories"); await visit("/categories");
assert assert

View File

@ -1,10 +1,6 @@
import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers"; import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance,
query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
acceptance("EmojiPicker", function (needs) { acceptance("EmojiPicker", function (needs) {
needs.user(); needs.user();
@ -131,26 +127,32 @@ acceptance("EmojiPicker", function (needs) {
await click(`.emoji-picker-emoji-area img.emoji[title="sunglasses"]`); await click(`.emoji-picker-emoji-area img.emoji[title="sunglasses"]`);
await click(`.emoji-picker-emoji-area img.emoji[title="grinning"]`); await click(`.emoji-picker-emoji-area img.emoji[title="grinning"]`);
let recent = queryAll(".section.recent .section-group img.emoji"); let recent = document.querySelectorAll(
assert.strictEqual(recent[0].title, "grinning"); ".section.recent .section-group img.emoji"
assert.strictEqual(recent[1].title, "sunglasses"); );
assert.dom(recent[0]).hasAttribute("title", "grinning");
assert.dom(recent[1]).hasAttribute("title", "sunglasses");
await click( await click(
`.section[data-section="recent"] .section-group img.emoji[title="sunglasses"]` `.section[data-section="recent"] .section-group img.emoji[title="sunglasses"]`
); );
// The order is still the same // The order is still the same
recent = queryAll(".section.recent .section-group img.emoji"); recent = document.querySelectorAll(
assert.strictEqual(recent[0].title, "grinning"); ".section.recent .section-group img.emoji"
assert.strictEqual(recent[1].title, "sunglasses"); );
assert.dom(recent[0]).hasAttribute("title", "grinning");
assert.dom(recent[1]).hasAttribute("title", "sunglasses");
await click("button.emoji.btn"); await click("button.emoji.btn");
await click("button.emoji.btn"); await click("button.emoji.btn");
// but updates when you re-open // but updates when you re-open
recent = queryAll(".section.recent .section-group img.emoji"); recent = document.querySelectorAll(
assert.strictEqual(recent[0].title, "sunglasses"); ".section.recent .section-group img.emoji"
assert.strictEqual(recent[1].title, "grinning"); );
assert.dom(recent[0]).hasAttribute("title", "sunglasses");
assert.dom(recent[1]).hasAttribute("title", "grinning");
}); });
test("emoji picker persists state", async function (assert) { test("emoji picker persists state", async function (assert) {

View File

@ -35,15 +35,16 @@ acceptance("Lightbox", function (needs) {
"image · 1500×842 234 KB · download · original image" "image · 1500×842 234 KB · download · original image"
); );
assert.equal( assert
query(".image-source-link:nth-child(1)").href, .dom(".image-source-link:nth-child(1)")
"http://discourse.local/uploads/default/ad768537789cdf4679a18161ac0b0b6f0f4ccf9e" .hasAttribute(
); "href",
"//discourse.local/uploads/default/ad768537789cdf4679a18161ac0b0b6f0f4ccf9e"
);
assert.equal( assert
query(".image-source-link:nth-child(2)").href, .dom(".image-source-link:nth-child(2)")
`${document.location.origin}/images/d-logo-sketch.png` .hasAttribute("href", `/images/d-logo-sketch.png`);
);
await click(".mfp-close"); await click(".mfp-close");
}); });

View File

@ -55,11 +55,12 @@ acceptance("Share and Invite modal", function (needs) {
test("Post date link", async function (assert) { test("Post date link", async function (assert) {
await visit("/t/short-topic-with-two-posts/54077"); await visit("/t/short-topic-with-two-posts/54077");
assert.ok( assert
query("#post_2 .post-info.post-date a").href.endsWith( .dom("#post_2 .post-info.post-date a")
.hasAttribute(
"href",
"/t/short-topic-with-two-posts/54077/2?u=eviltrout" "/t/short-topic-with-two-posts/54077/2?u=eviltrout"
) );
);
await click("#post_2 a.post-date"); await click("#post_2 a.post-date");
assert.dom(".share-topic-modal").exists("shows the share modal"); assert.dom(".share-topic-modal").exists("shows the share modal");

View File

@ -173,10 +173,13 @@ acceptance("Sidebar - Plugin API", function (needs) {
"displays first link with correct title attribute" "displays first link with correct title attribute"
); );
assert.true( assert
links[0].href.endsWith("/some-slug/1"), .dom(links[0])
"link has the correct href attribute" .hasAttribute(
); "href",
"/t/some-slug/1",
"link has the correct href attribute"
);
assert assert
.dom(links[0].children[0]) .dom(links[0].children[0])

View File

@ -654,13 +654,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) {
await visit("/"); await visit("/");
assert.strictEqual( assert
query( .dom(`.sidebar-section-link-wrapper[data-category-id="${category.id}"] a`)
`.sidebar-section-link-wrapper[data-category-id="${category.id}"] a` .hasAttribute(
).title, "title",
category.descriptionText, category.descriptionText,
"category description without HTML entity is used as the link's title" "category description without HTML entity is used as the link's title"
); );
}); });
test("visiting category discovery new route", async function (assert) { test("visiting category discovery new route", async function (assert) {
@ -1211,26 +1211,35 @@ acceptance(
await visit("/"); await visit("/");
assert.true( assert
query( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a` `.sidebar-section-link-wrapper[data-category-id="${category1.id}"] a`
).href.endsWith("/c/meta/3/l/new"), )
"links to the new topics list for the category because there's 1 new topic" .hasAttribute(
); "href",
"/c/meta/3/l/new",
"links to the new topics list for the category because there's 1 new topic"
);
assert.true( assert
query( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category2.id}"] a` `.sidebar-section-link-wrapper[data-category-id="${category2.id}"] a`
).href.endsWith("/c/howto/10/l/new"), )
"links to the new topics list for the category because there's 1 unread topic" .hasAttribute(
); "href",
"/c/howto/10/l/new",
"links to the new topics list for the category because there's 1 unread topic"
);
assert.true( assert
query( .dom(
`.sidebar-section-link-wrapper[data-category-id="${category3.id}"] a` `.sidebar-section-link-wrapper[data-category-id="${category3.id}"] a`
).href.endsWith("/c/feature/spec/26"), )
"links to the latest topics list for the category because there are no unread or new topics" .hasAttribute(
); "href",
"/c/feature/spec/26",
"links to the latest topics list for the category because there are no unread or new topics"
);
}); });
test("category link href is always the latest topics list when sidebar_link_to_filtered_list is false", async function (assert) { test("category link href is always the latest topics list when sidebar_link_to_filtered_list is false", async function (assert) {

View File

@ -470,13 +470,15 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary" ".sidebar-section[data-section-name='community'] .sidebar-more-section-links-details-summary"
); );
assert.strictEqual( assert
query( .dom(
".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='faq']" ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='faq']"
).href, )
"http://some.faq.url/", .hasAttribute(
"href attribute is set to custom FAQ URL on the section link" "href",
); "http://some.faq.url",
"href attribute is set to custom FAQ URL on the section link"
);
}); });
test("navigating to admin from sidebar", async function (assert) { test("navigating to admin from sidebar", async function (assert) {
@ -576,21 +578,25 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
test("my posts title changes when drafts are present", async function (assert) { test("my posts title changes when drafts are present", async function (assert) {
await visit("/"); await visit("/");
assert.strictEqual( assert
query(".sidebar-section-link[data-link-name='my-posts']").title, .dom(".sidebar-section-link[data-link-name='my-posts']")
I18n.t("sidebar.sections.community.links.my_posts.title"), .hasAttribute(
"displays the default title when no drafts are present" "title",
); I18n.t("sidebar.sections.community.links.my_posts.title"),
"displays the default title when no drafts are present"
);
await publishToMessageBus(`/user-drafts/${loggedInUser().id}`, { await publishToMessageBus(`/user-drafts/${loggedInUser().id}`, {
draft_count: 1, draft_count: 1,
}); });
assert.strictEqual( assert
query(".sidebar-section-link[data-link-name='my-posts']").title, .dom(".sidebar-section-link[data-link-name='my-posts']")
I18n.t("sidebar.sections.community.links.my_posts.title_drafts"), .hasAttribute(
"displays the draft title when drafts are present" "title",
); I18n.t("sidebar.sections.community.links.my_posts.title_drafts"),
"displays the draft title when drafts are present"
);
}); });
test("my posts changes its text when drafts are present and new new view experiment is enabled", async function (assert) { test("my posts changes its text when drafts are present and new new view experiment is enabled", async function (assert) {
@ -1027,11 +1033,13 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
"displays the right text for the link" "displays the right text for the link"
); );
assert.strictEqual( assert
query(".sidebar-section-link[data-link-name='unread']").title, .dom(".sidebar-section-link[data-link-name='unread']")
"List of unread topics", .hasAttribute(
"displays the right title for the link" "title",
); "List of unread topics",
"displays the right title for the link"
);
assert assert
.dom( .dom(
@ -1099,11 +1107,13 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
"displays the right text for the link" "displays the right text for the link"
); );
assert.strictEqual( assert
query(".sidebar-section-link[data-link-name='user-summary']").title, .dom(".sidebar-section-link[data-link-name='user-summary']")
"eviltrout summary", .hasAttribute(
"displays the right title for the link" "title",
); "eviltrout summary",
"displays the right title for the link"
);
assert assert
.dom( .dom(

View File

@ -749,26 +749,29 @@ acceptance(
await visit("/"); await visit("/");
assert.true( assert
query( .dom('.sidebar-section-link-wrapper[data-tag-name="tag1"] a')
'.sidebar-section-link-wrapper[data-tag-name="tag1"] a' .hasAttribute(
).href.endsWith("/tag/tag1/l/new"), "href",
"links to the new topics list for the tag because there's 1 new topic" "/tag/tag1/l/new",
); "links to the new topics list for the tag because there's 1 new topic"
);
assert.true( assert
query( .dom('.sidebar-section-link-wrapper[data-tag-name="tag2"] a')
'.sidebar-section-link-wrapper[data-tag-name="tag2"] a' .hasAttribute(
).href.endsWith("/tag/tag2/l/new"), "href",
"links to the new topics list for the tag because there's 1 unread topic" "/tag/tag2/l/new",
); "links to the new topics list for the tag because there's 1 unread topic"
);
assert.true( assert
query( .dom('.sidebar-section-link-wrapper[data-tag-name="tag3"] a')
'.sidebar-section-link-wrapper[data-tag-name="tag3"] a' .hasAttribute(
).href.endsWith("/tag/tag3"), "href",
"links to the latest topics list for the tag because there are no unread or new topics" "/tag/tag3",
); "links to the latest topics list for the tag because there are no unread or new topics"
);
}); });
test("tag link href is always to the latest topics list when sidebar_link_to_filtered_list is false", async function (assert) { test("tag link href is always to the latest topics list when sidebar_link_to_filtered_list is false", async function (assert) {

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import Sinon from "sinon"; import Sinon from "sinon";
import { import {
acceptance, acceptance,
query,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -212,11 +211,13 @@ acceptance(
"has the right accessibility attributes set when sidebar is expanded" "has the right accessibility attributes set when sidebar is expanded"
); );
assert.strictEqual( assert
query(".btn-sidebar-toggle").title, .dom(".btn-sidebar-toggle")
I18n.t("sidebar.title"), .hasAttribute(
"has the right title attribute when sidebar is expanded" "title",
); I18n.t("sidebar.title"),
"has the right title attribute when sidebar is expanded"
);
await click(".btn-sidebar-toggle"); await click(".btn-sidebar-toggle");
@ -228,11 +229,13 @@ acceptance(
"has the right accessibility attributes set when sidebar is collapsed" "has the right accessibility attributes set when sidebar is collapsed"
); );
assert.strictEqual( assert
query(".btn-sidebar-toggle").title, .dom(".btn-sidebar-toggle")
I18n.t("sidebar.title"), .hasAttribute(
"has the right title attribute when sidebar is collapsed" "title",
); I18n.t("sidebar.title"),
"has the right title attribute when sidebar is collapsed"
);
}); });
} }
); );

View File

@ -85,25 +85,29 @@ acceptance("Topic Discovery Tracked", function (needs) {
"the categories nav item is not displayed when tracked filter is present" "the categories nav item is not displayed when tracked filter is present"
); );
assert.ok( assert
query("#navigation-bar li.unread a").href.endsWith("/unread?f=tracked"), .dom("#navigation-bar li.unread a")
"unread link has tracked filter" .hasAttribute(
); "href",
"/unread?f=tracked",
"unread link has tracked filter"
);
assert.ok( assert
query("#navigation-bar li.new a").href.endsWith("/new?f=tracked"), .dom("#navigation-bar li.new a")
"new link has tracked filter" .hasAttribute("href", "/new?f=tracked", "new link has tracked filter");
);
assert.ok( assert
query("#navigation-bar li.hot a").href.endsWith("/hot?f=tracked"), .dom("#navigation-bar li.hot a")
"hot link has tracked filter" .hasAttribute("href", "/hot?f=tracked", "hot link has tracked filter");
);
assert.ok( assert
query("#navigation-bar li.latest a").href.endsWith("/latest?f=tracked"), .dom("#navigation-bar li.latest a")
"latest link has tracked filter" .hasAttribute(
); "href",
"/latest?f=tracked",
"latest link has tracked filter"
);
}); });
test("visit discovery pages with tracked filter", async function (assert) { test("visit discovery pages with tracked filter", async function (assert) {

View File

@ -567,20 +567,24 @@ acceptance("Topic filter replies to post number", function (needs) {
test("visit topic", async function (assert) { test("visit topic", async function (assert) {
await visit("/t/-/280"); await visit("/t/-/280");
assert.equal( assert
query("#post_3 .show-replies").title, .dom("#post_3 .show-replies")
I18n.t("post.filtered_replies_hint", { count: 3 }), .hasAttribute(
"it displays the right title for filtering by replies" "title",
); I18n.t("post.filtered_replies_hint", { count: 3 }),
"displays the right title for filtering by replies"
);
await visit("/"); await visit("/");
await visit("/t/-/280?replies_to_post_number=3"); await visit("/t/-/280?replies_to_post_number=3");
assert.equal( assert
query("#post_3 .show-replies").title, .dom("#post_3 .show-replies")
I18n.t("post.view_all_posts"), .hasAttribute(
"it displays the right title when filtered by replies" "title",
); I18n.t("post.view_all_posts"),
"displays the right title when filtered by replies"
);
}); });
}); });

View File

@ -57,11 +57,8 @@ acceptance("User Drafts", function (needs) {
"shows the excerpt" "shows the excerpt"
); );
assert.ok( assert
query(".user-stream-item:nth-child(2) a.avatar-link").href.endsWith( .dom(".user-stream-item:nth-child(2) a.avatar-link")
"/u/eviltrout" .hasAttribute("href", "/u/eviltrout", "has correct avatar link");
),
"has correct avatar link"
);
}); });
}); });

View File

@ -215,21 +215,21 @@ acceptance("User menu", function (needs) {
await visit("/"); await visit("/");
await click(".d-header-icons .current-user button"); await click(".d-header-icons .current-user button");
for (const [key, title] of Object.entries(expectedTitles)) { for (const [key, title] of Object.entries(expectedTitles)) {
assert.strictEqual( assert
query(`#${key}`).title, .dom(`#${key}`)
title, .hasAttribute("title", title, `${key} tab has the right title`);
`${key} tab has the right title`
);
} }
await publishToMessageBus(`/notification/${loggedInUser().id}`, { await publishToMessageBus(`/notification/${loggedInUser().id}`, {
unread_high_priority_notifications: 22, unread_high_priority_notifications: 22,
}); });
assert.strictEqual( assert
query("#user-menu-button-tiny-tab-1").title, .dom("#user-menu-button-tiny-tab-1")
"Custom title: 22", .hasAttribute(
"tabs titles can update dynamically" "title",
); "Custom title: 22",
"tabs titles can update dynamically"
);
}); });
test("tabs added via the plugin API", async function (assert) { test("tabs added via the plugin API", async function (assert) {

View File

@ -350,10 +350,9 @@ acceptance(
await selectKit(".light-color-scheme .combobox").expand(); await selectKit(".light-color-scheme .combobox").expand();
await selectKit(".light-color-scheme .combobox").selectRowByValue(3); await selectKit(".light-color-scheme .combobox").selectRowByValue(3);
assert.ok( assert
document.querySelector("link#cs-preview-light").href.endsWith("/3.css"), .dom("link#cs-preview-light", document.body)
"correct stylesheet loaded" .hasAttribute("href", "3.css", "correct stylesheet loaded");
);
document.querySelector("link#cs-preview-light").remove(); document.querySelector("link#cs-preview-light").remove();

View File

@ -107,16 +107,20 @@ acceptance("User Profile - Summary - Stats", function (needs) {
await visit("/u/eviltrout/summary"); await visit("/u/eviltrout/summary");
assert.equal(query(".stats-time-read span").textContent.trim(), "1d"); assert.equal(query(".stats-time-read span").textContent.trim(), "1d");
assert.equal( assert
query(".stats-time-read span").title, .dom(".stats-time-read span")
I18n.t("user.summary.time_read_title", { duration: "1 day" }) .hasAttribute(
); "title",
I18n.t("user.summary.time_read_title", { duration: "1 day" })
);
assert.equal(query(".stats-recent-read span").textContent.trim(), "17m"); assert.equal(query(".stats-recent-read span").textContent.trim(), "17m");
assert.equal( assert
query(".stats-recent-read span").title, .dom(".stats-recent-read span")
I18n.t("user.summary.recent_time_read_title", { duration: "17 mins" }) .hasAttribute(
); "title",
I18n.t("user.summary.recent_time_read_title", { duration: "17 mins" })
);
}); });
}); });

View File

@ -93,11 +93,9 @@ acceptance("User Status", function (needs) {
await visit("/"); await visit("/");
await openUserStatusModal(); await openUserStatusModal();
assert.equal( assert
query(`.btn-emoji img.emoji`).title, .dom(".btn-emoji img.emoji")
userStatusEmoji, .hasAttribute("title", userStatusEmoji, "status emoji is shown");
"status emoji is shown"
);
assert.equal( assert.equal(
query(".user-status-description").value, query(".user-status-description").value,
userStatus, userStatus,
@ -278,11 +276,13 @@ acceptance("User Status", function (needs) {
await click(".d-modal-cancel"); await click(".d-modal-cancel");
await openUserStatusModal(); await openUserStatusModal();
assert.equal( assert
query(`.btn-emoji img.emoji`).title, .dom(".btn-emoji img.emoji")
userStatusEmoji, .hasAttribute(
"the actual status emoji is shown" "title",
); userStatusEmoji,
"the actual status emoji is shown"
);
assert.equal( assert.equal(
query(".user-status-description").value, query(".user-status-description").value,
userStatus, userStatus,

View File

@ -12,7 +12,6 @@ import {
acceptance, acceptance,
publishToMessageBus, publishToMessageBus,
query, query,
queryAll,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper"; import selectKit from "discourse/tests/helpers/select-kit-helper";
@ -75,11 +74,11 @@ acceptance("User Routes", function (needs) {
.dom(document.body) .dom(document.body)
.hasClass("user-notifications-page", "has the body class"); .hasClass("user-notifications-page", "has the body class");
const $links = queryAll(".notification a"); const links = [...document.querySelectorAll(".notification a")];
assert.ok( assert
$links[2].href.includes("/u/eviltrout/notifications/likes-received") .dom(links[2])
); .hasAttribute("href", /^\/u\/eviltrout\/notifications\/likes-received/);
updateCurrentUser({ moderator: true, admin: false }); updateCurrentUser({ moderator: true, admin: false });

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 | Component | badge-button", function (hooks) { module("Integration | Component | badge-button", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -36,19 +35,19 @@ module("Integration | Component | badge-button", function (hooks) {
await render(hbs`<BadgeButton @badge={{this.badge}} />`); await render(hbs`<BadgeButton @badge={{this.badge}} />`);
assert.strictEqual( assert
query(".user-badge").title, .dom(".user-badge")
"a good run", .hasAttribute("title", "a good run", "strips html");
"it strips html"
);
this.set("badge", { description: "a bad run" }); this.set("badge", { description: "a bad run" });
assert.strictEqual( assert
query(".user-badge").title, .dom(".user-badge")
"a bad run", .hasAttribute(
"it updates title when changing description" "title",
); "a bad run",
"updates title when changing description"
);
}); });
test("icon", async function (assert) { test("icon", async function (assert) {

View File

@ -5,7 +5,6 @@ import { formattedReminderTime } from "discourse/lib/bookmark";
import { tomorrow } from "discourse/lib/time-utils"; import { tomorrow } from "discourse/lib/time-utils";
import Bookmark from "discourse/models/bookmark"; import Bookmark from "discourse/models/bookmark";
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 I18n from "discourse-i18n"; import I18n from "discourse-i18n";
module("Integration | Component | bookmark-icon", function (hooks) { module("Integration | Component | bookmark-icon", function (hooks) {
@ -25,8 +24,8 @@ module("Integration | Component | bookmark-icon", function (hooks) {
assert assert
.dom(".d-icon-discourse-bookmark-clock.bookmark-icon__bookmarked") .dom(".d-icon-discourse-bookmark-clock.bookmark-icon__bookmarked")
.exists(); .exists();
assert.strictEqual( assert.dom(".svg-icon-title").hasAttribute(
query(".svg-icon-title").title, "title",
I18n.t("bookmarks.created_with_reminder_generic", { I18n.t("bookmarks.created_with_reminder_generic", {
date: formattedReminderTime( date: formattedReminderTime(
this.bookmark.reminder_at, this.bookmark.reminder_at,
@ -49,8 +48,8 @@ module("Integration | Component | bookmark-icon", function (hooks) {
await render(hbs`<BookmarkIcon @bookmark={{this.bookmark}} />`); await render(hbs`<BookmarkIcon @bookmark={{this.bookmark}} />`);
assert.dom(".d-icon-bookmark.bookmark-icon__bookmarked").exists(); assert.dom(".d-icon-bookmark.bookmark-icon__bookmarked").exists();
assert.strictEqual( assert.dom(".svg-icon-title").hasAttribute(
query(".svg-icon-title").title, "title",
I18n.t("bookmarks.created_generic", { I18n.t("bookmarks.created_generic", {
name: "some name", name: "some name",
}) })
@ -65,9 +64,8 @@ module("Integration | Component | bookmark-icon", function (hooks) {
await render(hbs`<BookmarkIcon @bookmark={{this.bookmark}} />`); await render(hbs`<BookmarkIcon @bookmark={{this.bookmark}} />`);
assert.dom(".d-icon-bookmark.bookmark-icon").exists(); assert.dom(".d-icon-bookmark.bookmark-icon").exists();
assert.strictEqual( assert
query(".svg-icon-title").title, .dom(".svg-icon-title")
I18n.t("bookmarks.create") .hasAttribute("title", I18n.t("bookmarks.create"));
);
}); });
}); });

View File

@ -29,12 +29,13 @@ module(
test("show all button for bookmark notifications", async function (assert) { test("show all button for bookmark notifications", async function (assert) {
await render(template); await render(template);
const link = query(".panel-body-bottom .show-all"); assert
assert.strictEqual( .dom(".panel-body-bottom .show-all")
link.title, .hasAttribute(
I18n.t("user_menu.view_all_bookmarks"), "title",
"has the correct title" I18n.t("user_menu.view_all_bookmarks"),
); "has the correct title"
);
}); });
test("dismiss button", async function (assert) { test("dismiss button", async function (assert) {
@ -47,11 +48,13 @@ module(
dismiss, dismiss,
"dismiss button is shown if the user has unread bookmark_reminder notifications" "dismiss button is shown if the user has unread bookmark_reminder notifications"
); );
assert.strictEqual( assert
dismiss.title, .dom(".panel-body-bottom .notifications-dismiss")
I18n.t("user.dismiss_bookmarks_tooltip"), .hasAttribute(
"dismiss button has a title" "title",
); I18n.t("user.dismiss_bookmarks_tooltip"),
"dismiss button has a title"
);
this.currentUser.set("grouped_unread_notifications", {}); this.currentUser.set("grouped_unread_notifications", {});
await settled(); await settled();

View File

@ -16,17 +16,21 @@ module(
pretender.get("/notifications", () => { pretender.get("/notifications", () => {
return response({ notifications: [] }); return response({ notifications: [] });
}); });
await render(template); await render(template);
assert.strictEqual( assert.strictEqual(
query(".empty-state-title").textContent.trim(), query(".empty-state-title").textContent.trim(),
I18n.t("user.no_likes_title"), I18n.t("user.no_likes_title"),
"empty state title for the likes tab is shown" "empty state title for the likes tab is shown"
); );
const emptyStateBodyLink = query(".empty-state-body a"); assert
assert.ok( .dom(".empty-state-body a")
emptyStateBodyLink.href.endsWith("/my/preferences/notifications"), .hasAttribute(
"link to /my/preferences/notification inside empty state body is rendered" "href",
); "/my/preferences/notifications",
"link to /my/preferences/notification inside empty state body is rendered"
);
}); });
} }
); );

View File

@ -124,8 +124,7 @@ module(
getNotification(this.currentUser, this.siteSettings, this.site) getNotification(this.currentUser, this.siteSettings, this.site)
); );
await render(template); await render(template);
const link = query("li a"); assert.dom("li a").hasAttribute("href", "/t/this-is-fancy-title/449/113");
assert.ok(link.href.endsWith("/t/this-is-fancy-title/449/113"));
}); });
test("the item's href links to the group messages if the notification is for a group messages", async function (assert) { test("the item's href links to the group messages if the notification is for a group messages", async function (assert) {
@ -143,8 +142,7 @@ module(
}) })
); );
await render(template); await render(template);
const link = query("li a"); assert.dom("li a").hasAttribute("href", "/u/ossaama/messages/grouperss");
assert.ok(link.href.endsWith("/u/ossaama/messages/grouperss"));
}); });
test("the item's link has a title for accessibility", async function (assert) { test("the item's link has a title for accessibility", async function (assert) {
@ -153,8 +151,10 @@ module(
getNotification(this.currentUser, this.siteSettings, this.site) getNotification(this.currentUser, this.siteSettings, this.site)
); );
await render(template); await render(template);
const link = query("li a");
assert.strictEqual(link.title, I18n.t("notifications.titles.mentioned")); assert
.dom("li a")
.hasAttribute("title", I18n.t("notifications.titles.mentioned"));
}); });
test("has elements for label and description", async function (assert) { test("has elements for label and description", async function (assert) {
@ -289,16 +289,16 @@ module(
.dom("li.additional.classes") .dom("li.additional.classes")
.exists("extra classes are included on the item"); .exists("extra classes are included on the item");
const link = query("li a"); assert
assert.ok( .dom("li a")
link.href.endsWith("/somewhere/awesome"), .hasAttribute("href", "/somewhere/awesome", "link href is customized");
"link href is customized" assert
); .dom("li a")
assert.strictEqual( .hasAttribute(
link.title, "title",
"hello world this is unsafe '\"<span>", "hello world this is unsafe '\"<span>",
"link title is customized and rendered safely" "link title is customized and rendered safely"
); );
assert.dom("svg.d-icon-wrench").exists("icon is customized"); assert.dom("svg.d-icon-wrench").exists("icon is customized");
@ -490,9 +490,9 @@ module(
test("uses bookmarkable_url for the href", async function (assert) { test("uses bookmarkable_url for the href", async function (assert) {
this.set("item", getBookmark({}, this.siteSettings, this.site)); this.set("item", getBookmark({}, this.siteSettings, this.site));
await render(template); await render(template);
assert.ok( assert
query("li.bookmark a").href.endsWith("/t/this-bookmarkable-url/227/1") .dom("li.bookmark a")
); .hasAttribute("href", /\/t\/this-bookmarkable-url\/227\/1$/);
}); });
test("item label is the bookmarked post author", async function (assert) { test("item label is the bookmarked post author", async function (assert) {

View File

@ -255,12 +255,13 @@ module("Integration | Component | user-menu | messages-list", function (hooks) {
test("show all button for message notifications", async function (assert) { test("show all button for message notifications", async function (assert) {
await render(template); await render(template);
const link = query(".panel-body-bottom .show-all"); assert
assert.strictEqual( .dom(".panel-body-bottom .show-all")
link.title, .hasAttribute(
I18n.t("user_menu.view_all_messages"), "title",
"has the correct title" I18n.t("user_menu.view_all_messages"),
); "has the correct title"
);
}); });
test("dismiss button", async function (assert) { test("dismiss button", async function (assert) {
@ -268,16 +269,19 @@ module("Integration | Component | user-menu | messages-list", function (hooks) {
[NOTIFICATION_TYPES.private_message]: 72, [NOTIFICATION_TYPES.private_message]: 72,
}); });
await render(template); await render(template);
const dismiss = query(".panel-body-bottom .notifications-dismiss"); const dismiss = query(".panel-body-bottom .notifications-dismiss");
assert.ok( assert.ok(
dismiss, dismiss,
"dismiss button is shown if the user has unread private_message notifications" "dismiss button is shown if the user has unread private_message notifications"
); );
assert.strictEqual( assert
dismiss.title, .dom(".panel-body-bottom .notifications-dismiss")
I18n.t("user.dismiss_messages_tooltip"), .hasAttribute(
"dismiss button has a title" "title",
); I18n.t("user.dismiss_messages_tooltip"),
"dismiss button has a title"
);
this.currentUser.set("grouped_unread_notifications", {}); this.currentUser.set("grouped_unread_notifications", {});
await settled(); await settled();
@ -297,7 +301,9 @@ module("Integration | Component | user-menu | messages-list", function (hooks) {
read_notifications: [], read_notifications: [],
}); });
}); });
await render(template); await render(template);
assert.strictEqual( assert.strictEqual(
query(".empty-state-title").textContent.trim(), query(".empty-state-title").textContent.trim(),
I18n.t("user.no_messages_title"), I18n.t("user.no_messages_title"),
@ -306,10 +312,12 @@ module("Integration | Component | user-menu | messages-list", function (hooks) {
assert assert
.dom(".empty-state-body svg.d-icon-envelope") .dom(".empty-state-body svg.d-icon-envelope")
.exists("icon is correctly rendered in the empty state body"); .exists("icon is correctly rendered in the empty state body");
const emptyStateBodyLink = query(".empty-state-body a"); assert
assert.ok( .dom(".empty-state-body a")
emptyStateBodyLink.href.endsWith("/about"), .hasAttribute(
"link inside empty state body is rendered" "href",
); "/about",
"link inside empty state body is rendered"
);
}); });
}); });

View File

@ -67,12 +67,13 @@ module(
test("show all button for all notifications page", async function (assert) { test("show all button for all notifications page", async function (assert) {
await render(template); await render(template);
const showAllBtn = query(".panel-body-bottom .btn.show-all"); assert
assert.strictEqual( .dom(".panel-body-bottom .btn.show-all")
showAllBtn.title, .hasAttribute(
I18n.t("user_menu.view_all_notifications"), "title",
"has the correct title" I18n.t("user_menu.view_all_notifications"),
); "has the correct title"
);
}); });
test("has a dismiss button if some notification types have unread notifications", async function (assert) { test("has a dismiss button if some notification types have unread notifications", async function (assert) {

View File

@ -2,7 +2,7 @@ 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, queryAll } from "discourse/tests/helpers/qunit-helpers"; import { queryAll } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
module( module(
@ -14,12 +14,13 @@ module(
test("show all button for reviewable notifications", async function (assert) { test("show all button for reviewable notifications", async function (assert) {
await render(template); await render(template);
const showAll = query(".panel-body-bottom .show-all"); assert
assert.strictEqual( .dom(".panel-body-bottom .show-all")
showAll.title, .hasAttribute(
I18n.t("user_menu.reviewable.view_all"), "title",
"has the correct title" I18n.t("user_menu.reviewable.view_all"),
); "has the correct title"
);
}); });
test("renders a list of reviewables", async function (assert) { test("renders a list of reviewables", async function (assert) {

View File

@ -31,11 +31,9 @@ module("Unit | Utility | category-badge", function (hooks) {
); );
const label = tag.children[0]; const label = tag.children[0];
assert.strictEqual( assert
label.title, .dom(label)
"cool description", .hasAttribute("title", "cool description", "has the correct title");
"it has the correct title"
);
assert.strictEqual( assert.strictEqual(
label.children[0].innerText, label.children[0].innerText,
"hello", "hello",

View File

@ -125,10 +125,9 @@ module("Unit | Utility | formatter", function (hooks) {
shortDateYear(500) shortDateYear(500)
); );
assert.strictEqual( assert
domFromString(formatDays(0, { format: "medium" }))[0].title, .dom(domFromString(formatDays(0, { format: "medium" }))[0])
longDate(new Date()) .hasAttribute("title", longDate(new Date()));
);
assert assert
.dom(domFromString(formatDays(0, { format: "medium" }))[0]) .dom(domFromString(formatDays(0, { format: "medium" }))[0])
@ -235,10 +234,10 @@ module("Unit | Utility | formatter", function (hooks) {
let elem = domFromString(autoUpdatingRelativeAge(d))[0]; let elem = domFromString(autoUpdatingRelativeAge(d))[0];
assert.strictEqual(elem.dataset.format, "tiny"); assert.strictEqual(elem.dataset.format, "tiny");
assert.strictEqual(elem.dataset.time, d.getTime().toString()); assert.strictEqual(elem.dataset.time, d.getTime().toString());
assert.strictEqual(elem.title, ""); assert.dom(elem).doesNotHaveAttribute("title");
elem = domFromString(autoUpdatingRelativeAge(d, { title: true }))[0]; elem = domFromString(autoUpdatingRelativeAge(d, { title: true }))[0];
assert.strictEqual(elem.title, longDate(d)); assert.dom(elem).hasAttribute("title", longDate(d));
elem = domFromString( elem = domFromString(
autoUpdatingRelativeAge(d, { autoUpdatingRelativeAge(d, {
@ -250,13 +249,13 @@ 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.strictEqual(elem.title, longDate(d)); assert.dom(elem).hasAttribute("title", longDate(d));
assert.strictEqual(elem.innerHTML, "1 day ago"); assert.strictEqual(elem.innerHTML, "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.strictEqual(elem.title, ""); assert.dom(elem).doesNotHaveAttribute("title");
assert.strictEqual(elem.innerHTML, "1 day"); assert.strictEqual(elem.innerHTML, "1 day");
elem = domFromString(autoUpdatingRelativeAge(d, { prefix: "test" }))[0]; elem = domFromString(autoUpdatingRelativeAge(d, { prefix: "test" }))[0];

View File

@ -4,7 +4,6 @@ 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 pretender from "discourse/tests/helpers/create-pretender"; import pretender from "discourse/tests/helpers/create-pretender";
import { query } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators"; import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
@ -34,8 +33,9 @@ module("Discourse Chat | Component | chat-channel-leave-btn", function (hooks) {
await render(hbs`<ChatChannelLeaveBtn @channel={{this.channel}} />`); await render(hbs`<ChatChannelLeaveBtn @channel={{this.channel}} />`);
const btn = query(".chat-channel-leave-btn"); assert
assert.strictEqual(btn.title, I18n.t("chat.direct_messages.leave")); .dom(".chat-channel-leave-btn")
.hasAttribute("title", I18n.t("chat.direct_messages.leave"));
}); });
test("has a specific title for message channel", async function (assert) { test("has a specific title for message channel", async function (assert) {
@ -43,8 +43,9 @@ module("Discourse Chat | Component | chat-channel-leave-btn", function (hooks) {
await render(hbs`<ChatChannelLeaveBtn @channel={{this.channel}} />`); await render(hbs`<ChatChannelLeaveBtn @channel={{this.channel}} />`);
const btn = query(".chat-channel-leave-btn"); assert
assert.strictEqual(btn.title, I18n.t("chat.leave")); .dom(".chat-channel-leave-btn")
.hasAttribute("title", I18n.t("chat.leave"));
}); });
test("is not visible on mobile", async function (assert) { test("is not visible on mobile", async function (assert) {

View File

@ -76,11 +76,12 @@ module(
); );
await render(hbs`<ChatMessageCollapser @cooked={{this.cooked}} />`); await render(hbs`<ChatMessageCollapser @cooked={{this.cooked}} />`);
assert.true( assert
query(".chat-message-collapser-link").href.includes( .dom(".chat-message-collapser-link")
"%3Cscript%3Esomeeviltitle%3C/script%3E" .hasProperty(
) "href",
); "https://www.youtube.com/watch?v=%3Cscript%3Esomeeviltitle%3C/script%3E"
);
}); });
test("shows youtube link in header", async function (assert) { test("shows youtube link in header", async function (assert) {
@ -91,8 +92,12 @@ module(
const link = queryAll(".chat-message-collapser-link"); const link = queryAll(".chat-message-collapser-link");
assert.strictEqual(link.length, 2, "two youtube links rendered"); assert.strictEqual(link.length, 2, "two youtube links rendered");
assert.strictEqual(link[0].href, "https://www.youtube.com/watch?v=ytId1"); assert
assert.strictEqual(link[1].href, "https://www.youtube.com/watch?v=ytId2"); .dom(link[0])
.hasAttribute("href", "https://www.youtube.com/watch?v=ytId1");
assert
.dom(link[1])
.hasAttribute("href", "https://www.youtube.com/watch?v=ytId2");
}); });
test("shows all user written text", async function (assert) { test("shows all user written text", async function (assert) {
@ -249,12 +254,14 @@ module(
const links = queryAll("a.chat-message-collapser-link-small"); const links = queryAll("a.chat-message-collapser-link-small");
assert.true(links[0].innerText.trim().includes("avatar.png")); assert.true(links[0].innerText.trim().includes("avatar.png"));
assert.true(links[0].href.includes("avatar.png")); assert.dom(links[0]).hasAttribute("href", "/images/avatar.png");
assert.true( assert.true(
links[1].innerText.trim().includes("d-logo-sketch-small.png") links[1].innerText.trim().includes("d-logo-sketch-small.png")
); );
assert.true(links[1].href.includes("d-logo-sketch-small.png")); assert
.dom(links[1])
.hasAttribute("href", "/images/d-logo-sketch-small.png");
}); });
test("shows all user written text", async function (assert) { test("shows all user written text", async function (assert) {
@ -321,10 +328,10 @@ module(
const links = queryAll("a.chat-message-collapser-link-small"); const links = queryAll("a.chat-message-collapser-link-small");
assert.true(links[0].innerText.trim().includes("http://cat1.com")); assert.true(links[0].innerText.trim().includes("http://cat1.com"));
assert.true(links[0].href.includes("http://cat1.com")); assert.dom(links[0]).hasAttribute("href", "http://cat1.com/");
assert.true(links[1].innerText.trim().includes("http://cat2.com")); assert.true(links[1].innerText.trim().includes("http://cat2.com"));
assert.true(links[1].href.includes("http://cat2.com")); assert.dom(links[1]).hasAttribute("href", "http://cat2.com/");
}); });
test("shows all user written text", async function (assert) { test("shows all user written text", async function (assert) {
@ -412,12 +419,14 @@ module(
const links = queryAll("a.chat-message-collapser-link-small"); const links = queryAll("a.chat-message-collapser-link-small");
assert.true(links[0].innerText.trim().includes("shows alt")); assert.true(links[0].innerText.trim().includes("shows alt"));
assert.true(links[0].href.includes("/images/avatar.png")); assert.dom(links[0]).hasAttribute("href", "/images/avatar.png");
assert.true( assert.true(
links[1].innerText.trim().includes("/images/d-logo-sketch-small.png") links[1].innerText.trim().includes("/images/d-logo-sketch-small.png")
); );
assert.true(links[1].href.includes("/images/d-logo-sketch-small.png")); assert
.dom(links[1])
.hasAttribute("href", "/images/d-logo-sketch-small.png");
}); });
test("shows all user written text", async function (assert) { test("shows all user written text", async function (assert) {
@ -499,11 +508,9 @@ module(
); );
await render(hbs`<ChatMessageCollapser @cooked={{this.cooked}} />`); await render(hbs`<ChatMessageCollapser @cooked={{this.cooked}} />`);
assert.true( assert
query(".chat-message-collapser-link-small").href.includes( .dom(".chat-message-collapser-link-small")
"%3Cscript%3Esomeeviltitle%3C/script%3E" .hasProperty("href", /%3Cscript%3Esomeeviltitle%3C\/script%3E$/);
)
);
assert.strictEqual( assert.strictEqual(
query(".chat-message-collapser-link-small").innerHTML.trim(), query(".chat-message-collapser-link-small").innerHTML.trim(),
"someeviltitle" "someeviltitle"

View File

@ -131,7 +131,8 @@ module("Discourse Chat | Component | chat-upload", function (hooks) {
await render(hbs`<ChatUpload @upload={{this.upload}} />`); await render(hbs`<ChatUpload @upload={{this.upload}} />`);
assert.dom("a.chat-other-upload").exists("displays as a link"); assert.dom("a.chat-other-upload").exists("displays as a link");
const link = query("a.chat-other-upload"); assert
assert.strictEqual(link.href, TXT_FIXTURE.url, "has the correct URL"); .dom("a.chat-other-upload")
.hasAttribute("href", TXT_FIXTURE.url, "has the correct URL");
}); });
}); });