Skip to content

Commit c57b9f1

Browse files
committed
Write a spec test for the busted cache
1 parent 6905339 commit c57b9f1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

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

+29
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,35 @@ describeSpec('Listens:', [], () => {
283283
);
284284
});
285285

286+
specTest('Deleted documents in cache are fixed', ['exclusive'], () => {
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 spec()
292+
// Presuppose an initial state where the remote document cache has a
293+
// broken synthesized delete at a timestamp later than the true version
294+
// of the document.
295+
.withGCEnabled(false)
296+
.userListens(allQuery)
297+
.watchAcksFull(allQuery, 1000, docAv1)
298+
.expectEvents(allQuery, { added: [docAv1], fromCache: false })
299+
.watchSends({ removed: [allQuery] }, docDeleted)
300+
.watchCurrents(allQuery, 'resume-token-2000')
301+
.watchSnapshots(2000)
302+
.expectEvents(allQuery, { removed: [docAv1], fromCache: false })
303+
.userUnlistens(allQuery)
304+
.watchRemoves(allQuery)
305+
.restart()
306+
307+
// Now when the client listens expect the cached NoDocument to be
308+
// discarded because the global snapshot version exceeds what came before.
309+
.userListens(allQuery, 'resume-token-2000')
310+
.watchAcksFull(allQuery, 3000, docAv1)
311+
.expectEvents(allQuery, { added: [docAv1], fromCache: false })
312+
;
313+
});
314+
286315
specTest('Listens are reestablished after network disconnect', [], () => {
287316
const expectRequestCount = requestCounts =>
288317
requestCounts.addTarget + requestCounts.removeTarget;

0 commit comments

Comments
 (0)