@@ -79,7 +79,27 @@ jest.mock('react-native-callkeep', () => ({
7979
8080jest . mock ( 'react-native-device-info' , ( ) => ( {
8181 getUniqueId : jest . fn ( ( ) => 'test-device-id' ) ,
82- getUniqueIdSync : jest . fn ( ( ) => 'test-device-id' )
82+ getUniqueIdSync : jest . fn ( ( ) => 'test-device-id' ) ,
83+ getSystemVersion : jest . fn ( ( ) => '15.0' ) ,
84+ getVersion : jest . fn ( ( ) => '4.0.0' ) ,
85+ getBuildNumber : jest . fn ( ( ) => '1' ) ,
86+ hasNotch : jest . fn ( ( ) => false ) ,
87+ getReadableVersion : jest . fn ( ( ) => '4.0.0.1' ) ,
88+ getBundleId : jest . fn ( ( ) => 'com.rocket.chat' ) ,
89+ getModel : jest . fn ( ( ) => 'iPhone' ) ,
90+ isTablet : jest . fn ( ( ) => false ) ,
91+ default : {
92+ getUniqueId : jest . fn ( ( ) => 'test-device-id' ) ,
93+ getUniqueIdSync : jest . fn ( ( ) => 'test-device-id' ) ,
94+ getSystemVersion : jest . fn ( ( ) => '15.0' ) ,
95+ getVersion : jest . fn ( ( ) => '4.0.0' ) ,
96+ getBuildNumber : jest . fn ( ( ) => '1' ) ,
97+ hasNotch : jest . fn ( ( ) => false ) ,
98+ getReadableVersion : jest . fn ( ( ) => '4.0.0.1' ) ,
99+ getBundleId : jest . fn ( ( ) => 'com.rocket.chat' ) ,
100+ getModel : jest . fn ( ( ) => 'iPhone' ) ,
101+ isTablet : jest . fn ( ( ) => false )
102+ }
83103} ) ) ;
84104
85105jest . mock ( '../../native/NativeVoip' , ( ) => ( {
@@ -105,7 +125,7 @@ type MockMediaSignalingSession = {
105125 processSignal : jest . Mock ;
106126 setIceGatheringTimeout : jest . Mock ;
107127 startCall : jest . Mock ;
108- getMainCall : jest . Mock ;
128+ register : jest . Mock ;
109129} ;
110130
111131const createdSessions : MockMediaSignalingSession [ ] = [ ] ;
@@ -124,7 +144,7 @@ jest.mock('@rocket.chat/media-signaling', () => ({
124144 this . processSignal = jest . fn ( ) . mockResolvedValue ( undefined ) ;
125145 this . setIceGatheringTimeout = jest . fn ( ) ;
126146 this . startCall = jest . fn ( ) . mockResolvedValue ( undefined ) ;
127- this . getMainCall = jest . fn ( ) ;
147+ this . register = jest . fn ( ) ;
128148 Object . defineProperty ( this , 'sessionId' , { value : `session-${ config . userId } ` , writable : false } ) ;
129149 createdSessions . push ( this ) ;
130150 } )
@@ -165,9 +185,21 @@ function buildClientMediaCall(options: {
165185 const emitter = { on : jest . fn ( ) , off : jest . fn ( ) , emit : jest . fn ( ) } ;
166186 return {
167187 callId : options . callId ,
168- role : options . role ,
169188 hidden : options . hidden ?? false ,
189+ localParticipant : {
190+ role : options . role ,
191+ contact : { username : 'bob' , sipExtension : '' } ,
192+ muted : false ,
193+ held : false ,
194+ setMuted : ( ) => { } ,
195+ setHeld : ( ) => { }
196+ } ,
197+ remoteParticipants : [ ] ,
198+ participants : [ ] ,
170199 reject,
200+ accept : jest . fn ( ) ,
201+ hangup : jest . fn ( ) ,
202+ sendDTMF : jest . fn ( ) ,
171203 emitter : emitter as unknown as IClientMediaCall [ 'emitter' ]
172204 } as unknown as IClientMediaCall ;
173205}
@@ -505,9 +537,17 @@ describe('MediaSessionInstance', () => {
505537 newCallHandler ( {
506538 call : {
507539 hidden : false ,
508- role : 'caller' ,
509540 callId : 'c1' ,
510- contact : { username : 'alice' , sipExtension : '' } ,
541+ localParticipant : {
542+ role : 'caller' ,
543+ contact : { username : 'alice' , sipExtension : '' } ,
544+ muted : false ,
545+ held : false ,
546+ setMuted : ( ) => { } ,
547+ setHeld : ( ) => { }
548+ } ,
549+ remoteParticipants : [ ] ,
550+ participants : [ ] ,
511551 emitter : { on : jest . fn ( ) , off : jest . fn ( ) }
512552 } as unknown as IClientMediaCall
513553 } ) ;
@@ -536,9 +576,17 @@ describe('MediaSessionInstance', () => {
536576 newCallHandler ( {
537577 call : {
538578 hidden : false ,
539- role : 'caller' ,
540579 callId : 'c1' ,
541- contact : { username : 'alice' , sipExtension : '' } ,
580+ localParticipant : {
581+ role : 'caller' ,
582+ contact : { username : 'alice' , sipExtension : '' } ,
583+ muted : false ,
584+ held : false ,
585+ setMuted : ( ) => { } ,
586+ setHeld : ( ) => { }
587+ } ,
588+ remoteParticipants : [ ] ,
589+ participants : [ ] ,
542590 emitter : { on : jest . fn ( ) , off : jest . fn ( ) }
543591 } as unknown as IClientMediaCall
544592 } ) ;
@@ -557,9 +605,17 @@ describe('MediaSessionInstance', () => {
557605 newCallHandler ( {
558606 call : {
559607 hidden : false ,
560- role : 'caller' ,
561608 callId : 'c1' ,
562- contact : { username : 'alice' , sipExtension : '100' } ,
609+ localParticipant : {
610+ role : 'caller' ,
611+ contact : { username : 'alice' , sipExtension : '100' } ,
612+ muted : false ,
613+ held : false ,
614+ setMuted : ( ) => { } ,
615+ setHeld : ( ) => { }
616+ } ,
617+ remoteParticipants : [ ] ,
618+ participants : [ ] ,
563619 emitter : { on : jest . fn ( ) , off : jest . fn ( ) }
564620 } as unknown as IClientMediaCall
565621 } ) ;
@@ -570,14 +626,17 @@ describe('MediaSessionInstance', () => {
570626
571627 it ( 'answerCall resolves roomId from DM for non-SIP callee' , async ( ) => {
572628 mockGetDMSubscriptionByUsername . mockResolvedValue ( { rid : 'dm-rid' } as any ) ;
573- mediaSessionInstance . init ( 'user-1' ) ;
574- const session = createdSessions [ 0 ] ;
575- const mainCall = {
629+ const calleeCall = buildClientMediaCall ( { callId : 'call-ans' , role : 'callee' } ) ;
630+ mockUseCallStoreGetState . mockReturnValue ( {
631+ reset : mockCallStoreReset ,
632+ setCall : jest . fn ( ) ,
633+ setRoomId : mockSetRoomId ,
634+ resetNativeCallId : jest . fn ( ) ,
635+ call : calleeCall ,
576636 callId : 'call-ans' ,
577- accept : jest . fn ( ) . mockResolvedValue ( undefined ) ,
578- contact : { username : 'bob' , sipExtension : '' }
579- } ;
580- session . getMainCall . mockReturnValue ( mainCall ) ;
637+ nativeAcceptedCallId : null ,
638+ roomId : null
639+ } ) ;
581640
582641 await mediaSessionInstance . answerCall ( 'call-ans' ) ;
583642
@@ -586,14 +645,18 @@ describe('MediaSessionInstance', () => {
586645 } ) ;
587646
588647 it ( 'answerCall skips DM lookup for SIP contact' , async ( ) => {
589- mediaSessionInstance . init ( 'user-1' ) ;
590- const session = createdSessions [ 0 ] ;
591- const mainCall = {
648+ const sipCall = buildClientMediaCall ( { callId : 'call-sip' , role : 'callee' } ) ;
649+ sipCall . localParticipant . contact . sipExtension = 'ext' ;
650+ mockUseCallStoreGetState . mockReturnValue ( {
651+ reset : mockCallStoreReset ,
652+ setCall : jest . fn ( ) ,
653+ setRoomId : mockSetRoomId ,
654+ resetNativeCallId : jest . fn ( ) ,
655+ call : sipCall ,
592656 callId : 'call-sip' ,
593- accept : jest . fn ( ) . mockResolvedValue ( undefined ) ,
594- contact : { username : 'bob' , sipExtension : 'ext' }
595- } ;
596- session . getMainCall . mockReturnValue ( mainCall ) ;
657+ nativeAcceptedCallId : null ,
658+ roomId : null
659+ } ) ;
597660
598661 await mediaSessionInstance . answerCall ( 'call-sip' ) ;
599662
0 commit comments