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

// Drives the Vite dev server (frontend with HTTP-shim bindings) against a real
// Windows-side matrix_client_pc.exe running with MATRIX_CLIENT_PC_E2E=1 +
// BIND_ALL=1 (E2E HTTP API reachable on 127.0.0.1:8767 cross-WSL).
//
// Prerequisites:
//   1. bash scripts/launch_e2e.sh    (Windows .exe up, :8767 listening)
//   2. VITE_E2E_API=http://localhost:8767 pnpm dev --host 0.0.0.0
//   3. pnpm e2e:wails
//
// Default URL targets the Vite dev port. Set BASE_URL env if vite picked a
// different port (5173 if free, otherwise 5174 etc.).

const BASE_URL = process.env.BASE_URL || "http://localhost:5174";

export default defineConfig({
  testDir: "./e2e_cdp",
  timeout: 60_000,
  fullyParallel: false,
  workers: 1,
  retries: 0,
  reporter: "list",
  use: {
    baseURL: BASE_URL,
    headless: process.env.HEADED ? false : true,
    trace: "retain-on-failure",
    screenshot: "only-on-failure",
    viewport: { width: 1280, height: 800 },
    actionTimeout: 10_000,
  },
});
