import { defineConfig } from '@playwright/test'

/**
 * E2E harness for the Electron app. Tests launch the *built* app
 * (`out/main/index.js`) through Playwright's `_electron` API — see
 * `e2e/fixtures.ts`. There is no browser project and no chromium download:
 * `_electron` drives the app's own bundled electron.
 *
 * Run `yarn e2e` (builds first) for a fresh run, or `yarn e2e:only` to reuse
 * the existing `out/` build during a tight iteration loop.
 */
export default defineConfig({
  testDir: './e2e',
  outputDir: './e2e/.artifacts/test-results',
  fullyParallel: false,
  workers: 1, // one electron instance at a time — deterministic, avoids window races
  forbidOnly: !!process.env.CI,
  retries: 0,
  timeout: 30_000,
  expect: { timeout: 5_000 },
  reporter: [['list'], ['html', { outputFolder: './e2e/.artifacts/report', open: 'never' }]],
  use: {
    trace: 'retain-on-failure',
    screenshot: 'only-on-failure',
  },
})
