Implement integration tests with Playwright

This commit is contained in:
Hördle Bot
2025-12-06 18:31:40 +01:00
parent 2e1f1e599b
commit 4b4468deeb
9 changed files with 267 additions and 7 deletions

31
tests/auth.spec.ts Normal file
View File

@@ -0,0 +1,31 @@
import { test, expect } from '@playwright/test';
test.describe('Authentication', () => {
test('Public pages should be accessible without login', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(/Hördle/);
await expect(page.getByRole('button', { name: 'Start' })).toBeVisible();
});
test('Admin page should be protected', async ({ page }) => {
await page.goto('/en/admin');
// We expect to see the Login form, NOT the dashboard content
await expect(page.getByPlaceholder('Password')).toBeVisible();
await expect(page.getByText('Manage Specials')).not.toBeVisible();
});
test('Admin login flow', async ({ page }) => {
// Navigate to admin login
await page.goto('/en/admin');
const passwordInput = page.getByPlaceholder('Password');
if (await passwordInput.isVisible()) {
await passwordInput.fill('admin123');
await page.getByRole('button', { name: 'Login' }).click({ force: true });
// Should now be on admin page
await expect(page.getByRole('heading', { name: 'Hördle Admin Dashboard' })).toBeVisible();
}
});
});