DEV: Convert assert.true(exists()) to qunit-dom (#29638)

This commit is contained in:
Jarek Radosz
2024-11-08 20:27:32 +01:00
committed by GitHub
parent 3a23ff98bc
commit c1916f7984
20 changed files with 101 additions and 120 deletions

View File

@ -47,7 +47,7 @@ acceptance("Composer - Messages", function (needs) {
await triggerKeyEvent(".d-editor-input", "keyup", "Space"); await triggerKeyEvent(".d-editor-input", "keyup", "Space");
assert.true(exists(".composer-popup"), "shows composer warning message"); assert.dom(".composer-popup").exists("shows composer warning message");
assert.true( assert.true(
query(".composer-popup").innerHTML.includes( query(".composer-popup").innerHTML.includes(
@ -101,7 +101,7 @@ acceptance("Composer - Messages - Cannot see group", function (needs) {
); );
await fillIn(".d-editor-input", "Mention @staff"); await fillIn(".d-editor-input", "Mention @staff");
assert.true(exists(".composer-popup"), "shows composer warning message"); assert.dom(".composer-popup").exists("shows composer warning message");
assert.true( assert.true(
query(".composer-popup").innerHTML.includes( query(".composer-popup").innerHTML.includes(
I18n.t("composer.cannot_see_group_mention.not_allowed", { I18n.t("composer.cannot_see_group_mention.not_allowed", {
@ -121,7 +121,7 @@ acceptance("Composer - Messages - Cannot see group", function (needs) {
); );
await fillIn(".d-editor-input", "Mention @staff2"); await fillIn(".d-editor-input", "Mention @staff2");
assert.true(exists(".composer-popup"), "shows composer warning message"); assert.dom(".composer-popup").exists("shows composer warning message");
assert.true( assert.true(
query(".composer-popup").innerHTML.includes( query(".composer-popup").innerHTML.includes(
I18n.t("composer.cannot_see_group_mention.some_not_allowed", { I18n.t("composer.cannot_see_group_mention.some_not_allowed", {
@ -242,7 +242,7 @@ acceptance("Composer - Messages - Private Messages", function (needs) {
await triggerKeyEvent(".d-editor-input", "keyup", "Space"); await triggerKeyEvent(".d-editor-input", "keyup", "Space");
assert.true(exists(".composer-popup"), "shows composer warning message"); assert.dom(".composer-popup").exists("shows composer warning message");
assert.true( assert.true(
query(".composer-popup").innerHTML.includes( query(".composer-popup").innerHTML.includes(
I18n.t("composer.yourself_confirm.title") I18n.t("composer.yourself_confirm.title")

View File

@ -141,10 +141,9 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) {
".sidebar-section[data-section-name='categories'] .sidebar-section-header-button" ".sidebar-section[data-section-name='categories'] .sidebar-section-header-button"
); );
assert.true( assert
exists(".sidebar-categories-form"), .dom(".sidebar-categories-form")
"it shows the categories form modal" .exists("shows the categories form modal");
);
}); });
test("categories section is shown with site's top categories when user has not added any categories and there are no default categories set for the user", async function (assert) { test("categories section is shown with site's top categories when user has not added any categories and there are no default categories set for the user", async function (assert) {

View File

@ -4,7 +4,6 @@ import { click, fillIn, render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars"; import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists } from "discourse/tests/helpers/qunit-helpers";
import widgetHbs from "discourse/widgets/hbs-compiler"; import widgetHbs from "discourse/widgets/hbs-compiler";
import RenderGlimmer, { import RenderGlimmer, {
registerWidgetShim, registerWidgetShim,
@ -169,8 +168,8 @@ module("Integration | Component | Widget | render-glimmer", function (hooks) {
<MountWidget @widget="demo-widget" @args={{hash arg1="val1" dynamicArg=this.dynamicValue}} />` <MountWidget @widget="demo-widget" @args={{hash arg1="val1" dynamicArg=this.dynamicValue}} />`
); );
assert.true(exists("div.my-widget"), "widget is rendered"); assert.dom("div.my-widget").exists("widget is rendered");
assert.true(exists("div.glimmer-content"), "glimmer content is rendered"); assert.dom("div.glimmer-content").exists("glimmer content is rendered");
assert assert
.dom("div.glimmer-content") .dom("div.glimmer-content")
.hasText("arg1=val1 dynamicArg=", "arguments are passed through"); .hasText("arg1=val1 dynamicArg=", "arguments are passed through");
@ -200,9 +199,9 @@ module("Integration | Component | Widget | render-glimmer", function (hooks) {
{{/unless}}` {{/unless}}`
); );
assert.true(exists("div.my-widget"), "widget is rendered"); assert.dom("div.my-widget").exists("widget is rendered");
assert.true(exists("div.glimmer-content"), "glimmer content is rendered"); assert.dom("div.glimmer-content").exists("glimmer content is rendered");
assert.true(exists("div.demo-component"), "demo component is rendered"); assert.dom("div.demo-component").exists("demo component is rendered");
assert.deepEqual( assert.deepEqual(
DemoComponent.eventLog, DemoComponent.eventLog,
@ -261,10 +260,9 @@ module("Integration | Component | Widget | render-glimmer", function (hooks) {
{{/unless}}` {{/unless}}`
); );
assert.true( assert
exists("div.demo-component button"), .dom("div.demo-component button")
"component button is rendered" .exists("component button is rendered");
);
await click("div.demo-component button"); await click("div.demo-component button");
assert.true(DemoWidget.actionTriggered, "widget event is triggered"); assert.true(DemoWidget.actionTriggered, "widget event is triggered");
@ -284,10 +282,9 @@ module("Integration | Component | Widget | render-glimmer", function (hooks) {
.dom(".action-state") .dom(".action-state")
.hasText("false", "eventTriggered is false in nested component"); .hasText("false", "eventTriggered is false in nested component");
assert.true( assert
exists("div.demo-component button"), .dom("div.demo-component button")
"component button is rendered" .exists("component button is rendered");
);
await click("div.demo-component button"); await click("div.demo-component button");
assert.true(DemoWidget.actionTriggered, "widget event is triggered"); assert.true(DemoWidget.actionTriggered, "widget event is triggered");

View File

@ -42,7 +42,7 @@ module("Discourse Chat | Component | <ChannelIcon />", function (hooks) {
await render(<template><ChannelIcon @channel={{channel}} /></template>); await render(<template><ChannelIcon @channel={{channel}} /></template>);
assert.true(exists(".d-icon-lock")); assert.dom(".d-icon-lock").exists();
}); });
test("category channel - not read restricted", async function (assert) { test("category channel - not read restricted", async function (assert) {
@ -67,7 +67,7 @@ module("Discourse Chat | Component | <ChannelIcon />", function (hooks) {
await render(<template><ChannelIcon @channel={{channel}} /></template>); await render(<template><ChannelIcon @channel={{channel}} /></template>);
assert.true(exists(`.chat-user-avatar .avatar[title="${user.username}"]`)); assert.dom(`.chat-user-avatar .avatar[title="${user.username}"]`).exists();
}); });
test("dm channel - multiple users", async function (assert) { test("dm channel - multiple users", async function (assert) {

View File

@ -114,7 +114,7 @@ module("Discourse Chat | Component | <ChannelName />", function (hooks) {
<ChannelName @channel={{channel}} @unreadIndicator={{unreadIndicator}} /> <ChannelName @channel={{channel}} @unreadIndicator={{unreadIndicator}} />
</template>); </template>);
assert.true(exists(".chat-channel-unread-indicator")); assert.dom(".chat-channel-unread-indicator").exists();
unreadIndicator = false; unreadIndicator = false;
await render(<template> await render(<template>

View File

@ -36,14 +36,14 @@ module("Discourse Chat | Component | chat-channel-card", function (hooks) {
this.channel.status = "closed"; this.channel.status = "closed";
await render(hbs`<ChatChannelCard @channel={{this.channel}} />`); await render(hbs`<ChatChannelCard @channel={{this.channel}} />`);
assert.true(exists(".chat-channel-card.--closed")); assert.dom(".chat-channel-card.--closed").exists();
}); });
test("Archived channel", async function (assert) { test("Archived channel", async function (assert) {
this.channel.status = "archived"; this.channel.status = "archived";
await render(hbs`<ChatChannelCard @channel={{this.channel}} />`); await render(hbs`<ChatChannelCard @channel={{this.channel}} />`);
assert.true(exists(".chat-channel-card.--archived")); assert.dom(".chat-channel-card.--archived").exists();
}); });
test("Muted channel", async function (assert) { test("Muted channel", async function (assert) {
@ -51,19 +51,19 @@ module("Discourse Chat | Component | chat-channel-card", function (hooks) {
this.channel.currentUserMembership.following = true; this.channel.currentUserMembership.following = true;
await render(hbs`<ChatChannelCard @channel={{this.channel}} />`); await render(hbs`<ChatChannelCard @channel={{this.channel}} />`);
assert.true(exists(".chat-channel-card__muted")); assert.dom(".chat-channel-card__muted").exists();
}); });
test("Joined channel", async function (assert) { test("Joined channel", async function (assert) {
this.channel.currentUserMembership.following = true; this.channel.currentUserMembership.following = true;
await render(hbs`<ChatChannelCard @channel={{this.channel}} />`); await render(hbs`<ChatChannelCard @channel={{this.channel}} />`);
assert.true(exists(".toggle-channel-membership-button.-leave")); assert.dom(".toggle-channel-membership-button.-leave").exists();
}); });
test("Joinable channel", async function (assert) { test("Joinable channel", async function (assert) {
await render(hbs`<ChatChannelCard @channel={{this.channel}} />`); await render(hbs`<ChatChannelCard @channel={{this.channel}} />`);
assert.true(exists(".chat-channel-card__join-btn")); assert.dom(".chat-channel-card__join-btn").exists();
}); });
test("Memberships count", async function (assert) { test("Memberships count", async function (assert) {
@ -101,6 +101,6 @@ module("Discourse Chat | Component | chat-channel-card", function (hooks) {
test("Read restricted chatable", async function (assert) { test("Read restricted chatable", async function (assert) {
this.channel.chatable.read_restricted = true; this.channel.chatable.read_restricted = true;
await render(hbs`<ChatChannelCard @channel={{this.channel}} />`); await render(hbs`<ChatChannelCard @channel={{this.channel}} />`);
assert.true(exists(".d-icon-lock")); assert.dom(".d-icon-lock").exists();
}); });
}); });

View File

@ -35,10 +35,9 @@ module(
"it shows the channel title" "it shows the channel title"
); );
assert.true( assert
exists(query(".chat-channel-icon.--category-badge")), .dom(".chat-channel-icon.--category-badge")
"it shows the category hashtag badge" .exists("shows the category hashtag badge");
);
}); });
test("channel description", async function (assert) { test("channel description", async function (assert) {
@ -61,28 +60,25 @@ module(
"no line is left for the channel description if there is none" "no line is left for the channel description if there is none"
); );
assert.true( assert
exists(".chat-channel-preview-card.-no-description"), .dom(".chat-channel-preview-card.-no-description")
"it adds a modifier class for styling" .exists("adds a modifier class for styling");
);
}); });
test("join", async function (assert) { test("join", async function (assert) {
await render(hbs`<ChatChannelPreviewCard @channel={{this.channel}} />`); await render(hbs`<ChatChannelPreviewCard @channel={{this.channel}} />`);
assert.true( assert
exists(".toggle-channel-membership-button.-join"), .dom(".toggle-channel-membership-button.-join")
"it shows the join channel button" .exists("shows the join channel button");
);
}); });
test("browse all", async function (assert) { test("browse all", async function (assert) {
await render(hbs`<ChatChannelPreviewCard @channel={{this.channel}} />`); await render(hbs`<ChatChannelPreviewCard @channel={{this.channel}} />`);
assert.true( assert
exists(".chat-channel-preview-card__browse-all"), .dom(".chat-channel-preview-card__browse-all")
"it shows a link to browse all channels" .exists("shows a link to browse all channels");
);
}); });
test("closed channel", async function (assert) { test("closed channel", async function (assert) {

View File

@ -2,7 +2,6 @@ import { click, render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists } from "discourse/tests/helpers/qunit-helpers";
module("Discourse Chat | Component | chat-composer-dropdown", function (hooks) { module("Discourse Chat | Component | chat-composer-dropdown", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -13,9 +12,9 @@ module("Discourse Chat | Component | chat-composer-dropdown", function (hooks) {
await render(hbs`<ChatComposerDropdown @buttons={{this.buttons}} />`); await render(hbs`<ChatComposerDropdown @buttons={{this.buttons}} />`);
await click(".chat-composer-dropdown__trigger-btn"); await click(".chat-composer-dropdown__trigger-btn");
assert.true(exists(".chat-composer-dropdown__item.foo")); assert.dom(".chat-composer-dropdown__item.foo").exists();
assert.true( assert
exists(".chat-composer-dropdown__action-btn.foo .d-icon-xmark") .dom(".chat-composer-dropdown__action-btn.foo .d-icon-xmark")
); .exists();
}); });
}); });

View File

@ -2,7 +2,6 @@ import { click, render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
module("Discourse Chat | Component | chat-composer-upload", function (hooks) { module("Discourse Chat | Component | chat-composer-upload", function (hooks) {
@ -17,7 +16,7 @@ module("Discourse Chat | Component | chat-composer-upload", function (hooks) {
await render(hbs`<ChatComposerUpload @upload={{this.upload}} />`); await render(hbs`<ChatComposerUpload @upload={{this.upload}} />`);
assert.true(exists(".upload-progress[value=50]")); assert.dom(".upload-progress[value='50']").exists();
assert.dom(".uploading").hasText(I18n.t("uploading")); assert.dom(".uploading").hasText(I18n.t("uploading"));
}); });
@ -30,8 +29,8 @@ module("Discourse Chat | Component | chat-composer-upload", function (hooks) {
await render(hbs`<ChatComposerUpload @upload={{this.upload}} />`); await render(hbs`<ChatComposerUpload @upload={{this.upload}} />`);
assert.true(exists(".d-icon-far-image")); assert.dom(".d-icon-far-image").exists();
assert.true(exists(".upload-progress[value=78]")); assert.dom(".upload-progress[value='78']").exists();
assert.dom(".uploading").hasText(I18n.t("uploading")); assert.dom(".uploading").hasText(I18n.t("uploading"));
}); });
@ -59,7 +58,7 @@ module("Discourse Chat | Component | chat-composer-upload", function (hooks) {
hbs`<ChatComposerUpload @isDone={{true}} @upload={{this.upload}} />` hbs`<ChatComposerUpload @isDone={{true}} @upload={{this.upload}} />`
); );
assert.true(exists(".d-icon-file-lines")); assert.dom(".d-icon-file-lines").exists();
assert.dom(".file-name").hasText("some file.pdf"); assert.dom(".file-name").hasText("some file.pdf");
assert.dom(".extension-pill").hasText("pdf"); assert.dom(".extension-pill").hasText("pdf");
}); });
@ -76,7 +75,7 @@ module("Discourse Chat | Component | chat-composer-upload", function (hooks) {
hbs`<ChatComposerUpload @isDone={{true}} @upload={{this.upload}} />` hbs`<ChatComposerUpload @isDone={{true}} @upload={{this.upload}} />`
); );
assert.true(exists("img.preview-img[src='/images/avatar.png']")); assert.dom("img.preview-img[src='/images/avatar.png']").exists();
}); });
test("removing completed upload", async function (assert) { test("removing completed upload", async function (assert) {

View File

@ -2,7 +2,6 @@ import { render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists } from "discourse/tests/helpers/qunit-helpers";
module("Discourse Chat | Component | chat-emoji-avatar", function (hooks) { module("Discourse Chat | Component | chat-emoji-avatar", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -12,10 +11,10 @@ module("Discourse Chat | Component | chat-emoji-avatar", function (hooks) {
await render(hbs`<ChatEmojiAvatar @emoji={{this.emoji}} />`); await render(hbs`<ChatEmojiAvatar @emoji={{this.emoji}} />`);
assert.true( assert
exists( .dom(
`.chat-emoji-avatar .chat-emoji-avatar-container .emoji[title=otter]` ".chat-emoji-avatar .chat-emoji-avatar-container .emoji[title=otter]"
) )
); .exists();
}); });
}); });

View File

@ -3,7 +3,6 @@ import { render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists } from "discourse/tests/helpers/qunit-helpers";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators"; import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
import ChatMessage from "discourse/plugins/chat/discourse/models/chat-message"; import ChatMessage from "discourse/plugins/chat/discourse/models/chat-message";
@ -33,6 +32,6 @@ module("Discourse Chat | Component | chat-message-avatar", function (hooks) {
await render(hbs`<Chat::Message::Avatar @message={{this.message}} />`); await render(hbs`<Chat::Message::Avatar @message={{this.message}} />`);
assert.true(exists('.chat-user-avatar [data-user-card="discobot"]')); assert.dom('.chat-user-avatar [data-user-card="discobot"]').exists();
}); });
}); });

View File

@ -4,7 +4,7 @@ import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit"; import { module, test } from "qunit";
import Bookmark from "discourse/models/bookmark"; import Bookmark from "discourse/models/bookmark";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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 I18n from "discourse-i18n";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators"; import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
import ChatMessage from "discourse/plugins/chat/discourse/models/chat-message"; import ChatMessage from "discourse/plugins/chat/discourse/models/chat-message";
@ -52,7 +52,7 @@ module("Discourse Chat | Component | chat-message-info", function (hooks) {
await render(template); await render(template);
assert.true(exists(".chat-message-info__date")); assert.dom(".chat-message-info__date").exists();
}); });
test("bookmark (with reminder)", async function (assert) { test("bookmark (with reminder)", async function (assert) {
@ -66,9 +66,9 @@ module("Discourse Chat | Component | chat-message-info", function (hooks) {
await render(template); await render(template);
assert.true( assert
exists(".chat-message-info__bookmark .d-icon-discourse-bookmark-clock") .dom(".chat-message-info__bookmark .d-icon-discourse-bookmark-clock")
); .exists();
}); });
test("bookmark (no reminder)", async function (assert) { test("bookmark (no reminder)", async function (assert) {
@ -84,7 +84,7 @@ module("Discourse Chat | Component | chat-message-info", function (hooks) {
await render(template); await render(template);
assert.true(exists(".chat-message-info__bookmark .d-icon-bookmark")); assert.dom(".chat-message-info__bookmark .d-icon-bookmark").exists();
}); });
test("user status", async function (assert) { test("user status", async function (assert) {
@ -95,7 +95,7 @@ module("Discourse Chat | Component | chat-message-info", function (hooks) {
await render(template); await render(template);
assert.true(exists(".chat-message-info__status .user-status-message")); assert.dom(".chat-message-info__status .user-status-message").exists();
}); });
test("flag status", async function (assert) { test("flag status", async function (assert) {

View File

@ -12,13 +12,13 @@ module("Discourse Chat | Component | chat-message-reaction", function (hooks) {
<ChatMessageReaction @reaction={{hash emoji="heart" reacted=true}} /> <ChatMessageReaction @reaction={{hash emoji="heart" reacted=true}} />
`); `);
assert.true(exists(".chat-message-reaction.reacted")); assert.dom(".chat-message-reaction.reacted").exists();
}); });
test("adds reaction name as class", async function (assert) { test("adds reaction name as class", async function (assert) {
await render(hbs`<ChatMessageReaction @reaction={{hash emoji="heart"}} />`); await render(hbs`<ChatMessageReaction @reaction={{hash emoji="heart"}} />`);
assert.true(exists(`.chat-message-reaction[data-emoji-name="heart"]`)); assert.dom(`.chat-message-reaction[data-emoji-name="heart"]`).exists();
}); });
test("title/alt attributes", async function (assert) { test("title/alt attributes", async function (assert) {

View File

@ -4,7 +4,7 @@ import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit"; import { module, test } from "qunit";
import CoreFabricators from "discourse/lib/fabricators"; import CoreFabricators from "discourse/lib/fabricators";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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"; import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
module("Discourse Chat | Component | chat-message", function (hooks) { module("Discourse Chat | Component | chat-message", function (hooks) {
@ -20,7 +20,7 @@ module("Discourse Chat | Component | chat-message", function (hooks) {
}); });
await render(template); await render(template);
assert.true(exists(".chat-message-edited"), "has the correct css class"); assert.dom(".chat-message-edited").exists("has the correct css class");
}); });
test("Deleted message", async function (assert) { test("Deleted message", async function (assert) {
@ -30,10 +30,9 @@ module("Discourse Chat | Component | chat-message", function (hooks) {
}); });
await render(template); await render(template);
assert.true( assert
exists(".chat-message-text.-deleted .chat-message-expand"), .dom(".chat-message-text.-deleted .chat-message-expand")
"has the correct css class and expand button within" .exists("has the correct css class and expand button within");
);
}); });
test("Hidden message", async function (assert) { test("Hidden message", async function (assert) {
@ -42,10 +41,9 @@ module("Discourse Chat | Component | chat-message", function (hooks) {
}); });
await render(template); await render(template);
assert.true( assert
exists(".chat-message-text.-hidden .chat-message-expand"), .dom(".chat-message-text.-hidden .chat-message-expand")
"has the correct css class and expand button within" .exists("has the correct css class and expand button within");
);
}); });
test("Message by a bot", async function (assert) { test("Message by a bot", async function (assert) {
@ -79,10 +77,9 @@ module("Discourse Chat | Component | chat-message", function (hooks) {
}); });
await render(template); await render(template);
assert.true( assert
exists(".chat-message-container.has-reply"), .dom(".chat-message-container.has-reply")
"has the correct css class" .exists("has the correct css class");
);
}); });
test("Message with streaming", async function (assert) { test("Message with streaming", async function (assert) {

View File

@ -16,7 +16,7 @@ module("Discourse Chat | Component | chat-message-text", function (hooks) {
</ChatMessageText> </ChatMessageText>
`); `);
assert.true(exists(".yield-me")); assert.dom(".yield-me").exists();
}); });
test("shows collapsed", async function (assert) { test("shows collapsed", async function (assert) {
@ -29,7 +29,7 @@ module("Discourse Chat | Component | chat-message-text", function (hooks) {
hbs`<ChatMessageText @cooked={{this.cooked}} @uploads={{this.uploads}} />` hbs`<ChatMessageText @cooked={{this.cooked}} @uploads={{this.uploads}} />`
); );
assert.true(exists(".chat-message-collapser")); assert.dom(".chat-message-collapser").exists();
}); });
test("does not collapse a non-image onebox", async function (assert) { test("does not collapse a non-image onebox", async function (assert) {
@ -47,7 +47,7 @@ module("Discourse Chat | Component | chat-message-text", function (hooks) {
hbs`<ChatMessageText @cooked={{this.cooked}} @edited={{true}} />` hbs`<ChatMessageText @cooked={{this.cooked}} @edited={{true}} />`
); );
assert.true(exists(".chat-message-edited")); assert.dom(".chat-message-edited").exists();
}); });
test("shows edits - collapsible message", async function (assert) { test("shows edits - collapsible message", async function (assert) {
@ -60,6 +60,6 @@ module("Discourse Chat | Component | chat-message-text", function (hooks) {
hbs`<ChatMessageText @cooked={{this.cooked}} @edited={{true}} />` hbs`<ChatMessageText @cooked={{this.cooked}} @edited={{true}} />`
); );
assert.true(exists(".chat-message-edited")); assert.dom(".chat-message-edited").exists();
}); });
}); });

View File

@ -2,7 +2,7 @@ import { render, settled } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; 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";
const IMAGE_FIXTURE = { const IMAGE_FIXTURE = {
id: 290, id: 290,
@ -73,7 +73,7 @@ module("Discourse Chat | Component | chat-upload", function (hooks) {
await render(hbs`<ChatUpload @upload={{this.upload}} />`); await render(hbs`<ChatUpload @upload={{this.upload}} />`);
assert.true(exists("img.chat-img-upload"), "displays as an image"); assert.dom("img.chat-img-upload").exists("displays as an image");
const image = query("img.chat-img-upload"); const image = query("img.chat-img-upload");
assert.strictEqual(image.loading, "lazy", "is lazy loading"); assert.strictEqual(image.loading, "lazy", "is lazy loading");
@ -98,7 +98,7 @@ module("Discourse Chat | Component | chat-upload", function (hooks) {
await render(hbs`<ChatUpload @upload={{this.upload}} />`); await render(hbs`<ChatUpload @upload={{this.upload}} />`);
assert.true(exists("video.chat-video-upload"), "displays as an video"); assert.dom("video.chat-video-upload").exists("displays as an video");
assert.dom("video.chat-video-upload").hasAttribute("controls"); assert.dom("video.chat-video-upload").hasAttribute("controls");
assert assert
.dom("video.chat-video-upload") .dom("video.chat-video-upload")
@ -114,7 +114,7 @@ module("Discourse Chat | Component | chat-upload", function (hooks) {
await render(hbs`<ChatUpload @upload={{this.upload}} />`); await render(hbs`<ChatUpload @upload={{this.upload}} />`);
assert.true(exists("audio.chat-audio-upload"), "displays as an audio"); assert.dom("audio.chat-audio-upload").exists("displays as an audio");
assert.dom("audio.chat-audio-upload").hasAttribute("controls"); assert.dom("audio.chat-audio-upload").hasAttribute("controls");
assert assert
.dom("audio.chat-audio-upload") .dom("audio.chat-audio-upload")
@ -130,7 +130,7 @@ module("Discourse Chat | Component | chat-upload", function (hooks) {
await render(hbs`<ChatUpload @upload={{this.upload}} />`); await render(hbs`<ChatUpload @upload={{this.upload}} />`);
assert.true(exists("a.chat-other-upload"), "displays as a link"); assert.dom("a.chat-other-upload").exists("displays as a link");
const link = query("a.chat-other-upload"); const link = query("a.chat-other-upload");
assert.strictEqual(link.href, TXT_FIXTURE.url, "has the correct URL"); assert.strictEqual(link.href, TXT_FIXTURE.url, "has the correct URL");
}); });

View File

@ -3,7 +3,7 @@ import { click, render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile"; import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists, visible } from "discourse/tests/helpers/qunit-helpers"; import { visible } from "discourse/tests/helpers/qunit-helpers";
module("Discourse Chat | Component | collapser", function (hooks) { module("Discourse Chat | Component | collapser", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
@ -13,7 +13,7 @@ module("Discourse Chat | Component | collapser", function (hooks) {
await render(hbs`<Collapser @header={{this.header}} />`); await render(hbs`<Collapser @header={{this.header}} />`);
assert.true(exists(".cat")); assert.dom(".cat").exists();
}); });
test("collapses and expands yielded body", async function (assert) { test("collapses and expands yielded body", async function (assert) {

View File

@ -10,26 +10,26 @@ module("Discourse Chat | Component | dc-filter-input", function (hooks) {
test("Left icon", async function (assert) { test("Left icon", async function (assert) {
await render(hbs`<DcFilterInput @icons={{hash left="bell"}} />`); await render(hbs`<DcFilterInput @icons={{hash left="bell"}} />`);
assert.true(exists(".d-icon-bell.-left")); assert.dom(".d-icon-bell.-left").exists();
}); });
test("Right icon", async function (assert) { test("Right icon", async function (assert) {
await render(hbs`<DcFilterInput @icons={{hash right="bell"}} />`); await render(hbs`<DcFilterInput @icons={{hash right="bell"}} />`);
assert.true(exists(".d-icon-bell.-right")); assert.dom(".d-icon-bell.-right").exists();
}); });
test("containerClass argument", async function (assert) { test("containerClass argument", async function (assert) {
await render(hbs`<DcFilterInput @containerClass="foo" />`); await render(hbs`<DcFilterInput @containerClass="foo" />`);
assert.true(exists(".dc-filter-input-container.foo")); assert.dom(".dc-filter-input-container.foo").exists();
}); });
test("Html attributes", async function (assert) { test("Html attributes", async function (assert) {
await render(hbs`<DcFilterInput data-foo="1" placeholder="bar" />`); await render(hbs`<DcFilterInput data-foo="1" placeholder="bar" />`);
assert.true(exists('.dc-filter-input[data-foo="1"]')); assert.dom('.dc-filter-input[data-foo="1"]').exists();
assert.true(exists('.dc-filter-input[placeholder="bar"]')); assert.dom('.dc-filter-input[placeholder="bar"]').exists();
}); });
test("Filter action", async function (assert) { test("Filter action", async function (assert) {
@ -47,7 +47,7 @@ module("Discourse Chat | Component | dc-filter-input", function (hooks) {
await render(hbs`<DcFilterInput @filterAction={{this.action}} />`); await render(hbs`<DcFilterInput @filterAction={{this.action}} />`);
await triggerEvent(".dc-filter-input", "focusin"); await triggerEvent(".dc-filter-input", "focusin");
assert.true(exists(".dc-filter-input-container.is-focused")); assert.dom(".dc-filter-input-container.is-focused").exists();
await triggerEvent(".dc-filter-input", "focusout"); await triggerEvent(".dc-filter-input", "focusout");

View File

@ -3,7 +3,7 @@ import { hbs } from "ember-cli-htmlbars";
import { module, test } from "qunit"; import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import pretender, { response } from "discourse/tests/helpers/create-pretender"; import pretender, { response } from "discourse/tests/helpers/create-pretender";
import { exists, query } from "discourse/tests/helpers/qunit-helpers"; import { query } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
module( module(
@ -21,7 +21,7 @@ module(
test("empty state when there are no notifications", async function (assert) { test("empty state when there are no notifications", async function (assert) {
await render(template); await render(template);
assert.true(exists(".empty-state .empty-state-body")); assert.dom(".empty-state .empty-state-body").exists();
assert.strictEqual( assert.strictEqual(
query(".empty-state .empty-state-title").textContent.trim(), query(".empty-state .empty-state-title").textContent.trim(),
I18n.t("user_menu.no_chat_notifications_title") I18n.t("user_menu.no_chat_notifications_title")

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import { AUTO_GROUPS } from "discourse/lib/constants"; import { AUTO_GROUPS } from "discourse/lib/constants";
import { import {
acceptance, acceptance,
exists,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
@ -34,24 +33,21 @@ acceptance("Poll Builder - polls are enabled", function (needs) {
await click(pollBuilderButtonSelector); await click(pollBuilderButtonSelector);
assert.true( assert
exists(".poll-type-value-regular.active"), .dom(".poll-type-value-regular.active")
"regular type is active" .exists("regular type is active");
);
await click(".poll-type-value-multiple"); await click(".poll-type-value-multiple");
assert.true( assert
exists(".poll-type-value-multiple.active"), .dom(".poll-type-value-multiple.active")
"multiple type is active" .exists("multiple type is active");
);
await click(".poll-type-value-regular"); await click(".poll-type-value-regular");
assert.true( assert
exists(".poll-type-value-regular.active"), .dom(".poll-type-value-regular.active")
"regular type is active" .exists("regular type is active");
);
}); });
test("regular user - insufficient trust level", async function (assert) { test("regular user - insufficient trust level", async function (assert) {