import { test, expect } from '@playwright/test'; function uniqueEmail(): string { return `playwright-${Date.now()}-${Math.floor(Math.random() * 10000)}@example.com`; } test.describe('Customer accounts', () => { test('marketing consent checkbox is unchecked by default', async ({ page }) => { await page.goto('/register'); await expect(page.getByRole('checkbox')).not.toBeChecked(); }); test('registers a new account and lands on the account page', async ({ page }) => { const email = uniqueEmail(); await page.goto('/register'); await page.getByLabel('Email').fill(email); await page.getByLabel('Password').fill('supersecret123'); await page.getByRole('button', { name: 'Create account' }).click(); await expect(page).toHaveURL(/\/account/); await expect(page.getByText(email)).toBeVisible(); }); test('rejects login with the wrong password', async ({ page }) => { const email = uniqueEmail(); await page.goto('/register'); await page.getByLabel('Email').fill(email); await page.getByLabel('Password').fill('supersecret123'); await page.getByRole('button', { name: 'Create account' }).click(); await expect(page).toHaveURL(/\/account/); await page.getByRole('button', { name: 'Log out' }).click(); await page.goto('/login'); await page.getByLabel('Email').fill(email); await page.getByLabel('Password').fill('wrong-password'); await page.getByRole('button', { name: 'Log in' }).click(); await expect(page.getByText('invalid email or password')).toBeVisible(); }); });