/** * SSE reconnection after tab background. USER_JOURNEYS.md §17 / edge cases. */ import { test, expect } from '../../fixtures/test'; test.describe('Feed — SSE behavior', () => { test('SSE reconnects after tab visibility goes hidden then visible', async ({ page, guest, signIn }) => { const h = await guest('SseReconnect'); await signIn(page, h); await page.goto('/feed'); // Force-fire a visibilitychange to hidden, then back to visible. The app's // sse.ts is expected to close + reopen the EventSource around this. await page.evaluate(() => { Object.defineProperty(document, 'visibilityState', { configurable: true, value: 'hidden' }); document.dispatchEvent(new Event('visibilitychange')); }); await page.waitForTimeout(500); await page.evaluate(() => { Object.defineProperty(document, 'visibilityState', { configurable: true, value: 'visible' }); document.dispatchEvent(new Event('visibilitychange')); }); // App should still be functional — assert the bottom nav remains visible. await expect(page.getByRole('link', { name: 'Galerie' })).toBeVisible(); }); });