Skip to content

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

DEV: Attempt to resolve flaky chat lightbox test (#38236)

David Taylor37e695796424
diff --git a/frontend/discourse/app/lib/lightbox.js b/frontend/discourse/app/lib/lightbox.js
index 79b53c49b54..51f6ec57c75 100644
--- a/frontend/discourse/app/lib/lightbox.js
+++ b/frontend/discourse/app/lib/lightbox.js
@@ -1,3 +1,4 @@
+import { waitForPromise } from "@ember/test-waiters";
import { isRailsTesting, isTesting } from "discourse/lib/environment";
import { helperContext } from "discourse/lib/helpers";
import { SELECTORS } from "discourse/lib/lightbox/constants";
@@ -19,10 +20,12 @@ export default function lightbox(elem, additionalData = {}) {
return INIT_PROMISES.get(elem);
}
- const promise = initLightbox(elem, additionalData).catch((error) => {
- INIT_PROMISES.delete(elem);
- throw error;
- });
+ const promise = waitForPromise(initLightbox(elem, additionalData)).catch(
+ (error) => {
+ INIT_PROMISES.delete(elem);
+ throw error;
+ }
+ );
INIT_PROMISES.set(elem, promise);
return promise;
diff --git a/plugins/chat/test/javascripts/components/chat-message-collapser-test.gjs b/plugins/chat/test/javascripts/components/chat-message-collapser-test.gjs
index fd580b810c7..f642c8d86ee 100644
--- a/plugins/chat/test/javascripts/components/chat-message-collapser-test.gjs
+++ b/plugins/chat/test/javascripts/components/chat-message-collapser-test.gjs
@@ -1,4 +1,4 @@
-import { click, render, waitFor } from "@ember/test-helpers";
+import { click, render, settled, waitFor } from "@ember/test-helpers";
import { module, skip, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
@@ -284,6 +284,7 @@ module(
height: 16,
},
]);
+ await settled();
await click(".chat-img-upload");
await waitFor(".pswp--open");