diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js index 4f371cae1c4..64e47e26cec 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js @@ -8,7 +8,7 @@ import { import { test } from "qunit"; import siteSettingFixture from "discourse/tests/fixtures/site-settings"; 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) { let updatedTitle; @@ -192,14 +192,18 @@ acceptance("Admin - Site Settings", function (needs) { test("nav menu items have titles", async (assert) => { await visit("/admin/site_settings"); - const navItems = queryAll(".admin-nav .nav-stacked li a"); - navItems.each((_, item) => { - assert.strictEqual( - item.title, - item.innerText, - "menu item has title, and the title is equal to menu item's label" - ); - }); + const navItems = [ + ...document.querySelectorAll(".admin-nav .nav-stacked li a"), + ]; + for (const item of navItems) { + assert + .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) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/categories-test.js b/app/assets/javascripts/discourse/tests/acceptance/categories-test.js index 7b37c4cf619..d5f539377d4 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/categories-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/categories-test.js @@ -2,13 +2,14 @@ import { visit } from "@ember/test-helpers"; import { test } from "qunit"; import PreloadStore from "discourse/lib/preload-store"; 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"; acceptance("Categories - 'categories_only'", function (needs) { needs.settings({ desktop_category_page_style: "categories_only", }); + test("basic functionality", async function (assert) { await visit("/categories"); assert @@ -21,6 +22,7 @@ acceptance("Categories - 'categories_and_latest_topics'", function (needs) { needs.settings({ desktop_category_page_style: "categories_and_latest_topics", }); + test("basic functionality", async function (assert) { await visit("/categories"); assert @@ -29,10 +31,13 @@ acceptance("Categories - 'categories_and_latest_topics'", function (needs) { assert .dom("div.latest-topic-list div[data-topic-id='8']") .exists("shows the topic list"); - assert.notOk( - query(".more-topics a").href.endsWith("?order=created"), - "the load more button doesn't include the order=created param" - ); + assert + .dom(".more-topics a") + .hasAttribute( + "href", + "/latest", + "the load more button doesn't include the order=created param" + ); }); }); @@ -42,13 +47,17 @@ acceptance( needs.settings({ desktop_category_page_style: "categories_and_latest_topics_created_date", }); + test("order topics by", async function (assert) { await visit("/categories"); - assert.ok( - query(".more-topics a").href.endsWith("?order=created"), - "the load more button includes the order=created param" - ); + assert + .dom(".more-topics a") + .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({ desktop_category_page_style: "categories_with_featured_topics", }); + test("basic functionality", async function (assert) { await visit("/categories"); assert @@ -74,6 +84,7 @@ acceptance( needs.settings({ desktop_category_page_style: "subcategories_with_featured_topics", }); + test("basic functionality", async function (assert) { await visit("/categories"); assert @@ -98,6 +109,7 @@ acceptance( needs.settings({ desktop_category_page_style: "subcategories_with_featured_topics", }); + test("basic functionality", async function (assert) { await visit("/categories"); assert diff --git a/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js b/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js index 40ead612d73..de7c98d9083 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/emoji-picker-test.js @@ -1,10 +1,6 @@ import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers"; import { test } from "qunit"; -import { - acceptance, - query, - queryAll, -} from "discourse/tests/helpers/qunit-helpers"; +import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; acceptance("EmojiPicker", function (needs) { 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="grinning"]`); - let recent = queryAll(".section.recent .section-group img.emoji"); - assert.strictEqual(recent[0].title, "grinning"); - assert.strictEqual(recent[1].title, "sunglasses"); + let recent = document.querySelectorAll( + ".section.recent .section-group img.emoji" + ); + assert.dom(recent[0]).hasAttribute("title", "grinning"); + assert.dom(recent[1]).hasAttribute("title", "sunglasses"); await click( `.section[data-section="recent"] .section-group img.emoji[title="sunglasses"]` ); // The order is still the same - recent = queryAll(".section.recent .section-group img.emoji"); - assert.strictEqual(recent[0].title, "grinning"); - assert.strictEqual(recent[1].title, "sunglasses"); + recent = document.querySelectorAll( + ".section.recent .section-group img.emoji" + ); + assert.dom(recent[0]).hasAttribute("title", "grinning"); + assert.dom(recent[1]).hasAttribute("title", "sunglasses"); await click("button.emoji.btn"); await click("button.emoji.btn"); // but updates when you re-open - recent = queryAll(".section.recent .section-group img.emoji"); - assert.strictEqual(recent[0].title, "sunglasses"); - assert.strictEqual(recent[1].title, "grinning"); + recent = document.querySelectorAll( + ".section.recent .section-group img.emoji" + ); + assert.dom(recent[0]).hasAttribute("title", "sunglasses"); + assert.dom(recent[1]).hasAttribute("title", "grinning"); }); test("emoji picker persists state", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/lightbox-test.js b/app/assets/javascripts/discourse/tests/acceptance/lightbox-test.js index e9770f5b314..fb151886131 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/lightbox-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/lightbox-test.js @@ -35,15 +35,16 @@ acceptance("Lightbox", function (needs) { "image · 1500×842 234 KB · download · original image" ); - assert.equal( - query(".image-source-link:nth-child(1)").href, - "http://discourse.local/uploads/default/ad768537789cdf4679a18161ac0b0b6f0f4ccf9e" - ); + assert + .dom(".image-source-link:nth-child(1)") + .hasAttribute( + "href", + "//discourse.local/uploads/default/ad768537789cdf4679a18161ac0b0b6f0f4ccf9e" + ); - assert.equal( - query(".image-source-link:nth-child(2)").href, - `${document.location.origin}/images/d-logo-sketch.png` - ); + assert + .dom(".image-source-link:nth-child(2)") + .hasAttribute("href", `/images/d-logo-sketch.png`); await click(".mfp-close"); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js index 655bc186411..f205c9ca3d4 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js @@ -55,11 +55,12 @@ acceptance("Share and Invite modal", function (needs) { test("Post date link", async function (assert) { await visit("/t/short-topic-with-two-posts/54077"); - assert.ok( - query("#post_2 .post-info.post-date a").href.endsWith( + assert + .dom("#post_2 .post-info.post-date a") + .hasAttribute( + "href", "/t/short-topic-with-two-posts/54077/2?u=eviltrout" - ) - ); + ); await click("#post_2 a.post-date"); assert.dom(".share-topic-modal").exists("shows the share modal"); diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-plugin-api-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-plugin-api-test.js index f408f0a15a8..054daf16b8f 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-plugin-api-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-plugin-api-test.js @@ -173,10 +173,13 @@ acceptance("Sidebar - Plugin API", function (needs) { "displays first link with correct title attribute" ); - assert.true( - links[0].href.endsWith("/some-slug/1"), - "link has the correct href attribute" - ); + assert + .dom(links[0]) + .hasAttribute( + "href", + "/t/some-slug/1", + "link has the correct href attribute" + ); assert .dom(links[0].children[0]) diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-categories-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-categories-section-test.js index ee44b489310..cd33f29816e 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-categories-section-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-categories-section-test.js @@ -654,13 +654,13 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) { await visit("/"); - assert.strictEqual( - query( - `.sidebar-section-link-wrapper[data-category-id="${category.id}"] a` - ).title, - category.descriptionText, - "category description without HTML entity is used as the link's title" - ); + assert + .dom(`.sidebar-section-link-wrapper[data-category-id="${category.id}"] a`) + .hasAttribute( + "title", + category.descriptionText, + "category description without HTML entity is used as the link's title" + ); }); test("visiting category discovery new route", async function (assert) { @@ -1211,26 +1211,35 @@ acceptance( await visit("/"); - assert.true( - query( + assert + .dom( `.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( - query( + assert + .dom( `.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( - query( + assert + .dom( `.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) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js index 2ba734d0d01..5b046753ec6 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js @@ -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" ); - assert.strictEqual( - query( + assert + .dom( ".sidebar-section[data-section-name='community'] .sidebar-section-link[data-link-name='faq']" - ).href, - "http://some.faq.url/", - "href attribute is set to custom FAQ URL on the section link" - ); + ) + .hasAttribute( + "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) { @@ -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) { await visit("/"); - assert.strictEqual( - query(".sidebar-section-link[data-link-name='my-posts']").title, - I18n.t("sidebar.sections.community.links.my_posts.title"), - "displays the default title when no drafts are present" - ); + assert + .dom(".sidebar-section-link[data-link-name='my-posts']") + .hasAttribute( + "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}`, { draft_count: 1, }); - assert.strictEqual( - query(".sidebar-section-link[data-link-name='my-posts']").title, - I18n.t("sidebar.sections.community.links.my_posts.title_drafts"), - "displays the draft title when drafts are present" - ); + assert + .dom(".sidebar-section-link[data-link-name='my-posts']") + .hasAttribute( + "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) { @@ -1027,11 +1033,13 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "displays the right text for the link" ); - assert.strictEqual( - query(".sidebar-section-link[data-link-name='unread']").title, - "List of unread topics", - "displays the right title for the link" - ); + assert + .dom(".sidebar-section-link[data-link-name='unread']") + .hasAttribute( + "title", + "List of unread topics", + "displays the right title for the link" + ); assert .dom( @@ -1099,11 +1107,13 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) { "displays the right text for the link" ); - assert.strictEqual( - query(".sidebar-section-link[data-link-name='user-summary']").title, - "eviltrout summary", - "displays the right title for the link" - ); + assert + .dom(".sidebar-section-link[data-link-name='user-summary']") + .hasAttribute( + "title", + "eviltrout summary", + "displays the right title for the link" + ); assert .dom( diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-tags-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-tags-section-test.js index 6746dba296e..5d9027ce365 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-tags-section-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-tags-section-test.js @@ -749,26 +749,29 @@ acceptance( await visit("/"); - assert.true( - query( - '.sidebar-section-link-wrapper[data-tag-name="tag1"] a' - ).href.endsWith("/tag/tag1/l/new"), - "links to the new topics list for the tag because there's 1 new topic" - ); + assert + .dom('.sidebar-section-link-wrapper[data-tag-name="tag1"] a') + .hasAttribute( + "href", + "/tag/tag1/l/new", + "links to the new topics list for the tag because there's 1 new topic" + ); - assert.true( - query( - '.sidebar-section-link-wrapper[data-tag-name="tag2"] a' - ).href.endsWith("/tag/tag2/l/new"), - "links to the new topics list for the tag because there's 1 unread topic" - ); + assert + .dom('.sidebar-section-link-wrapper[data-tag-name="tag2"] a') + .hasAttribute( + "href", + "/tag/tag2/l/new", + "links to the new topics list for the tag because there's 1 unread topic" + ); - assert.true( - query( - '.sidebar-section-link-wrapper[data-tag-name="tag3"] a' - ).href.endsWith("/tag/tag3"), - "links to the latest topics list for the tag because there are no unread or new topics" - ); + assert + .dom('.sidebar-section-link-wrapper[data-tag-name="tag3"] a') + .hasAttribute( + "href", + "/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) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js index d6a1f8b3d02..65cacd35bdd 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-test.js @@ -3,7 +3,6 @@ import { test } from "qunit"; import Sinon from "sinon"; import { acceptance, - query, updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; @@ -212,11 +211,13 @@ acceptance( "has the right accessibility attributes set when sidebar is expanded" ); - assert.strictEqual( - query(".btn-sidebar-toggle").title, - I18n.t("sidebar.title"), - "has the right title attribute when sidebar is expanded" - ); + assert + .dom(".btn-sidebar-toggle") + .hasAttribute( + "title", + I18n.t("sidebar.title"), + "has the right title attribute when sidebar is expanded" + ); await click(".btn-sidebar-toggle"); @@ -228,11 +229,13 @@ acceptance( "has the right accessibility attributes set when sidebar is collapsed" ); - assert.strictEqual( - query(".btn-sidebar-toggle").title, - I18n.t("sidebar.title"), - "has the right title attribute when sidebar is collapsed" - ); + assert + .dom(".btn-sidebar-toggle") + .hasAttribute( + "title", + I18n.t("sidebar.title"), + "has the right title attribute when sidebar is collapsed" + ); }); } ); diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-tracked-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-tracked-test.js index 19caf2bd239..90ba525e438 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-tracked-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-discovery-tracked-test.js @@ -85,25 +85,29 @@ acceptance("Topic Discovery Tracked", function (needs) { "the categories nav item is not displayed when tracked filter is present" ); - assert.ok( - query("#navigation-bar li.unread a").href.endsWith("/unread?f=tracked"), - "unread link has tracked filter" - ); + assert + .dom("#navigation-bar li.unread a") + .hasAttribute( + "href", + "/unread?f=tracked", + "unread link has tracked filter" + ); - assert.ok( - query("#navigation-bar li.new a").href.endsWith("/new?f=tracked"), - "new link has tracked filter" - ); + assert + .dom("#navigation-bar li.new a") + .hasAttribute("href", "/new?f=tracked", "new link has tracked filter"); - assert.ok( - query("#navigation-bar li.hot a").href.endsWith("/hot?f=tracked"), - "hot link has tracked filter" - ); + assert + .dom("#navigation-bar li.hot a") + .hasAttribute("href", "/hot?f=tracked", "hot link has tracked filter"); - assert.ok( - query("#navigation-bar li.latest a").href.endsWith("/latest?f=tracked"), - "latest link has tracked filter" - ); + assert + .dom("#navigation-bar li.latest a") + .hasAttribute( + "href", + "/latest?f=tracked", + "latest link has tracked filter" + ); }); test("visit discovery pages with tracked filter", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-test.js index cae2d615af0..f8624d63a24 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/topic-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/topic-test.js @@ -567,20 +567,24 @@ acceptance("Topic filter replies to post number", function (needs) { test("visit topic", async function (assert) { await visit("/t/-/280"); - assert.equal( - query("#post_3 .show-replies").title, - I18n.t("post.filtered_replies_hint", { count: 3 }), - "it displays the right title for filtering by replies" - ); + assert + .dom("#post_3 .show-replies") + .hasAttribute( + "title", + I18n.t("post.filtered_replies_hint", { count: 3 }), + "displays the right title for filtering by replies" + ); await visit("/"); await visit("/t/-/280?replies_to_post_number=3"); - assert.equal( - query("#post_3 .show-replies").title, - I18n.t("post.view_all_posts"), - "it displays the right title when filtered by replies" - ); + assert + .dom("#post_3 .show-replies") + .hasAttribute( + "title", + I18n.t("post.view_all_posts"), + "displays the right title when filtered by replies" + ); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js index 6637286c0ac..d60b35dc05e 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-drafts-stream-test.js @@ -57,11 +57,8 @@ acceptance("User Drafts", function (needs) { "shows the excerpt" ); - assert.ok( - query(".user-stream-item:nth-child(2) a.avatar-link").href.endsWith( - "/u/eviltrout" - ), - "has correct avatar link" - ); + assert + .dom(".user-stream-item:nth-child(2) a.avatar-link") + .hasAttribute("href", "/u/eviltrout", "has correct avatar link"); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js index 9b47c914996..80ab927f9b2 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-menu-test.js @@ -215,21 +215,21 @@ acceptance("User menu", function (needs) { await visit("/"); await click(".d-header-icons .current-user button"); for (const [key, title] of Object.entries(expectedTitles)) { - assert.strictEqual( - query(`#${key}`).title, - title, - `${key} tab has the right title` - ); + assert + .dom(`#${key}`) + .hasAttribute("title", title, `${key} tab has the right title`); } await publishToMessageBus(`/notification/${loggedInUser().id}`, { unread_high_priority_notifications: 22, }); - assert.strictEqual( - query("#user-menu-button-tiny-tab-1").title, - "Custom title: 22", - "tabs titles can update dynamically" - ); + assert + .dom("#user-menu-button-tiny-tab-1") + .hasAttribute( + "title", + "Custom title: 22", + "tabs titles can update dynamically" + ); }); test("tabs added via the plugin API", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js index 5af4bc27695..7d0d988d802 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js @@ -350,10 +350,9 @@ acceptance( await selectKit(".light-color-scheme .combobox").expand(); await selectKit(".light-color-scheme .combobox").selectRowByValue(3); - assert.ok( - document.querySelector("link#cs-preview-light").href.endsWith("/3.css"), - "correct stylesheet loaded" - ); + assert + .dom("link#cs-preview-light", document.body) + .hasAttribute("href", "3.css", "correct stylesheet loaded"); document.querySelector("link#cs-preview-light").remove(); diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js index ab334350f24..000cae86cf8 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-profile-summary-test.js @@ -107,16 +107,20 @@ acceptance("User Profile - Summary - Stats", function (needs) { await visit("/u/eviltrout/summary"); assert.equal(query(".stats-time-read span").textContent.trim(), "1d"); - assert.equal( - query(".stats-time-read span").title, - I18n.t("user.summary.time_read_title", { duration: "1 day" }) - ); + assert + .dom(".stats-time-read span") + .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").title, - I18n.t("user.summary.recent_time_read_title", { duration: "17 mins" }) - ); + assert + .dom(".stats-recent-read span") + .hasAttribute( + "title", + I18n.t("user.summary.recent_time_read_title", { duration: "17 mins" }) + ); }); }); diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-status-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-status-test.js index a6d6500d140..5b694f33c3c 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-status-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-status-test.js @@ -93,11 +93,9 @@ acceptance("User Status", function (needs) { await visit("/"); await openUserStatusModal(); - assert.equal( - query(`.btn-emoji img.emoji`).title, - userStatusEmoji, - "status emoji is shown" - ); + assert + .dom(".btn-emoji img.emoji") + .hasAttribute("title", userStatusEmoji, "status emoji is shown"); assert.equal( query(".user-status-description").value, userStatus, @@ -278,11 +276,13 @@ acceptance("User Status", function (needs) { await click(".d-modal-cancel"); await openUserStatusModal(); - assert.equal( - query(`.btn-emoji img.emoji`).title, - userStatusEmoji, - "the actual status emoji is shown" - ); + assert + .dom(".btn-emoji img.emoji") + .hasAttribute( + "title", + userStatusEmoji, + "the actual status emoji is shown" + ); assert.equal( query(".user-status-description").value, userStatus, diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-test.js index 1dea60481c6..8911b57d52d 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/user-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/user-test.js @@ -12,7 +12,6 @@ import { acceptance, publishToMessageBus, query, - queryAll, updateCurrentUser, } from "discourse/tests/helpers/qunit-helpers"; import selectKit from "discourse/tests/helpers/select-kit-helper"; @@ -75,11 +74,11 @@ acceptance("User Routes", function (needs) { .dom(document.body) .hasClass("user-notifications-page", "has the body class"); - const $links = queryAll(".notification a"); + const links = [...document.querySelectorAll(".notification a")]; - assert.ok( - $links[2].href.includes("/u/eviltrout/notifications/likes-received") - ); + assert + .dom(links[2]) + .hasAttribute("href", /^\/u\/eviltrout\/notifications\/likes-received/); updateCurrentUser({ moderator: true, admin: false }); diff --git a/app/assets/javascripts/discourse/tests/integration/components/badge-button-test.js b/app/assets/javascripts/discourse/tests/integration/components/badge-button-test.js index 929a9fd295f..54a5a5b1c9b 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/badge-button-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/badge-button-test.js @@ -2,7 +2,6 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { query } from "discourse/tests/helpers/qunit-helpers"; module("Integration | Component | badge-button", function (hooks) { setupRenderingTest(hooks); @@ -36,19 +35,19 @@ module("Integration | Component | badge-button", function (hooks) { await render(hbs``); - assert.strictEqual( - query(".user-badge").title, - "a good run", - "it strips html" - ); + assert + .dom(".user-badge") + .hasAttribute("title", "a good run", "strips html"); this.set("badge", { description: "a bad run" }); - assert.strictEqual( - query(".user-badge").title, - "a bad run", - "it updates title when changing description" - ); + assert + .dom(".user-badge") + .hasAttribute( + "title", + "a bad run", + "updates title when changing description" + ); }); test("icon", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/integration/components/bookmark-icon-test.js b/app/assets/javascripts/discourse/tests/integration/components/bookmark-icon-test.js index f36735feb3c..857ba1cdac9 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/bookmark-icon-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/bookmark-icon-test.js @@ -5,7 +5,6 @@ import { formattedReminderTime } from "discourse/lib/bookmark"; import { tomorrow } from "discourse/lib/time-utils"; import Bookmark from "discourse/models/bookmark"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; -import { query } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; module("Integration | Component | bookmark-icon", function (hooks) { @@ -25,8 +24,8 @@ module("Integration | Component | bookmark-icon", function (hooks) { assert .dom(".d-icon-discourse-bookmark-clock.bookmark-icon__bookmarked") .exists(); - assert.strictEqual( - query(".svg-icon-title").title, + assert.dom(".svg-icon-title").hasAttribute( + "title", I18n.t("bookmarks.created_with_reminder_generic", { date: formattedReminderTime( this.bookmark.reminder_at, @@ -49,8 +48,8 @@ module("Integration | Component | bookmark-icon", function (hooks) { await render(hbs``); assert.dom(".d-icon-bookmark.bookmark-icon__bookmarked").exists(); - assert.strictEqual( - query(".svg-icon-title").title, + assert.dom(".svg-icon-title").hasAttribute( + "title", I18n.t("bookmarks.created_generic", { name: "some name", }) @@ -65,9 +64,8 @@ module("Integration | Component | bookmark-icon", function (hooks) { await render(hbs``); assert.dom(".d-icon-bookmark.bookmark-icon").exists(); - assert.strictEqual( - query(".svg-icon-title").title, - I18n.t("bookmarks.create") - ); + assert + .dom(".svg-icon-title") + .hasAttribute("title", I18n.t("bookmarks.create")); }); }); diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js index 3be06eae156..995e27fa78e 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/bookmarks-list-test.js @@ -29,12 +29,13 @@ module( test("show all button for bookmark notifications", async function (assert) { await render(template); - const link = query(".panel-body-bottom .show-all"); - assert.strictEqual( - link.title, - I18n.t("user_menu.view_all_bookmarks"), - "has the correct title" - ); + assert + .dom(".panel-body-bottom .show-all") + .hasAttribute( + "title", + I18n.t("user_menu.view_all_bookmarks"), + "has the correct title" + ); }); test("dismiss button", async function (assert) { @@ -47,11 +48,13 @@ module( dismiss, "dismiss button is shown if the user has unread bookmark_reminder notifications" ); - assert.strictEqual( - dismiss.title, - I18n.t("user.dismiss_bookmarks_tooltip"), - "dismiss button has a title" - ); + assert + .dom(".panel-body-bottom .notifications-dismiss") + .hasAttribute( + "title", + I18n.t("user.dismiss_bookmarks_tooltip"), + "dismiss button has a title" + ); this.currentUser.set("grouped_unread_notifications", {}); await settled(); diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/likes-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/likes-list-test.js index 3943f277c33..0451c9f8a39 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/likes-list-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/likes-list-test.js @@ -16,17 +16,21 @@ module( pretender.get("/notifications", () => { return response({ notifications: [] }); }); + await render(template); + assert.strictEqual( query(".empty-state-title").textContent.trim(), I18n.t("user.no_likes_title"), "empty state title for the likes tab is shown" ); - const emptyStateBodyLink = query(".empty-state-body a"); - assert.ok( - emptyStateBodyLink.href.endsWith("/my/preferences/notifications"), - "link to /my/preferences/notification inside empty state body is rendered" - ); + assert + .dom(".empty-state-body a") + .hasAttribute( + "href", + "/my/preferences/notifications", + "link to /my/preferences/notification inside empty state body is rendered" + ); }); } ); diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.js index 5f2ed412a69..5b48b4523da 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/menu-item-test.js @@ -124,8 +124,7 @@ module( getNotification(this.currentUser, this.siteSettings, this.site) ); await render(template); - const link = query("li a"); - assert.ok(link.href.endsWith("/t/this-is-fancy-title/449/113")); + assert.dom("li a").hasAttribute("href", "/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) { @@ -143,8 +142,7 @@ module( }) ); await render(template); - const link = query("li a"); - assert.ok(link.href.endsWith("/u/ossaama/messages/grouperss")); + assert.dom("li a").hasAttribute("href", "/u/ossaama/messages/grouperss"); }); 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) ); 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) { @@ -289,16 +289,16 @@ module( .dom("li.additional.classes") .exists("extra classes are included on the item"); - const link = query("li a"); - assert.ok( - link.href.endsWith("/somewhere/awesome"), - "link href is customized" - ); - assert.strictEqual( - link.title, - "hello world this is unsafe '\"", - "link title is customized and rendered safely" - ); + assert + .dom("li a") + .hasAttribute("href", "/somewhere/awesome", "link href is customized"); + assert + .dom("li a") + .hasAttribute( + "title", + "hello world this is unsafe '\"", + "link title is customized and rendered safely" + ); 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) { this.set("item", getBookmark({}, this.siteSettings, this.site)); await render(template); - assert.ok( - query("li.bookmark a").href.endsWith("/t/this-bookmarkable-url/227/1") - ); + assert + .dom("li.bookmark a") + .hasAttribute("href", /\/t\/this-bookmarkable-url\/227\/1$/); }); test("item label is the bookmarked post author", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/messages-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/messages-list-test.js index 39dce29ba1d..f69f96d6d72 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/messages-list-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/messages-list-test.js @@ -255,12 +255,13 @@ module("Integration | Component | user-menu | messages-list", function (hooks) { test("show all button for message notifications", async function (assert) { await render(template); - const link = query(".panel-body-bottom .show-all"); - assert.strictEqual( - link.title, - I18n.t("user_menu.view_all_messages"), - "has the correct title" - ); + assert + .dom(".panel-body-bottom .show-all") + .hasAttribute( + "title", + I18n.t("user_menu.view_all_messages"), + "has the correct title" + ); }); test("dismiss button", async function (assert) { @@ -268,16 +269,19 @@ module("Integration | Component | user-menu | messages-list", function (hooks) { [NOTIFICATION_TYPES.private_message]: 72, }); await render(template); + const dismiss = query(".panel-body-bottom .notifications-dismiss"); assert.ok( dismiss, "dismiss button is shown if the user has unread private_message notifications" ); - assert.strictEqual( - dismiss.title, - I18n.t("user.dismiss_messages_tooltip"), - "dismiss button has a title" - ); + assert + .dom(".panel-body-bottom .notifications-dismiss") + .hasAttribute( + "title", + I18n.t("user.dismiss_messages_tooltip"), + "dismiss button has a title" + ); this.currentUser.set("grouped_unread_notifications", {}); await settled(); @@ -297,7 +301,9 @@ module("Integration | Component | user-menu | messages-list", function (hooks) { read_notifications: [], }); }); + await render(template); + assert.strictEqual( query(".empty-state-title").textContent.trim(), I18n.t("user.no_messages_title"), @@ -306,10 +312,12 @@ module("Integration | Component | user-menu | messages-list", function (hooks) { assert .dom(".empty-state-body svg.d-icon-envelope") .exists("icon is correctly rendered in the empty state body"); - const emptyStateBodyLink = query(".empty-state-body a"); - assert.ok( - emptyStateBodyLink.href.endsWith("/about"), - "link inside empty state body is rendered" - ); + assert + .dom(".empty-state-body a") + .hasAttribute( + "href", + "/about", + "link inside empty state body is rendered" + ); }); }); diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js index 3ab8d53d66b..ae15071207c 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/notifications-list-test.js @@ -67,12 +67,13 @@ module( test("show all button for all notifications page", async function (assert) { await render(template); - const showAllBtn = query(".panel-body-bottom .btn.show-all"); - assert.strictEqual( - showAllBtn.title, - I18n.t("user_menu.view_all_notifications"), - "has the correct title" - ); + assert + .dom(".panel-body-bottom .btn.show-all") + .hasAttribute( + "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) { diff --git a/app/assets/javascripts/discourse/tests/integration/components/user-menu/reviewables-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/user-menu/reviewables-list-test.js index 66c60e69e8e..285abdcfaa2 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/user-menu/reviewables-list-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/user-menu/reviewables-list-test.js @@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers"; import { hbs } from "ember-cli-htmlbars"; import { module, test } from "qunit"; 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"; module( @@ -14,12 +14,13 @@ module( test("show all button for reviewable notifications", async function (assert) { await render(template); - const showAll = query(".panel-body-bottom .show-all"); - assert.strictEqual( - showAll.title, - I18n.t("user_menu.reviewable.view_all"), - "has the correct title" - ); + assert + .dom(".panel-body-bottom .show-all") + .hasAttribute( + "title", + I18n.t("user_menu.reviewable.view_all"), + "has the correct title" + ); }); test("renders a list of reviewables", async function (assert) { diff --git a/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js b/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js index 53b5e7225f6..b7e80144e46 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/category-badge-test.js @@ -31,11 +31,9 @@ module("Unit | Utility | category-badge", function (hooks) { ); const label = tag.children[0]; - assert.strictEqual( - label.title, - "cool description", - "it has the correct title" - ); + assert + .dom(label) + .hasAttribute("title", "cool description", "has the correct title"); assert.strictEqual( label.children[0].innerText, "hello", diff --git a/app/assets/javascripts/discourse/tests/unit/lib/formatter-test.js b/app/assets/javascripts/discourse/tests/unit/lib/formatter-test.js index 4c81a34e3d3..315bfa9fb3a 100644 --- a/app/assets/javascripts/discourse/tests/unit/lib/formatter-test.js +++ b/app/assets/javascripts/discourse/tests/unit/lib/formatter-test.js @@ -125,10 +125,9 @@ module("Unit | Utility | formatter", function (hooks) { shortDateYear(500) ); - assert.strictEqual( - domFromString(formatDays(0, { format: "medium" }))[0].title, - longDate(new Date()) - ); + assert + .dom(domFromString(formatDays(0, { format: "medium" }))[0]) + .hasAttribute("title", longDate(new Date())); assert .dom(domFromString(formatDays(0, { format: "medium" }))[0]) @@ -235,10 +234,10 @@ module("Unit | Utility | formatter", function (hooks) { let elem = domFromString(autoUpdatingRelativeAge(d))[0]; assert.strictEqual(elem.dataset.format, "tiny"); assert.strictEqual(elem.dataset.time, d.getTime().toString()); - assert.strictEqual(elem.title, ""); + assert.dom(elem).doesNotHaveAttribute("title"); elem = domFromString(autoUpdatingRelativeAge(d, { title: true }))[0]; - assert.strictEqual(elem.title, longDate(d)); + assert.dom(elem).hasAttribute("title", longDate(d)); elem = domFromString( autoUpdatingRelativeAge(d, { @@ -250,13 +249,13 @@ module("Unit | Utility | formatter", function (hooks) { assert.strictEqual(elem.dataset.format, "medium-with-ago"); 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"); elem = domFromString(autoUpdatingRelativeAge(d, { format: "medium" }))[0]; assert.strictEqual(elem.dataset.format, "medium"); assert.strictEqual(elem.dataset.time, d.getTime().toString()); - assert.strictEqual(elem.title, ""); + assert.dom(elem).doesNotHaveAttribute("title"); assert.strictEqual(elem.innerHTML, "1 day"); elem = domFromString(autoUpdatingRelativeAge(d, { prefix: "test" }))[0]; diff --git a/plugins/chat/test/javascripts/components/chat-channel-leave-btn-test.js b/plugins/chat/test/javascripts/components/chat-channel-leave-btn-test.js index b85c0d40283..8a53b964f7a 100644 --- a/plugins/chat/test/javascripts/components/chat-channel-leave-btn-test.js +++ b/plugins/chat/test/javascripts/components/chat-channel-leave-btn-test.js @@ -4,7 +4,6 @@ import hbs from "htmlbars-inline-precompile"; import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import pretender from "discourse/tests/helpers/create-pretender"; -import { query } from "discourse/tests/helpers/qunit-helpers"; import I18n from "discourse-i18n"; 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``); - const btn = query(".chat-channel-leave-btn"); - assert.strictEqual(btn.title, I18n.t("chat.direct_messages.leave")); + assert + .dom(".chat-channel-leave-btn") + .hasAttribute("title", I18n.t("chat.direct_messages.leave")); }); 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``); - const btn = query(".chat-channel-leave-btn"); - assert.strictEqual(btn.title, I18n.t("chat.leave")); + assert + .dom(".chat-channel-leave-btn") + .hasAttribute("title", I18n.t("chat.leave")); }); test("is not visible on mobile", async function (assert) { diff --git a/plugins/chat/test/javascripts/components/chat-message-collapser-test.js b/plugins/chat/test/javascripts/components/chat-message-collapser-test.js index ac6e8fe2034..0e75199d28a 100644 --- a/plugins/chat/test/javascripts/components/chat-message-collapser-test.js +++ b/plugins/chat/test/javascripts/components/chat-message-collapser-test.js @@ -76,11 +76,12 @@ module( ); await render(hbs``); - assert.true( - query(".chat-message-collapser-link").href.includes( - "%3Cscript%3Esomeeviltitle%3C/script%3E" - ) - ); + assert + .dom(".chat-message-collapser-link") + .hasProperty( + "href", + "https://www.youtube.com/watch?v=%3Cscript%3Esomeeviltitle%3C/script%3E" + ); }); test("shows youtube link in header", async function (assert) { @@ -91,8 +92,12 @@ module( const link = queryAll(".chat-message-collapser-link"); assert.strictEqual(link.length, 2, "two youtube links rendered"); - assert.strictEqual(link[0].href, "https://www.youtube.com/watch?v=ytId1"); - assert.strictEqual(link[1].href, "https://www.youtube.com/watch?v=ytId2"); + assert + .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) { @@ -249,12 +254,14 @@ module( const links = queryAll("a.chat-message-collapser-link-small"); 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( 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) { @@ -321,10 +328,10 @@ module( const links = queryAll("a.chat-message-collapser-link-small"); 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].href.includes("http://cat2.com")); + assert.dom(links[1]).hasAttribute("href", "http://cat2.com/"); }); test("shows all user written text", async function (assert) { @@ -412,12 +419,14 @@ module( const links = queryAll("a.chat-message-collapser-link-small"); 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( 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) { @@ -499,11 +508,9 @@ module( ); await render(hbs``); - assert.true( - query(".chat-message-collapser-link-small").href.includes( - "%3Cscript%3Esomeeviltitle%3C/script%3E" - ) - ); + assert + .dom(".chat-message-collapser-link-small") + .hasProperty("href", /%3Cscript%3Esomeeviltitle%3C\/script%3E$/); assert.strictEqual( query(".chat-message-collapser-link-small").innerHTML.trim(), "someeviltitle" diff --git a/plugins/chat/test/javascripts/components/chat-upload-test.js b/plugins/chat/test/javascripts/components/chat-upload-test.js index 5c659fb2520..aff72f1a936 100644 --- a/plugins/chat/test/javascripts/components/chat-upload-test.js +++ b/plugins/chat/test/javascripts/components/chat-upload-test.js @@ -131,7 +131,8 @@ module("Discourse Chat | Component | chat-upload", function (hooks) { await render(hbs``); assert.dom("a.chat-other-upload").exists("displays as a link"); - const link = query("a.chat-other-upload"); - assert.strictEqual(link.href, TXT_FIXTURE.url, "has the correct URL"); + assert + .dom("a.chat-other-upload") + .hasAttribute("href", TXT_FIXTURE.url, "has the correct URL"); }); });