@@ -52,7 +52,6 @@ import * as ShieldUtils from "../../../../../../src/utils/ShieldUtils";
5252import { Container , WidgetLayoutStore } from "../../../../../../src/stores/widgets/WidgetLayoutStore" ;
5353import MatrixClientContext from "../../../../../../src/contexts/MatrixClientContext" ;
5454import { _t } from "../../../../../../src/languageHandler" ;
55- import * as UseCall from "../../../../../../src/hooks/useCall" ;
5655import { SdkContextClass } from "../../../../../../src/contexts/SDKContext" ;
5756import WidgetStore , { type IApp } from "../../../../../../src/stores/WidgetStore" ;
5857import { UIFeature } from "../../../../../../src/settings/UIFeature" ;
@@ -97,8 +96,9 @@ describe("RoomHeader", () => {
9796 setCardSpy = jest . spyOn ( RightPanelStore . instance , "setCard" ) ;
9897 jest . spyOn ( ShieldUtils , "shieldStatusForRoom" ) . mockResolvedValue ( ShieldUtils . E2EStatus . Normal ) ;
9998
100- // Mock useCall to return a Call object with stable participants to prevent React dependency errors
101- jest . spyOn ( UseCall , 'useCall' ) . mockReturnValue ( createMockCall ( ) ) ;
99+ // Mock CallStore.instance.getCall to return a Call object with stable participants
100+ // This prevents React dependency errors without disrupting hook execution order
101+ jest . spyOn ( CallStore . instance , "getCall" ) . mockReturnValue ( createMockCall ( ) ) ;
102102 } ) ;
103103
104104 afterEach ( ( ) => {
@@ -558,17 +558,17 @@ describe("RoomHeader", () => {
558558
559559 it ( "join button is shown if there is an ongoing call" , async ( ) => {
560560 mockRoomMembers ( room , 3 ) ;
561- // Mock a call with 3 participants instead of mocking useParticipantCount
562- jest . spyOn ( UseCall , 'useCall' ) . mockReturnValue ( createMockCall ( ROOM_ID , 3 ) ) ;
561+ // Mock CallStore to return a call with 3 participants
562+ jest . spyOn ( CallStore . instance , "getCall" ) . mockReturnValue ( createMockCall ( ROOM_ID , 3 ) ) ;
563563 render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
564564 const joinButton = getByLabelText ( document . body , "Join" ) ;
565565 expect ( joinButton ) . not . toHaveAttribute ( "aria-disabled" , "true" ) ;
566566 } ) ;
567567
568568 it ( "join button is disabled if there is an other ongoing call" , async ( ) => {
569569 mockRoomMembers ( room , 3 ) ;
570- // Mock a call with 3 participants instead of mocking useParticipantCount
571- jest . spyOn ( UseCall , 'useCall' ) . mockReturnValue ( createMockCall ( ROOM_ID , 3 ) ) ;
570+ // Mock CallStore to return a call with 3 participants
571+ jest . spyOn ( CallStore . instance , "getCall" ) . mockReturnValue ( createMockCall ( ROOM_ID , 3 ) ) ;
572572 jest . spyOn ( CallStore . prototype , "connectedCalls" , "get" ) . mockReturnValue (
573573 new Set ( [ { roomId : "some_other_room" } as Call ] ) ,
574574 ) ;
@@ -588,8 +588,8 @@ describe("RoomHeader", () => {
588588
589589 it ( "close lobby button is shown if there is an ongoing call but we are viewing the lobby" , async ( ) => {
590590 mockRoomMembers ( room , 3 ) ;
591- // Mock a call with 3 participants instead of mocking useParticipantCount
592- jest . spyOn ( UseCall , 'useCall' ) . mockReturnValue ( createMockCall ( ROOM_ID , 3 ) ) ;
591+ // Mock CallStore to return a call with 3 participants
592+ jest . spyOn ( CallStore . instance , "getCall" ) . mockReturnValue ( createMockCall ( ROOM_ID , 3 ) ) ;
593593 jest . spyOn ( SdkContextClass . instance . roomViewStore , "isViewingCall" ) . mockReturnValue ( true ) ;
594594
595595 render ( < RoomHeader room = { room } /> , getWrapper ( ) ) ;
0 commit comments