Skip to content

AI Chat Streaming Under Flaky SSE

AI chat and notification screens often depend on one long-lived EventSource. Drop or delay named token events and assert that the UI stays recoverable.

await injectChaos(page, {
seed: 42,
sse: {
drops: [{ urlPattern: '/chat/stream', eventType: 'token', probability: 0.15 }],
delays: [{ urlPattern: '/chat/stream', eventType: 'token', delayMs: 750, probability: 1 }],
},
});
await page.goto('/chat');
await page.getByRole('textbox').fill('Summarize the incident');
await page.getByRole('button', { name: 'Send' }).click();
await expect(page.locator('[data-testid="streaming-indicator"]')).toBeVisible();
await expect(page.locator('[data-testid="retry-stream"]')).toBeVisible();
expect((await getChaosLog(page)).some((event) => event.type === 'sse:drop' && event.applied)).toBe(true);