@@ -185,7 +185,7 @@ describeSpec('Limits:', [], () => {
185
185
} ) ;
186
186
187
187
specTest (
188
- 'Initial snapshots for limit queries are re-filled from cache' ,
188
+ 'Initial snapshots for limit queries are re-filled from cache (with removal) ' ,
189
189
[ ] ,
190
190
( ) => {
191
191
// Verify that views for limit queries are re-filled even if the initial
@@ -217,6 +217,38 @@ describeSpec('Limits:', [], () => {
217
217
}
218
218
) ;
219
219
220
+ specTest (
221
+ 'Initial snapshots for limit queries are re-filled from cache (with order change)' ,
222
+ [ ] ,
223
+ ( ) => {
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.
227
+ const fullQuery = Query . atPath ( path ( 'collection' ) ) ;
228
+ const limitQuery = Query . atPath ( path ( 'collection' ) )
229
+ . addOrderBy ( orderBy ( 'pos' ) )
230
+ . withLimit ( 2 ) ;
231
+ const doc1 = doc ( 'collection/a' , 1001 , { pos : 1 } ) ;
232
+ const doc2 = doc ( 'collection/b' , 1002 , { pos : 2 } ) ;
233
+ const doc3 = doc ( 'collection/c' , 1003 , { pos : 3 } ) ;
234
+ return spec ( )
235
+ . withGCEnabled ( false )
236
+ . userListens ( fullQuery )
237
+ . watchAcksFull ( fullQuery , 1003 , doc1 , doc2 , doc3 )
238
+ . expectEvents ( fullQuery , { added : [ doc1 , doc2 , doc3 ] } )
239
+ . userUnlistens ( fullQuery )
240
+ . userListens ( limitQuery )
241
+ . expectEvents ( limitQuery , { added : [ doc1 , doc2 ] , fromCache : true } )
242
+ . watchAcksFull ( limitQuery , 1004 , doc1 , doc2 )
243
+ . expectEvents ( limitQuery , { } )
244
+ . userUnlistens ( limitQuery )
245
+ . watchRemoves ( limitQuery )
246
+ . userSets ( 'collection/a' , { pos : 4 } )
247
+ . userListens ( limitQuery , 'resume-token-1004' )
248
+ . expectEvents ( limitQuery , { added : [ doc2 , doc3 ] , fromCache : true } ) ;
249
+ }
250
+ ) ;
251
+
220
252
specTest (
221
253
'Resumed limit queries exclude deleted documents ' ,
222
254
[ 'durable-persistence' ] ,
0 commit comments