DEV: Replace remaining uses of query helper (#30019)

This commit is contained in:
Jarek Radosz
2025-01-22 00:25:03 +01:00
committed by GitHub
parent fbb90aac1b
commit e98644fbc6
55 changed files with 671 additions and 778 deletions

View File

@ -1,8 +1,7 @@
import { render, settled } from "@ember/test-helpers";
import { render, triggerEvent } 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";
const IMAGE_FIXTURE = {
id: 290,
@ -74,23 +73,25 @@ module("Discourse Chat | Component | chat-upload", function (hooks) {
await render(hbs`<ChatUpload @upload={{this.upload}} />`);
assert.dom("img.chat-img-upload").exists("displays as an image");
const image = query("img.chat-img-upload");
assert.strictEqual(image.loading, "lazy", "is lazy loading");
assert
.dom("img.chat-img-upload")
.hasProperty("loading", "lazy", "is lazy loading");
assert.strictEqual(
image.style.backgroundColor,
"rgb(120, 131, 112)",
"sets background to dominant color"
);
assert
.dom("img.chat-img-upload")
.hasStyle(
{ backgroundColor: "rgb(120, 131, 112)" },
"sets background to dominant color"
);
image.dispatchEvent(new Event("load")); // Fake that the image has loaded
await settled();
await triggerEvent("img.chat-img-upload", "load"); // Fake that the image has loaded
assert.strictEqual(
image.style.backgroundColor,
"",
"removes the background color once the image has loaded"
);
assert
.dom("img.chat-img-upload")
.doesNotHaveStyle(
"backgroundColor",
"removes the background color once the image has loaded"
);
});
test("with a video", async function (assert) {