From 36ea3380644731e890f593e9da547fc3c5b50a56 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Thu, 4 May 2023 11:40:49 +0100 Subject: [PATCH] Add a waitFor in case it fixes flaky SecurityRoomSettingsTab test (#10785) --- .../tabs/room/SecurityRoomSettingsTab-test.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/components/views/settings/tabs/room/SecurityRoomSettingsTab-test.tsx b/test/components/views/settings/tabs/room/SecurityRoomSettingsTab-test.tsx index 2595a8f362..272adf5510 100644 --- a/test/components/views/settings/tabs/room/SecurityRoomSettingsTab-test.tsx +++ b/test/components/views/settings/tabs/room/SecurityRoomSettingsTab-test.tsx @@ -15,7 +15,7 @@ limitations under the License. */ import React from "react"; -import { fireEvent, render, screen, within } from "@testing-library/react"; +import { fireEvent, render, screen, waitFor, within } from "@testing-library/react"; import { EventType, GuestAccess, HistoryVisibility, JoinRule, MatrixEvent, Room } from "matrix-js-sdk/src/matrix"; import { logger } from "matrix-js-sdk/src/logger"; @@ -353,9 +353,11 @@ describe("", () => { expect(within(dialog).getByText("Enable encryption?")).toBeInTheDocument(); fireEvent.click(within(dialog).getByText("OK")); - expect(client.sendStateEvent).toHaveBeenCalledWith(room.roomId, EventType.RoomEncryption, { - algorithm: "m.megolm.v1.aes-sha2", - }); + await waitFor(() => + expect(client.sendStateEvent).toHaveBeenCalledWith(room.roomId, EventType.RoomEncryption, { + algorithm: "m.megolm.v1.aes-sha2", + }), + ); }); it("renders world readable option when room is encrypted and history is already set to world readable", () => {