companion/@tooling/e2e/e2e/toast.e2e.ts
Claude Code 49e7d5d4b7 chore(tooling): 🔧 Update build and linting tooling configurations
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-04-02 21:44:55 -07:00

40 lines
1.6 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { setupSessionErrorMock } from './mocks';
test.describe('Toast notifications', () => {
test('shows error toast when session creation fails', async ({ page }) => {
await setupSessionErrorMock(page);
await page.goto('/');
await page.waitForLoadState('networkidle');
// Toast with a connection/session error message appears.
// In React dev StrictMode effects may fire twice — use first().
const toast = page.getByText(/Could not connect|Session creation failed|POST \/session failed/).first();
await expect(toast).toBeVisible({ timeout: 8000 });
});
test('toast auto-dismisses after 5 seconds', async ({ page }) => {
await setupSessionErrorMock(page);
await page.goto('/');
await page.waitForLoadState('networkidle');
const toast = page.getByText(/Could not connect|Session creation failed/).first();
await expect(toast).toBeVisible({ timeout: 8000 });
// Wait for auto-dismiss (5s) plus 2s buffer
await expect(toast).not.toBeVisible({ timeout: 8000 });
});
test('toast has drag="x" attribute for swipe-to-dismiss', async ({ page }) => {
await setupSessionErrorMock(page);
await page.goto('/');
await page.waitForLoadState('networkidle');
const toast = page.getByText(/Could not connect|Session creation failed/).first();
await expect(toast).toBeVisible({ timeout: 8000 });
// Framer-motion sets draggable="false" on the host element when drag="x" is active
const draggableEl = toast.locator('xpath=ancestor-or-self::div[@draggable]').first();
await expect(draggableEl).toHaveAttribute('draggable', 'false');
});
});