@@ -1333,8 +1333,8 @@ apiDescribe('Queries', persistence => {
1333
1333
} ) ;
1334
1334
} ) ;
1335
1335
1336
- // OR Query tests only run when the SDK is configured with persistence that
1337
- // uses LRU garbage collection (rather than eager garbage collection) because
1336
+ // OR Query tests only run when the SDK's local cache is configured to use
1337
+ // LRU garbage collection (rather than eager garbage collection) because
1338
1338
// they validate that the result from server and cache match.
1339
1339
// eslint-disable-next-line no-restricted-properties
1340
1340
( persistence . gc === 'lru' ? describe : describe . skip ) ( 'OR Queries' , ( ) => {
@@ -1647,8 +1647,8 @@ apiDescribe('Queries', persistence => {
1647
1647
} ) ;
1648
1648
} ) ;
1649
1649
1650
- // OR Query tests only run when the SDK is configured with persistence that
1651
- // uses LRU garbage collection (rather than eager garbage collection) because
1650
+ // OR Query tests only run when the SDK's local cache is configured to use
1651
+ // LRU garbage collection (rather than eager garbage collection) because
1652
1652
// they validate that the result from server and cache match. Additionally,
1653
1653
// these tests must be skipped if running against production because it
1654
1654
// results in a 'missing index' error. The Firestore Emulator, however, does
@@ -2034,49 +2034,46 @@ apiDescribe('Queries', persistence => {
2034
2034
) ;
2035
2035
2036
2036
// Reproduces https://github.com/firebase/firebase-js-sdk/issues/5873
2037
- describe (
2038
- 'Caching empty results' ,
2039
- ( ) => {
2040
- it ( 'can raise initial snapshot from cache, even if it is empty' , ( ) => {
2041
- // Use persistence with LRU garbage collection so that the cached resume
2042
- // token and document data do not get cleared.
2043
- return withTestCollection ( persistence . toLruGc ( ) , { } , async coll => {
2044
- const snapshot1 = await getDocs ( coll ) ; // Populate the cache.
2045
- expect ( snapshot1 . metadata . fromCache ) . to . be . false ;
2046
- expect ( toDataArray ( snapshot1 ) ) . to . deep . equal ( [ ] ) ; // Precondition check.
2047
-
2048
- // Add a snapshot listener whose first event should be raised from cache.
2049
- const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
2050
- onSnapshot ( coll , storeEvent . storeEvent ) ;
2051
- const snapshot2 = await storeEvent . awaitEvent ( ) ;
2052
- expect ( snapshot2 . metadata . fromCache ) . to . be . true ;
2053
- expect ( toDataArray ( snapshot2 ) ) . to . deep . equal ( [ ] ) ;
2054
- } ) ;
2037
+ describe ( 'Caching empty results' , ( ) => {
2038
+ it ( 'can raise initial snapshot from cache, even if it is empty' , ( ) => {
2039
+ // Use persistence with LRU garbage collection so the resume token and
2040
+ // document data do not get prematurely deleted from the local cache.
2041
+ return withTestCollection ( persistence . toLruGc ( ) , { } , async coll => {
2042
+ const snapshot1 = await getDocs ( coll ) ; // Populate the cache.
2043
+ expect ( snapshot1 . metadata . fromCache ) . to . be . false ;
2044
+ expect ( toDataArray ( snapshot1 ) ) . to . deep . equal ( [ ] ) ; // Precondition check.
2045
+
2046
+ // Add a snapshot listener whose first event should be raised from cache.
2047
+ const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
2048
+ onSnapshot ( coll , storeEvent . storeEvent ) ;
2049
+ const snapshot2 = await storeEvent . awaitEvent ( ) ;
2050
+ expect ( snapshot2 . metadata . fromCache ) . to . be . true ;
2051
+ expect ( toDataArray ( snapshot2 ) ) . to . deep . equal ( [ ] ) ;
2055
2052
} ) ;
2053
+ } ) ;
2056
2054
2057
- it ( 'can raise initial snapshot from cache, even if it has become empty' , ( ) => {
2058
- const testDocs = {
2059
- a : { key : 'a' }
2060
- } ;
2061
- // Use persistence with LRU garbage collection so that the cached resume
2062
- // token and document data do not get cleared.
2063
- return withTestCollection ( persistence . toLruGc ( ) , testDocs , async coll => {
2064
- // Populate the cache.
2065
- const snapshot1 = await getDocs ( coll ) ;
2066
- expect ( snapshot1 . metadata . fromCache ) . to . be . false ;
2067
- expect ( toDataArray ( snapshot1 ) ) . to . deep . equal ( [ { key : 'a' } ] ) ;
2068
- // Empty the collection.
2069
- void deleteDoc ( doc ( coll , 'a' ) ) ;
2070
-
2071
- const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
2072
- onSnapshot ( coll , storeEvent . storeEvent ) ;
2073
- const snapshot2 = await storeEvent . awaitEvent ( ) ;
2074
- expect ( snapshot2 . metadata . fromCache ) . to . be . true ;
2075
- expect ( toDataArray ( snapshot2 ) ) . to . deep . equal ( [ ] ) ;
2076
- } ) ;
2055
+ it ( 'can raise initial snapshot from cache, even if it has become empty' , ( ) => {
2056
+ const testDocs = {
2057
+ a : { key : 'a' }
2058
+ } ;
2059
+ // Use persistence with LRU garbage collection so the resume token and
2060
+ // document data do not get prematurely deleted from the local cache.
2061
+ return withTestCollection ( persistence . toLruGc ( ) , testDocs , async coll => {
2062
+ // Populate the cache.
2063
+ const snapshot1 = await getDocs ( coll ) ;
2064
+ expect ( snapshot1 . metadata . fromCache ) . to . be . false ;
2065
+ expect ( toDataArray ( snapshot1 ) ) . to . deep . equal ( [ { key : 'a' } ] ) ;
2066
+ // Empty the collection.
2067
+ void deleteDoc ( doc ( coll , 'a' ) ) ;
2068
+
2069
+ const storeEvent = new EventsAccumulator < QuerySnapshot > ( ) ;
2070
+ onSnapshot ( coll , storeEvent . storeEvent ) ;
2071
+ const snapshot2 = await storeEvent . awaitEvent ( ) ;
2072
+ expect ( snapshot2 . metadata . fromCache ) . to . be . true ;
2073
+ expect ( toDataArray ( snapshot2 ) ) . to . deep . equal ( [ ] ) ;
2077
2074
} ) ;
2078
- }
2079
- ) ;
2075
+ } ) ;
2076
+ } ) ;
2080
2077
2081
2078
it ( 'resuming a query should use bloom filter to avoid full requery' , async ( ) => {
2082
2079
// Prepare the names and contents of the 100 documents to create.
@@ -2142,10 +2139,10 @@ apiDescribe('Queries', persistence => {
2142
2139
) ;
2143
2140
}
2144
2141
2145
- // Skip the verification of the existence filter mismatch when persistence
2146
- // uses eager garbage collection because with eager GC there is no resume
2147
- // token specified in the subsequent call to getDocs(), and, therefore,
2148
- // Watch will _not_ send an existence filter.
2142
+ // Skip the verification of the existence filter mismatch when the local
2143
+ // cache is configured to use eager garbage collection because with eager
2144
+ // GC there is no resume token specified in the subsequent call to
2145
+ // getDocs(), and, therefore, Watch will _not_ send an existence filter.
2149
2146
// TODO(b/272754156) Re-write this test using a snapshot listener instead
2150
2147
// of calls to getDocs() and remove this check for disabled persistence.
2151
2148
if ( persistence . gc === 'eager' ) {
0 commit comments