import { es, en } from '@impuestos/i18n'; import { expect, test } from '@playwright/test'; test.describe('sign in screen', () => { test('renders in Spanish by default', async ({ page }) => { await page.goto('/es/login'); await expect(page.getByRole('heading', { name: es['auth.login.title'] })).toBeVisible(); await expect(page.getByLabel(es['auth.register.email'])).toBeVisible(); await expect(page.getByRole('button', { name: es['auth.login.submit'] })).toBeVisible(); }); test('the language switcher flips it to English and stays on the page', async ({ page }) => { await page.goto('/es/login'); await page.getByLabel(es['common.language']).selectOption('en'); await expect(page).toHaveURL(/\/en\/login$/); await expect(page.getByRole('heading', { name: en['auth.login.title'] })).toBeVisible(); await expect(page.getByRole('button', { name: en['auth.login.submit'] })).toBeVisible(); }); test('the choice survives a reload', async ({ page }) => { await page.goto('/en/login'); await page.reload(); await expect(page.getByRole('heading', { name: en['auth.login.title'] })).toBeVisible(); }); // The en catalog exists for expats and international users (COPY.md section 0-EN), // so the root honours the browser language and falls back to es, the default. test('the root follows the browser language', async ({ browser }) => { for (const [locale, expected] of [ ['es-PY', /\/es\/login$/], ['en-US', /\/en\/login$/], ['pt-BR', /\/es\/login$/], ] as const) { const context = await browser.newContext({ locale }); const page = await context.newPage(); await page.goto('/'); await expect(page, locale).toHaveURL(expected); await context.close(); } }); });