import { defineConfig } from '@playwright/test'

const configuredBaseUrl = process.env.PLAYWRIGHT_BASE_URL
const baseURL = configuredBaseUrl || 'http://127.0.0.1:4173'

export default defineConfig({
  testDir: 'tests/e2e',
  retries: 0,
  use: {
    baseURL,
    headless: true,
    actionTimeout: 10_000,
    navigationTimeout: 20_000,
    viewport: { width: 1440, height: 900 },
    locale: 'en-US',
    timezoneId: 'UTC',
    colorScheme: 'dark',
    reducedMotion: 'reduce',
  },
  webServer: configuredBaseUrl
    ? undefined
    : {
        command: 'npm run build && npm run preview -- --host 127.0.0.1 --port 4173 --strictPort',
        url: baseURL,
        timeout: 180_000,
        reuseExistingServer: !process.env.CI,
      },
  reporter: [['list']],
})
