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

@ -76,11 +76,12 @@ module(
);
await render(hbs`<ChatMessageCollapser @cooked={{this.cooked}} />`);
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`<ChatMessageCollapser @cooked={{this.cooked}} />`);
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"