import { defineConfig, devices } from '@playwright/test';

/*
  E2E runs against the built static output served by `astro preview` (TECH_SPEC §9.3).
  The relay is not required — the form spec mocks /api/contact.
*/
export default defineConfig({
  testDir: './e2e',
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 1 : 0,
  reporter: process.env.CI ? [['list'], ['html', { open: 'never' }]] : 'list',
  use: {
    baseURL: 'http://localhost:4399',
    trace: 'on-first-retry',
  },
  projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
  webServer: {
    command: 'pnpm -C ../site build && pnpm -C ../site preview --port 4399 --host',
    url: 'http://localhost:4399/',
    timeout: 180_000,
    reuseExistingServer: !process.env.CI,
  },
});
