DEV: Use waitFor instead of waitUntil (#22803)

Short and to the point 😉
This commit is contained in:
Jarek Radosz 2023-07-26 12:59:17 +02:00 committed by GitHub
parent a2eb2b0490
commit 1de0fa020e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 28 deletions

View File

@ -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) {

View File

@ -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");