DEV: Update `visible`/`invisible` uses to qunit-dom (#29672)

This commit is contained in:
Jarek Radosz 2024-11-10 01:41:50 +01:00 committed by GitHub
parent de6d575d40
commit f9e58938ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 196 additions and 261 deletions

View File

@ -1,11 +1,7 @@
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
import DiscoveryFixtures from "discourse/tests/fixtures/discovery-fixtures";
import {
acceptance,
count,
visible,
} from "discourse/tests/helpers/qunit-helpers";
import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
acceptance("Category Banners", function (needs) {
needs.user();
@ -44,22 +40,21 @@ acceptance("Category Banners", function (needs) {
await visit("/c/test-read-only-without-banner");
await click("#create-topic");
assert.ok(!visible(".dialog-body"), "it does not pop up a modal");
assert.ok(
!visible(".category-read-only-banner"),
"it does not show a banner"
);
assert.dom(".dialog-body").doesNotExist("does not pop up a modal");
assert
.dom(".category-read-only-banner")
.doesNotExist("does not show a banner");
});
test("Displays category banners when set", async function (assert) {
await visit("/c/test-read-only-with-banner");
await click("#create-topic");
assert.ok(visible(".dialog-body"), "it pops up a modal");
assert.dom(".dialog-body").exists("pops up a modal");
await click(".dialog-footer .btn-primary");
assert.ok(!visible(".dialog-body"), "it closes the modal");
assert.ok(visible(".category-read-only-banner"), "it shows a banner");
assert.dom(".dialog-body").doesNotExist("closes the modal");
assert.dom(".category-read-only-banner").exists("shows a banner");
assert.strictEqual(
count(".category-read-only-banner .inner"),
1,
@ -91,9 +86,8 @@ acceptance("Anonymous Category Banners", function (needs) {
test("Does not display category banners when set", async function (assert) {
await visit("/c/test-read-only-with-banner");
assert.ok(
!visible(".category-read-only-banner"),
"it does not show a banner"
);
assert
.dom(".category-read-only-banner")
.doesNotExist("does not show a banner");
});
});

View File

@ -7,7 +7,6 @@ import {
acceptance,
count,
query,
visible,
} from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import I18n from "discourse-i18n";
@ -197,7 +196,7 @@ acceptance("Category Edit", function (needs) {
);
await click(".dialog-footer .btn-primary");
assert.ok(!visible(".dialog-body"));
assert.dom(".dialog-body").doesNotExist();
});
test("Nested subcategory error when saving", async function (assert) {
@ -217,33 +216,31 @@ acceptance("Category Edit", function (needs) {
);
await click(".dialog-footer .btn-primary");
assert.ok(!visible(".dialog-body"));
assert.dom(".dialog-body").doesNotExist();
assert.ok(
!visible(".category-breadcrumb .category-drop-header[data-value='1002']"),
"it doesn't show the nested subcategory in the breadcrumb"
);
assert
.dom(".category-breadcrumb .category-drop-header[data-value='1002']")
.doesNotExist("doesn't show the nested subcategory in the breadcrumb");
assert.ok(
!visible(".category-breadcrumb .single-select-header[data-value='1002']"),
"it clears the category chooser"
);
assert
.dom(".category-breadcrumb .single-select-header[data-value='1002']")
.doesNotExist("clears the category chooser");
});
test("Subcategory list settings", async function (assert) {
await visit("/c/bug/edit/settings");
assert.ok(
!visible(".subcategory-list-style-field"),
"subcategory list style isn't visible by default"
);
assert
.dom(".subcategory-list-style-field")
.doesNotExist("subcategory list style isn't visible by default");
await click(".show-subcategory-list-field input[type=checkbox]");
assert.ok(
visible(".subcategory-list-style-field"),
"subcategory list style is shown if show subcategory list is checked"
);
assert
.dom(".subcategory-list-style-field")
.exists(
"subcategory list style is shown if show subcategory list is checked"
);
await visit("/c/bug/edit/general");
@ -255,14 +252,14 @@ acceptance("Category Edit", function (needs) {
await visit("/c/bug/edit/settings");
assert.ok(
!visible(".show-subcategory-list-field"),
"show subcategory list isn't visible for child categories"
);
assert.ok(
!visible(".subcategory-list-style-field"),
"subcategory list style isn't visible for child categories"
);
assert
.dom(".show-subcategory-list-field")
.doesNotExist("show subcategory list isn't visible for child categories");
assert
.dom(".subcategory-list-style-field")
.doesNotExist(
"subcategory list style isn't visible for child categories"
);
});
});

View File

@ -4,9 +4,7 @@ import { withPluginApi } from "discourse/lib/plugin-api";
import {
acceptance,
count,
invisible,
query,
visible,
} from "discourse/tests/helpers/qunit-helpers";
acceptance("Composer - Image Preview", function (needs) {
@ -168,20 +166,24 @@ acceptance("Composer - Image Preview", function (needs) {
await fillIn(".d-editor-input", `![zorro|200x200](upload://zorro.png)`);
assert.equal(query(readonlyAltText).innerText, "zorro", "correct alt text");
assert.ok(visible(readonlyAltText), "alt text is visible");
assert.ok(visible(editAltTextButton), "alt text edit button is visible");
assert.ok(invisible(altTextInput), "alt text input is hidden");
assert.ok(invisible(altTextEditOk), "alt text edit ok button is hidden");
assert.ok(invisible(altTextEditCancel), "alt text edit cancel is hidden");
assert.dom(readonlyAltText).isVisible("alt text is visible");
assert.dom(editAltTextButton).isVisible("alt text edit button is visible");
assert.dom(altTextInput).isNotVisible("alt text input is hidden");
assert.dom(altTextEditOk).isNotVisible("alt text edit ok button is hidden");
assert
.dom(altTextEditCancel)
.isNotVisible("alt text edit cancel is hidden");
await click(editAltTextButton);
assert.ok(invisible(scaleButtonContainer), "scale buttons are hidden");
assert.ok(invisible(readonlyAltText), "alt text is hidden");
assert.ok(invisible(editAltTextButton), "alt text edit button is hidden");
assert.ok(visible(altTextInput), "alt text input is visible");
assert.ok(visible(altTextEditOk), "alt text edit ok button is visible");
assert.ok(visible(altTextEditCancel), "alt text edit cancel is hidden");
assert.dom(scaleButtonContainer).isNotVisible("scale buttons are hidden");
assert.dom(readonlyAltText).isNotVisible("alt text is hidden");
assert
.dom(editAltTextButton)
.isNotVisible("alt text edit button is hidden");
assert.dom(altTextInput).isVisible("alt text input is visible");
assert.dom(altTextEditOk).isVisible("alt text edit ok button is visible");
assert.dom(altTextEditCancel).isVisible("alt text edit cancel is hidden");
assert.equal(
query(altTextInput).value,
"zorro",
@ -205,12 +207,14 @@ acceptance("Composer - Image Preview", function (needs) {
"steak",
"shows the alt text"
);
assert.ok(visible(editAltTextButton), "alt text edit button is visible");
assert.ok(visible(scaleButtonContainer), "scale buttons are visible");
assert.ok(visible(editAltTextButton), "alt text edit button is visible");
assert.ok(invisible(altTextInput), "alt text input is hidden");
assert.ok(invisible(altTextEditOk), "alt text edit ok button is hidden");
assert.ok(invisible(altTextEditCancel), "alt text edit cancel is hidden");
assert.dom(editAltTextButton).isVisible("alt text edit button is visible");
assert.dom(scaleButtonContainer).isVisible("scale buttons are visible");
assert.dom(editAltTextButton).isVisible("alt text edit button is visible");
assert.dom(altTextInput).isNotVisible("alt text input is hidden");
assert.dom(altTextEditOk).isNotVisible("alt text edit ok button is hidden");
assert
.dom(altTextEditCancel)
.isNotVisible("alt text edit cancel is hidden");
});
test("Editing alt text (with check button) in preview updates alt text in composer", async function (assert) {
@ -243,12 +247,14 @@ acceptance("Composer - Image Preview", function (needs) {
"shows the alt text"
);
assert.ok(visible(editAltTextButton), "alt text edit button is visible");
assert.ok(visible(scaleButtonContainer), "scale buttons are visible");
assert.ok(visible(editAltTextButton), "alt text edit button is visible");
assert.ok(invisible(altTextInput), "alt text input is hidden");
assert.ok(invisible(altTextEditOk), "alt text edit ok button is hidden");
assert.ok(invisible(altTextEditCancel), "alt text edit cancel is hidden");
assert.dom(editAltTextButton).isVisible("alt text edit button is visible");
assert.dom(scaleButtonContainer).isVisible("scale buttons are visible");
assert.dom(editAltTextButton).isVisible("alt text edit button is visible");
assert.dom(altTextInput).isNotVisible("alt text input is hidden");
assert.dom(altTextEditOk).isNotVisible("alt text edit ok button is hidden");
assert
.dom(altTextEditCancel)
.isNotVisible("alt text edit cancel is hidden");
});
test("Cancel alt text edit in preview does not update alt text in composer", async function (assert) {
@ -282,12 +288,14 @@ acceptance("Composer - Image Preview", function (needs) {
"shows the unedited alt text"
);
assert.ok(visible(editAltTextButton), "alt text edit button is visible");
assert.ok(visible(scaleButtonContainer), "scale buttons are visible");
assert.ok(visible(editAltTextButton), "alt text edit button is visible");
assert.ok(invisible(altTextInput), "alt text input is hidden");
assert.ok(invisible(altTextEditOk), "alt text edit ok button is hidden");
assert.ok(invisible(altTextEditCancel), "alt text edit cancel is hidden");
assert.dom(editAltTextButton).isVisible("alt text edit button is visible");
assert.dom(scaleButtonContainer).isVisible("scale buttons are visible");
assert.dom(editAltTextButton).isVisible("alt text edit button is visible");
assert.dom(altTextInput).isNotVisible("alt text input is hidden");
assert.dom(altTextEditOk).isNotVisible("alt text edit ok button is hidden");
assert
.dom(altTextEditCancel)
.isNotVisible("alt text edit cancel is hidden");
});
test("Editing alt text for one of two images in preview updates correct alt text in composer", async function (assert) {

View File

@ -1,10 +1,6 @@
import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit";
import {
acceptance,
query,
visible,
} from "discourse/tests/helpers/qunit-helpers";
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
acceptance("Composer - Onebox", function (needs) {
needs.user();
@ -32,7 +28,7 @@ http://www.example.com/has-title.html
`
);
assert.ok(visible(".d-editor-preview"));
assert.dom(".d-editor-preview").exists();
assert.strictEqual(
query(".d-editor-preview").innerHTML.trim(),
`

View File

@ -25,11 +25,9 @@ import pretender, { response } from "discourse/tests/helpers/create-pretender";
import {
acceptance,
count,
invisible,
metaModifier,
query,
updateCurrentUser,
visible,
} from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { cloneJSON } from "discourse-common/lib/object";
@ -279,11 +277,11 @@ acceptance("Composer", function (needs) {
await fillIn("#reply-title", "Internationalization Localization");
await fillIn(".d-editor-input", "enqueue this content please");
await click("#reply-control button.create");
assert.ok(visible(".d-modal"), "it pops up a modal");
assert.dom(".d-modal").exists("pops up a modal");
assert.strictEqual(currentURL(), "/", "it doesn't change routes");
await click(".d-modal__footer button");
assert.ok(invisible(".d-modal"), "the modal can be dismissed");
assert.dom(".d-modal").doesNotExist("the modal can be dismissed");
});
test("Can display a message and route to a URL", async function (assert) {
@ -350,7 +348,7 @@ acceptance("Composer", function (needs) {
await click(".topic-post:nth-of-type(1) button.edit");
await click(".d-modal__footer button.keep-editing");
assert.ok(invisible(".discard-draft-modal.modal"));
assert.dom(".discard-draft-modal.modal").doesNotExist();
assert.strictEqual(
query(".d-editor-input").value,
"this is the content of my reply",
@ -358,9 +356,9 @@ acceptance("Composer", function (needs) {
);
await click(".topic-post:nth-of-type(1) button.edit");
assert.ok(invisible(".d-modal__footer button.save-draft"));
assert.dom(".d-modal__footer button.save-draft").doesNotExist();
await click(".d-modal__footer button.discard-draft");
assert.ok(invisible(".discard-draft-modal.modal"));
assert.dom(".discard-draft-modal.modal").doesNotExist();
assert.strictEqual(
query(".d-editor-input").value,
@ -377,10 +375,10 @@ acceptance("Composer", function (needs) {
await visit("/t/this-is-a-test-topic/9");
await click("#topic-footer-buttons .create");
assert.ok(visible(".discard-draft-modal.modal"));
assert.dom(".discard-draft-modal.modal").exists();
await click(".d-modal__footer button.keep-editing");
assert.ok(invisible(".discard-draft-modal.modal"));
assert.dom(".discard-draft-modal.modal").doesNotExist();
assert.strictEqual(
query(".d-editor-input").value,
@ -403,7 +401,7 @@ acceptance("Composer", function (needs) {
"/t/1-3-0beta9-no-rate-limit-popups/28830"
);
await click("#reply-control button.create");
assert.ok(visible(".reply-where-modal"), "it pops up a modal");
assert.dom(".reply-where-modal").exists("pops up a modal");
await click(".btn-reply-here");
assert
@ -430,7 +428,7 @@ acceptance("Composer", function (needs) {
await click(".d-modal__footer button.keep-editing");
assert.ok(invisible(".discard-draft-modal.modal"), "hides modal");
assert.dom(".discard-draft-modal.modal").doesNotExist("hides modal");
await click("#topic-footer-buttons .btn.create");
assert
.dom(".discard-draft-modal.modal")
@ -473,10 +471,10 @@ acceptance("Composer", function (needs) {
"enqueue this content please",
"it doesn't insert the post"
);
assert.ok(visible(".d-modal"), "it pops up a modal");
assert.dom(".d-modal").exists("pops up a modal");
await click(".d-modal__footer button");
assert.ok(invisible(".d-modal"), "the modal can be dismissed");
assert.dom(".d-modal").doesNotExist("the modal can be dismissed");
assert.dom(".pending-posts .reviewable-item").exists();
});
@ -788,7 +786,7 @@ acceptance("Composer", function (needs) {
assert
.dom(".discard-draft-modal.modal")
.exists("it pops up a confirmation dialog");
assert.ok(invisible(".d-modal__footer button.save-draft"));
assert.dom(".d-modal__footer button.save-draft").doesNotExist();
assert
.dom(".d-modal__footer button.keep-editing")
.hasText(

View File

@ -1,10 +1,6 @@
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
import {
acceptance,
count,
invisible,
} from "discourse/tests/helpers/qunit-helpers";
import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
acceptance("Groups", function () {
test("Browsing Groups", async function (assert) {
@ -28,7 +24,7 @@ acceptance("Groups", function () {
assert.dom(".modal.login-modal").exists("shows the login modal");
await click(".login-modal .modal-close");
assert.ok(invisible(".modal.login-modal"), "it closes the login modal");
assert.dom(".modal.login-modal").doesNotExist("closes the login modal");
await click(".group-index-request");
assert.dom(".modal.login-modal").exists("shows the login modal");

View File

@ -6,7 +6,6 @@ import {
loggedInUser,
publishToMessageBus,
query,
visible,
} from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import I18n from "discourse-i18n";
@ -63,7 +62,7 @@ acceptance("Review", function (needs) {
await reviewableActionDropdown.expand();
await reviewableActionDropdown.selectRowByValue("reject_user_delete");
assert.ok(visible(".reject-reason-reviewable-modal"));
assert.dom(".reject-reason-reviewable-modal").exists();
assert.ok(
query(
".reject-reason-reviewable-modal .d-modal__title"
@ -75,7 +74,7 @@ acceptance("Review", function (needs) {
await reviewableActionDropdown.expand();
await reviewableActionDropdown.selectRowByValue("reject_user_block");
assert.ok(visible(".reject-reason-reviewable-modal"));
assert.dom(".reject-reason-reviewable-modal").exists();
assert.ok(
query(
".reject-reason-reviewable-modal .d-modal__title"

View File

@ -3,7 +3,6 @@ import { test } from "qunit";
import {
acceptance,
count,
invisible,
query,
queryAll,
updateCurrentUser,
@ -118,12 +117,12 @@ acceptance("Tags", function (needs) {
await visit("/tag/test/l/unread");
await click("button.dismiss-read");
await click(".dismiss-read-modal button.btn-primary");
assert.ok(invisible(".dismiss-read-modal"));
assert.dom(".dismiss-read-modal").doesNotExist();
});
test("hide tag notifications menu", async function (assert) {
await visit("/tags/c/faq/4/test");
assert.ok(invisible(".tag-notifications-button"));
assert.dom(".tag-notifications-button").doesNotExist();
});
});

View File

@ -16,7 +16,6 @@ import {
publishToMessageBus,
query,
selectText,
visible,
} from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { withSilencedDeprecations } from "discourse-common/lib/deprecated";
@ -229,16 +228,14 @@ acceptance("Topic", function (needs) {
await visit("/t/internationalization-localization/280");
await click(".topic-post:nth-of-type(1) button.show-more-actions");
await click(".widget-button.delete");
assert.ok(
visible(".delete-topic-confirm-modal"),
"it shows the delete confirmation modal"
);
assert
.dom(".delete-topic-confirm-modal")
.exists("shows the delete confirmation modal");
await click(".delete-topic-confirm-modal .btn-primary");
assert.ok(
!visible(".delete-topic-confirm-modal"),
"it hides the delete confirmation modal"
);
assert
.dom(".delete-topic-confirm-modal")
.doesNotExist("hides the delete confirmation modal");
await click(".widget-button.delete");
await click(".delete-topic-confirm-modal .btn-danger");
await click(".toggle-admin-menu");

View File

@ -6,7 +6,6 @@ import {
count,
normalizeHtml,
query,
visible,
} from "discourse/tests/helpers/qunit-helpers";
acceptance("User Drafts", function (needs) {
@ -17,7 +16,7 @@ acceptance("User Drafts", function (needs) {
assert.strictEqual(count(".user-stream-item"), 3, "has drafts");
await click(".user-stream-item:first-child .remove-draft");
assert.ok(visible(".dialog-body"));
assert.dom(".dialog-body").exists();
await click(".dialog-footer .btn-primary");
assert.strictEqual(
@ -27,7 +26,7 @@ acceptance("User Drafts", function (needs) {
);
await visit("/");
assert.ok(visible("#create-topic"));
assert.dom("#create-topic").exists();
assert
.dom("#create-topic.open-draft")
.doesNotExist("Open Draft button is not present");

View File

@ -1,6 +1,6 @@
import { click, visit } from "@ember/test-helpers";
import { skip } from "qunit";
import { acceptance, visible } from "discourse/tests/helpers/qunit-helpers";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Discourse Chat - Chat live pane collapse", function (needs) {
needs.user({
@ -112,21 +112,21 @@ acceptance("Discourse Chat - Chat live pane collapse", function (needs) {
await visit("/chat/c/cat/1");
assert.ok(visible(videoContainer));
assert.ok(visible(collapseImage), "the open arrow is shown");
assert.dom(expandImage).doesNotExist("the close arrow is hidden");
assert.dom(videoContainer).isVisible();
assert.dom(collapseImage).isVisible("the open arrow is shown");
assert.dom(expandImage).isNotVIsible("the close arrow is hidden");
await click(collapseImage);
assert.dom(videoContainer).isNotVisible();
assert.ok(visible(expandImage), "the close arrow is shown");
assert.dom(collapseImage).doesNotExist("the open arrow is hidden");
assert.dom(expandImage).isVisible("the close arrow is shown");
assert.dom(collapseImage).isNotVIsible("the open arrow is hidden");
await click(expandImage);
assert.ok(visible(videoContainer));
assert.ok(visible(collapseImage), "the open arrow is shown again");
assert.dom(expandImage).doesNotExist("the close arrow is hidden again");
assert.dom(videoContainer).isVisible();
assert.dom(collapseImage).isVisible("the open arrow is shown again");
assert.dom(expandImage).isNotVIsible("the close arrow is hidden again");
});
skip("lightbox shows up before and after expand and collapse", async function (assert) {

View File

@ -2,11 +2,7 @@ import { click, render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import { module, skip, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import {
query,
queryAll,
visible,
} from "discourse/tests/helpers/qunit-helpers";
import { query, queryAll } from "discourse/tests/helpers/qunit-helpers";
const youtubeCooked =
"<p>written text</p>" +
@ -24,16 +20,16 @@ const animatedImageCooked =
const externalImageCooked =
"<p>written text</p>" +
'<p><a href="http://cat1.com" class="onebox"><img src=""></img></a></p>' +
'<p><a href="http://cat1.com" class="onebox"><img src="/images/d-logo-sketch-small.png" width=8" height="8"></img></a></p>' +
"<p>more written text</p>" +
'<p><a href="http://cat2.com" class="onebox"><img src=""></img></a></p>' +
'<p><a href="http://cat2.com" class="onebox"><img src="/images/d-logo-sketch-small.png" width=8" height="8"></img></a></p>' +
"<p>and even more</p>";
const imageCooked =
"<p>written text</p>" +
'<p><img src="/images/avatar.png" alt="shows alt"></p>' +
'<p><img src="/images/avatar.png" alt="shows alt" width="8" height="8"></p>' +
"<p>more written text</p>" +
'<p><img src="/images/d-logo-sketch-small.png" alt=""></p>' +
'<p><img src="/images/d-logo-sketch-small.png" alt="" width="8" height="8"></p>' +
"<p>and even more</p>" +
'<p><img src="/images/d-logo-sketch.png" class="emoji"></p>';
@ -138,19 +134,14 @@ module(
"two youtube previews rendered"
);
await click(
queryAll(".chat-message-collapser-opened")[0],
"close first preview"
);
await click(".chat-message-collapser-opened");
assert.false(
visible(".youtube-onebox[data-video-id='ytId1']"),
"first youtube preview hidden"
);
assert.true(
visible(".youtube-onebox[data-video-id='ytId2']"),
"second youtube preview still visible"
);
assert
.dom(".youtube-onebox[data-video-id='ytId1']")
.isNotVisible("first youtube preview hidden");
assert
.dom(".youtube-onebox[data-video-id='ytId2']")
.isVisible("second youtube preview still visible");
await click(".chat-message-collapser-closed");
@ -160,19 +151,14 @@ module(
"two youtube previews rendered"
);
await click(
queryAll(".chat-message-collapser-opened")[1],
"close second preview"
);
await click(queryAll(".chat-message-collapser-opened")[1]);
assert.true(
visible(".youtube-onebox[data-video-id='ytId1']"),
"first youtube preview still visible"
);
assert.false(
visible(".youtube-onebox[data-video-id='ytId2']"),
"second youtube preview hidden"
);
assert
.dom(".youtube-onebox[data-video-id='ytId1']")
.isVisible("first youtube preview still visible");
assert
.dom(".youtube-onebox[data-video-id='ytId2']")
.isNotVisible("second youtube preview hidden");
await click(".chat-message-collapser-closed");
@ -223,25 +209,29 @@ module(
test("collapses and expands images", async function (assert) {
this.set("cooked", imageTextCooked);
this.set("uploads", [{ original_filename: "tomtom.png" }]);
this.set("uploads", [
{
original_filename: "tomtom.png",
url: "images/d-logo-sketch-small.png",
width: 16,
height: 16,
},
]);
await render(
hbs`<ChatMessageCollapser @cooked={{this.cooked}} @uploads={{this.uploads}} />`
);
const uploads = ".chat-uploads";
const chatImageUpload = ".chat-img-upload";
assert.true(visible(uploads));
assert.true(visible(chatImageUpload));
assert.dom(".chat-uploads").isVisible();
assert.dom(".chat-img-upload").isVisible();
await click(".chat-message-collapser-opened");
assert.false(visible(uploads));
assert.false(visible(chatImageUpload));
assert.dom(".chat-uploads").isNotVisible();
assert.dom(".chat-img-upload").isNotVisible();
await click(".chat-message-collapser-closed");
assert.true(visible(uploads));
assert.true(visible(chatImageUpload));
assert.dom(".chat-uploads").isVisible();
assert.dom(".chat-img-upload").isVisible();
});
}
);
@ -289,37 +279,27 @@ module(
assert.strictEqual(animatedOneboxes.length, 2, "two oneboxes rendered");
await click(
queryAll(".chat-message-collapser-opened")[0],
"close first preview"
);
await click(".chat-message-collapser-opened");
assert.false(
visible(".onebox[src='/images/avatar.png']"),
"first onebox hidden"
);
assert.true(
visible(".onebox[src='/images/d-logo-sketch-small.png']"),
"second onebox still visible"
);
assert
.dom(".onebox[src='/images/avatar.png']")
.isNotVisible("first onebox hidden");
assert
.dom(".onebox[src='/images/d-logo-sketch-small.png']")
.isVisible("second onebox still visible");
await click(".chat-message-collapser-closed");
assert.strictEqual(animatedOneboxes.length, 2, "two oneboxes rendered");
await click(
queryAll(".chat-message-collapser-opened")[1],
"close second preview"
);
await click(queryAll(".chat-message-collapser-opened")[1]);
assert.true(
visible(".onebox[src='/images/avatar.png']"),
"first onebox still visible"
);
assert.false(
visible(".onebox[src='/images/d-logo-sketch-small.png']"),
"second onebox hidden"
);
assert
.dom(".onebox[src='/images/avatar.png']")
.isVisible("first onebox still visible");
assert
.dom(".onebox[src='/images/d-logo-sketch-small.png']")
.isNotVisible("second onebox hidden");
await click(".chat-message-collapser-closed");
@ -369,37 +349,27 @@ module(
assert.strictEqual(imageOneboxes.length, 2, "two oneboxes rendered");
await click(
queryAll(".chat-message-collapser-opened")[0],
"close first preview"
);
await click(".chat-message-collapser-opened");
assert.false(
visible(".onebox[href='http://cat1.com']"),
"first onebox hidden"
);
assert.true(
visible(".onebox[href='http://cat2.com']"),
"second onebox still visible"
);
assert
.dom(".onebox[href='http://cat1.com']")
.isNotVisible("first onebox hidden");
assert
.dom(".onebox[href='http://cat2.com']")
.isVisible("second onebox still visible");
await click(".chat-message-collapser-closed");
assert.strictEqual(imageOneboxes.length, 2, "two oneboxes rendered");
await click(
queryAll(".chat-message-collapser-opened")[1],
"close second preview"
);
await click(queryAll(".chat-message-collapser-opened")[1]);
assert.true(
visible(".onebox[href='http://cat1.com']"),
"first onebox still visible"
);
assert.false(
visible(".onebox[href='http://cat2.com']"),
"second onebox hidden"
);
assert
.dom(".onebox[href='http://cat1.com']")
.isVisible("first onebox still visible");
assert
.dom(".onebox[href='http://cat2.com']")
.isNotVisible("second onebox hidden");
await click(".chat-message-collapser-closed");
@ -472,37 +442,27 @@ module(
assert.strictEqual(images.length, 3);
await click(
queryAll(".chat-message-collapser-opened")[0],
"close first preview"
);
await click(".chat-message-collapser-opened");
assert.false(
visible("img[src='/images/avatar.png']"),
"first image hidden"
);
assert.true(
visible("img[src='/images/d-logo-sketch-small.png']"),
"second image still visible"
);
assert
.dom("img[src='/images/avatar.png']")
.isNotVisible("first image hidden");
assert
.dom("img[src='/images/d-logo-sketch-small.png']")
.isVisible("second image still visible");
await click(".chat-message-collapser-closed");
assert.strictEqual(images.length, 3);
await click(
queryAll(".chat-message-collapser-opened")[1],
"close second preview"
);
await click(queryAll(".chat-message-collapser-opened")[1]);
assert.true(
visible("img[src='/images/avatar.png']"),
"first image still visible"
);
assert.false(
visible("img[src='/images/d-logo-sketch-small.png']"),
"second image hidden"
);
assert
.dom("img[src='/images/avatar.png']")
.isVisible("first image still visible");
assert
.dom("img[src='/images/d-logo-sketch-small.png']")
.isNotVisible("second image hidden");
await click(".chat-message-collapser-closed");
@ -555,7 +515,7 @@ module(
await render(hbs`<ChatMessageCollapser @cooked={{this.cooked}} />`);
assert.false(visible(".album-title"), "album title removed");
assert.dom(".album-title").doesNotExist("album title removed");
});
test("shows gallery link", async function (assert) {
@ -587,16 +547,13 @@ module(
await render(hbs`<ChatMessageCollapser @cooked={{this.cooked}} />`);
assert.true(visible("img"), "image visible initially");
assert.dom("img").isVisible("image visible initially");
await click(
queryAll(".chat-message-collapser-opened")[0],
"close preview"
);
assert.false(visible("img"), "image hidden");
await click(".chat-message-collapser-opened");
assert.dom("img").isNotVisible("image hidden");
await click(".chat-message-collapser-closed");
assert.true(visible("img"), "image visible initially");
assert.dom("img").isVisible("image visible initially");
});
}
);

View File

@ -3,7 +3,6 @@ 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 { visible } from "discourse/tests/helpers/qunit-helpers";
module("Discourse Chat | Component | collapser", function (hooks) {
setupRenderingTest(hooks);
@ -23,16 +22,12 @@ module("Discourse Chat | Component | collapser", function (hooks) {
</Collapser>
`);
const openButton = ".chat-message-collapser-closed";
const closeButton = ".chat-message-collapser-opened";
const body = ".cat";
assert.dom(".cat").isVisible();
assert.true(visible(body));
await click(".chat-message-collapser-opened");
assert.dom(".cat").isNotVisible();
await click(closeButton);
assert.false(visible(body));
await click(openButton);
assert.true(visible(body));
await click(".chat-message-collapser-closed");
assert.dom(".cat").isVisible();
});
});