@@ -66,7 +66,7 @@ describeSpec(
66
66
fromCache : true ,
67
67
hasPendingWrites : true
68
68
} )
69
- . writeAcks ( `collection/${ i } ` , ++ currentVersion )
69
+ . writeAcks ( `collection/${ i } ` , docRemote . version . toMicroseconds ( ) )
70
70
. watchAcksFull ( query , ++ currentVersion , docRemote )
71
71
. expectEvents ( query , { metadata : [ docRemote ] } )
72
72
. userUnlistens ( query )
@@ -143,7 +143,7 @@ describeSpec(
143
143
fromCache : true ,
144
144
hasPendingWrites : true
145
145
} )
146
- . writeAcks ( `collection/doc` , ++ currentVersion )
146
+ . writeAcks ( `collection/doc` , docRemote . version . toMicroseconds ( ) )
147
147
. watchAcksFull ( query , ++ currentVersion , docRemote )
148
148
. expectEvents ( query , { metadata : [ docRemote ] } ) ;
149
149
@@ -163,7 +163,7 @@ describeSpec(
163
163
modified : [ docLocal ] ,
164
164
hasPendingWrites : true
165
165
} )
166
- . writeAcks ( `collection/doc` , ++ currentVersion )
166
+ . writeAcks ( `collection/doc` , docRemote . version . toMicroseconds ( ) )
167
167
. watchSends ( { affects : [ query ] } , docRemote )
168
168
. watchSnapshots ( ++ currentVersion )
169
169
. expectEvents ( query , { metadata : [ docRemote ] } ) ;
@@ -292,5 +292,56 @@ describeSpec(
292
292
293
293
return steps ;
294
294
} ) ;
295
+
296
+ specTest (
297
+ 'Add 500 documents, issue 10 queries that return 10 documents each, unlisten' ,
298
+ [ ] ,
299
+ ( ) => {
300
+ const documentCount = 500 ;
301
+ const matchingCount = 10 ;
302
+ const queryCount = 10 ;
303
+
304
+ const steps = spec ( ) . withGCEnabled ( false ) ;
305
+
306
+ const collPath = `collection` ;
307
+ const query = Query . atPath ( path ( collPath ) ) . addOrderBy ( orderBy ( 'val' ) ) ;
308
+ steps . userListens ( query ) . watchAcks ( query ) ;
309
+
310
+ const allDocs : Document [ ] = [ ] ;
311
+
312
+ let currentVersion = 1 ;
313
+ // Create `documentCount` documents.
314
+ for ( let j = 0 ; j < documentCount ; ++ j ) {
315
+ const document = doc ( `${ collPath } /doc${ j } ` , ++ currentVersion , {
316
+ val : j
317
+ } ) ;
318
+ allDocs . push ( document ) ;
319
+ steps . watchSends ( { affects : [ query ] } , document ) ;
320
+ }
321
+
322
+ steps . watchCurrents ( query , `current-version-${ ++ currentVersion } ` ) ;
323
+ steps . watchSnapshots ( currentVersion ) ;
324
+ steps . expectEvents ( query , { added : allDocs } ) ;
325
+ steps . userUnlistens ( query ) . watchRemoves ( query ) ;
326
+
327
+ for ( let i = 1 ; i <= STEP_COUNT ; ++ i ) {
328
+ // Create `queryCount` listens, each against collPath but with a
329
+ // unique query constraint.
330
+ for ( let j = 0 ; j < queryCount ; ++ j ) {
331
+ const partialQuery = Query . atPath ( path ( collPath ) )
332
+ . addFilter ( filter ( 'val' , '>=' , j * matchingCount ) )
333
+ . addFilter ( filter ( 'val' , '<' , ( j + 1 ) * matchingCount ) ) ;
334
+ steps . userListens ( partialQuery ) ;
335
+ steps . expectEvents ( partialQuery , {
336
+ added : allDocs . slice ( j * matchingCount , ( j + 1 ) * matchingCount ) ,
337
+ fromCache : true
338
+ } ) ;
339
+ steps . userUnlistens ( partialQuery ) ;
340
+ }
341
+ }
342
+
343
+ return steps ;
344
+ }
345
+ ) ;
295
346
}
296
347
) ;
0 commit comments