@@ -13,7 +13,7 @@ import {
13
13
test ,
14
14
vi ,
15
15
} from "vitest" ;
16
- import { render , waitFor , screen } from "@testing-library/react" ;
16
+ import { render , waitFor , screen , act } from "@testing-library/react" ;
17
17
import { type MatrixClient , JoinRule , type RoomState } from "matrix-js-sdk" ;
18
18
import {
19
19
MatrixRTCSessionEvent ,
@@ -22,7 +22,7 @@ import {
22
22
import { BrowserRouter } from "react-router-dom" ;
23
23
import userEvent from "@testing-library/user-event" ;
24
24
import { type RelationsContainer } from "matrix-js-sdk/lib/models/relations-container" ;
25
- import { act , useState } from "react" ;
25
+ import { useState } from "react" ;
26
26
import { TooltipProvider } from "@vector-im/compound-web" ;
27
27
28
28
import { type MuteStates } from "./MuteStates" ;
@@ -268,9 +268,12 @@ test("user can reconnect after a membership manager error", async () => {
268
268
await act ( ( ) =>
269
269
rtcSession . emit ( MatrixRTCSessionEvent . MembershipManagerError , undefined ) ,
270
270
) ;
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
+ ) ;
272
277
// 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" } ) ) ;
276
279
} ) ;
0 commit comments