@@ -34,6 +34,7 @@ import {
3434 getByRole ,
3535 getByText ,
3636 queryAllByLabelText ,
37+ queryByLabelText ,
3738 render ,
3839 RenderOptions ,
3940 screen ,
@@ -232,6 +233,28 @@ describe("RoomHeader", () => {
232233 expect ( setCardSpy ) . toHaveBeenCalledWith ( { phase : RightPanelPhases . NotificationPanel } ) ;
233234 } ) ;
234235
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+
235258 describe ( "groups call disabled" , ( ) => {
236259 it ( "you can't call if you're alone" , ( ) => {
237260 mockRoomMembers ( room , 1 ) ;
@@ -270,22 +293,18 @@ describe("RoomHeader", () => {
270293 }
271294 } ) ;
272295
273- it ( "can calls in large rooms if able to edit widgets" , ( ) => {
296+ it ( "can call in large rooms if able to edit widgets" , ( ) => {
274297 mockRoomMembers ( room , 10 ) ;
275298 jest . spyOn ( room . currentState , "mayClientSendStateEvent" ) . mockReturnValue ( true ) ;
276299 const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
277300
278- expect ( getByLabelText ( container , "Voice call" ) ) . not . toHaveAttribute ( "aria-disabled" , "true" ) ;
279301 expect ( getByLabelText ( container , "Video call" ) ) . not . toHaveAttribute ( "aria-disabled" , "true" ) ;
280302 } ) ;
281303
282304 it ( "disable calls in large rooms by default" , ( ) => {
283305 mockRoomMembers ( room , 10 ) ;
284306 jest . spyOn ( room . currentState , "mayClientSendStateEvent" ) . mockReturnValue ( false ) ;
285307 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" ) ;
289308 expect (
290309 getByLabelText ( container , "You do not have permission to start video calls" , { selector : "button" } ) ,
291310 ) . toHaveAttribute ( "aria-disabled" , "true" ) ;
@@ -456,15 +475,10 @@ describe("RoomHeader", () => {
456475
457476 const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
458477
459- const voiceButton = getByLabelText ( container , "Voice call" ) ;
460478 const videoButton = getByLabelText ( container , "Video call" ) ;
461- expect ( voiceButton ) . not . toHaveAttribute ( "aria-disabled" , "true" ) ;
462479 expect ( videoButton ) . not . toHaveAttribute ( "aria-disabled" , "true" ) ;
463480
464481 const placeCallSpy = jest . spyOn ( LegacyCallHandler . instance , "placeCall" ) ;
465- fireEvent . click ( voiceButton ) ;
466- expect ( placeCallSpy ) . toHaveBeenLastCalledWith ( room . roomId , CallType . Voice ) ;
467-
468482 fireEvent . click ( videoButton ) ;
469483 expect ( placeCallSpy ) . toHaveBeenLastCalledWith ( room . roomId , CallType . Video ) ;
470484 } ) ;
@@ -479,9 +493,7 @@ describe("RoomHeader", () => {
479493
480494 const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
481495
482- const voiceButton = getByLabelText ( container , "Voice call" ) ;
483496 const videoButton = getByLabelText ( container , "Video call" ) ;
484- expect ( voiceButton ) . not . toHaveAttribute ( "aria-disabled" , "true" ) ;
485497 expect ( videoButton ) . not . toHaveAttribute ( "aria-disabled" , "true" ) ;
486498
487499 const dispatcherSpy = jest . spyOn ( dispatcher , "dispatch" ) ;
@@ -497,9 +509,8 @@ describe("RoomHeader", () => {
497509 ) ;
498510 const { container } = render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
499511
500- const [ videoButton , voiceButton ] = getAllByLabelText ( container , "Ongoing call" ) ;
512+ const [ videoButton ] = getAllByLabelText ( container , "Ongoing call" ) ;
501513
502- expect ( voiceButton ) . toHaveAttribute ( "aria-disabled" , "true" ) ;
503514 expect ( videoButton ) . toHaveAttribute ( "aria-disabled" , "true" ) ;
504515 } ) ;
505516
0 commit comments