open-swe/tests/e2e/global-setup.ts
Adam Moussa 5c3ca6e615
Revert upstream pnpm switch; keep bun for the UI build
The merge auto-adopted upstream's pnpm switch (#1645) in tests/e2e/
global-setup.ts and ui/package.json, but our fork builds the UI with
bun (vercel.json + the E2E workflow's setup-bun). That left the
Playwright globalSetup running `corepack pnpm install --frozen-lockfile`
with no pnpm-lock.yaml, failing E2E at UI build time.

Revert global-setup.ts and ui/package.json to the dev (bun) baseline,
drop the merge-added ui/pnpm-lock.yaml, and remove the re-added
ui/AGENTS.md (our fork had deleted it).
2026-06-30 16:20:41 -04:00

24 lines
938 B
TypeScript

import { execSync } from "node:child_process";
import { existsSync } from "node:fs";
import { resolve } from "node:path";
// Build the real ui/ SPA once so the harness can serve it same-origin. The API
// base is baked in at build time, so it must match the harness port. Set
// E2E_FORCE_UI_BUILD=1 to rebuild (e.g. after changing the port or the UI).
export default function globalSetup() {
const repoRoot = resolve(__dirname, "..", "..");
const ui = resolve(repoRoot, "ui");
const shell = resolve(ui, ".output", "public", "_shell.html");
const port = process.env.E2E_PORT ?? "2024";
if (existsSync(shell) && !process.env.E2E_FORCE_UI_BUILD) return;
if (!existsSync(resolve(ui, "node_modules"))) {
execSync("bun install", { cwd: ui, stdio: "inherit" });
}
execSync("bun run build", {
cwd: ui,
stdio: "inherit",
env: { ...process.env, VITE_DASHBOARD_API_BASE_URL: `http://127.0.0.1:${port}` },
});
}