@@ -62,6 +62,7 @@ import {
62
62
toChangesArray ,
63
63
toDataArray ,
64
64
toIds ,
65
+ PERSISTENCE_MODE_UNSPECIFIED ,
65
66
withEmptyTestCollection ,
66
67
withRetry ,
67
68
withTestCollection ,
@@ -2106,16 +2107,18 @@ apiDescribe('Queries', persistence => {
2106
2107
snapshot => snapshot . ref
2107
2108
) ;
2108
2109
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.
2111
2112
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
+ } ) ;
2119
2122
2120
2123
// Wait for 10 seconds, during which Watch will stop tracking the
2121
2124
// query and will send an existence filter rather than "delete"
@@ -2258,12 +2261,12 @@ apiDescribe('Queries', persistence => {
2258
2261
) ;
2259
2262
2260
2263
// 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.
2263
2266
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
+ } ) ;
2267
2270
2268
2271
// Wait for 10 seconds, during which Watch will stop tracking the query
2269
2272
// and will send an existence filter rather than "delete" events when
0 commit comments