import { es } from '@impuestos/i18n'; import { expect, test } from '@playwright/test'; /** * The full first party chain in a real browser: the page posts to /api on the web * origin, the proxy forwards it, better-auth sets the session cookie, and the next * server render reads it back. */ test.describe('signing in', () => { test('a seeded account reaches the app shell', async ({ page }) => { await page.goto('/es/login'); await page.getByLabel(es['auth.register.email']).fill('maria@demo.local'); await page.getByLabel(es['auth.login.password']).fill('demo-maria-1'); await page.getByRole('button', { name: es['auth.login.submit'] }).click(); await expect(page).toHaveURL(/\/es\/inicio$/); await expect(page.getByRole('heading', { name: es['home.title'] })).toBeVisible(); }); test('a wrong password says so without blaming the user', async ({ page }) => { await page.goto('/es/login'); await page.getByLabel(es['auth.register.email']).fill('maria@demo.local'); await page.getByLabel(es['auth.login.password']).fill('not-the-password'); await page.getByRole('button', { name: es['auth.login.submit'] }).click(); // Scoped to the form: Next's route announcer is also role="alert". await expect(page.locator('form').getByRole('alert')).toHaveText(es['auth.login.failed']); await expect(page).toHaveURL(/\/es\/login$/); }); test('the app shell is not reachable without a session', async ({ page }) => { await page.goto('/es/inicio'); await expect(page).toHaveURL(/\/es\/login$/); }); });