Skip to content

Commit a5bf94c

Browse files
authored
Firestore: query.test.ts: use a different Firestore instance instead of a WriteBatch
1 parent 223ac18 commit a5bf94c

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

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

+17-14
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import {
6262
toChangesArray,
6363
toDataArray,
6464
toIds,
65+
PERSISTENCE_MODE_UNSPECIFIED,
6566
withEmptyTestCollection,
6667
withRetry,
6768
withTestCollection,
@@ -2106,16 +2107,18 @@ apiDescribe('Queries', persistence => {
21062107
snapshot => snapshot.ref
21072108
);
21082109

2109-
// Delete 50 of the 100 documents. Use a WriteBatch, rather than
2110-
// deleteDoc(), to avoid affecting the local cache.
2110+
// Delete 50 of the 100 documents. Use a different Firestore
2111+
// instance to avoid affecting the local cache.
21112112
const deletedDocumentIds = new Set<string>();
2112-
const writeBatchForDocumentDeletes = writeBatch(db);
2113-
for (let i = 0; i < createdDocuments.length; i += 2) {
2114-
const documentToDelete = createdDocuments[i];
2115-
writeBatchForDocumentDeletes.delete(documentToDelete);
2116-
deletedDocumentIds.add(documentToDelete.id);
2117-
}
2118-
await writeBatchForDocumentDeletes.commit();
2113+
await withTestDb(PERSISTENCE_MODE_UNSPECIFIED, async db2 => {
2114+
const batch = writeBatch(db2);
2115+
for (let i = 0; i < createdDocuments.length; i += 2) {
2116+
const documentToDelete = doc(db2, createdDocuments[i].path);
2117+
batch.delete(documentToDelete);
2118+
deletedDocumentIds.add(documentToDelete.id);
2119+
}
2120+
await batch.commit();
2121+
});
21192122

21202123
// Wait for 10 seconds, during which Watch will stop tracking the
21212124
// query and will send an existence filter rather than "delete"
@@ -2258,12 +2261,12 @@ apiDescribe('Queries', persistence => {
22582261
);
22592262

22602263
// Delete one of the documents so that the next call to getDocs() will
2261-
// experience an existence filter mismatch. Use a WriteBatch, rather
2262-
// than deleteDoc(), to avoid affecting the local cache.
2264+
// experience an existence filter mismatch. Use a different Firestore
2265+
// instance to avoid affecting the local cache.
22632266
const documentToDelete = doc(coll, 'DocumentToDelete');
2264-
const writeBatchForDocumentDeletes = writeBatch(db);
2265-
writeBatchForDocumentDeletes.delete(documentToDelete);
2266-
await writeBatchForDocumentDeletes.commit();
2267+
await withTestDb(PERSISTENCE_MODE_UNSPECIFIED, async db2 => {
2268+
await deleteDoc(doc(db2, documentToDelete.path));
2269+
});
22672270

22682271
// Wait for 10 seconds, during which Watch will stop tracking the query
22692272
// and will send an existence filter rather than "delete" events when

0 commit comments

Comments
 (0)