mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 06:57:43 +08:00
DEV: Use qunit-dom instead of raw href
/title
comparisons (#29678)
This commit is contained in:
@ -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`<ChatChannelLeaveBtn @channel={{this.channel}} />`);
|
||||
|
||||
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`<ChatChannelLeaveBtn @channel={{this.channel}} />`);
|
||||
|
||||
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) {
|
||||
|
@ -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"
|
||||
|
@ -131,7 +131,8 @@ module("Discourse Chat | Component | chat-upload", function (hooks) {
|
||||
await render(hbs`<ChatUpload @upload={{this.upload}} />`);
|
||||
|
||||
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");
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user