@@ -3,6 +3,9 @@ import p from 'p-defer';
3
3
import { afterEach , beforeAll , beforeEach , describe , expect , it , vi } from 'vitest' ;
4
4
import { ConnectedDatabaseUtils , generateConnectedDatabase } from './stream.test' ;
5
5
6
+ // Don't want to actually export the warning string from the package
7
+ const PARTIAL_WARNING = 'Potentially previously uploaded CRUD entries are still present' ;
8
+
6
9
describe ( 'CRUD Uploads' , ( ) => {
7
10
let connectedUtils : ConnectedDatabaseUtils ;
8
11
const logger = Logger . get ( 'crud-logger' ) ;
@@ -13,11 +16,7 @@ describe('CRUD Uploads', () => {
13
16
connectedUtils = await generateConnectedDatabase ( {
14
17
powerSyncOptions : {
15
18
logger,
16
- /**
17
- * The timeout here is set to longer than the default test timeout
18
- * A retry wil cause tests to fail.
19
- */
20
- crudUploadThrottleMs : 10_000 ,
19
+ crudUploadThrottleMs : 1_000 ,
21
20
flags : {
22
21
enableMultiTabs : false
23
22
}
@@ -52,11 +51,7 @@ describe('CRUD Uploads', () => {
52
51
53
52
await vi . waitFor (
54
53
( ) => {
55
- expect (
56
- loggerSpy . mock . calls . find ( ( logArgs ) =>
57
- logArgs [ 0 ] . includes ( 'Potentially previously uploaded CRUD entries are still present' )
58
- )
59
- ) . exist ;
54
+ expect ( loggerSpy . mock . calls . find ( ( logArgs ) => logArgs [ 0 ] . includes ( PARTIAL_WARNING ) ) ) . exist ;
60
55
} ,
61
56
{
62
57
timeout : 500
@@ -66,15 +61,15 @@ describe('CRUD Uploads', () => {
66
61
67
62
it ( 'should immediately upload sequential transactions' , async ( ) => {
68
63
const { powersync, uploadSpy } = connectedUtils ;
64
+ const loggerSpy = vi . spyOn ( logger , 'warn' ) ;
65
+
69
66
const deferred = p ( ) ;
70
67
71
68
uploadSpy . mockImplementation ( async ( db ) => {
72
- // This upload method does not perform an upload
73
69
const nextTransaction = await db . getNextCrudTransaction ( ) ;
74
70
if ( ! nextTransaction ) {
75
71
return ;
76
72
}
77
-
78
73
// Mockingly delete the crud op in order to progress through the CRUD queue
79
74
for ( const op of nextTransaction . crud ) {
80
75
await db . execute ( `DELETE FROM ps_crud WHERE id = ?` , [ op . clientId ] ) ;
@@ -111,5 +106,7 @@ describe('CRUD Uploads', () => {
111
106
timeout : 5_000
112
107
}
113
108
) ;
109
+
110
+ expect ( loggerSpy . mock . calls . find ( ( logArgs ) => logArgs [ 0 ] . includes ( PARTIAL_WARNING ) ) ) . toBeUndefined ;
114
111
} ) ;
115
112
} ) ;
0 commit comments