fix: resolve flaky offline sync e2e test in CI

Playwright's setOffline(false) doesn't reliably emit the browser's
'online' DOM event in headless/CI environments. Manually dispatch it
as a safety net so the sync client always triggers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Frederic Cabassut
2026-03-12 09:31:11 +01:00
co-authored by Claude Opus 4.6
parent 8108e62cf1
commit 990639d804
2 changed files with 5 additions and 1 deletions
+4 -1
View File
@@ -62,8 +62,11 @@ test.describe('Offline Support', () => {
await expect(page.getByText('Survive Reload')).toBeVisible();
// When the network is restored and sync completes
const syncResponse = page.waitForResponse('**/api/sync');
const syncResponse = page.waitForResponse((resp) => resp.url().includes('/api/sync'));
await page.context().setOffline(false);
// Manually dispatch the online event as a safety net — in CI/headless
// environments, setOffline(false) doesn't always emit it reliably
await page.evaluate(() => window.dispatchEvent(new Event('online')));
await syncResponse;
// And the user reloads the page