Hacky fix to the MatrixChat flakiness (#30429)

Add a sleep to let these tests clean up.
This commit is contained in:
Richard van der Hoff 2025-07-30 21:50:19 +01:00 committed by GitHub
parent 1b38624fd8
commit 7eb5a29cf0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -270,11 +270,17 @@ describe("<MatrixChat />", () => {
// (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();