@@ -556,29 +556,29 @@ describe('LocalStore w/ Memory Persistence', () => {
556
556
genericLocalStoreTests ( initialize , /* gcIsEager= */ true ) ;
557
557
} ) ;
558
558
559
- // describe('LocalStore w/ IndexedDB Persistence', () => {
560
- // if (!IndexedDbPersistence.isAvailable()) {
561
- // console.warn(
562
- // 'No IndexedDB. Skipping LocalStore w/ IndexedDB persistence tests.'
563
- // );
564
- // return;
565
- // }
566
- //
567
- // async function initialize(): Promise<LocalStoreComponents> {
568
- // const queryEngine = new CountingQueryEngine();
569
- // const persistence = await persistenceHelpers.testIndexedDbPersistence();
570
- // const localStore = newLocalStore(
571
- // persistence,
572
- // queryEngine,
573
- // User.UNAUTHENTICATED,
574
- // JSON_SERIALIZER
575
- // );
576
- // return { queryEngine, persistence, localStore };
577
- // }
578
- //
579
- // addEqualityMatcher();
580
- // genericLocalStoreTests(initialize, /* gcIsEager= */ false);
581
- // });
559
+ describe ( 'LocalStore w/ IndexedDB Persistence' , ( ) => {
560
+ if ( ! IndexedDbPersistence . isAvailable ( ) ) {
561
+ console . warn (
562
+ 'No IndexedDB. Skipping LocalStore w/ IndexedDB persistence tests.'
563
+ ) ;
564
+ return ;
565
+ }
566
+
567
+ async function initialize ( ) : Promise < LocalStoreComponents > {
568
+ const queryEngine = new CountingQueryEngine ( ) ;
569
+ const persistence = await persistenceHelpers . testIndexedDbPersistence ( ) ;
570
+ const localStore = newLocalStore (
571
+ persistence ,
572
+ queryEngine ,
573
+ User . UNAUTHENTICATED ,
574
+ JSON_SERIALIZER
575
+ ) ;
576
+ return { queryEngine, persistence, localStore } ;
577
+ }
578
+
579
+ addEqualityMatcher ( ) ;
580
+ genericLocalStoreTests ( initialize , /* gcIsEager= */ false ) ;
581
+ } ) ;
582
582
583
583
function genericLocalStoreTests (
584
584
getComponents : ( ) => Promise < LocalStoreComponents > ,
@@ -616,10 +616,10 @@ function genericLocalStoreTests(
616
616
. toContain ( doc ( 'foo/bar' , 0 , { foo : 'bar' } ) . setHasLocalMutations ( ) )
617
617
. afterAcknowledgingMutation ( { documentVersion : 1 } )
618
618
. toReturnChanged (
619
- doc ( 'foo/bar' , 1 , { foo : 'bar' } , 1 ) . setHasCommittedMutations ( )
619
+ doc ( 'foo/bar' , 1 , { foo : 'bar' } ) . setHasCommittedMutations ( )
620
620
)
621
621
. toNotContainIfEager (
622
- doc ( 'foo/bar' , 1 , { foo : 'bar' } , 1 ) . setHasCommittedMutations ( )
622
+ doc ( 'foo/bar' , 1 , { foo : 'bar' } ) . setHasCommittedMutations ( )
623
623
)
624
624
. finish ( ) ;
625
625
} ) ;
@@ -653,10 +653,10 @@ function genericLocalStoreTests(
653
653
// Last seen version is zero, so this ack must be held.
654
654
. afterAcknowledgingMutation ( { documentVersion : 1 } )
655
655
. toReturnChanged (
656
- doc ( 'foo/bar' , 1 , { foo : 'bar' } , 1 ) . setHasCommittedMutations ( )
656
+ doc ( 'foo/bar' , 1 , { foo : 'bar' } ) . setHasCommittedMutations ( )
657
657
)
658
658
. toNotContainIfEager (
659
- doc ( 'foo/bar' , 1 , { foo : 'bar' } , 1 ) . setHasCommittedMutations ( )
659
+ doc ( 'foo/bar' , 1 , { foo : 'bar' } ) . setHasCommittedMutations ( )
660
660
)
661
661
. after ( setMutation ( 'bar/baz' , { bar : 'baz' } ) )
662
662
. toReturnChanged (
@@ -667,10 +667,10 @@ function genericLocalStoreTests(
667
667
. toReturnRemoved ( 'bar/baz' )
668
668
. toNotContain ( 'bar/baz' )
669
669
. afterRemoteEvent (
670
- docAddedRemoteEvent ( doc ( 'foo/bar' , 2 , { it : 'changed' } , 1 ) , [ 2 ] )
670
+ docAddedRemoteEvent ( doc ( 'foo/bar' , 2 , { it : 'changed' } ) , [ 2 ] )
671
671
)
672
- . toReturnChanged ( doc ( 'foo/bar' , 2 , { it : 'changed' } , 1 ) )
673
- . toContain ( doc ( 'foo/bar' , 2 , { it : 'changed' } , 1 ) )
672
+ . toReturnChanged ( doc ( 'foo/bar' , 2 , { it : 'changed' } ) )
673
+ . toContain ( doc ( 'foo/bar' , 2 , { it : 'changed' } ) )
674
674
. toNotContain ( 'bar/baz' )
675
675
. finish ( )
676
676
) ;
@@ -686,31 +686,15 @@ function genericLocalStoreTests(
686
686
. toReturnRemoved ( 'foo/bar' )
687
687
. toNotContainIfEager ( deletedDoc ( 'foo/bar' , 2 ) )
688
688
. after ( setMutation ( 'foo/bar' , { foo : 'bar' } ) )
689
- . toReturnChanged (
690
- // For Memory Persistence, after the `deletedDoc` event, eager GC
691
- // removes the document from the cache, so the setMutation is applied on
692
- // a non-existent document. The result is therefore a document without a
693
- // createTime.
694
- //
695
- // For IndexedDB Persistence, a "NO_DOCUMENT" with version '2' remains
696
- // in the cache, and the setMutation is applied on top of the
697
- // NO_DOCUMENT, and uses its version (2000) as the new createTime.
698
- gcIsEager ?
699
- doc ( 'foo/bar' , 0 , { foo : 'bar' } ) . setHasLocalMutations ( ) :
700
- doc ( 'foo/bar' , 0 , { foo : 'bar' } , 2 ) . setHasLocalMutations ( )
701
- )
702
- . toContain (
703
- gcIsEager ?
704
- doc ( 'foo/bar' , 0 , { foo : 'bar' } ) . setHasLocalMutations ( ) :
705
- doc ( 'foo/bar' , 0 , { foo : 'bar' } , 2 ) . setHasLocalMutations ( )
706
- )
689
+ . toReturnChanged ( doc ( 'foo/bar' , 0 , { foo : 'bar' } ) . setHasLocalMutations ( ) )
690
+ . toContain ( doc ( 'foo/bar' , 0 , { foo : 'bar' } ) . setHasLocalMutations ( ) )
707
691
. afterReleasingTarget ( 2 )
708
692
. afterAcknowledgingMutation ( { documentVersion : 3 } )
709
693
. toReturnChanged (
710
- doc ( 'foo/bar' , 3 , { foo : 'bar' } , 3 ) . setHasCommittedMutations ( )
694
+ doc ( 'foo/bar' , 3 , { foo : 'bar' } ) . setHasCommittedMutations ( )
711
695
)
712
696
. toNotContainIfEager (
713
- doc ( 'foo/bar' , 3 , { foo : 'bar' } , 3 ) . setHasCommittedMutations ( )
697
+ doc ( 'foo/bar' , 3 , { foo : 'bar' } ) . setHasCommittedMutations ( )
714
698
)
715
699
. finish ( ) ;
716
700
} ) ;
@@ -722,8 +706,8 @@ function genericLocalStoreTests(
722
706
. after ( setMutation ( 'foo/bar' , { foo : 'bar' } ) )
723
707
. toReturnChanged ( doc ( 'foo/bar' , 0 , { foo : 'bar' } ) . setHasLocalMutations ( ) )
724
708
. after ( docUpdateRemoteEvent ( deletedDoc ( 'foo/bar' , 2 ) , [ 2 ] ) )
725
- . toReturnChanged ( doc ( 'foo/bar' , 0 , { foo : 'bar' } , 2 ) . setHasLocalMutations ( ) )
726
- . toContain ( doc ( 'foo/bar' , 0 , { foo : 'bar' } , 2 ) . setHasLocalMutations ( ) )
709
+ . toReturnChanged ( doc ( 'foo/bar' , 0 , { foo : 'bar' } ) . setHasLocalMutations ( ) )
710
+ . toContain ( doc ( 'foo/bar' , 0 , { foo : 'bar' } ) . setHasLocalMutations ( ) )
727
711
. finish ( ) ;
728
712
} ) ;
729
713
@@ -1345,23 +1329,23 @@ function genericLocalStoreTests(
1345
1329
. toContain ( doc ( 'foo/bar' , 0 , { sum : 0 } ) . setHasLocalMutations ( ) )
1346
1330
. afterAcknowledgingMutation ( { documentVersion : 1 } )
1347
1331
. toReturnChanged (
1348
- doc ( 'foo/bar' , 1 , { sum : 0 } , 1 ) . setHasCommittedMutations ( )
1332
+ doc ( 'foo/bar' , 1 , { sum : 0 } ) . setHasCommittedMutations ( )
1349
1333
)
1350
- . toContain ( doc ( 'foo/bar' , 1 , { sum : 0 } , 1 ) . setHasCommittedMutations ( ) )
1334
+ . toContain ( doc ( 'foo/bar' , 1 , { sum : 0 } ) . setHasCommittedMutations ( ) )
1351
1335
. after ( patchMutation ( 'foo/bar' , { sum : increment ( 1 ) } ) )
1352
- . toReturnChanged ( doc ( 'foo/bar' , 1 , { sum : 1 } , 1 ) . setHasLocalMutations ( ) )
1353
- . toContain ( doc ( 'foo/bar' , 1 , { sum : 1 } , 1 ) . setHasLocalMutations ( ) )
1336
+ . toReturnChanged ( doc ( 'foo/bar' , 1 , { sum : 1 } ) . setHasLocalMutations ( ) )
1337
+ . toContain ( doc ( 'foo/bar' , 1 , { sum : 1 } ) . setHasLocalMutations ( ) )
1354
1338
. afterAcknowledgingMutation ( {
1355
1339
documentVersion : 2 ,
1356
1340
transformResults : [ { integerValue : 1 } ]
1357
1341
} )
1358
1342
. toReturnChanged (
1359
- doc ( 'foo/bar' , 2 , { sum : 1 } , 1 ) . setHasCommittedMutations ( )
1343
+ doc ( 'foo/bar' , 2 , { sum : 1 } ) . setHasCommittedMutations ( )
1360
1344
)
1361
- . toContain ( doc ( 'foo/bar' , 2 , { sum : 1 } , 1 ) . setHasCommittedMutations ( ) )
1345
+ . toContain ( doc ( 'foo/bar' , 2 , { sum : 1 } ) . setHasCommittedMutations ( ) )
1362
1346
. after ( patchMutation ( 'foo/bar' , { sum : increment ( 2 ) } ) )
1363
- . toReturnChanged ( doc ( 'foo/bar' , 2 , { sum : 3 } , 1 ) . setHasLocalMutations ( ) )
1364
- . toContain ( doc ( 'foo/bar' , 2 , { sum : 3 } , 1 ) . setHasLocalMutations ( ) )
1347
+ . toReturnChanged ( doc ( 'foo/bar' , 2 , { sum : 3 } ) . setHasLocalMutations ( ) )
1348
+ . toContain ( doc ( 'foo/bar' , 2 , { sum : 3 } ) . setHasLocalMutations ( ) )
1365
1349
. finish ( ) ;
1366
1350
}
1367
1351
) ;
@@ -1429,45 +1413,45 @@ function genericLocalStoreTests(
1429
1413
doc ( 'foo/bar' , 1 , {
1430
1414
sum : 0 ,
1431
1415
arrayUnion : [ ]
1432
- } , 1 ) . setHasCommittedMutations ( )
1416
+ } ) . setHasCommittedMutations ( )
1433
1417
)
1434
1418
. afterRemoteEvent (
1435
1419
docAddedRemoteEvent (
1436
1420
doc ( 'foo/bar' , 1 , {
1437
1421
sum : 0 ,
1438
1422
arrayUnion : [ ]
1439
- } , 1 ) ,
1423
+ } ) ,
1440
1424
[ 2 ]
1441
1425
)
1442
1426
)
1443
- . toReturnChanged ( doc ( 'foo/bar' , 1 , { sum : 0 , arrayUnion : [ ] } , 1 ) )
1427
+ . toReturnChanged ( doc ( 'foo/bar' , 1 , { sum : 0 , arrayUnion : [ ] } ) )
1444
1428
. after ( patchMutation ( 'foo/bar' , { sum : increment ( 1 ) } ) )
1445
1429
. toReturnChanged (
1446
1430
doc ( 'foo/bar' , 1 , {
1447
1431
sum : 1 ,
1448
1432
arrayUnion : [ ]
1449
- } , 1 ) . setHasLocalMutations ( )
1433
+ } ) . setHasLocalMutations ( )
1450
1434
)
1451
1435
. after ( patchMutation ( 'foo/bar' , { arrayUnion : arrayUnion ( 'foo' ) } ) )
1452
1436
. toReturnChanged (
1453
1437
doc ( 'foo/bar' , 1 , {
1454
1438
sum : 1 ,
1455
1439
arrayUnion : [ 'foo' ]
1456
- } , 1 ) . setHasLocalMutations ( )
1440
+ } ) . setHasLocalMutations ( )
1457
1441
)
1458
1442
// The sum transform and array union transform make the SDK ignore the
1459
1443
// backend's updated value.
1460
1444
. afterRemoteEvent (
1461
1445
docUpdateRemoteEvent (
1462
- doc ( 'foo/bar' , 2 , { sum : 1337 , arrayUnion : [ 'bar' ] } , 1 ) ,
1446
+ doc ( 'foo/bar' , 2 , { sum : 1337 , arrayUnion : [ 'bar' ] } ) ,
1463
1447
[ 2 ]
1464
1448
)
1465
1449
)
1466
1450
. toReturnChanged (
1467
1451
doc ( 'foo/bar' , 2 , {
1468
1452
sum : 1 ,
1469
1453
arrayUnion : [ 'foo' ]
1470
- } , 1 ) . setHasLocalMutations ( )
1454
+ } ) . setHasLocalMutations ( )
1471
1455
)
1472
1456
// With a field transform acknowledgement, the overlay is recalculated
1473
1457
// with the remaining local mutations.
@@ -1479,7 +1463,7 @@ function genericLocalStoreTests(
1479
1463
doc ( 'foo/bar' , 3 , {
1480
1464
sum : 1338 ,
1481
1465
arrayUnion : [ 'bar' , 'foo' ]
1482
- } , 1 )
1466
+ } )
1483
1467
. setReadTime ( SnapshotVersion . fromTimestamp ( new Timestamp ( 0 , 3000 ) ) )
1484
1468
. setHasLocalMutations ( )
1485
1469
)
@@ -1497,7 +1481,7 @@ function genericLocalStoreTests(
1497
1481
doc ( 'foo/bar' , 4 , {
1498
1482
sum : 1338 ,
1499
1483
arrayUnion : [ 'bar' , 'foo' ]
1500
- } , 1 )
1484
+ } )
1501
1485
. setReadTime ( SnapshotVersion . fromTimestamp ( new Timestamp ( 0 , 4000 ) ) )
1502
1486
. setHasCommittedMutations ( )
1503
1487
)
@@ -2021,7 +2005,7 @@ function genericLocalStoreTests(
2021
2005
// set mutations. This is OK because it has no impact on aggregation's heuristic logic. But it feels
2022
2006
// "wrong" to have createTime 0 here. We should revisit this.
2023
2007
. toContain (
2024
- doc ( 'col/doc1' , 12 , { foo : 'newBar' } , 12 ) . setHasLocalMutations ( )
2008
+ doc ( 'col/doc1' , 12 , { foo : 'newBar' } , 0 ) . setHasLocalMutations ( )
2025
2009
)
2026
2010
. afterAcknowledgingMutation ( { documentVersion : 13 } )
2027
2011
// We haven't seen the remote event yet
@@ -2225,28 +2209,28 @@ function genericLocalStoreTests(
2225
2209
. afterAllocatingQuery ( query1 )
2226
2210
. toReturnTargetId ( 2 )
2227
2211
. after (
2228
- docAddedRemoteEvent ( [ doc ( 'foo/a' , 10 , { matches : true } , 5 ) ] , [ 2 ] , [ ] )
2212
+ docAddedRemoteEvent ( [ doc ( 'foo/a' , 10 , { matches : true } ) ] , [ 2 ] , [ ] )
2229
2213
)
2230
2214
. after ( localViewChanges ( 2 , /* fromCache= */ false , { } ) )
2231
2215
// Execute the query based on the RemoteEvent.
2232
2216
. afterExecutingQuery ( query1 )
2233
- . toReturnChanged ( doc ( 'foo/a' , 10 , { matches : true } , 5 ) )
2217
+ . toReturnChanged ( doc ( 'foo/a' , 10 , { matches : true } ) )
2234
2218
// Write a document.
2235
2219
. after ( setMutation ( 'foo/b' , { matches : true } ) )
2236
2220
// Execute the query and make sure that the pending mutation is
2237
2221
// included in the result.
2238
2222
. afterExecutingQuery ( query1 )
2239
2223
. toReturnChanged (
2240
- doc ( 'foo/a' , 10 , { matches : true } , 5 ) ,
2224
+ doc ( 'foo/a' , 10 , { matches : true } ) ,
2241
2225
doc ( 'foo/b' , 0 , { matches : true } ) . setHasLocalMutations ( )
2242
2226
)
2243
2227
. afterAcknowledgingMutation ( { documentVersion : 11 } )
2244
2228
// Execute the query and make sure that the acknowledged mutation is
2245
2229
// included in the result.
2246
2230
. afterExecutingQuery ( query1 )
2247
2231
. toReturnChanged (
2248
- doc ( 'foo/a' , 10 , { matches : true } , 5 ) ,
2249
- doc ( 'foo/b' , 11 , { matches : true } , 11 ) . setHasCommittedMutations ( )
2232
+ doc ( 'foo/a' , 10 , { matches : true } ) ,
2233
+ doc ( 'foo/b' , 11 , { matches : true } ) . setHasCommittedMutations ( )
2250
2234
)
2251
2235
. finish ( )
2252
2236
) ;
0 commit comments