Skip to content

Commit 3c3ddb4

Browse files
Add spec test for limit query initialization (#2050)
1 parent 16bbe6c commit 3c3ddb4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

packages/firestore/test/unit/specs/limit_spec.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,33 @@ describeSpec('Limits:', [], () => {
184184
});
185185
});
186186

187+
specTest(
188+
'Initial snapshots for limit queries are re-filled from cache',
189+
[],
190+
() => {
191+
// Verify that views for limit queries are re-filled even if the initial
192+
// snapshot does not contain the requested number of results.
193+
const fullQuery = Query.atPath(path('collection')).addFilter(
194+
filter('matches', '==', true)
195+
);
196+
const limitQuery = Query.atPath(path('collection'))
197+
.addFilter(filter('matches', '==', true))
198+
.withLimit(2);
199+
const doc1 = doc('collection/a', 1001, { matches: true });
200+
const doc2 = doc('collection/b', 1002, { matches: true });
201+
const doc3 = doc('collection/c', 1003, { matches: true });
202+
return spec()
203+
.withGCEnabled(false)
204+
.userListens(fullQuery)
205+
.watchAcksFull(fullQuery, 1003, doc1, doc2, doc3)
206+
.expectEvents(fullQuery, { added: [doc1, doc2, doc3] })
207+
.userUnlistens(fullQuery)
208+
.userSets('collection/a', { matches: false })
209+
.userListens(limitQuery)
210+
.expectEvents(limitQuery, { added: [doc2, doc3], fromCache: true });
211+
}
212+
);
213+
187214
specTest(
188215
'Resumed limit queries exclude deleted documents ',
189216
['durable-persistence'],

0 commit comments

Comments
 (0)