@@ -505,7 +505,7 @@ describe('Caching', () => {
505505 await waitFor ( ( ) => conflictSourceRequest ?. id === id ) ;
506506 const sourceTimestamp = conflictSourceRequest . timestamp ;
507507 assert . equal ( typeof sourceTimestamp , 'number' ) ;
508- await ConflictCachingTable . put ( id , { id, name : 'authoritative' } ) ;
508+ await ConflictCachingTable . put ( id , { id, name : 'authoritative' } , { timestamp : sourceTimestamp + 1 } ) ;
509509 await waitFor ( ( ) => ConflictCachingTable . primaryStore . getSync ( id ) ?. name === 'authoritative' ) ;
510510 const authoritativeVersion = ConflictCachingTable . primaryStore . getEntry ( id ) . version ;
511511 conflictSourceRequest . respond ( { id, name : 'source' } ) ;
@@ -523,15 +523,16 @@ describe('Caching', () => {
523523 const existingVersion = ConflictCachingTable . primaryStore . getEntry ( id ) . version ;
524524 await ConflictCachingTable . invalidate ( id ) ;
525525 await waitFor ( ( ) => ConflictCachingTable . primaryStore . getEntry ( id ) ?. metadataFlags ) ;
526+ const invalidatedVersion = ConflictCachingTable . primaryStore . getEntry ( id ) . version ;
526527 conflictSourceRequest = null ;
527528 const fill = ConflictCachingTable . get ( id , { timestamp : existingVersion - 1000 } ) ;
528529 await waitFor ( ( ) => conflictSourceRequest ?. id === id ) ;
529- assert ( conflictSourceRequest . timestamp > existingVersion ) ;
530+ assert ( conflictSourceRequest . timestamp > invalidatedVersion ) ;
530531 conflictSourceRequest . respond ( { id, name : 'refreshed' } ) ;
531532 assert . equal ( ( await fill ) . name , 'refreshed' ) ;
532533 await waitFor ( ( ) => ! ConflictCachingTable . primaryStore . hasLock ( id ) ) ;
533534 assert . equal ( ConflictCachingTable . primaryStore . getSync ( id ) . name , 'refreshed' ) ;
534- assert ( ConflictCachingTable . primaryStore . getEntry ( id ) . version > existingVersion ) ;
535+ assert ( ConflictCachingTable . primaryStore . getEntry ( id ) . version > invalidatedVersion ) ;
535536 } ) ;
536537
537538 it ( 'first source fill replaces an older raced record and its index entries' , async function ( ) {
@@ -541,7 +542,7 @@ describe('Caching', () => {
541542 await waitFor ( ( ) => conflictSourceRequest ?. id === id ) ;
542543 const sourceTimestamp = conflictSourceRequest . timestamp ;
543544 const createdAt = new Date ( sourceTimestamp - 0.0001 ) ;
544- await ConflictCachingTable . put ( id , { id, name : 'older' , createdAt } ) ;
545+ await ConflictCachingTable . put ( id , { id, name : 'older' , createdAt } , { timestamp : sourceTimestamp - 1 } ) ;
545546 await waitFor ( ( ) => ConflictCachingTable . primaryStore . getSync ( id ) ?. name === 'older' ) ;
546547 const racedEntry = ConflictCachingTable . primaryStore . getEntry ( id ) ;
547548 assert ( racedEntry . version < sourceTimestamp ) ;
@@ -574,7 +575,7 @@ describe('Caching', () => {
574575 const fill = ConflictCachingTable . get ( id , { timestamp : nextConflictTimestamp ( ) } ) ;
575576 await waitFor ( ( ) => conflictSourceRequest ?. id === id ) ;
576577 const sourceTimestamp = conflictSourceRequest . timestamp ;
577- await ConflictCachingTable . put ( id , { id, name : 'raced' } ) ;
578+ await ConflictCachingTable . put ( id , { id, name : 'raced' } , { timestamp : sourceTimestamp - 1 } ) ;
578579 await waitFor ( ( ) => ConflictCachingTable . primaryStore . getSync ( id ) ?. name === 'raced' ) ;
579580 assert ( ConflictCachingTable . primaryStore . getEntry ( id ) . version < sourceTimestamp ) ;
580581 const racedVersion = ConflictCachingTable . primaryStore . getEntry ( id ) . version ;
@@ -591,7 +592,7 @@ describe('Caching', () => {
591592 const fill = ConflictCachingTable . get ( id , { timestamp : nextConflictTimestamp ( ) } ) ;
592593 await waitFor ( ( ) => conflictSourceRequest ?. id === id ) ;
593594 const sourceTimestamp = conflictSourceRequest . timestamp ;
594- await ConflictCachingTable . put ( id , { id, name : 'older-delete' } ) ;
595+ await ConflictCachingTable . put ( id , { id, name : 'older-delete' } , { timestamp : sourceTimestamp - 1 } ) ;
595596 await waitFor ( ( ) => ConflictCachingTable . primaryStore . getSync ( id ) ?. name === 'older-delete' ) ;
596597 assert ( ConflictCachingTable . primaryStore . getEntry ( id ) . version < sourceTimestamp ) ;
597598 const racedVersion = ConflictCachingTable . primaryStore . getEntry ( id ) . version ;
0 commit comments