O que mudou
Infra (por app):
i18n/locales.ts — lista de locales (pt, en), default pt, labels para o seletor
i18n/request.ts — lê o cookie NEXT_LOCALE, carrega as mensagens
messages/pt.json + messages/en.json — todas as strings extraídas
next.config.ts — envolvido com withNextIntl (operator-pwa: withPWA(withNextIntl(...)))
app/layout.tsx — <html lang={locale}> dinâmico, NextIntlClientProvider
app/language-switcher.tsx — seletor PT | EN (cookie + router.refresh())
23 ficheiros de UI atualizados — todos os textos visíveis agora usam t('...') ou getTranslations.
Datas no relatório passaram de toLocaleString('pt-PT') fixo para useFormatter() do next-intl — localizam-se automaticamente.
Plurais em ICU no sync-chip: {count, plural, one {# pedido...} other {# pedidos...}}.
Resultado dos testes:
pnpm test:e2e — 3/3 ✓
pnpm test:e2e:auth — 4/4 ✓
tsc --noEmit em ambas as apps — limpo ✓
Para adicionar uma língua futura: criar messages/<locale>.json + adicionar o locale a i18n/locales.ts em cada app. O seletor aparece automaticamente.
67 lines
2.1 KiB
TypeScript
67 lines
2.1 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
|
|
const OPERATOR_URL = 'http://localhost:3000';
|
|
const ADMIN_URL = 'http://localhost:3001';
|
|
|
|
export const ADMIN_BASE = ADMIN_URL;
|
|
|
|
/**
|
|
* Playwright config for real-login E2E tests.
|
|
*
|
|
* Key differences from playwright.config.ts:
|
|
* - testDir: './tests-auth' (separate from the autologin tests in ./tests)
|
|
* - AUTH_DEV_AUTOLOGIN: 'false' on both servers → middleware enforces login
|
|
* - reuseExistingServer: false → always starts fresh servers without autologin
|
|
*
|
|
* IMPORTANT: this config starts its own dev servers on ports 3000 and 3001.
|
|
* Do NOT run `pnpm test:e2e:auth` while those ports are already in use.
|
|
* Stop any running dev servers first:
|
|
* Windows: Get-Process node | Stop-Process -Force
|
|
*/
|
|
export default defineConfig({
|
|
testDir: './tests-auth',
|
|
fullyParallel: false,
|
|
forbidOnly: !!process.env.CI,
|
|
retries: process.env.CI ? 2 : 0,
|
|
workers: 1,
|
|
reporter: [['list'], ['html', { open: 'never' }]],
|
|
use: {
|
|
baseURL: OPERATOR_URL,
|
|
trace: 'retain-on-failure',
|
|
screenshot: 'only-on-failure',
|
|
},
|
|
projects: [
|
|
{
|
|
name: 'chromium',
|
|
use: { ...devices['Desktop Chrome'] },
|
|
},
|
|
],
|
|
webServer: [
|
|
{
|
|
command: 'pnpm --filter @repo/operator-pwa dev',
|
|
cwd: '..',
|
|
url: OPERATOR_URL,
|
|
reuseExistingServer: false,
|
|
timeout: 120_000,
|
|
stdout: 'pipe',
|
|
stderr: 'pipe',
|
|
// 'false' → dotenv-cli does not override env vars already in the process,
|
|
// so this wins over whatever AUTH_DEV_AUTOLOGIN is set in .env.
|
|
env: { AUTH_DEV_AUTOLOGIN: 'false' },
|
|
},
|
|
{
|
|
command: 'pnpm --filter @repo/admin-web dev',
|
|
cwd: '..',
|
|
url: ADMIN_URL,
|
|
reuseExistingServer: false,
|
|
timeout: 120_000,
|
|
stdout: 'pipe',
|
|
stderr: 'pipe',
|
|
// AUTH_URL is no longer overridden here — the admin-web `dev` script loads
|
|
// apps/admin-web/.env.admin (AUTH_URL=:3001) with precedence over the root
|
|
// .env, so the app knows its own base URL. See apps/admin-web/.env.admin.
|
|
env: { AUTH_DEV_AUTOLOGIN: 'false' },
|
|
},
|
|
],
|
|
});
|