Skip to content

Commit 90d449e

Browse files
committed
add integration test
1 parent b7072d1 commit 90d449e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

packages/firestore/test/integration/api/query.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
Query,
4848
query,
4949
QuerySnapshot,
50+
runTransaction,
5051
setDoc,
5152
startAfter,
5253
startAt,
@@ -1614,6 +1615,30 @@ apiDescribe('Queries', (persistence: boolean) => {
16141615
});
16151616
});
16161617
});
1618+
1619+
it('can handle existence filter', () => {
1620+
const testDocs = {};
1621+
for (let i = 1; i <= 100; i++) {
1622+
Object.assign(testDocs, { ['doc' + i]: { key: i } });
1623+
}
1624+
return withTestCollection(persistence, testDocs, async (coll, db) => {
1625+
const snapshot1 = await getDocs(coll);
1626+
expect(snapshot1.size).to.equal(100);
1627+
// Delete 50 docs in transaction so that it doesn't affect local cache.
1628+
await runTransaction(db, async txn => {
1629+
for (let i = 1; i <= 50; i++) {
1630+
txn.delete(doc(coll, 'doc' + i));
1631+
}
1632+
});
1633+
// Wait 10 seconds, during which the watch will stop tracking the query
1634+
// and will send an existence filter rather than "delete" events.
1635+
await (function () {
1636+
return new Promise(resolve => setTimeout(resolve, 10000));
1637+
})();
1638+
const snapshot2 = await getDocs(coll);
1639+
expect(snapshot2.size).to.equal(50);
1640+
});
1641+
}).timeout('15s');
16171642
});
16181643

16191644
function verifyDocumentChange<T>(

0 commit comments

Comments
 (0)