// SPEC: PJ2026-010401 Web工作台 draft-2026-06-17-r0; PJ2026-010403 API契约 draft-2026-06-17-r0.
// Responsibility: Playwright configuration for independent Workbench browser regression tests.

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

const port = Number(process.env.HWLAB_WORKBENCH_E2E_PORT ?? 4173);
const baseURL = `http://127.0.0.1:${port}`;

export default defineConfig({
  testDir: "./tests/workbench-e2e/specs",
  outputDir: ".state/workbench-e2e/test-results",
  timeout: 45_000,
  expect: { timeout: 8_000 },
  fullyParallel: false,
  workers: 1,
  retries: 0,
  reporter: [
    ["list"],
    ["html", { outputFolder: ".state/workbench-e2e/html-report", open: "never" }]
  ],
  use: {
    baseURL,
    screenshot: "only-on-failure",
    trace: "retain-on-failure",
    video: "off"
  },
  webServer: {
    command: `bun scripts/workbench-e2e-server.ts --port ${port} --dist dist`,
    url: `${baseURL}/__e2e/health`,
    reuseExistingServer: false,
    timeout: 30_000
  },
  projects: [
    { name: "chromium", use: { ...devices["Desktop Chrome"] } }
  ]
});
