Skip to content

Commit d1a640d

Browse files
Add one more test case
1 parent c2504df commit d1a640d

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

packages/firestore/src/util/log.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ export function setLogLevel(newLevel: LogLevel): void {
5959
}
6060

6161
export function debug(tag: string, msg: string, ...obj: unknown[]): void {
62-
if (logClient.logLevel <= FirebaseLogLevel.DEBUG) {
63-
const args = obj.map(argToString);
64-
logClient.debug(`Firestore (${SDK_VERSION}) [${tag}]: ${msg}`, ...args);
65-
}
62+
// if (logClient.logLevel <= FirebaseLogLevel.DEBUG) {
63+
const args = obj.map(argToString);
64+
console.info(`Firestore (${SDK_VERSION}) [${tag}]: ${msg}`, ...args);
65+
// }
6666
}
6767

6868
export function error(msg: string, ...obj: unknown[]): void {

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

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,12 @@ describeSpec('Limits:', [], () => {
218218
);
219219

220220
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)',
222222
[],
223223
() => {
224224
// 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.
227227
const fullQuery = Query.atPath(path('collection'));
228228
const limitQuery = Query.atPath(path('collection'))
229229
.addOrderBy(orderBy('pos'))
@@ -237,6 +237,7 @@ describeSpec('Limits:', [], () => {
237237
.watchAcksFull(fullQuery, 1003, doc1, doc2, doc3)
238238
.expectEvents(fullQuery, { added: [doc1, doc2, doc3] })
239239
.userUnlistens(fullQuery)
240+
.watchRemoves(fullQuery)
240241
.userListens(limitQuery)
241242
.expectEvents(limitQuery, { added: [doc1, doc2], fromCache: true })
242243
.watchAcksFull(limitQuery, 1004, doc1, doc2)
@@ -249,6 +250,43 @@ describeSpec('Limits:', [], () => {
249250
}
250251
);
251252

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+
252290
specTest(
253291
'Resumed limit queries exclude deleted documents ',
254292
['durable-persistence'],

0 commit comments

Comments
 (0)