@@ -46,9 +46,11 @@ describe("<CallGuestLinkButton />", () => {
46
46
*/
47
47
const makeRoom = ( isVideoRoom = true ) : Room => {
48
48
const room = new Room ( roomId , sdkContext . client ! , sdkContext . client ! . getSafeUserId ( ) ) ;
49
+ sdkContext . client ! . getRoomDirectoryVisibility = jest . fn ( ) . mockResolvedValue ( "public" ) ;
49
50
jest . spyOn ( room , "isElementVideoRoom" ) . mockReturnValue ( isVideoRoom ) ;
50
51
// stub
51
52
jest . spyOn ( room , "getPendingEvents" ) . mockReturnValue ( [ ] ) ;
53
+ jest . spyOn ( room , "getVersion" ) . mockReturnValue ( "9" ) ;
52
54
return room ;
53
55
} ;
54
56
function mockRoomMembers ( room : Room , count : number ) {
@@ -221,32 +223,33 @@ describe("<CallGuestLinkButton />", () => {
221
223
} ) ;
222
224
223
225
it ( "shows ask to join if feature is enabled" , ( ) => {
224
- const { container } = getComponent ( room ) ;
225
- expect ( getByText ( container , "Ask to join" ) ) . toBeInTheDocument ( ) ;
226
+ getComponent ( room ) ;
227
+ expect ( screen . getByRole ( "radio" , { name : "Ask to join ( Recommended )" } ) ) . toBeInTheDocument ( ) ;
226
228
} ) ;
227
- it ( "font show ask to join if feature is enabled but cannot invite" , ( ) => {
229
+ it ( "dont show ask to join if feature is enabled but cannot invite" , ( ) => {
228
230
getComponent ( room , false ) ;
229
- expect ( screen . queryByText ( " Ask to join" ) ) . not . toBeInTheDocument ( ) ;
231
+ expect ( screen . queryByRole ( "radio" , { name : " Ask to join ( Recommended )" } ) ) . not . toBeInTheDocument ( ) ;
230
232
} ) ;
231
233
it ( "doesn't show ask to join if feature is disabled" , ( ) => {
232
234
jest . spyOn ( SettingsStore , "getValue" ) . mockReturnValue ( false ) ;
233
235
getComponent ( room ) ;
234
- expect ( screen . queryByText ( " Ask to join" ) ) . not . toBeInTheDocument ( ) ;
236
+ expect ( screen . queryByRole ( "radio" , { name : " Ask to join ( Recommended )" } ) ) . not . toBeInTheDocument ( ) ;
235
237
} ) ;
236
238
237
239
it ( "sends correct state event on click" , async ( ) => {
238
240
const sendStateSpy = jest . spyOn ( sdkContext . client ! , "sendStateEvent" ) ;
241
+
239
242
let container ;
240
243
container = getComponent ( room ) . container ;
241
- fireEvent . click ( getByText ( container , "Ask to join" ) ) ;
244
+ fireEvent . click ( screen . getByRole ( "radio" , { name : "Ask to join ( Recommended )" } ) ) ;
242
245
expect ( sendStateSpy ) . toHaveBeenCalledWith (
243
246
"!room:server.org" ,
244
247
"m.room.join_rules" ,
245
248
{ join_rule : "knock" } ,
246
249
"" ,
247
250
) ;
248
251
expect ( sendStateSpy ) . toHaveBeenCalledTimes ( 1 ) ;
249
- await waitFor ( ( ) => expect ( onFinished ) . toHaveBeenCalledTimes ( 1 ) ) ;
252
+ await waitFor ( ( ) => expect ( onFinished ) . toHaveBeenCalledTimes ( 1 ) , { timeout : 3000 } ) ;
250
253
onFinished . mockClear ( ) ;
251
254
sendStateSpy . mockClear ( ) ;
252
255
@@ -260,7 +263,7 @@ describe("<CallGuestLinkButton />", () => {
260
263
) ;
261
264
expect ( sendStateSpy ) . toHaveBeenCalledTimes ( 1 ) ;
262
265
container = getComponent ( room ) . container ;
263
- await waitFor ( ( ) => expect ( onFinished ) . toHaveBeenCalledTimes ( 1 ) ) ;
266
+ await waitFor ( ( ) => expect ( onFinished ) . toHaveBeenCalledTimes ( 1 ) , { timeout : 1010 } ) ;
264
267
onFinished . mockClear ( ) ;
265
268
sendStateSpy . mockClear ( ) ;
266
269
0 commit comments