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

const authFile = path.join(__dirname, "e2e", ".auth", "admin.json")

export default defineConfig({
  testDir: "./e2e",
  fullyParallel: false,
  retries: 0,
  timeout: 90_000,
  use: {
    baseURL: "http://localhost:3000",
    screenshot: "on",
    trace: "on-first-retry",
    navigationTimeout: 60_000,
    actionTimeout: 30_000,
  },
  projects: [
    {
      name: "setup",
      testMatch: /global-setup\.ts/,
    },
    {
      name: "authenticated",
      testMatch:
        /authenticated-admin|visual-regression|accessibility/,
      dependencies: ["setup"],
      use: {
        storageState: authFile,
        browserName: "chromium",
      },
    },
    {
      name: "unauthenticated",
      testMatch:
        /functional-flows|full-check|user-story-tests|system-test|staff-management|screenshot-tour|authenticated-tour/,
      use: { browserName: "chromium" },
    },
  ],
  outputDir: "./e2e/test-results",
})
