From 9efa458b6805bcb9dbc964abbdb38a5df17f3ee2 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Thu, 5 Oct 2023 04:30:57 +0100 Subject: [PATCH] Unflake JoinRuleSettings test (#11715) * Don't look for 'Updating space' message in joinrulesettings test as it may disappear too quickly for us to see. Fixes https://github.com/vector-im/element-web/issues/25625 * Provide mock function to avoid warning in JoinRuleSettings test --- .../views/settings/JoinRuleSettings-test.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/components/views/settings/JoinRuleSettings-test.tsx b/test/components/views/settings/JoinRuleSettings-test.tsx index 0095bfa03d..636c2ffd95 100644 --- a/test/components/views/settings/JoinRuleSettings-test.tsx +++ b/test/components/views/settings/JoinRuleSettings-test.tsx @@ -15,7 +15,7 @@ limitations under the License. */ import React from "react"; -import { act, fireEvent, render, screen, within } from "@testing-library/react"; +import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react"; import { EventType, GuestAccess, @@ -47,6 +47,7 @@ describe("", () => { const client = getMockClientWithEventEmitter({ ...mockClientMethodsUser(userId), getRoom: jest.fn(), + getDomain: jest.fn(), getLocalAliases: jest.fn().mockReturnValue([]), sendStateEvent: jest.fn(), upgradeRoom: jest.fn(), @@ -225,13 +226,14 @@ describe("", () => { expect(await screen.findByText("Sending invites... (1 out of 2)")).toBeInTheDocument(); deferredInvites.pop()!.resolve({}); - // update spaces - expect(await screen.findByText("Updating space...")).toBeInTheDocument(); + // Usually we see "Updating space..." in the UI here, but we + // removed the assertion about it, because it sometimes fails, + // presumably because it disappeared too quickly to be visible. await flushPromises(); // done, modal closed - expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); + await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument()); }); it(`upgrades room with no parent spaces or members when changing join rule to ${joinRule}`, async () => {