@@ -303,127 +303,5 @@ function describeStreamingTests(createConnectedDatabase: () => Promise<Connected
303303 }
304304 ) ;
305305 } ) ;
306-
307- it ( 'Should upload after reconnecting' , async ( ) => {
308- const { powersync, connect, uploadSpy } = await createConnectedDatabase ( ) ;
309- expect ( powersync . connected ) . toBe ( true ) ;
310-
311- await powersync . disconnect ( ) ;
312-
313- // Status should update after uploads are completed
314- await vi . waitFor (
315- ( ) => {
316- // to-have-been-called seems to not work after failing a check
317- expect ( powersync . currentStatus . dataFlowStatus . uploading ) . false ;
318- } ,
319- {
320- timeout : UPLOAD_TIMEOUT_MS
321- }
322- ) ;
323- } ) ;
324-
325- it ( 'Should update sync state incrementally' , async ( ) => {
326- const { powersync, remote } = await createConnectedDatabase ( ) ;
327- expect ( powersync . currentStatus . dataFlowStatus . downloading ) . toBe ( false ) ;
328-
329- const buckets : BucketChecksum [ ] = [ ] ;
330- for ( let prio = 0 ; prio <= 3 ; prio ++ ) {
331- buckets . push ( { bucket : `prio${ prio } ` , priority : prio , checksum : 10 + prio } ) ;
332- }
333- remote . enqueueLine ( {
334- checkpoint : {
335- last_op_id : '4' ,
336- buckets
337- }
338- } ) ;
339-
340- let operationId = 1 ;
341- const addRow = ( prio : number ) => {
342- remote . enqueueLine ( {
343- data : {
344- bucket : `prio${ prio } ` ,
345- data : [
346- {
347- checksum : prio + 10 ,
348- data : JSON . stringify ( { name : 'row' } ) ,
349- op : 'PUT' ,
350- op_id : ( operationId ++ ) . toString ( ) ,
351- object_id : `prio${ prio } ` ,
352- object_type : 'users'
353- }
354- ]
355- }
356- } ) ;
357- } ;
358-
359- const syncCompleted = vi . fn ( ) ;
360- powersync . waitForFirstSync ( ) . then ( syncCompleted ) ;
361-
362- // Emit partial sync complete for each priority but the last.
363- for ( var prio = 0 ; prio < 3 ; prio ++ ) {
364- const partialSyncCompleted = vi . fn ( ) ;
365- powersync . waitForFirstSync ( { priority : prio } ) . then ( partialSyncCompleted ) ;
366- expect ( powersync . currentStatus . statusForPriority ( prio ) . hasSynced ) . toBe ( false ) ;
367- expect ( partialSyncCompleted ) . not . toHaveBeenCalled ( ) ;
368- expect ( syncCompleted ) . not . toHaveBeenCalled ( ) ;
369-
370- addRow ( prio ) ;
371- remote . enqueueLine ( {
372- partial_checkpoint_complete : {
373- last_op_id : operationId . toString ( ) ,
374- priority : prio
375- }
376- } ) ;
377-
378- await powersync . syncStreamImplementation ! . waitUntilStatusMatches ( ( status ) => {
379- return status . statusForPriority ( prio ) . hasSynced === true ;
380- } ) ;
381- await new Promise ( ( r ) => setTimeout ( r ) ) ;
382- expect ( partialSyncCompleted ) . toHaveBeenCalledOnce ( ) ;
383-
384- expect ( await powersync . getAll ( 'select * from users' ) ) . toHaveLength ( prio + 1 ) ;
385- }
386-
387- // Then, complete the sync.
388- addRow ( 3 ) ;
389- remote . enqueueLine ( { checkpoint_complete : { last_op_id : operationId . toString ( ) } } ) ;
390- await vi . waitFor ( ( ) => expect ( syncCompleted ) . toHaveBeenCalledOnce ( ) , 500 ) ;
391- expect ( await powersync . getAll ( 'select * from users' ) ) . toHaveLength ( 4 ) ;
392- } ) ;
393-
394- it ( 'Should remember sync state' , async ( ) => {
395- const { powersync, remote, openAnother } = await createConnectedDatabase ( ) ;
396- expect ( powersync . currentStatus . dataFlowStatus . downloading ) . toBe ( false ) ;
397-
398- const buckets : BucketChecksum [ ] = [ ] ;
399- for ( let prio = 0 ; prio <= 3 ; prio ++ ) {
400- buckets . push ( { bucket : `prio${ prio } ` , priority : prio , checksum : 0 } ) ;
401- }
402- remote . enqueueLine ( {
403- checkpoint : {
404- last_op_id : '0' ,
405- buckets
406- }
407- } ) ;
408- remote . enqueueLine ( {
409- partial_checkpoint_complete : {
410- last_op_id : '0' ,
411- priority : 0
412- }
413- } ) ;
414-
415- await powersync . waitForFirstSync ( { priority : 0 } ) ;
416-
417- // Open another database instance.
418- const another = openAnother ( ) ;
419- onTestFinished ( async ( ) => {
420- await another . close ( ) ;
421- } ) ;
422- await another . init ( ) ;
423-
424- expect ( another . currentStatus . priorityStatusEntries ) . toHaveLength ( 1 ) ;
425- expect ( another . currentStatus . statusForPriority ( 0 ) . hasSynced ) . toBeTruthy ( ) ;
426- await another . waitForFirstSync ( { priority : 0 } ) ;
427- } ) ;
428306 } ;
429307}
0 commit comments