Files
rail-game/frontend/tests/e2e/login.spec.ts
zwitschi 1099a738a3 feat: add Playwright configuration and initial e2e test for authentication
- Created Playwright configuration file to set up testing environment.
- Added a new e2e test for user authentication in login.spec.ts.
- Updated tsconfig.node.json to include playwright.config.ts.
- Enhanced vite.config.ts to include API proxying for backend integration.
- Added a placeholder for last run test results in .last-run.json.
2025-10-11 17:25:38 +02:00

27 lines
934 B
TypeScript

import { expect, test, type Page } from '@playwright/test';
const demoCredentials = {
username: process.env.DEMO_USERNAME ?? 'demo',
password: process.env.DEMO_PASSWORD ?? 'railgame123',
};
test.describe('Authentication', () => {
test('allows the demo user to sign in and view the network snapshot', async ({
page,
}: {
page: Page;
}) => {
await page.goto('/');
await expect(page.getByRole('heading', { name: 'Sign in' })).toBeVisible();
await page.getByLabel('Username').fill(demoCredentials.username);
await page.getByLabel('Password').fill(demoCredentials.password);
await page.getByRole('button', { name: 'Sign in' }).click();
await expect(page.getByRole('heading', { name: 'Network Snapshot' })).toBeVisible();
await expect(page.getByRole('heading', { name: 'Stations' })).toBeVisible();
await expect(page.getByRole('button', { name: 'Sign out' })).toBeVisible();
});
});