File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
packages/firestore/test/integration/api Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ import {
47
47
Query ,
48
48
query ,
49
49
QuerySnapshot ,
50
+ runTransaction ,
50
51
setDoc ,
51
52
startAfter ,
52
53
startAt ,
@@ -1614,6 +1615,30 @@ apiDescribe('Queries', (persistence: boolean) => {
1614
1615
} ) ;
1615
1616
} ) ;
1616
1617
} ) ;
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' ) ;
1617
1642
} ) ;
1618
1643
1619
1644
function verifyDocumentChange < T > (
You can’t perform that action at this time.
0 commit comments