55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Website smoke - core pages render', () => {
|
|
const routes = process.env.DOCKER_SMOKE
|
|
? [
|
|
{ path: '/', name: 'landing' },
|
|
{ path: '/leagues', name: 'leagues list' },
|
|
{ path: '/teams', name: 'teams list' },
|
|
]
|
|
: [
|
|
{ path: '/', name: 'landing' },
|
|
{ path: '/dashboard', name: 'dashboard' },
|
|
{ path: '/drivers', name: 'drivers list' },
|
|
{ path: '/leagues', name: 'leagues list' },
|
|
{ path: '/profile', name: 'profile' },
|
|
{ path: '/teams', name: 'teams list' },
|
|
];
|
|
|
|
for (const route of routes) {
|
|
test(`renders ${route.name} page without console errors (${route.path})`, async ({ page }) => {
|
|
const consoleMessages: string[] = [];
|
|
|
|
page.on('console', (msg) => {
|
|
const type = msg.type();
|
|
if (type === 'error') {
|
|
consoleMessages.push(`[${type}] ${msg.text()}`);
|
|
}
|
|
});
|
|
|
|
const apiCallPromise =
|
|
route.path === '/leagues'
|
|
? page.waitForResponse((resp) => {
|
|
return resp.url().includes('/leagues/all-with-capacity') && resp.status() === 200;
|
|
})
|
|
: route.path === '/teams'
|
|
? page.waitForResponse((resp) => {
|
|
return resp.url().includes('/teams/all') && resp.status() === 200;
|
|
})
|
|
: null;
|
|
|
|
await page.goto(route.path, { waitUntil: 'networkidle' });
|
|
|
|
if (apiCallPromise) {
|
|
await apiCallPromise;
|
|
}
|
|
|
|
await expect(page).toHaveTitle(/GridPilot/i);
|
|
|
|
expect(
|
|
consoleMessages.length,
|
|
`Console errors on route ${route.path}:\n${consoleMessages.join('\n')}`,
|
|
).toBe(0);
|
|
});
|
|
}
|
|
}); |