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

const e2ePort = process.env["PLAYWRIGHT_TEST_PORT"] ?? "3110";
const e2eBaseUrl = process.env["PLAYWRIGHT_TEST_BASE_URL"] ?? `http://localhost:${e2ePort}`;

export default defineConfig({
  testDir: "./e2e",
  fullyParallel: false,
  forbidOnly: !!process.env["CI"],
  retries: process.env["CI"] ? 2 : 0,
  workers: 1,
  reporter: "html",
  use: {
    baseURL: e2eBaseUrl,
    trace: "on-first-retry",
  },
  projects: [
    {
      name: "chromium",
      use: { ...devices["Desktop Chrome"] },
    },
  ],
  webServer: {
    command: "node ./e2e/test-server.mjs",
    url: e2eBaseUrl,
    reuseExistingServer: false,
    timeout: 180000,
  },
});
