import { expect, test } from '@playwright/test'; test('index page redirects to login page', async ({ page }) => { await page.goto('/'); await page.waitForURL('/login'); await expect(page.url()).toContain('/login'); }); test('login page has a register link that redirects to the register page', async ({ page }) => { await page.goto('/login'); const link = await page.$('a[href*="/register"]'); await link?.click(); await page.waitForURL('/register'); await expect(page.url()).toContain('/register'); }); test('register page has a login link that redirects to the login page', async ({ page }) => { await page.goto('/register'); const link = await page.$('a[href*="/login"]'); await link?.click(); await page.waitForURL('/login'); await expect(page.url()).toContain('/login'); }); test('dashboard page redirects to login page if user is not logged in', async ({ page }) => { await page.goto(''); await expect(page.url()).toContain('/login'); }); test('login form accepts valid credentials', async ({ page }) => { await page.context().clearCookies(); await page.goto('/login'); await page.fill('input[name="pseudo"]', 'glazk0'); await page.fill('input[name="passwd"]', 'Cookies Are #Miam42'); await Promise.all([page.getByRole('button').click(), page.waitForURL('')]); await expect(page.url()).toContain(''); });