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

const baseURL = process.env.BASE_URL;

if (!baseURL) {
  throw new Error("BASE_URL is required");
}

export default defineConfig({
  testDir: "./cross-client",
  outputDir: "./output/test-results",
  fullyParallel: false,
  workers: 1,
  forbidOnly: true,
  retries: 0,
  timeout: 60_000,
  expect: {
    timeout: 12_000,
  },
  reporter: [
    ["line"],
    ["html", { outputFolder: "./output/html-report", open: "never" }],
    ["json", { outputFile: "./output/results.json" }],
  ],
  use: {
    ...devices["Desktop Chrome"],
    baseURL,
    ignoreHTTPSErrors: false,
    serviceWorkers: "block",
    actionTimeout: 10_000,
    navigationTimeout: 20_000,
    trace: "retain-on-failure",
    screenshot: "only-on-failure",
    video: "retain-on-failure",
  },
  projects: [{ name: "chromium" }],
});
