Skip to content

A platform for community discussion. Free, open, simple.

DEV: Use `waitFor` instead of `waitUntil` (#22803)

Jarek Radosz1de0fa020edb
diff --git a/app/assets/javascripts/discourse/tests/acceptance/d-lightbox-test.js b/app/assets/javascripts/discourse/tests/acceptance/d-lightbox-test.js
index 7c42aac7b8d..a5061fbfc88 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/d-lightbox-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/d-lightbox-test.js
@@ -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) {
diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-narrow-desktop-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-narrow-desktop-test.js
index f344cdf6f7e..fcbb9f2374f 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-narrow-desktop-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-narrow-desktop-test.js
@@ -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");