@@ -34,6 +34,7 @@ import {
34
34
getByRole ,
35
35
getByText ,
36
36
queryAllByLabelText ,
37
+ queryByLabelText ,
37
38
render ,
38
39
RenderOptions ,
39
40
screen ,
@@ -232,6 +233,28 @@ describe("RoomHeader", () => {
232
233
expect ( setCardSpy ) . toHaveBeenCalledWith ( { phase : RightPanelPhases . NotificationPanel } ) ;
233
234
} ) ;
234
235
236
+ it ( "should show both call buttons in rooms smaller than 3 members" , async ( ) => {
237
+ mockRoomMembers ( room , 2 ) ;
238
+ const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
239
+ expect ( getByLabelText ( container , "Video call" ) ) . toBeInTheDocument ( ) ;
240
+ expect ( getByLabelText ( container , "Voice call" ) ) . toBeInTheDocument ( ) ;
241
+ } ) ;
242
+
243
+ it ( "should not show voice call button in managed hybrid environments" , async ( ) => {
244
+ mockRoomMembers ( room , 2 ) ;
245
+ jest . spyOn ( SdkConfig , "get" ) . mockReturnValue ( { widget_build_url : "https://widget.build.url" } ) ;
246
+ const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
247
+ expect ( getByLabelText ( container , "Video call" ) ) . toBeInTheDocument ( ) ;
248
+ expect ( queryByLabelText ( container , "Voice call" ) ) . not . toBeInTheDocument ( ) ;
249
+ } ) ;
250
+
251
+ it ( "should not show voice call button in rooms larger than 2 members" , async ( ) => {
252
+ mockRoomMembers ( room , 3 ) ;
253
+ const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
254
+ expect ( getByLabelText ( container , "Video call" ) ) . toBeInTheDocument ( ) ;
255
+ expect ( queryByLabelText ( container , "Voice call" ) ) . not . toBeInTheDocument ( ) ;
256
+ } ) ;
257
+
235
258
describe ( "groups call disabled" , ( ) => {
236
259
it ( "you can't call if you're alone" , ( ) => {
237
260
mockRoomMembers ( room , 1 ) ;
@@ -270,22 +293,18 @@ describe("RoomHeader", () => {
270
293
}
271
294
} ) ;
272
295
273
- it ( "can calls in large rooms if able to edit widgets" , ( ) => {
296
+ it ( "can call in large rooms if able to edit widgets" , ( ) => {
274
297
mockRoomMembers ( room , 10 ) ;
275
298
jest . spyOn ( room . currentState , "mayClientSendStateEvent" ) . mockReturnValue ( true ) ;
276
299
const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
277
300
278
- expect ( getByLabelText ( container , "Voice call" ) ) . not . toHaveAttribute ( "aria-disabled" , "true" ) ;
279
301
expect ( getByLabelText ( container , "Video call" ) ) . not . toHaveAttribute ( "aria-disabled" , "true" ) ;
280
302
} ) ;
281
303
282
304
it ( "disable calls in large rooms by default" , ( ) => {
283
305
mockRoomMembers ( room , 10 ) ;
284
306
jest . spyOn ( room . currentState , "mayClientSendStateEvent" ) . mockReturnValue ( false ) ;
285
307
const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
286
- expect (
287
- getByLabelText ( container , "You do not have permission to start voice calls" , { selector : "button" } ) ,
288
- ) . toHaveAttribute ( "aria-disabled" , "true" ) ;
289
308
expect (
290
309
getByLabelText ( container , "You do not have permission to start video calls" , { selector : "button" } ) ,
291
310
) . toHaveAttribute ( "aria-disabled" , "true" ) ;
@@ -456,15 +475,10 @@ describe("RoomHeader", () => {
456
475
457
476
const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
458
477
459
- const voiceButton = getByLabelText ( container , "Voice call" ) ;
460
478
const videoButton = getByLabelText ( container , "Video call" ) ;
461
- expect ( voiceButton ) . not . toHaveAttribute ( "aria-disabled" , "true" ) ;
462
479
expect ( videoButton ) . not . toHaveAttribute ( "aria-disabled" , "true" ) ;
463
480
464
481
const placeCallSpy = jest . spyOn ( LegacyCallHandler . instance , "placeCall" ) ;
465
- fireEvent . click ( voiceButton ) ;
466
- expect ( placeCallSpy ) . toHaveBeenLastCalledWith ( room . roomId , CallType . Voice ) ;
467
-
468
482
fireEvent . click ( videoButton ) ;
469
483
expect ( placeCallSpy ) . toHaveBeenLastCalledWith ( room . roomId , CallType . Video ) ;
470
484
} ) ;
@@ -479,9 +493,7 @@ describe("RoomHeader", () => {
479
493
480
494
const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
481
495
482
- const voiceButton = getByLabelText ( container , "Voice call" ) ;
483
496
const videoButton = getByLabelText ( container , "Video call" ) ;
484
- expect ( voiceButton ) . not . toHaveAttribute ( "aria-disabled" , "true" ) ;
485
497
expect ( videoButton ) . not . toHaveAttribute ( "aria-disabled" , "true" ) ;
486
498
487
499
const dispatcherSpy = jest . spyOn ( dispatcher , "dispatch" ) ;
@@ -497,9 +509,8 @@ describe("RoomHeader", () => {
497
509
) ;
498
510
const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
499
511
500
- const [ videoButton , voiceButton ] = getAllByLabelText ( container , "Ongoing call" ) ;
512
+ const [ videoButton ] = getAllByLabelText ( container , "Ongoing call" ) ;
501
513
502
- expect ( voiceButton ) . toHaveAttribute ( "aria-disabled" , "true" ) ;
503
514
expect ( videoButton ) . toHaveAttribute ( "aria-disabled" , "true" ) ;
504
515
} ) ;
505
516
0 commit comments