import { expect, test } from '@playwright/test'; // Requires a dev user. Set TEST_USERNAME / TEST_PASSWORD in the environment; otherwise the test skips. const username = process.env.TEST_USERNAME; const password = process.env.TEST_PASSWORD; test.describe('login', () => { test.skip(!username || !password, 'TEST_USERNAME/TEST_PASSWORD not set'); test('logs in and lands on the dashboard', async ({ page }) => { await page.goto('/login'); await page.getByLabel(/username/i).fill(username!); await page.getByLabel(/password/i).fill(password!); await page.getByRole('button', { name: /sign in|log in/i }).click(); await expect(page).toHaveURL(/\/(?!login)/, { timeout: 10_000 }); await expect(page.getByRole('heading', { name: /dashboard/i })).toBeVisible(); }); test('shows an error on bad credentials', async ({ page }) => { await page.goto('/login'); await page.getByLabel(/username/i).fill('does-not-exist'); await page.getByLabel(/password/i).fill('wrong-password'); await page.getByRole('button', { name: /sign in|log in/i }).click(); await expect(page.getByText(/invalid|incorrect|unauthor/i)).toBeVisible(); }); });