mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 18:52:45 +08:00
DEV: Use waitFor
instead of waitUntil
(#22803)
Short and to the point 😉
This commit is contained in:
parent
a2eb2b0490
commit
1de0fa020e
|
@ -12,7 +12,7 @@ import {
|
|||
triggerEvent,
|
||||
triggerKeyEvent,
|
||||
visit,
|
||||
waitUntil,
|
||||
waitFor,
|
||||
} from "@ember/test-helpers";
|
||||
|
||||
import { cloneJSON } from "discourse-common/lib/object";
|
||||
|
@ -23,12 +23,9 @@ import topicFixtures from "discourse/tests/fixtures/topic";
|
|||
import { SELECTORS } from "discourse/lib/lightbox/constants";
|
||||
|
||||
async function waitForLoad() {
|
||||
return await waitUntil(
|
||||
() => document.querySelector(".d-lightbox.is-finished-loading"),
|
||||
{
|
||||
timeout: 5000,
|
||||
}
|
||||
);
|
||||
return await waitFor(".d-lightbox.is-finished-loading", {
|
||||
timeout: 5000,
|
||||
});
|
||||
}
|
||||
|
||||
const singleLargeImageMarkup = `
|
||||
|
@ -39,14 +36,14 @@ ${generateLightboxMarkup(LIGHTBOX_IMAGE_FIXTURES.smallerThanViewPort)}
|
|||
`;
|
||||
|
||||
const multipleLargeImagesMarkup = `
|
||||
${generateLightboxMarkup(LIGHTBOX_IMAGE_FIXTURES.first)}
|
||||
${generateLightboxMarkup(LIGHTBOX_IMAGE_FIXTURES.second)}
|
||||
${generateLightboxMarkup(LIGHTBOX_IMAGE_FIXTURES.first)}
|
||||
${generateLightboxMarkup(LIGHTBOX_IMAGE_FIXTURES.second)}
|
||||
${generateLightboxMarkup(LIGHTBOX_IMAGE_FIXTURES.third)}
|
||||
`;
|
||||
|
||||
const markupWithInvalidImage = `
|
||||
${generateLightboxMarkup(LIGHTBOX_IMAGE_FIXTURES.first)}
|
||||
${generateLightboxMarkup(LIGHTBOX_IMAGE_FIXTURES.invalidImage)}
|
||||
${generateLightboxMarkup(LIGHTBOX_IMAGE_FIXTURES.first)}
|
||||
${generateLightboxMarkup(LIGHTBOX_IMAGE_FIXTURES.invalidImage)}
|
||||
${generateLightboxMarkup(LIGHTBOX_IMAGE_FIXTURES.second)}`;
|
||||
|
||||
function setupPretender(server, helper, markup) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { test } from "qunit";
|
||||
|
||||
import { click, settled, visit, waitUntil } from "@ember/test-helpers";
|
||||
|
||||
import { click, settled, visit, waitFor } from "@ember/test-helpers";
|
||||
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
acceptance("Sidebar - Narrow Desktop", function (needs) {
|
||||
|
@ -27,12 +25,9 @@ acceptance("Sidebar - Narrow Desktop", function (needs) {
|
|||
const bodyElement = document.querySelector("body");
|
||||
bodyElement.style.width = "767px";
|
||||
|
||||
await waitUntil(
|
||||
() => document.querySelector(".btn-sidebar-toggle.narrow-desktop"),
|
||||
{
|
||||
timeout: 5000,
|
||||
}
|
||||
);
|
||||
await waitFor(".btn-sidebar-toggle.narrow-desktop", {
|
||||
timeout: 5000,
|
||||
});
|
||||
await click(".btn-sidebar-toggle");
|
||||
|
||||
assert.ok(
|
||||
|
@ -47,7 +42,7 @@ acceptance("Sidebar - Narrow Desktop", function (needs) {
|
|||
);
|
||||
|
||||
bodyElement.style.width = "1200px";
|
||||
await waitUntil(() => document.querySelector("#d-sidebar"), {
|
||||
await waitFor("#d-sidebar", {
|
||||
timeout: 5000,
|
||||
});
|
||||
assert.ok(exists("#d-sidebar"), "wide sidebar is displayed");
|
||||
|
@ -62,16 +57,13 @@ acceptance("Sidebar - Narrow Desktop", function (needs) {
|
|||
const bodyElement = document.querySelector("body");
|
||||
bodyElement.style.width = "767px";
|
||||
|
||||
await waitUntil(
|
||||
() => document.querySelector(".btn-sidebar-toggle.narrow-desktop"),
|
||||
{
|
||||
timeout: 5000,
|
||||
}
|
||||
);
|
||||
await waitFor(".btn-sidebar-toggle.narrow-desktop", {
|
||||
timeout: 5000,
|
||||
});
|
||||
await click(".btn-sidebar-toggle");
|
||||
|
||||
bodyElement.style.width = "1200px";
|
||||
await waitUntil(() => document.querySelector("#d-sidebar"), {
|
||||
await waitFor("#d-sidebar", {
|
||||
timeout: 5000,
|
||||
});
|
||||
await click(".header-dropdown-toggle.current-user");
|
||||
|
|
Loading…
Reference in New Issue
Block a user