@@ -401,7 +401,7 @@ function defineSyncTests(impl: SyncClientImplementation) {
401401
402402 mockSyncServiceTest ( 'interrupt and defrag' , async ( { syncService } ) => {
403403 let database = await syncService . createDatabase ( ) ;
404- database . connect ( new TestConnector ( ) , { connectionMethod : SyncStreamConnectionMethod . HTTP } ) ;
404+ database . connect ( new TestConnector ( ) , options ) ;
405405 await vi . waitFor ( ( ) => expect ( syncService . connectedListeners ) . toHaveLength ( 1 ) ) ;
406406
407407 syncService . pushLine ( {
@@ -419,7 +419,7 @@ function defineSyncTests(impl: SyncClientImplementation) {
419419 await database . close ( ) ;
420420 await vi . waitFor ( ( ) => expect ( syncService . connectedListeners ) . toHaveLength ( 0 ) ) ;
421421 database = await syncService . createDatabase ( ) ;
422- database . connect ( new TestConnector ( ) , { connectionMethod : SyncStreamConnectionMethod . HTTP } ) ;
422+ database . connect ( new TestConnector ( ) , options ) ;
423423 await vi . waitFor ( ( ) => expect ( syncService . connectedListeners ) . toHaveLength ( 1 ) ) ;
424424
425425 // A sync rule deploy could reset buckets, making the new bucket smaller than the existing one.
@@ -436,6 +436,39 @@ function defineSyncTests(impl: SyncClientImplementation) {
436436 await waitForSyncStatus ( database , ( s ) => s . downloadProgress == null ) ;
437437 } ) ;
438438 } ) ;
439+
440+ mockSyncServiceTest ( 'should upload after connecting' , async ( { syncService } ) => {
441+ let database = await syncService . createDatabase ( ) ;
442+
443+ database . execute ( 'INSERT INTO lists (id, name) values (uuid(), ?)' , [ 'local write' ] ) ;
444+ const query = database . watchWithAsyncGenerator ( 'SELECT name FROM lists' ) [ Symbol . asyncIterator ] ( ) ;
445+ let rows = ( await query . next ( ) ) . value . rows . _array ;
446+ expect ( rows ) . toStrictEqual ( [ { name : 'local write' } ] ) ;
447+
448+ database . connect ( new TestConnector ( ) , options ) ;
449+ await vi . waitFor ( ( ) => expect ( syncService . connectedListeners ) . toHaveLength ( 1 ) ) ;
450+
451+ syncService . pushLine ( { checkpoint : { last_op_id : '1' , write_checkpoint : '1' , buckets : [ bucket ( 'a' , 1 ) ] } } ) ;
452+ syncService . pushLine ( {
453+ data : {
454+ bucket : 'a' ,
455+ data : [
456+ {
457+ checksum : 0 ,
458+ op_id : '1' ,
459+ op : 'PUT' ,
460+ object_id : '1' ,
461+ object_type : 'lists' ,
462+ data : '{"name": "from server"}'
463+ }
464+ ]
465+ }
466+ } ) ;
467+ syncService . pushLine ( { checkpoint_complete : { last_op_id : '1' } } ) ;
468+
469+ rows = ( await query . next ( ) ) . value . rows . _array ;
470+ expect ( rows ) . toStrictEqual ( [ { name : 'from server' } ] ) ;
471+ } ) ;
439472}
440473
441474function bucket ( name : string , count : number , options : { priority : number } = { priority : 3 } ) : BucketChecksum {
0 commit comments