@@ -364,7 +364,10 @@ export default class Queue {
364
364
if ( useCapsBuildId ) {
365
365
this . ctx . log . info ( `Using cached buildId: ${ capsBuildId } ` ) ;
366
366
if ( useKafkaFlowCaps ) {
367
- const snapshotUuid = uuidv4 ( ) ;
367
+ let snapshotUuid = uuidv4 ( ) ;
368
+ if ( snapshot ?. options ?. contextId && this . ctx . contextToSnapshotMap ?. has ( snapshot . options . contextId ) ) {
369
+ snapshotUuid = snapshot . options . contextId ;
370
+ }
368
371
let uploadDomToS3 = this . ctx . config . useLambdaInternal || uploadDomToS3ViaEnv ;
369
372
if ( ! uploadDomToS3 ) {
370
373
this . ctx . log . debug ( `Uploading dom to S3 for snapshot using presigned URL for CAPS` ) ;
@@ -375,16 +378,20 @@ export default class Queue {
375
378
this . ctx . log . debug ( `Uploading dom to S3 for snapshot using LSRS` ) ;
376
379
await this . ctx . client . sendDomToLSRSForCaps ( this . ctx , processedSnapshot , snapshotUuid , capsBuildId , capsProjectToken ) ;
377
380
}
378
- await this . ctx . client . processSnapshotCaps ( this . ctx , processedSnapshot , snapshotUuid , capsBuildId , capsProjectToken , discoveryErrors ) ;
381
+ await this . ctx . client . processSnapshotCaps ( this . ctx , processedSnapshot , snapshotUuid , capsBuildId , capsProjectToken , discoveryErrors , calculateVariantCountFromSnapshot ( processedSnapshot , this . ctx . config ) , snapshot ?. options ?. sync ) ;
379
382
} else {
380
- await this . ctx . client . uploadSnapshotForCaps ( this . ctx , processedSnapshot , capsBuildId , capsProjectToken , discoveryErrors ) ;
383
+ await this . ctx . client . uploadSnapshotForCaps ( this . ctx , processedSnapshot , capsBuildId , capsProjectToken , discoveryErrors , calculateVariantCountFromSnapshot ( processedSnapshot , this . ctx . config ) , snapshot ?. options ?. sync ) ;
381
384
}
382
385
383
386
// Increment snapshot count for the specific buildId
384
387
const cachedCapabilities = this . ctx . sessionCapabilitiesMap . get ( sessionId ) ;
385
388
const currentCount = cachedCapabilities ?. snapshotCount || 0 ; // Get the current snapshot count for sessionId
386
389
cachedCapabilities . snapshotCount = currentCount + 1 ; // Increment snapshot count
387
390
this . ctx . sessionCapabilitiesMap . set ( sessionId , cachedCapabilities ) ;
391
+
392
+ if ( snapshot ?. options ?. contextId && this . ctx . contextToSnapshotMap ) {
393
+ this . ctx . contextToSnapshotMap . set ( snapshot . options . contextId , capsBuildId ) ;
394
+ }
388
395
} else {
389
396
if ( ! this . ctx . build ?. id ) {
390
397
if ( this . ctx . authenticatedInitially ) {
@@ -440,15 +447,15 @@ export default class Queue {
440
447
}
441
448
}
442
449
if ( snapshot ?. options ?. contextId ) {
443
- this . ctx . contextToSnapshotMap ?. set ( snapshot ?. options ?. contextId , 2 ) ;
450
+ this . ctx . contextToSnapshotMap ?. set ( snapshot ?. options ?. contextId , '2' ) ;
444
451
}
445
452
this . processNext ( ) ;
446
453
} else {
447
454
let approvalThreshold = snapshot ?. options ?. approvalThreshold || this . ctx . config . approvalThreshold ;
448
455
let rejectionThreshold = snapshot ?. options ?. rejectionThreshold || this . ctx . config . rejectionThreshold ;
449
456
await this . ctx . client . processSnapshot ( this . ctx , processedSnapshot , snapshotUuid , discoveryErrors , calculateVariantCountFromSnapshot ( processedSnapshot , this . ctx . config ) , snapshot ?. options ?. sync , approvalThreshold , rejectionThreshold ) ;
450
457
if ( snapshot ?. options ?. contextId && this . ctx . contextToSnapshotMap ?. has ( snapshot . options . contextId ) ) {
451
- this . ctx . contextToSnapshotMap . set ( snapshot . options . contextId , 1 ) ;
458
+ this . ctx . contextToSnapshotMap . set ( snapshot . options . contextId , this . ctx . build . id ) ;
452
459
}
453
460
this . ctx . log . debug ( `ContextId: ${ snapshot ?. options ?. contextId } status set to uploaded` ) ;
454
461
}
@@ -465,7 +472,7 @@ export default class Queue {
465
472
this . ctx . log . debug ( `snapshot failed; ${ error } ` ) ;
466
473
this . processedSnapshots . push ( { name : snapshot ?. name , error : error . message } ) ;
467
474
if ( snapshot ?. options ?. contextId && this . ctx . contextToSnapshotMap ) {
468
- this . ctx . contextToSnapshotMap . set ( snapshot . options . contextId , 2 ) ;
475
+ this . ctx . contextToSnapshotMap . set ( snapshot . options . contextId , '2' ) ;
469
476
}
470
477
}
471
478
// Close open browser contexts and pages
0 commit comments