@@ -218,12 +218,12 @@ describeSpec('Limits:', [], () => {
218
218
) ;
219
219
220
220
specTest (
221
- 'Initial snapshots for limit queries are re-filled from cache (with order change)' ,
221
+ 'Initial snapshots for limit queries are re-filled from cache (with uncommitted change)' ,
222
222
[ ] ,
223
223
( ) => {
224
224
// Verify that views for limit queries contain the correct set of documents
225
- // even if a previously matching document is updated to sort below an older
226
- // document.
225
+ // even if a previously matching document receives a latency-compensate update
226
+ // that makes it sort below an older document.
227
227
const fullQuery = Query . atPath ( path ( 'collection' ) ) ;
228
228
const limitQuery = Query . atPath ( path ( 'collection' ) )
229
229
. addOrderBy ( orderBy ( 'pos' ) )
@@ -237,6 +237,7 @@ describeSpec('Limits:', [], () => {
237
237
. watchAcksFull ( fullQuery , 1003 , doc1 , doc2 , doc3 )
238
238
. expectEvents ( fullQuery , { added : [ doc1 , doc2 , doc3 ] } )
239
239
. userUnlistens ( fullQuery )
240
+ . watchRemoves ( fullQuery )
240
241
. userListens ( limitQuery )
241
242
. expectEvents ( limitQuery , { added : [ doc1 , doc2 ] , fromCache : true } )
242
243
. watchAcksFull ( limitQuery , 1004 , doc1 , doc2 )
@@ -249,6 +250,43 @@ describeSpec('Limits:', [], () => {
249
250
}
250
251
) ;
251
252
253
+ specTest (
254
+ 'Initial snapshots for limit queries are re-filled from cache (with committed change)' ,
255
+ [ ] ,
256
+ ( ) => {
257
+ // Verify that views for limit queries contain the correct set of documents
258
+ // even if a previously matching document receives an update from the backend
259
+ // that makes it sort below an older document.
260
+ const fullQuery = Query . atPath ( path ( 'collection' ) ) ;
261
+ const limitQuery = Query . atPath ( path ( 'collection' ) )
262
+ . addOrderBy ( orderBy ( 'pos' ) )
263
+ . withLimit ( 2 ) ;
264
+ const doc1 = doc ( 'collection/a' , 1001 , { pos : 1 } ) ;
265
+ const doc1Edited = doc ( 'collection/a' , 1005 , { pos : 4 } ) ;
266
+ const doc2 = doc ( 'collection/b' , 1002 , { pos : 2 } ) ;
267
+ const doc3 = doc ( 'collection/c' , 1003 , { pos : 3 } ) ;
268
+ return spec ( )
269
+ . withGCEnabled ( false )
270
+ . userListens ( fullQuery )
271
+ . watchAcksFull ( fullQuery , 1003 , doc1 , doc2 , doc3 )
272
+ . expectEvents ( fullQuery , { added : [ doc1 , doc2 , doc3 ] } )
273
+ . userUnlistens ( fullQuery )
274
+ . watchRemoves ( fullQuery )
275
+ . userListens ( limitQuery )
276
+ . expectEvents ( limitQuery , { added : [ doc1 , doc2 ] , fromCache : true } )
277
+ . watchAcksFull ( limitQuery , 1004 , doc1 , doc2 )
278
+ . expectEvents ( limitQuery , { } )
279
+ . userUnlistens ( limitQuery )
280
+ . watchRemoves ( limitQuery )
281
+ . userListens ( fullQuery , 'resume-token-1003' )
282
+ . expectEvents ( fullQuery , { added : [ doc1 , doc2 , doc3 ] , fromCache : true } )
283
+ . watchAcksFull ( fullQuery , 1005 , doc1Edited )
284
+ . expectEvents ( fullQuery , { modified : [ doc1Edited ] } )
285
+ . userListens ( limitQuery , 'resume-token-1004' )
286
+ . expectEvents ( limitQuery , { added : [ doc2 , doc3 ] , fromCache : true } ) ;
287
+ }
288
+ ) ;
289
+
252
290
specTest (
253
291
'Resumed limit queries exclude deleted documents ' ,
254
292
[ 'durable-persistence' ] ,
0 commit comments