DEV: Convert all uses of exists to qunit-dom (#29667)

This commit is contained in:
Jarek Radosz
2024-11-10 01:30:33 +01:00
committed by GitHub
parent b24c8a41ac
commit de6d575d40
122 changed files with 1285 additions and 1560 deletions

View File

@@ -3,7 +3,7 @@ import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
import CoreFabricators from "discourse/lib/fabricators";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists, query } from "discourse/tests/helpers/qunit-helpers";
import { query } from "discourse/tests/helpers/qunit-helpers";
import ChannelIcon from "discourse/plugins/chat/discourse/components/channel-icon";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
import { CHATABLE_TYPES } from "discourse/plugins/chat/discourse/models/chat-channel";
@@ -30,7 +30,7 @@ module("Discourse Chat | Component | <ChannelIcon />", function (hooks) {
await render(<template><ChannelIcon @channel={{channel}} /></template>);
assert.false(exists(".xss"));
assert.dom(".xss").doesNotExist();
});
test("category channel - read restricted", async function (assert) {
@@ -54,7 +54,7 @@ module("Discourse Chat | Component | <ChannelIcon />", function (hooks) {
await render(<template><ChannelIcon @channel={{channel}} /></template>);
assert.false(exists(".d-icon-lock"));
assert.dom(".d-icon-lock").doesNotExist();
});
test("dm channel - one user", async function (assert) {

View File

@@ -3,7 +3,7 @@ import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
import CoreFabricators from "discourse/lib/fabricators";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists, query } from "discourse/tests/helpers/qunit-helpers";
import { query } from "discourse/tests/helpers/qunit-helpers";
import ChannelName from "discourse/plugins/chat/discourse/components/channel-name";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
import { CHATABLE_TYPES } from "discourse/plugins/chat/discourse/models/chat-channel";
@@ -29,7 +29,7 @@ module("Discourse Chat | Component | <ChannelName />", function (hooks) {
await render(<template><ChannelName @channel={{channel}} /></template>);
assert.false(exists(".xss"));
assert.dom(".xss").doesNotExist();
});
test("dm channel - one user", async function (assert) {
@@ -121,6 +121,6 @@ module("Discourse Chat | Component | <ChannelName />", function (hooks) {
<ChannelName @channel={{channel}} @unreadIndicator={{unreadIndicator}} />
</template>);
assert.false(exists(".chat-channel-unread-indicator"));
assert.dom(".chat-channel-unread-indicator").doesNotExist();
});
});

View File

@@ -3,7 +3,7 @@ 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 { exists, query } from "discourse/tests/helpers/qunit-helpers";
import { query } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
@@ -21,7 +21,7 @@ module("Discourse Chat | Component | chat-channel-card", function (hooks) {
await render(hbs`<ChatChannelCard @channel={{this.channel}} />`);
assert.false(exists(".xss"));
assert.dom(".xss").doesNotExist();
});
test("escapes channel description", async function (assert) {
@@ -29,7 +29,7 @@ module("Discourse Chat | Component | chat-channel-card", function (hooks) {
await render(hbs`<ChatChannelCard @channel={{this.channel}} />`);
assert.false(exists(".xss"));
assert.dom(".xss").doesNotExist();
});
test("Closed channel", async function (assert) {
@@ -80,7 +80,7 @@ module("Discourse Chat | Component | chat-channel-card", function (hooks) {
this.channel.description = null;
await render(hbs`<ChatChannelCard @channel={{this.channel}} />`);
assert.false(exists(".chat-channel-card__description"));
assert.dom(".chat-channel-card__description").doesNotExist();
});
test("Description", async function (assert) {

View File

@@ -3,7 +3,7 @@ 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 { exists, query } from "discourse/tests/helpers/qunit-helpers";
import { query } from "discourse/tests/helpers/qunit-helpers";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
module(
@@ -55,10 +55,11 @@ module(
await render(hbs`<ChatChannelPreviewCard @channel={{this.channel}} />`);
assert.false(
exists(".chat-channel-preview-card__description"),
"no line is left for the channel description if there is none"
);
assert
.dom(".chat-channel-preview-card__description")
.doesNotExist(
"no line is left for the channel description if there is none"
);
assert
.dom(".chat-channel-preview-card.-no-description")
@@ -85,10 +86,9 @@ module(
this.channel.status = "closed";
await render(hbs`<ChatChannelPreviewCard @channel={{this.channel}} />`);
assert.false(
exists(".chat-channel-preview-card__join-channel-btn"),
"it does not show the join channel button"
);
assert
.dom(".chat-channel-preview-card__join-channel-btn")
.doesNotExist("it does not show the join channel button");
});
}
);

View File

@@ -3,11 +3,7 @@ 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 {
count,
createFile,
exists,
} from "discourse/tests/helpers/qunit-helpers";
import { count, createFile } from "discourse/tests/helpers/qunit-helpers";
const fakeUpload = {
type: ".png",
@@ -53,7 +49,7 @@ module("Discourse Chat | Component | chat-composer-uploads", function (hooks) {
`);
assert.strictEqual(count(".chat-composer-upload"), 1);
assert.strictEqual(exists(".chat-composer-upload"), true);
assert.dom(".chat-composer-upload").exists();
});
test("upload starts and completes", async function (assert) {

View File

@@ -2,7 +2,7 @@ import { click, 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 { exists, query } from "discourse/tests/helpers/qunit-helpers";
import { query } from "discourse/tests/helpers/qunit-helpers";
module("Discourse Chat | Component | chat-message-reaction", function (hooks) {
setupRenderingTest(hooks);
@@ -35,7 +35,7 @@ module("Discourse Chat | Component | chat-message-reaction", function (hooks) {
<ChatMessageReaction @reaction={{hash emoji="heart" count=this.count}} />
`);
assert.false(exists(".chat-message-reaction .count"));
assert.dom(".chat-message-reaction .count").doesNotExist();
this.set("count", 2);
assert.dom(".chat-message-reaction .count").hasText("2");
@@ -58,7 +58,7 @@ module("Discourse Chat | Component | chat-message-reaction", function (hooks) {
<ChatMessageReaction class="show" @reaction={{hash emoji="heart" count=this.count}} @onReaction={{this.react}} />
`);
assert.false(exists(".chat-message-reaction .count"));
assert.dom(".chat-message-reaction .count").doesNotExist();
await click(".chat-message-reaction");
assert.dom(".chat-message-reaction .count").hasText("1");

View File

@@ -2,7 +2,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 { exists } from "discourse/tests/helpers/qunit-helpers";
module("Discourse Chat | Component | chat-message-text", function (hooks) {
setupRenderingTest(hooks);
@@ -37,7 +36,7 @@ module("Discourse Chat | Component | chat-message-text", function (hooks) {
await render(hbs`<ChatMessageText @cooked={{this.cooked}} />`);
assert.false(exists(".chat-message-collapser"));
assert.dom(".chat-message-collapser").doesNotExist();
});
test("shows edits - regular message", async function (assert) {

View File

@@ -2,7 +2,6 @@ import { fillIn, 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 { exists } from "discourse/tests/helpers/qunit-helpers";
module("Discourse Chat | Component | dc-filter-input", function (hooks) {
setupRenderingTest(hooks);
@@ -51,6 +50,6 @@ module("Discourse Chat | Component | dc-filter-input", function (hooks) {
await triggerEvent(".dc-filter-input", "focusout");
assert.false(exists(".dc-filter-input-container.is-focused"));
assert.dom(".dc-filter-input-container.is-focused").doesNotExist();
});
});