Skip to content

Commit 36f0929

Browse files
committed
Fix web tests
1 parent 8b5c59f commit 36f0929

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

packages/web/src/db/sync/SharedWebStreamingSyncImplementation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,6 @@ export class SharedWebStreamingSyncImplementation extends WebStreamingSyncImplem
257257
*/
258258
private async _testUpdateStatus(status: SyncStatus) {
259259
await this.isInitialized;
260-
return (this.syncManager as any)['_testUpdateAllStatuses'](status.toJSON());
260+
return this.syncManager._testUpdateAllStatuses(status.toJSON());
261261
}
262262
}

packages/web/src/worker/sync/SharedSyncImplementation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ export class SharedSyncImplementation extends BaseObserver<SharedSyncImplementat
494494
* A function only used for unit tests which updates the internal
495495
* sync stream client and all tab client's sync status
496496
*/
497-
private async _testUpdateAllStatuses(status: SyncStatusOptions) {
497+
async _testUpdateAllStatuses(status: SyncStatusOptions) {
498498
if (!this.connectionManager.syncStreamImplementation) {
499499
throw new Error('Cannot update status without a sync stream implementation');
500500
}

packages/web/src/worker/sync/WorkerClient.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
SharedSyncInitOptions,
77
WrappedSyncPort
88
} from './SharedSyncImplementation';
9-
import { ILogLevel, PowerSyncConnectionOptions, SubscribedStream } from '@powersync/common';
9+
import { ILogLevel, PowerSyncConnectionOptions, SubscribedStream, SyncStatusOptions } from '@powersync/common';
1010

1111
/**
1212
* A client to the shared sync worker.
@@ -77,4 +77,8 @@ export class WorkerClient {
7777
disconnect() {
7878
return this.sync.disconnect();
7979
}
80+
81+
async _testUpdateAllStatuses(status: SyncStatusOptions) {
82+
return this.sync._testUpdateAllStatuses(status);
83+
}
8084
}

packages/web/tests/src/db/AbstractPowerSyncDatabase.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@ class TestPowerSyncDatabase extends AbstractPowerSyncDatabase {
3333

3434
get database() {
3535
return {
36-
get: vi.fn().mockResolvedValue({ version: '0.4.5' }),
36+
get: vi.fn().mockResolvedValue({
37+
version: '0.4.5',
38+
r: JSON.stringify({
39+
connected: false,
40+
connecting: false,
41+
priority_status: [],
42+
downloading: null,
43+
streams: []
44+
})
45+
}),
3746
getAll: vi.fn().mockResolvedValue([]),
3847
execute: vi.fn(),
3948
refreshSchema: vi.fn()

0 commit comments

Comments
 (0)