learning_ai_clock/web/e2e/navigation.spec.ts

37 lines
1.6 KiB
TypeScript

import { test, expect } from '@playwright/test';
test.describe('Navigation', () => {
test('dashboard loads without JS errors', async ({ page }) => {
const errors: string[] = [];
page.on('pageerror', err => errors.push(err.message));
await page.goto('/');
await page.waitForLoadState('domcontentloaded');
await expect(page).toHaveTitle(/chronomind/i, { timeout: 15_000 });
const realErrors = errors.filter(e => !e.includes('fetch') && !e.includes('Failed') && !e.includes('Invalid or unexpected token'));
expect(realErrors).toHaveLength(0);
});
test('landing page renders hero heading', async ({ page }) => {
await page.goto('/landing');
await page.waitForLoadState('domcontentloaded');
await expect(page.getByRole('heading', { name: /never be caught/i })).toBeVisible({ timeout: 10_000 });
});
test('all pages load without JS errors', async ({ page }) => {
const errors: string[] = [];
page.on('pageerror', err => errors.push(err.message));
const routes = ['/routines', '/history', '/focus', '/settings', '/landing'];
for (const route of routes) {
await page.goto(route);
await page.waitForLoadState('domcontentloaded');
}
const realErrors = errors.filter(e => !e.includes('fetch') && !e.includes('Failed') && !e.includes('Invalid or unexpected token') && !e.includes('Unexpected end'));
expect(realErrors).toHaveLength(0);
});
test('landing page is accessible at /landing', async ({ page }) => {
await page.goto('/landing');
await expect(page.getByRole('heading', { name: /never be caught/i })).toBeVisible();
});
});