@@ -283,6 +283,37 @@ describeSpec('Listens:', [], () => {
283
283
) ;
284
284
} ) ;
285
285
286
+ specTest ( 'Deleted documents in cache are fixed' , [ ] , ( ) => {
287
+ const allQuery = Query . atPath ( path ( 'collection' ) ) ;
288
+ const docAv1 = doc ( 'collection/a' , 1000 , { key : 'a' } ) ;
289
+ const docDeleted = deletedDoc ( 'collection/a' , 2000 ) ;
290
+
291
+ return (
292
+ spec ( )
293
+ // Presuppose an initial state where the remote document cache has a
294
+ // broken synthesized delete at a timestamp later than the true version
295
+ // of the document. This requires both adding and later removing the
296
+ // document in order to force the watch change aggregator to propagate
297
+ // the deletion.
298
+ . withGCEnabled ( false )
299
+ . userListens ( allQuery )
300
+ . watchAcksFull ( allQuery , 1000 , docAv1 )
301
+ . expectEvents ( allQuery , { added : [ docAv1 ] , fromCache : false } )
302
+ . watchSends ( { removed : [ allQuery ] } , docDeleted )
303
+ . watchSnapshots ( 2000 , [ allQuery ] , 'resume-token-2000' )
304
+ . watchSnapshots ( 2000 )
305
+ . expectEvents ( allQuery , { removed : [ docAv1 ] , fromCache : false } )
306
+ . userUnlistens ( allQuery )
307
+ . watchRemoves ( allQuery )
308
+
309
+ // Now when the client listens expect the cached NoDocument to be
310
+ // discarded because the global snapshot version exceeds what came before.
311
+ . userListens ( allQuery , 'resume-token-2000' )
312
+ . watchAcksFull ( allQuery , 3000 , docAv1 )
313
+ . expectEvents ( allQuery , { added : [ docAv1 ] , fromCache : false } )
314
+ ) ;
315
+ } ) ;
316
+
286
317
specTest ( 'Listens are reestablished after network disconnect' , [ ] , ( ) => {
287
318
const expectRequestCount = requestCounts =>
288
319
requestCounts . addTarget + requestCounts . removeTarget ;
0 commit comments