Skip to content

Commit 32cb854

Browse files
committed
Actually fix the test flake
1 parent 34a8977 commit 32cb854

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/room/GroupCallView.test.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
test,
1414
vi,
1515
} from "vitest";
16-
import { render, waitFor, screen } from "@testing-library/react";
16+
import { render, waitFor, screen, act } from "@testing-library/react";
1717
import { type MatrixClient, JoinRule, type RoomState } from "matrix-js-sdk";
1818
import {
1919
MatrixRTCSessionEvent,
@@ -22,7 +22,7 @@ import {
2222
import { BrowserRouter } from "react-router-dom";
2323
import userEvent from "@testing-library/user-event";
2424
import { type RelationsContainer } from "matrix-js-sdk/lib/models/relations-container";
25-
import { act, useState } from "react";
25+
import { useState } from "react";
2626
import { TooltipProvider } from "@vector-im/compound-web";
2727

2828
import { type MuteStates } from "./MuteStates";
@@ -268,9 +268,12 @@ test("user can reconnect after a membership manager error", async () => {
268268
await act(() =>
269269
rtcSession.emit(MatrixRTCSessionEvent.MembershipManagerError, undefined),
270270
);
271-
await user.click(screen.getByRole("button", { name: "Reconnect" }));
271+
// XXX: Wrapping the following click in act() shouldn't be necessary (the
272+
// async state update should be processed automatically by the waitFor call),
273+
// and yet here we are.
274+
await act(async () =>
275+
user.click(screen.getByRole("button", { name: "Reconnect" })),
276+
);
272277
// In-call controls should be visible again
273-
await waitFor(() => screen.getByRole("button", { name: "Leave" }), {
274-
timeout: 3000,
275-
});
278+
await waitFor(() => screen.getByRole("button", { name: "Leave" }));
276279
});

0 commit comments

Comments
 (0)