From 986be9c00d10c8e568a0d84a980e5d22dc51ef1e Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Mon, 14 Apr 2025 16:22:46 +0200 Subject: [PATCH] Fix flaky MatrixChat tests (#29739) * test: fix flaky MatrixChat `should persist login credentials` test * test: fix flaky MatrixChat `should log and return to welcome page with correct error when login state is not found` test * test: fix flaky MatrixChat `should store clientId and issuer in session storage` test --- test/unit-tests/components/structures/MatrixChat-test.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unit-tests/components/structures/MatrixChat-test.tsx b/test/unit-tests/components/structures/MatrixChat-test.tsx index 709fa9da92..d6db2ce941 100644 --- a/test/unit-tests/components/structures/MatrixChat-test.tsx +++ b/test/unit-tests/components/structures/MatrixChat-test.tsx @@ -321,7 +321,7 @@ describe("", () => { await flushPromises(); const dialog = await screen.findByRole("dialog"); - expect(within(dialog).getByText(errorMessage)).toBeInTheDocument(); + await waitFor(() => expect(within(dialog).getByText(errorMessage)).toBeInTheDocument()); }; beforeEach(() => { @@ -487,17 +487,17 @@ describe("", () => { it("should persist login credentials", async () => { getComponent({ realQueryParams }); - await waitFor(() => expect(localStorage.getItem("mx_hs_url")).toEqual(homeserverUrl)); + await waitFor(() => expect(localStorage.getItem("mx_device_id")).toEqual(deviceId)); + expect(localStorage.getItem("mx_hs_url")).toEqual(homeserverUrl); expect(localStorage.getItem("mx_user_id")).toEqual(userId); expect(localStorage.getItem("mx_has_access_token")).toEqual("true"); - expect(localStorage.getItem("mx_device_id")).toEqual(deviceId); }); it("should store clientId and issuer in session storage", async () => { getComponent({ realQueryParams }); await waitFor(() => expect(localStorage.getItem("mx_oidc_client_id")).toEqual(clientId)); - expect(localStorage.getItem("mx_oidc_token_issuer")).toEqual(issuer); + await waitFor(() => expect(localStorage.getItem("mx_oidc_token_issuer")).toEqual(issuer)); }); it("should set logged in and start MatrixClient", async () => {