@@ -283,6 +283,50 @@ describeSpec('Listens:', [], () => {
283
283
) ;
284
284
} ) ;
285
285
286
+ specTest ( 'Individual (deleted) documents cannot revert' , [ ] , ( ) => {
287
+ const allQuery = Query . atPath ( path ( 'collection' ) ) ;
288
+ const visibleQuery = Query . atPath ( path ( 'collection' ) ) . addFilter (
289
+ filter ( 'visible' , '==' , true )
290
+ ) ;
291
+ const docAv1 = doc ( 'collection/a' , 1000 , { visible : true , v : 'v1000' } ) ;
292
+ const docAv2 = doc ( 'collection/a' , 2000 , { visible : false , v : 'v2000' } ) ;
293
+ const docAv3 = deletedDoc ( 'collection/a' , 3000 ) ;
294
+
295
+ return (
296
+ spec ( )
297
+ // Disable GC so the cache persists across listens.
298
+ . withGCEnabled ( false )
299
+ . userListens ( visibleQuery )
300
+ . watchAcksFull ( visibleQuery , 1000 , docAv1 )
301
+ . expectEvents ( visibleQuery , { added : [ docAv1 ] } )
302
+ . userUnlistens ( visibleQuery )
303
+ . watchRemoves ( visibleQuery )
304
+ . userListens ( allQuery )
305
+ . expectEvents ( allQuery , { added : [ docAv1 ] , fromCache : true } )
306
+ . watchAcks ( allQuery )
307
+ . watchSends ( { removed : [ allQuery ] } , docAv3 )
308
+ . watchCurrents ( allQuery , 'resume-token-3000' )
309
+ . watchSnapshots ( 3000 )
310
+ . expectEvents ( allQuery , { removed : [ docAv1 ] , fromCache : false } )
311
+ . userUnlistens ( allQuery )
312
+ . watchRemoves ( allQuery )
313
+ // Supposing we sent a resume token for visibleQuery, watch could catch
314
+ // us up to docAV2 since that's the last relevant change to the query
315
+ // (the document falls out) and send us a snapshot that's ahead of
316
+ // docAv3 (which is already in our cache).
317
+ . userListens ( visibleQuery , 'resume-token-1000' )
318
+ . watchAcksFull ( visibleQuery , 5000 , docAv2 )
319
+ . expectEvents ( visibleQuery , { fromCache : false } )
320
+ . userUnlistens ( visibleQuery )
321
+ . watchRemoves ( visibleQuery )
322
+ // Listen to allQuery again and make sure we still get no docs.
323
+ . userListens ( allQuery , 'resume-token-4000' )
324
+ . expectEvents ( allQuery , { fromCache : true } )
325
+ . watchAcksFull ( allQuery , 6000 )
326
+ . expectEvents ( allQuery , { fromCache : false } )
327
+ ) ;
328
+ } ) ;
329
+
286
330
specTest ( 'Deleted documents in cache are fixed' , [ ] , ( ) => {
287
331
const allQuery = Query . atPath ( path ( 'collection' ) ) ;
288
332
const docAv1 = doc ( 'collection/a' , 1000 , { key : 'a' } ) ;
0 commit comments