diff --git a/e2e/pages/supersync.page.ts b/e2e/pages/supersync.page.ts index 41c4230f4d..bd9e5bf360 100644 --- a/e2e/pages/supersync.page.ts +++ b/e2e/pages/supersync.page.ts @@ -23,6 +23,13 @@ export interface SuperSyncConfig { * The password is entered and "Retry Decrypt" is clicked to proceed. */ decryptionFailedPassword?: string; + /** + * If true, allows the WebSocket connection for real-time push notifications. + * Default is false: the WS endpoint is blocked so tests have controlled, + * sequential sync via syncAndWait(). Set to true only for tests that + * specifically verify the WebSocket push flow. + */ + enableWebSocket?: boolean; } /** @@ -169,6 +176,12 @@ export class SuperSyncPage extends BasePage { * @param config - SuperSync configuration (includes optional waitForInitialSync flag) */ async setupSuperSync(config: SuperSyncConfig): Promise { + // Block WebSocket connections by default so tests have controlled, sequential sync. + // Only the realtime-push test opts in with enableWebSocket: true. + if (!config.enableWebSocket) { + await this.page.route('**/api/sync/ws**', (route) => route.abort()); + } + // Extract waitForInitialSync from config, defaulting to true const waitForInitialSync = config.waitForInitialSync ?? true; // Auto-accept native browser confirm dialogs (window.confirm used for fresh client sync confirmation) diff --git a/e2e/tests/sync/supersync-realtime-push.spec.ts b/e2e/tests/sync/supersync-realtime-push.spec.ts index d6ec791cf3..be4a39eb2d 100644 --- a/e2e/tests/sync/supersync-realtime-push.spec.ts +++ b/e2e/tests/sync/supersync-realtime-push.spec.ts @@ -35,7 +35,7 @@ test.describe('@supersync Realtime Push', () => { const syncConfig = getSuperSyncConfig(user); clientA = await createSimulatedClient(browser, appUrl, 'A', testRunId); - await clientA.sync.setupSuperSync(syncConfig); + await clientA.sync.setupSuperSync({ ...syncConfig, enableWebSocket: true }); const baselineTask = `Realtime-Baseline-${testRunId}`; await clientA.workView.addTask(baselineTask); @@ -43,7 +43,7 @@ test.describe('@supersync Realtime Push', () => { await waitForTask(clientA.page, baselineTask); clientB = await createSimulatedClient(browser, appUrl, 'B', testRunId); - await clientB.sync.setupSuperSync(syncConfig); + await clientB.sync.setupSuperSync({ ...syncConfig, enableWebSocket: true }); await clientB.sync.syncAndWait(); await waitForTask(clientB.page, baselineTask);