diff --git a/apps/web/src/components/structures/MatrixChat.test.tsx b/apps/web/src/components/structures/MatrixChat.test.tsx
index 9629f2ab8d..d5eb98a4c7 100644
--- a/apps/web/src/components/structures/MatrixChat.test.tsx
+++ b/apps/web/src/components/structures/MatrixChat.test.tsx
@@ -333,7 +333,10 @@ describe("", () => {
// So then, we start the next test while stuff is still ongoing from the previous test, which messes up the current test.
// There is no obvious event we could wait for which indicates that everything has completed,
// since each test does something different. Instead, we just let real timers and microtasks drain.
- await sleep(200);
+ await act(() => sleep(200));
+
+ // RTL cleanup won't touch roots we render ourselves so clean those up manually
+ await clearAllModals();
});
resetJsDomAfterEach();
@@ -708,13 +711,16 @@ describe("", () => {
action: Action.WillStartClient,
});
// client successfully started
- await waitFor(() =>
- expect(defaultDispatcher.dispatch).toHaveBeenCalledWith({ action: Action.ClientStarted }),
+ // Waiting for login -> startMatrixClient, which can be slow.
+ // Allow more time than the 1s default.
+ await waitFor(
+ () => expect(defaultDispatcher.dispatch).toHaveBeenCalledWith({ action: Action.ClientStarted }),
+ { timeout: 5000 },
);
// set up keys screen is rendered
await expect(screen.findByText("Setting up keys")).resolves.toBeInTheDocument();
- });
+ }, 15000);
it("should persist device language when available", async () => {
await SettingsStore.setValue("language", null, SettingLevel.DEVICE, "en");
@@ -1356,13 +1362,16 @@ describe("", () => {
defaultDispatcher.dispatch({
action: Action.WillStartClient,
});
- await waitFor(() =>
- expect(defaultDispatcher.dispatch).toHaveBeenCalledWith({ action: Action.ClientStarted }),
+ // Waiting for login -> startMatrixClient, which can be slow.
+ // Allow more time than the 1s default.
+ await waitFor(
+ () => expect(defaultDispatcher.dispatch).toHaveBeenCalledWith({ action: Action.ClientStarted }),
+ { timeout: 5000 },
);
// Then we are not allowed in - we are being asked to verify
await screen.findByRole("heading", { name: "Confirm your digital identity", level: 2 });
- });
+ }, 15000);
});
});