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

// Testy routingu uruchamiamy na systemowym Chrome (bez pobierania przegladarek Playwright).
// Domyslnie startujemy wlasny dev server; ustaw E2E_BASE_URL, zeby przetestowac
// build produkcyjny za nginx, np. E2E_BASE_URL=http://localhost npm run test:e2e
const baseURL = process.env.E2E_BASE_URL ?? 'http://localhost:5173';

export default defineConfig({
  testDir: './tests',
  timeout: 60_000,
  expect: { timeout: 15_000 },
  fullyParallel: false,
  workers: 1,
  reporter: [['list']],
  use: {
    baseURL,
    channel: 'chrome',
    viewport: { width: 1680, height: 1050 },
    actionTimeout: 15_000,
  },
  webServer: process.env.E2E_BASE_URL
    ? undefined
    : {
        command: 'npm run dev',
        url: 'http://localhost:5173',
        reuseExistingServer: true,
        timeout: 120_000,
      },
});
