mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
DEV: Use the new hasHtml
/includesHtml
from qunit-dom (#29680)
This commit is contained in:
@ -53,11 +53,9 @@ module("Discourse Chat | Component | chat message collapser", function (hooks) {
|
||||
this.set("uploads", [{ original_filename: evilString }]);
|
||||
await render(hbs`<ChatMessageCollapser @uploads={{this.uploads}} />`);
|
||||
|
||||
assert.true(
|
||||
query(".chat-message-collapser-link-small").innerHTML.includes(
|
||||
evilStringEscaped
|
||||
)
|
||||
);
|
||||
assert
|
||||
.dom(".chat-message-collapser-link-small")
|
||||
.includesHtml(evilStringEscaped);
|
||||
});
|
||||
});
|
||||
|
||||
@ -399,16 +397,14 @@ module(
|
||||
);
|
||||
await render(hbs`<ChatMessageCollapser @cooked={{this.cooked}} />`);
|
||||
|
||||
assert.true(
|
||||
queryAll(".chat-message-collapser-link-small")[0].innerHTML.includes(
|
||||
evilStringEscaped
|
||||
)
|
||||
);
|
||||
assert.true(
|
||||
queryAll(".chat-message-collapser-link-small")[1].innerHTML.includes(
|
||||
"<script>someeviltitle</script>"
|
||||
)
|
||||
);
|
||||
const links = [
|
||||
...document.querySelectorAll(".chat-message-collapser-link-small"),
|
||||
];
|
||||
|
||||
assert.dom(links[0]).includesHtml(evilStringEscaped);
|
||||
assert
|
||||
.dom(links[1])
|
||||
.includesHtml("<script>someeviltitle</script>");
|
||||
});
|
||||
|
||||
test("shows alt or links (if no alt) for linked image", async function (assert) {
|
||||
@ -511,10 +507,7 @@ module(
|
||||
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"
|
||||
);
|
||||
assert.dom(".chat-message-collapser-link-small").hasHtml("someeviltitle");
|
||||
});
|
||||
|
||||
test("removes album title overlay", async function (assert) {
|
||||
|
@ -4,7 +4,6 @@ import hbs from "htmlbars-inline-precompile";
|
||||
import { module, test } from "qunit";
|
||||
import CoreFabricators from "discourse/lib/fabricators";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
||||
|
||||
module("Discourse Chat | Component | chat-message", function (hooks) {
|
||||
@ -64,11 +63,9 @@ module("Discourse Chat | Component | chat-message", function (hooks) {
|
||||
await this.message.cook();
|
||||
await render(template);
|
||||
|
||||
assert.true(
|
||||
query(".chat-message-text")
|
||||
.innerHTML.trim()
|
||||
.includes("<p>what <mark>test</mark></p>")
|
||||
);
|
||||
assert
|
||||
.dom(".chat-message-text")
|
||||
.includesHtml("<p>what <mark>test</mark></p>");
|
||||
});
|
||||
|
||||
test("Message with reply", async function (assert) {
|
||||
|
@ -3,7 +3,6 @@ import { render } from "@ember/test-helpers";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
||||
|
||||
module(
|
||||
@ -20,11 +19,9 @@ module(
|
||||
hbs`<Chat::Modal::ArchiveChannel @inline={{true}} @model={{hash channel=this.channel}} />`
|
||||
);
|
||||
|
||||
assert.true(
|
||||
query(".chat-modal-archive-channel").innerHTML.includes(
|
||||
"<script>someeviltitle</script>"
|
||||
)
|
||||
);
|
||||
assert
|
||||
.dom(".chat-modal-archive-channel")
|
||||
.includesHtml("<script>someeviltitle</script>");
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -3,7 +3,6 @@ import { render } from "@ember/test-helpers";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
||||
|
||||
module(
|
||||
@ -20,11 +19,9 @@ module(
|
||||
hbs`<Chat::Modal::DeleteChannel @inline={{true}} @model={{hash channel=this.channel}} />`
|
||||
);
|
||||
|
||||
assert.true(
|
||||
query(".chat-modal-delete-channel__instructions").innerHTML.includes(
|
||||
"<script>someeviltitle</script>"
|
||||
)
|
||||
);
|
||||
assert
|
||||
.dom(".chat-modal-delete-channel__instructions")
|
||||
.includesHtml("<script>someeviltitle</script>");
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -3,7 +3,6 @@ import { render } from "@ember/test-helpers";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
||||
|
||||
module(
|
||||
@ -24,11 +23,9 @@ module(
|
||||
/>
|
||||
`);
|
||||
|
||||
assert.true(
|
||||
query(".chat-modal-move-message-to-channel").innerHTML.includes(
|
||||
"<script>someeviltitle</script>"
|
||||
)
|
||||
);
|
||||
assert
|
||||
.dom(".chat-modal-move-message-to-channel")
|
||||
.includesHtml("<script>someeviltitle</script>");
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -3,7 +3,6 @@ import { render } from "@ember/test-helpers";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
||||
|
||||
module("Discourse Chat | Component | chat-thread-header", function (hooks) {
|
||||
@ -17,10 +16,8 @@ module("Discourse Chat | Component | chat-thread-header", function (hooks) {
|
||||
<Chat::Thread::Header @thread={{this.thread}} @channel={{this.thread.channel}} />
|
||||
`);
|
||||
|
||||
assert.ok(
|
||||
query(".c-navbar__title")
|
||||
.innerHTML.trim()
|
||||
.includes("<style>body { background: red;}</style>")
|
||||
);
|
||||
assert
|
||||
.dom(".c-navbar__title")
|
||||
.includesHtml("<style>body { background: red;}</style>");
|
||||
});
|
||||
});
|
||||
|
@ -3,7 +3,6 @@ import { render } from "@ember/test-helpers";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
||||
|
||||
module("Discourse Chat | Component | chat-thread-list-item", function (hooks) {
|
||||
@ -17,9 +16,8 @@ module("Discourse Chat | Component | chat-thread-list-item", function (hooks) {
|
||||
<Chat::ThreadList::Item @thread={{this.thread}} />
|
||||
`);
|
||||
|
||||
assert.equal(
|
||||
query(".chat-thread-list-item__title").innerHTML.trim(),
|
||||
"<style>body { background: red;}</style>"
|
||||
);
|
||||
assert
|
||||
.dom(".chat-thread-list-item__title")
|
||||
.hasHtml("<style>body { background: red;}</style>");
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user