From 7eb5a29cf0bc070a890799ccaf34556d565cf5eb Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Wed, 30 Jul 2025 21:50:19 +0100 Subject: [PATCH] Hacky fix to the MatrixChat flakiness (#30429) Add a sleep to let these tests clean up. --- .../components/structures/MatrixChat-test.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/unit-tests/components/structures/MatrixChat-test.tsx b/test/unit-tests/components/structures/MatrixChat-test.tsx index 6d8dcec1a7..b33e1b9d45 100644 --- a/test/unit-tests/components/structures/MatrixChat-test.tsx +++ b/test/unit-tests/components/structures/MatrixChat-test.tsx @@ -270,11 +270,17 @@ describe("", () => { // (must be sync otherwise the next test will start before it happens) act(() => defaultDispatcher.dispatch({ action: Action.OnLoggedOut }, true)); - // that will cause the Login to kick off an update in the background, which we need to allow to finish within - // an `act` to avoid warnings - await flushPromises(); - localStorage.clear(); + + // This is a massive hack, but ... + // + // A lot of these tests end up completing while the login flow is still proceeding. So then, we start the next + // test while stuff is still ongoing from the previous test, which messes up the current test (by changing + // localStorage or opening modals, or whatever). + // + // There is no obvious event we could wait for which indicates that everything has completed, since each test + // does something different. Instead... + await act(() => sleep(200)); }); resetJsDomAfterEach();