@@ -364,7 +364,10 @@ export default class Queue {
364364 if ( useCapsBuildId ) {
365365 this . ctx . log . info ( `Using cached buildId: ${ capsBuildId } ` ) ;
366366 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+ }
368371 let uploadDomToS3 = this . ctx . config . useLambdaInternal || uploadDomToS3ViaEnv ;
369372 if ( ! uploadDomToS3 ) {
370373 this . ctx . log . debug ( `Uploading dom to S3 for snapshot using presigned URL for CAPS` ) ;
@@ -375,16 +378,20 @@ export default class Queue {
375378 this . ctx . log . debug ( `Uploading dom to S3 for snapshot using LSRS` ) ;
376379 await this . ctx . client . sendDomToLSRSForCaps ( this . ctx , processedSnapshot , snapshotUuid , capsBuildId , capsProjectToken ) ;
377380 }
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 ) ;
379382 } 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 ) ;
381384 }
382385
383386 // Increment snapshot count for the specific buildId
384387 const cachedCapabilities = this . ctx . sessionCapabilitiesMap . get ( sessionId ) ;
385388 const currentCount = cachedCapabilities ?. snapshotCount || 0 ; // Get the current snapshot count for sessionId
386389 cachedCapabilities . snapshotCount = currentCount + 1 ; // Increment snapshot count
387390 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+ }
388395 } else {
389396 if ( ! this . ctx . build ?. id ) {
390397 if ( this . ctx . authenticatedInitially ) {
@@ -440,15 +447,15 @@ export default class Queue {
440447 }
441448 }
442449 if ( snapshot ?. options ?. contextId ) {
443- this . ctx . contextToSnapshotMap ?. set ( snapshot ?. options ?. contextId , 2 ) ;
450+ this . ctx . contextToSnapshotMap ?. set ( snapshot ?. options ?. contextId , '2' ) ;
444451 }
445452 this . processNext ( ) ;
446453 } else {
447454 let approvalThreshold = snapshot ?. options ?. approvalThreshold || this . ctx . config . approvalThreshold ;
448455 let rejectionThreshold = snapshot ?. options ?. rejectionThreshold || this . ctx . config . rejectionThreshold ;
449456 await this . ctx . client . processSnapshot ( this . ctx , processedSnapshot , snapshotUuid , discoveryErrors , calculateVariantCountFromSnapshot ( processedSnapshot , this . ctx . config ) , snapshot ?. options ?. sync , approvalThreshold , rejectionThreshold ) ;
450457 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 ) ;
452459 }
453460 this . ctx . log . debug ( `ContextId: ${ snapshot ?. options ?. contextId } status set to uploaded` ) ;
454461 }
@@ -465,7 +472,7 @@ export default class Queue {
465472 this . ctx . log . debug ( `snapshot failed; ${ error } ` ) ;
466473 this . processedSnapshots . push ( { name : snapshot ?. name , error : error . message } ) ;
467474 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' ) ;
469476 }
470477 }
471478 // Close open browser contexts and pages
0 commit comments