import path from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "../../frontend/node_modules/@playwright/test/index.mjs";

const testingDir = path.dirname(fileURLToPath(import.meta.url));
const frontendRoot = path.resolve(testingDir, "../../frontend");

export default defineConfig({
  testDir: path.resolve(testingDir, "e2e"),
  use: {
    baseURL: "http://127.0.0.1:4173",
    trace: "on-first-retry",
    viewport: { width: 1440, height: 1080 },
  },
  webServer: {
    command: "npm run dev -- --host 127.0.0.1 --port 4173",
    cwd: frontendRoot,
    url: "http://127.0.0.1:4173",
    reuseExistingServer: !process.env.CI,
    timeout: 120000,
  },
  reporter: [["list"], ["junit", { outputFile: path.resolve(testingDir, "../../build/junit-frontend-e2e.xml") }]],
});
