import { defineConfig } from '@playwright/test'

// The metadata specs sign in, navigate, and (SLICE-4/5) write real commits,
// so a handful of steps are timing-sensitive: the cookie-consent banner's
// dismiss animation, first-render of the detail panel, and the round trip
// after a write. These flake intermittently on a busy local box and more so
// against a deployed host (network latency). `retries` makes the suite robust
// to that (and finally makes `trace: 'on-first-retry'` meaningful); the
// timeouts are bumped a notch for deployed runs over the public edge.
const DEPLOYED = !!process.env.E2E_TEST_AUTH_SECRET

export default defineConfig({
  testDir: '.',
  timeout: DEPLOYED ? 60_000 : 45_000,
  expect: { timeout: DEPLOYED ? 20_000 : 12_000 },
  retries: 2,
  // The metadata specs run in order against one seeded collection and write
  // real commits (SLICE-4/5); parallel workers would race on shared state —
  // and on a deployed host, on concurrent git pushes through the bot. Serialize.
  workers: 1,
  use: {
    baseURL: process.env.BASE_URL || 'http://localhost:8080',
    trace: 'on-first-retry',
  },
  reporter: [['list']],
})
