@@ -29,7 +29,11 @@ import {
2929 IStation ,
3030 IPersonDetails ,
3131 ISessionIdAndConversationId ,
32+ < << << << HEAD
3233 VideoSessionHandler , ScreenRecordingMetadata , IStartScreenConferenceSessionParams
34+ = === ===
35+ VideoSessionHandler
36+ >>> >>> > 3 d567e61595d3f56241eb475ca863cd3f2204ec0
3337} from '../../src' ;
3438import * as utils from '../../src/utils' ;
3539import { RetryPromise } from 'genesys-cloud-streaming-client/dist/es/utils' ;
@@ -329,6 +333,80 @@ describe('Client', () => {
329333 expect ( sessionManagerMock . startSession ) . not . toHaveBeenCalled ( ) ;
330334 }
331335 } ) ;
336+
337+ it ( 'should allow video conference with JWT authentication' , async ( ) => {
338+ const testJwt = 'test.jwt.token' ;
339+ sdk = constructSdk ( { jwt : testJwt } ) ;
340+
341+ sdk . _personDetails = {
342+ id : 'test-user-id' ,
343+ name : 'Test User' ,
344+ chat : {
345+ jabberId : 'test-user@test.com'
346+ }
347+ } ;
348+
349+ sessionManagerMock . startSession . mockResolvedValue ( { } ) ;
350+ await sdk . startVideoConference ( 'test-room@conference.com' ) ;
351+
352+ expect ( sessionManagerMock . startSession ) . toBeCalledWith ( {
353+ jid : 'test-room@conference.com' ,
354+ sessionType : SessionTypes . collaborateVideo
355+ } ) ;
356+ } ) ;
357+
358+ it ( 'should include JWT in video session request' , async ( ) => {
359+ const testJwt = 'test.jwt.token' ;
360+ const mockDecodedJwt = {
361+ data : {
362+ jid : 'test-user@test.com' ,
363+ conversationId : 'test-conversation-id' ,
364+ sourceCommunicationId : 'test-source-comm-id'
365+ }
366+ } ;
367+
368+ jwtDecodeSpy . mockReturnValue ( mockDecodedJwt ) ;
369+
370+ sdk = constructSdk ( { jwt : testJwt } ) ;
371+ const handler = new VideoSessionHandler ( sdk , sessionManagerMock ) ;
372+
373+ sdk . _personDetails = {
374+ id : 'test-user-id' ,
375+ name : 'Test User' ,
376+ chat : {
377+ jabberId : 'test-user@test.com'
378+ }
379+ } ;
380+
381+ const mockInitiateRtcSession = jest . fn ( ) . mockResolvedValue ( undefined ) ;
382+ sdk . _streamingConnection = {
383+ webrtcSessions : {
384+ initiateRtcSession : mockInitiateRtcSession
385+ } ,
386+ disconnect : jest . fn ( ) . mockResolvedValue ( undefined )
387+ } as any ;
388+
389+ const requestApiSpy = jest . spyOn ( utils , 'requestApi' ) ;
390+
391+ const result = await handler . startSession ( {
392+ jid : 'test-room@conference.com' ,
393+ sessionType : SessionTypes . collaborateVideo
394+ } ) ;
395+
396+ expect ( mockInitiateRtcSession ) . toHaveBeenCalledWith ( {
397+ jid : mockDecodedJwt . data . jid ,
398+ conversationId : mockDecodedJwt . data . conversationId ,
399+ sourceCommunicationId : mockDecodedJwt . data . sourceCommunicationId ,
400+ mediaPurpose : SessionTypes . collaborateVideo ,
401+ sessionType : SessionTypes . collaborateVideo
402+ } ) ;
403+
404+ expect ( result ) . toEqual ( {
405+ conversationId : mockDecodedJwt . data . conversationId
406+ } ) ;
407+
408+ expect ( requestApiSpy ) . not . toHaveBeenCalled ( ) ;
409+ } ) ;
332410 } ) ;
333411
334412 describe ( 'startLiveMonitoringSession()' , ( ) => {
0 commit comments