@@ -415,6 +415,14 @@ describe('AuthManager', () => {
415415 } ) ;
416416 const am = new AuthManager ( configWithPopupOverlayOptions , mockEmbeddedLoginPrompt ) ;
417417
418+ // Mock the embedded login prompt to return a result
419+ const mockEmbeddedLoginPromptResult = {
420+ directLoginMethod : 'google' as const ,
421+ marketingConsentStatus : MarketingConsentStatus . OptedIn ,
422+ imPassportTraceId : 'test-trace-id' ,
423+ } ;
424+ mockEmbeddedLoginPrompt . displayEmbeddedLoginPrompt . mockResolvedValue ( mockEmbeddedLoginPromptResult ) ;
425+
418426 mockSigninPopup . mockReturnValue ( mockOidcUser ) ;
419427 // Simulate `tryAgainOnClick` being called so that the `login()` promise can resolve
420428 mockOverlayAppend . mockImplementation ( async ( tryAgainOnClick : ( ) => Promise < void > ) => {
@@ -1080,6 +1088,13 @@ describe('AuthManager', () => {
10801088 expect ( url . searchParams . get ( 'marketingConsent' ) ) . toEqual ( MarketingConsentStatus . OptedIn ) ;
10811089 expect ( url . searchParams . get ( 'audience' ) ) . toEqual ( 'test-audience' ) ;
10821090 } ) ;
1091+
1092+ it ( 'should include im_passport_trace_id parameter when imPassportTraceId is provided' , async ( ) => {
1093+ const result = await authManager . getPKCEAuthorizationUrl ( undefined , 'test-trace-id' ) ;
1094+ const url = new URL ( result ) ;
1095+
1096+ expect ( url . searchParams . get ( 'im_passport_trace_id' ) ) . toEqual ( 'test-trace-id' ) ;
1097+ } ) ;
10831098 } ) ;
10841099
10851100 describe ( 'login with directLoginMethod' , ( ) => {
@@ -1178,8 +1193,12 @@ describe('AuthManager', () => {
11781193 } ) ;
11791194
11801195 it ( 'should call displayEmbeddedLoginPrompt when no directLoginOptions provided and overlay is enabled' , async ( ) => {
1181- const mockDirectLoginOptions = { directLoginMethod : 'google' as const } ;
1182- mockEmbeddedLoginPrompt . displayEmbeddedLoginPrompt . mockResolvedValue ( mockDirectLoginOptions ) ;
1196+ const mockEmbeddedLoginPromptResult = {
1197+ directLoginMethod : 'google' as const ,
1198+ marketingConsentStatus : MarketingConsentStatus . OptedIn ,
1199+ imPassportTraceId : 'test-trace-id' ,
1200+ } ;
1201+ mockEmbeddedLoginPrompt . displayEmbeddedLoginPrompt . mockResolvedValue ( mockEmbeddedLoginPromptResult ) ;
11831202 mockSigninPopup . mockResolvedValue ( mockOidcUser ) ;
11841203
11851204 await authManager . login ( ) ;
@@ -1190,6 +1209,8 @@ describe('AuthManager', () => {
11901209 rid : '' ,
11911210 third_party_a_id : '' ,
11921211 direct : 'google' ,
1212+ marketingConsent : MarketingConsentStatus . OptedIn ,
1213+ im_passport_trace_id : 'test-trace-id' ,
11931214 } ,
11941215 popupWindowFeatures : {
11951216 width : 410 ,
@@ -1234,12 +1255,13 @@ describe('AuthManager', () => {
12341255 } ) ;
12351256
12361257 it ( 'should handle email login method from embedded prompt' , async ( ) => {
1237- const mockDirectLoginOptions = {
1258+ const mockEmbeddedLoginPromptResult = {
12381259 directLoginMethod : 'email' as const ,
1239126012401261 marketingConsentStatus : MarketingConsentStatus . OptedIn ,
1262+ imPassportTraceId : 'test-trace-id-email' ,
12411263 } ;
1242- mockEmbeddedLoginPrompt . displayEmbeddedLoginPrompt . mockResolvedValue ( mockDirectLoginOptions ) ;
1264+ mockEmbeddedLoginPrompt . displayEmbeddedLoginPrompt . mockResolvedValue ( mockEmbeddedLoginPromptResult ) ;
12431265 mockSigninPopup . mockResolvedValue ( mockOidcUser ) ;
12441266
12451267 await authManager . login ( 'anonymous-id' ) ;
@@ -1252,6 +1274,7 @@ describe('AuthManager', () => {
12521274 direct : 'email' ,
1253127512541276 marketingConsent : MarketingConsentStatus . OptedIn ,
1277+ im_passport_trace_id : 'test-trace-id-email' ,
12551278 } ,
12561279 popupWindowFeatures : {
12571280 width : 410 ,
0 commit comments