@@ -28,6 +28,7 @@ import {
28
28
import { canonifyTarget , Target , targetEquals } from '../../../src/core/target' ;
29
29
import { TargetIdGenerator } from '../../../src/core/target_id_generator' ;
30
30
import { TargetId } from '../../../src/core/types' ;
31
+ import { TargetPurpose } from '../../../src/local/target_data' ;
31
32
import { Document } from '../../../src/model/document' ;
32
33
import { DocumentKey } from '../../../src/model/document_key' ;
33
34
import { FieldIndex } from '../../../src/model/field_index' ;
@@ -73,6 +74,7 @@ export interface LimboMap {
73
74
74
75
export interface ActiveTargetSpec {
75
76
queries : SpecQuery [ ] ;
77
+ targetPurpose ?: TargetPurpose ;
76
78
resumeToken ?: string ;
77
79
readTime ?: TestSnapshotVersion ;
78
80
}
@@ -299,7 +301,9 @@ export class SpecBuilder {
299
301
throw new Error ( "Can't restore an unknown query: " + query ) ;
300
302
}
301
303
302
- this . addQueryToActiveTargets ( targetId ! , query , { resumeToken } ) ;
304
+ this . addQueryToActiveTargets ( targetId ! , query , {
305
+ resumeToken
306
+ } ) ;
303
307
304
308
const currentStep = this . currentStep ! ;
305
309
currentStep . expectedState = currentStep . expectedState || { } ;
@@ -525,18 +529,24 @@ export class SpecBuilder {
525
529
expectActiveTargets (
526
530
...targets : Array < {
527
531
query : Query ;
532
+ targetPurpose ?: TargetPurpose ;
528
533
resumeToken ?: string ;
529
534
readTime ?: TestSnapshotVersion ;
530
535
} >
531
536
) : this {
532
537
this . assertStep ( 'Active target expectation requires previous step' ) ;
533
538
const currentStep = this . currentStep ! ;
534
539
this . clientState . activeTargets = { } ;
535
- targets . forEach ( ( { query, resumeToken, readTime } ) => {
536
- this . addQueryToActiveTargets ( this . getTargetId ( query ) , query , {
537
- resumeToken,
538
- readTime
539
- } ) ;
540
+ targets . forEach ( ( { query, targetPurpose, resumeToken, readTime } ) => {
541
+ this . addQueryToActiveTargets (
542
+ this . getTargetId ( query ) ,
543
+ query ,
544
+ {
545
+ resumeToken,
546
+ readTime
547
+ } ,
548
+ targetPurpose
549
+ ) ;
540
550
} ) ;
541
551
currentStep . expectedState = currentStep . expectedState || { } ;
542
552
currentStep . expectedState . activeTargets = { ...this . activeTargets } ;
@@ -567,7 +577,8 @@ export class SpecBuilder {
567
577
this . addQueryToActiveTargets (
568
578
this . limboMapping [ path ] ,
569
579
newQueryForPath ( key . path ) ,
570
- { resumeToken : '' }
580
+ { resumeToken : '' } ,
581
+ TargetPurpose . LimboResolution
571
582
) ;
572
583
} ) ;
573
584
@@ -1077,7 +1088,8 @@ export class SpecBuilder {
1077
1088
private addQueryToActiveTargets (
1078
1089
targetId : number ,
1079
1090
query : Query ,
1080
- resume ?: ResumeSpec
1091
+ resume : ResumeSpec = { } ,
1092
+ targetPurpose ?: TargetPurpose
1081
1093
) : void {
1082
1094
if ( this . activeTargets [ targetId ] ) {
1083
1095
const activeQueries = this . activeTargets [ targetId ] . queries ;
@@ -1089,21 +1101,24 @@ export class SpecBuilder {
1089
1101
// `query` is not added yet.
1090
1102
this . activeTargets [ targetId ] = {
1091
1103
queries : [ SpecBuilder . queryToSpec ( query ) , ...activeQueries ] ,
1092
- resumeToken : resume ?. resumeToken || '' ,
1093
- readTime : resume ?. readTime
1104
+ targetPurpose,
1105
+ resumeToken : resume . resumeToken || '' ,
1106
+ readTime : resume . readTime
1094
1107
} ;
1095
1108
} else {
1096
1109
this . activeTargets [ targetId ] = {
1097
1110
queries : activeQueries ,
1098
- resumeToken : resume ?. resumeToken || '' ,
1099
- readTime : resume ?. readTime
1111
+ targetPurpose,
1112
+ resumeToken : resume . resumeToken || '' ,
1113
+ readTime : resume . readTime
1100
1114
} ;
1101
1115
}
1102
1116
} else {
1103
1117
this . activeTargets [ targetId ] = {
1104
1118
queries : [ SpecBuilder . queryToSpec ( query ) ] ,
1105
- resumeToken : resume ?. resumeToken || '' ,
1106
- readTime : resume ?. readTime
1119
+ targetPurpose,
1120
+ resumeToken : resume . resumeToken || '' ,
1121
+ readTime : resume . readTime
1107
1122
} ;
1108
1123
}
1109
1124
}
@@ -1115,6 +1130,7 @@ export class SpecBuilder {
1115
1130
if ( queriesAfterRemoval . length > 0 ) {
1116
1131
this . activeTargets [ targetId ] = {
1117
1132
queries : queriesAfterRemoval ,
1133
+ targetPurpose : this . activeTargets [ targetId ] . targetPurpose ,
1118
1134
resumeToken : this . activeTargets [ targetId ] . resumeToken
1119
1135
} ;
1120
1136
} else {
0 commit comments