diff --git a/test/components/structures/auth/ForgotPassword-test.tsx b/test/components/structures/auth/ForgotPassword-test.tsx index de3558f349..b43e6bea6a 100644 --- a/test/components/structures/auth/ForgotPassword-test.tsx +++ b/test/components/structures/auth/ForgotPassword-test.tsx @@ -16,7 +16,7 @@ limitations under the License. import React from "react"; import { mocked } from "jest-mock"; -import { act, render, RenderResult, screen, waitFor } from "@testing-library/react"; +import { act, render, RenderResult, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { MatrixClient, createClient } from "matrix-js-sdk/src/matrix"; diff --git a/test/components/views/beacon/__snapshots__/DialogSidebar-test.tsx.snap b/test/components/views/beacon/__snapshots__/DialogSidebar-test.tsx.snap index bd6f9656ff..d58df5b7fb 100644 --- a/test/components/views/beacon/__snapshots__/DialogSidebar-test.tsx.snap +++ b/test/components/views/beacon/__snapshots__/DialogSidebar-test.tsx.snap @@ -38,9 +38,7 @@ exports[` renders sidebar correctly with beacons 1`] = ` data-type="round" role="presentation" style="--cpd-avatar-size: 32px;" - > - - + />
diff --git a/test/components/views/dialogs/AccessSecretStorageDialog-test.tsx b/test/components/views/dialogs/AccessSecretStorageDialog-test.tsx index 00b7242d96..3ebd2487fb 100644 --- a/test/components/views/dialogs/AccessSecretStorageDialog-test.tsx +++ b/test/components/views/dialogs/AccessSecretStorageDialog-test.tsx @@ -16,7 +16,7 @@ limitations under the License. import React, { ComponentProps } from "react"; import { SecretStorage, MatrixClient } from "matrix-js-sdk/src/matrix"; -import { act, fireEvent, render, screen } from "@testing-library/react"; +import { act, fireEvent, render, screen, waitFor } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { Mocked } from "jest-mock"; @@ -129,11 +129,13 @@ describe("AccessSecretStorageDialog", () => { expect(screen.getByPlaceholderText("Security Phrase")).toHaveValue(securityKey); await submitDialog(); - expect( - screen.getByText( - "👎 Unable to access secret storage. Please verify that you entered the correct Security Phrase.", - ), - ).toBeInTheDocument(); + await waitFor(() => + expect( + screen.getByText( + "👎 Unable to access secret storage. Please verify that you entered the correct Security Phrase.", + ), + ).toBeInTheDocument(), + ); expect(screen.getByPlaceholderText("Security Phrase")).toHaveFocus(); }); diff --git a/test/components/views/dialogs/SpotlightDialog-test.tsx b/test/components/views/dialogs/SpotlightDialog-test.tsx index f8fe3c00a7..86367b2811 100644 --- a/test/components/views/dialogs/SpotlightDialog-test.tsx +++ b/test/components/views/dialogs/SpotlightDialog-test.tsx @@ -27,7 +27,7 @@ import { } from "matrix-js-sdk/src/matrix"; import { KnownMembership } from "matrix-js-sdk/src/types"; import sanitizeHtml from "sanitize-html"; -import { fireEvent, render, screen } from "@testing-library/react"; +import { fireEvent, render, screen, waitFor } from "@testing-library/react"; import SpotlightDialog from "../../../../src/components/views/dialogs/spotlight/SpotlightDialog"; import { Filter } from "../../../../src/components/views/dialogs/spotlight/Filter"; @@ -201,10 +201,12 @@ describe("Spotlight Dialog", () => { expect(filterChip).toBeInTheDocument(); expect(filterChip.innerHTML).toContain("Public rooms"); - const content = document.querySelector("#mx_SpotlightDialog_content")!; - const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); - expect(options.length).toBe(1); - expect(options[0].innerHTML).toContain(testPublicRoom.name); + await waitFor(() => { + const content = document.querySelector("#mx_SpotlightDialog_content")!; + const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); + expect(options.length).toBe(1); + expect(options[0].innerHTML).toContain(testPublicRoom.name); + }); }); it("with people filter", async () => { @@ -223,10 +225,12 @@ describe("Spotlight Dialog", () => { expect(filterChip).toBeInTheDocument(); expect(filterChip.innerHTML).toContain("People"); - const content = document.querySelector("#mx_SpotlightDialog_content")!; - const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); - expect(options.length).toBeGreaterThanOrEqual(1); - expect(options[0]!.innerHTML).toContain(testPerson.display_name); + await waitFor(() => { + const content = document.querySelector("#mx_SpotlightDialog_content")!; + const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); + expect(options.length).toBeGreaterThanOrEqual(1); + expect(options[0]!.innerHTML).toContain(testPerson.display_name); + }); }); }); @@ -269,10 +273,12 @@ describe("Spotlight Dialog", () => { expect(filterChip).toBeInTheDocument(); expect(filterChip.innerHTML).toContain("Public rooms"); - const content = document.querySelector("#mx_SpotlightDialog_content")!; - const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); - expect(options.length).toBe(1); - expect(options[0]!.innerHTML).toContain(testPublicRoom.name); + await waitFor(() => { + const content = document.querySelector("#mx_SpotlightDialog_content")!; + const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); + expect(options.length).toBe(1); + expect(options[0]!.innerHTML).toContain(testPublicRoom.name); + }); // assert that getVisibleRooms is called without MSC3946 dynamic room predecessors expect(mockedClient.getVisibleRooms).toHaveBeenCalledWith(false); @@ -292,10 +298,12 @@ describe("Spotlight Dialog", () => { expect(filterChip).toBeInTheDocument(); expect(filterChip.innerHTML).toContain("People"); - const content = document.querySelector("#mx_SpotlightDialog_content")!; - const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); - expect(options.length).toBeGreaterThanOrEqual(1); - expect(options[0]!.innerHTML).toContain(testPerson.display_name); + await waitFor(() => { + const content = document.querySelector("#mx_SpotlightDialog_content")!; + const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); + expect(options.length).toBeGreaterThanOrEqual(1); + expect(options[0]!.innerHTML).toContain(testPerson.display_name); + }); }); }); @@ -380,11 +388,13 @@ describe("Spotlight Dialog", () => { jest.advanceTimersByTime(200); await flushPromisesWithFakeTimers(); - const content = document.querySelector("#mx_SpotlightDialog_content")!; - const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); - expect(options.length).toBeGreaterThanOrEqual(2); - expect(options[0]).toHaveTextContent("User Alpha"); - expect(options[1]).toHaveTextContent("User Beta"); + await waitFor(() => { + const content = document.querySelector("#mx_SpotlightDialog_content")!; + const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); + expect(options.length).toBeGreaterThanOrEqual(2); + expect(options[0]).toHaveTextContent("User Alpha"); + expect(options[1]).toHaveTextContent("User Beta"); + }); }); it("should not filter out users sent by the server even if a local suggestion gets filtered out", async () => { @@ -405,11 +415,13 @@ describe("Spotlight Dialog", () => { jest.advanceTimersByTime(200); await flushPromisesWithFakeTimers(); - const content = document.querySelector("#mx_SpotlightDialog_content")!; - const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); - expect(options.length).toBeGreaterThanOrEqual(2); - expect(options[0]).toHaveTextContent(testPerson.display_name!); - expect(options[1]).toHaveTextContent("User Beta"); + await waitFor(() => { + const content = document.querySelector("#mx_SpotlightDialog_content")!; + const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); + expect(options.length).toBeGreaterThanOrEqual(2); + expect(options[0]).toHaveTextContent(testPerson.display_name!); + expect(options[1]).toHaveTextContent("User Beta"); + }); }); it("show non-matching query members with DMs if they are present in the server search results", async () => { @@ -427,11 +439,13 @@ describe("Spotlight Dialog", () => { jest.advanceTimersByTime(200); await flushPromisesWithFakeTimers(); - const content = document.querySelector("#mx_SpotlightDialog_content")!; - const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); - expect(options.length).toBeGreaterThanOrEqual(2); - expect(options[0]).toHaveTextContent(testDMUserId); - expect(options[1]).toHaveTextContent("Bob Wonder"); + await waitFor(() => { + const content = document.querySelector("#mx_SpotlightDialog_content")!; + const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); + expect(options.length).toBeGreaterThanOrEqual(2); + expect(options[0]).toHaveTextContent(testDMUserId); + expect(options[1]).toHaveTextContent("Bob Wonder"); + }); }); it("don't sort the order of users sent by the server", async () => { @@ -449,11 +463,13 @@ describe("Spotlight Dialog", () => { jest.advanceTimersByTime(200); await flushPromisesWithFakeTimers(); - const content = document.querySelector("#mx_SpotlightDialog_content")!; - const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); - expect(options.length).toBeGreaterThanOrEqual(2); - expect(options[0]).toHaveTextContent("User Beta"); - expect(options[1]).toHaveTextContent("User Alpha"); + await waitFor(() => { + const content = document.querySelector("#mx_SpotlightDialog_content")!; + const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); + expect(options.length).toBeGreaterThanOrEqual(2); + expect(options[0]).toHaveTextContent("User Beta"); + expect(options[1]).toHaveTextContent("User Alpha"); + }); }); it("should start a DM when clicking a person", async () => { @@ -468,12 +484,13 @@ describe("Spotlight Dialog", () => { jest.advanceTimersByTime(200); await flushPromisesWithFakeTimers(); - const options = document.querySelectorAll("li.mx_SpotlightDialog_option"); - expect(options.length).toBeGreaterThanOrEqual(1); - expect(options[0]!.innerHTML).toContain(testPerson.display_name); - - fireEvent.click(options[0]!); - expect(startDmOnFirstMessage).toHaveBeenCalledWith(mockedClient, [new DirectoryMember(testPerson)]); + await waitFor(() => { + const options = document.querySelectorAll("li.mx_SpotlightDialog_option"); + expect(options.length).toBeGreaterThanOrEqual(1); + expect(options[0]!.innerHTML).toContain(testPerson.display_name); + fireEvent.click(options[0]!); + expect(startDmOnFirstMessage).toHaveBeenCalledWith(mockedClient, [new DirectoryMember(testPerson)]); + }); }); it("should pass via of the server being explored when joining room from directory", async () => { @@ -489,20 +506,22 @@ describe("Spotlight Dialog", () => { jest.advanceTimersByTime(200); await flushPromisesWithFakeTimers(); - const content = document.querySelector("#mx_SpotlightDialog_content")!; - const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); - expect(options.length).toBe(1); - expect(options[0].innerHTML).toContain(testPublicRoom.name); + await waitFor(() => { + const content = document.querySelector("#mx_SpotlightDialog_content")!; + const options = content.querySelectorAll("li.mx_SpotlightDialog_option"); + expect(options.length).toBe(1); + expect(options[0].innerHTML).toContain(testPublicRoom.name); - fireEvent.click(options[0].querySelector("[role='button']")!); - expect(defaultDispatcher.dispatch).toHaveBeenCalledTimes(1); - expect(defaultDispatcher.dispatch).toHaveBeenCalledWith( - expect.objectContaining({ - action: "view_room", - room_id: testPublicRoom.room_id, - via_servers: ["example.tld"], - }), - ); + fireEvent.click(options[0].querySelector("[role='button']")!); + expect(defaultDispatcher.dispatch).toHaveBeenCalledTimes(1); + expect(defaultDispatcher.dispatch).toHaveBeenCalledWith( + expect.objectContaining({ + action: "view_room", + room_id: testPublicRoom.room_id, + via_servers: ["example.tld"], + }), + ); + }); }); describe("nsfw public rooms filter", () => { @@ -549,9 +568,11 @@ describe("Spotlight Dialog", () => { jest.advanceTimersByTime(200); await flushPromisesWithFakeTimers(); - expect(screen.getByText(potatoRoom.name!)).toBeInTheDocument(); - expect(screen.queryByText(nsfwTopicRoom.name!)).not.toBeInTheDocument(); - expect(screen.queryByText(nsfwTopicRoom.name!)).not.toBeInTheDocument(); + await waitFor(() => { + expect(screen.getByText(potatoRoom.name!)).toBeInTheDocument(); + expect(screen.queryByText(nsfwTopicRoom.name!)).not.toBeInTheDocument(); + expect(screen.queryByText(nsfwTopicRoom.name!)).not.toBeInTheDocument(); + }); }); it("displays rooms with nsfw keywords in results when showNsfwPublicRooms is truthy", async () => { @@ -562,9 +583,11 @@ describe("Spotlight Dialog", () => { jest.advanceTimersByTime(200); await flushPromisesWithFakeTimers(); - expect(screen.getByText(nsfwTopicRoom.name!)).toBeInTheDocument(); - expect(screen.getByText(nsfwNameRoom.name!)).toBeInTheDocument(); - expect(screen.getByText(potatoRoom.name!)).toBeInTheDocument(); + await waitFor(() => { + expect(screen.getByText(nsfwTopicRoom.name!)).toBeInTheDocument(); + expect(screen.getByText(nsfwNameRoom.name!)).toBeInTheDocument(); + expect(screen.getByText(potatoRoom.name!)).toBeInTheDocument(); + }); }); }); @@ -575,7 +598,7 @@ describe("Spotlight Dialog", () => { jest.advanceTimersByTime(200); await flushPromisesWithFakeTimers(); - expect(screen.getByText("Failed to query public rooms")).toBeInTheDocument(); + await waitFor(() => expect(screen.getByText("Failed to query public rooms")).toBeInTheDocument()); }); describe("knock rooms", () => { diff --git a/test/components/views/dialogs/UserSettingsDialog-test.tsx b/test/components/views/dialogs/UserSettingsDialog-test.tsx index 322b7cc944..c01cd3ebac 100644 --- a/test/components/views/dialogs/UserSettingsDialog-test.tsx +++ b/test/components/views/dialogs/UserSettingsDialog-test.tsx @@ -57,14 +57,9 @@ jest.mock("../../../../src/settings/SettingsStore", () => ({ settingIsOveriddenAtConfigLevel: jest.fn(), })); -jest.mock("../../../../src/SdkConfig", () => ({ - get: jest.fn(), -})); - describe("", () => { const userId = "@alice:server.org"; const mockSettingsStore = mocked(SettingsStore); - const mockSdkConfig = mocked(SdkConfig); let mockClient!: MockedObject; let sdkContext: SdkContextClass; @@ -89,7 +84,8 @@ describe("", () => { mockSettingsStore.getValue.mockReturnValue(false); mockSettingsStore.getValueAt.mockReturnValue(false); mockSettingsStore.getFeatureSettingNames.mockReturnValue([]); - mockSdkConfig.get.mockReturnValue({ brand: "Test" }); + SdkConfig.reset(); + SdkConfig.put({ brand: "Test" }); }); const getActiveTabLabel = (container: Element) => @@ -115,6 +111,9 @@ describe("", () => { }); it("renders tabs correctly", () => { + SdkConfig.add({ + show_labs_settings: true, + }); const { container } = render(getComponent()); expect(container.querySelectorAll(".mx_TabbedView_tabLabel")).toMatchSnapshot(); }); @@ -181,7 +180,7 @@ describe("", () => { expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("Settings: Voice & Video"); }); - it("renders with secutity tab selected", () => { + it("renders with security tab selected", () => { const { container } = render(getComponent({ initialTabId: UserTab.Security })); expect(getActiveTabLabel(container)).toEqual("Security & Privacy"); @@ -189,18 +188,8 @@ describe("", () => { }); it("renders with labs tab selected", () => { - // @ts-ignore I give up trying to get the types right here - // why do we have functions that return different things depending on what they're passed? - mockSdkConfig.get.mockImplementation((x) => { - const mockConfig = { show_labs_settings: true, brand: "Test" }; - switch (x) { - case "show_labs_settings": - case "brand": - // @ts-ignore - return mockConfig[x]; - default: - return mockConfig; - } + SdkConfig.add({ + show_labs_settings: true, }); const { container } = render(getComponent({ initialTabId: UserTab.Labs })); @@ -223,8 +212,9 @@ describe("", () => { }); it("renders labs tab when show_labs_settings is enabled in config", () => { - // @ts-ignore simplified test stub - mockSdkConfig.get.mockImplementation((configName) => configName === "show_labs_settings"); + SdkConfig.add({ + show_labs_settings: true, + }); const { getByTestId } = render(getComponent()); expect(getByTestId(`settings-tab-${UserTab.Labs}`)).toBeTruthy(); }); diff --git a/test/components/views/messages/MImageBody-test.tsx b/test/components/views/messages/MImageBody-test.tsx index 3e10c199ef..27ee0c96c0 100644 --- a/test/components/views/messages/MImageBody-test.tsx +++ b/test/components/views/messages/MImageBody-test.tsx @@ -211,7 +211,7 @@ describe("", () => { it("should generate a thumbnail if one isn't included for animated media", async () => { Object.defineProperty(global.Image.prototype, "src", { set(src) { - window.setTimeout(() => this.onload()); + window.setTimeout(() => this.onload?.()); }, }); Object.defineProperty(global.Image.prototype, "height", { diff --git a/test/components/views/rooms/RoomHeader-test.tsx b/test/components/views/rooms/RoomHeader-test.tsx index 06eaaa1837..4ba4f9abee 100644 --- a/test/components/views/rooms/RoomHeader-test.tsx +++ b/test/components/views/rooms/RoomHeader-test.tsx @@ -375,6 +375,7 @@ describe("RoomHeader", () => { jest.spyOn(CallStore.instance, "getCall").mockReturnValue({ widget, on: () => {}, + off: () => {}, } as unknown as Call); jest.spyOn(WidgetStore.instance, "getApps").mockReturnValue([widget]); const { container } = render(, getWrapper()); @@ -393,6 +394,7 @@ describe("RoomHeader", () => { jest.spyOn(CallStore.instance, "getCall").mockReturnValue({ widget, on: () => {}, + off: () => {}, } as unknown as Call); jest.spyOn(WidgetStore.instance, "getApps").mockReturnValue([widget]); diff --git a/test/components/views/rooms/RoomHeader/VideoRoomChatButton-test.tsx b/test/components/views/rooms/RoomHeader/VideoRoomChatButton-test.tsx index daf075ce8e..3a6f863a57 100644 --- a/test/components/views/rooms/RoomHeader/VideoRoomChatButton-test.tsx +++ b/test/components/views/rooms/RoomHeader/VideoRoomChatButton-test.tsx @@ -17,7 +17,7 @@ limitations under the License. import React from "react"; import { MockedObject } from "jest-mock"; import { Room } from "matrix-js-sdk/src/matrix"; -import { fireEvent, render, screen } from "@testing-library/react"; +import { fireEvent, render, screen, waitFor } from "@testing-library/react"; import { VideoRoomChatButton } from "../../../../../src/components/views/rooms/RoomHeader/VideoRoomChatButton"; import { SDKContext, SdkContextClass } from "../../../../../src/contexts/SDKContext"; @@ -94,7 +94,7 @@ describe("", () => { expect(screen.getByLabelText("Chat").hasAttribute("data-indicator")).toBeTruthy(); }); - it("adds unread marker when room notification state changes to unread", () => { + it("adds unread marker when room notification state changes to unread", async () => { const room = makeRoom(); // start in read state const notificationState = mockRoomNotificationState(room, NotificationLevel.None); @@ -108,10 +108,10 @@ describe("", () => { notificationState.emit(NotificationStateEvents.Update); // unread marker - expect(screen.getByLabelText("Chat").hasAttribute("data-indicator")).toBeTruthy(); + await waitFor(() => expect(screen.getByLabelText("Chat").hasAttribute("data-indicator")).toBeTruthy()); }); - it("clears unread marker when room notification state changes to read", () => { + it("clears unread marker when room notification state changes to read", async () => { const room = makeRoom(); // start in unread state const notificationState = mockRoomNotificationState(room, NotificationLevel.Highlight); @@ -125,6 +125,6 @@ describe("", () => { notificationState.emit(NotificationStateEvents.Update); // unread marker cleared - expect(screen.getByLabelText("Chat").hasAttribute("data-indicator")).toBeFalsy(); + await waitFor(() => expect(screen.getByLabelText("Chat").hasAttribute("data-indicator")).toBeFalsy()); }); }); diff --git a/test/components/views/settings/Notifications-test.tsx b/test/components/views/settings/Notifications-test.tsx index 24a23832c1..e966d49732 100644 --- a/test/components/views/settings/Notifications-test.tsx +++ b/test/components/views/settings/Notifications-test.tsx @@ -30,7 +30,16 @@ import { ThreepidMedium, } from "matrix-js-sdk/src/matrix"; import { randomString } from "matrix-js-sdk/src/randomstring"; -import { act, fireEvent, getByTestId, render, screen, waitFor, within } from "@testing-library/react"; +import { + act, + fireEvent, + getByTestId, + render, + screen, + waitFor, + waitForElementToBeRemoved, + within, +} from "@testing-library/react"; import { mocked } from "jest-mock"; import userEvent from "@testing-library/user-event"; @@ -244,7 +253,7 @@ describe("", () => { // get component, wait for async data and force a render const getComponentAndWait = async () => { const component = getComponent(); - await flushPromises(); + await waitForElementToBeRemoved(() => component.queryAllByRole("progressbar")); return component; }; diff --git a/test/components/views/settings/__snapshots__/SecureBackupPanel-test.tsx.snap b/test/components/views/settings/__snapshots__/SecureBackupPanel-test.tsx.snap index 718df62fee..b86b391d72 100644 --- a/test/components/views/settings/__snapshots__/SecureBackupPanel-test.tsx.snap +++ b/test/components/views/settings/__snapshots__/SecureBackupPanel-test.tsx.snap @@ -39,7 +39,6 @@ exports[` handles error fetching backup 1`] = ` not found locally - @@ -75,20 +74,15 @@ exports[` suggests connecting session to key backup when ba Back up your encryption keys with your account data in case you lose access to your sessions. Your keys will be secured with a unique Security Key.
- - This session is - - not backing up your keys - - , but you do have an existing backup you can restore from and add to going forward. - -
-
- Connect this session to key backup before signing out to avoid losing any keys that may only be on this session. +
suggests connecting session to key backup when ba not found locally - @@ -140,54 +133,7 @@ exports[` suggests connecting session to key backup when ba not ready - - - Latest backup version on server: - - - 1 - ( - Algorithm: - - - test - - ) - - - - - Active backup version: - - - None - - - -
-
-
- Connect this session to Key Backup -
-
- Delete Backup -
-
`; diff --git a/test/components/views/settings/devices/DeviceDetailHeading-test.tsx b/test/components/views/settings/devices/DeviceDetailHeading-test.tsx index 966c0a4be8..4cfeb8a052 100644 --- a/test/components/views/settings/devices/DeviceDetailHeading-test.tsx +++ b/test/components/views/settings/devices/DeviceDetailHeading-test.tsx @@ -15,7 +15,7 @@ limitations under the License. */ import React from "react"; -import { fireEvent, render, RenderResult } from "@testing-library/react"; +import { fireEvent, render, RenderResult, waitFor } from "@testing-library/react"; import { DeviceDetailHeading } from "../../../../../src/components/views/settings/devices/DeviceDetailHeading"; import { flushPromisesWithFakeTimers } from "../../../../test-utils"; @@ -118,7 +118,7 @@ describe("", () => { await flushPromisesWithFakeTimers(); // read mode displayed - expect(getByTestId("device-detail-heading")).toBeTruthy(); + await waitFor(() => expect(getByTestId("device-detail-heading")).toBeTruthy()); }); it("displays error when device name fails to save", async () => { @@ -136,7 +136,7 @@ describe("", () => { await flushPromisesWithFakeTimers(); // error message displayed - expect(queryByText("Failed to set session name")).toBeTruthy(); + await waitFor(() => expect(queryByText("Failed to set session name")).toBeTruthy()); // spinner removed expect(container.getElementsByClassName("mx_Spinner").length).toBeFalsy(); diff --git a/test/components/views/settings/devices/FilteredDeviceList-test.tsx b/test/components/views/settings/devices/FilteredDeviceList-test.tsx index c37ea61228..be1ec2aa87 100644 --- a/test/components/views/settings/devices/FilteredDeviceList-test.tsx +++ b/test/components/views/settings/devices/FilteredDeviceList-test.tsx @@ -120,16 +120,15 @@ describe("", () => { }); describe("filtering", () => { - const setFilter = async (container: HTMLElement, option: DeviceSecurityVariation | string) => - await act(async () => { - const dropdown = container.querySelector('[aria-label="Filter devices"]'); + const setFilter = async (container: HTMLElement, option: DeviceSecurityVariation | string) => { + const dropdown = container.querySelector('[aria-label="Filter devices"]'); - fireEvent.click(dropdown as Element); - // tick to let dropdown render - await flushPromises(); + fireEvent.click(dropdown as Element); + // tick to let dropdown render + await flushPromises(); - fireEvent.click(container.querySelector(`#device-list-filter__${option}`) as Element); - }); + fireEvent.click(container.querySelector(`#device-list-filter__${option}`) as Element); + }; it("does not display filter description when filter is falsy", () => { const { container } = render(getComponent({ filter: undefined })); diff --git a/test/components/views/settings/tabs/user/__snapshots__/GeneralUserSettingsTab-test.tsx.snap b/test/components/views/settings/tabs/user/__snapshots__/GeneralUserSettingsTab-test.tsx.snap index 08cd795def..9c2e052e72 100644 --- a/test/components/views/settings/tabs/user/__snapshots__/GeneralUserSettingsTab-test.tsx.snap +++ b/test/components/views/settings/tabs/user/__snapshots__/GeneralUserSettingsTab-test.tsx.snap @@ -42,14 +42,14 @@ exports[` 3pids should display 3pid email addresses an > @@ -150,14 +150,14 @@ exports[` 3pids should display 3pid email addresses an diff --git a/test/components/views/spaces/__snapshots__/ThreadsActivityCentre-test.tsx.snap b/test/components/views/spaces/__snapshots__/ThreadsActivityCentre-test.tsx.snap index 0238347444..a2b3767bd8 100644 --- a/test/components/views/spaces/__snapshots__/ThreadsActivityCentre-test.tsx.snap +++ b/test/components/views/spaces/__snapshots__/ThreadsActivityCentre-test.tsx.snap @@ -2,7 +2,7 @@ exports[`ThreadsActivityCentre renders notifications matching the snapshot 1`] = `