Files
OmniRoute/scripts/run-next-playwright.mjs
diegosouzapw fe9d9a5a5c feat: migrate tests to TypeScript and add MCP advanced tools test suite
- Add unit tests for 8 MCP advanced tool handlers (Phase 3)
- Migrate test files from JavaScript to TypeScript (.ts/.tsx)
- Restructure file paths from app/ to src/app/ across all tests
- Refactor route assertions into reusable assertRouteMethods helper
- Add tests for new API routes (compliance, audit-log, evals/[suiteId])
- Update barrel export tests to use consolidated assertion pattern
2026-03-04 00:41:30 -03:00

71 lines
1.7 KiB
JavaScript

#!/usr/bin/env node
import { existsSync, renameSync } from "node:fs";
import { join } from "node:path";
import {
resolveRuntimePorts,
spawnWithForwardedSignals,
withRuntimePortEnv,
} from "./runtime-env.mjs";
const mode = process.argv[2] === "start" ? "start" : "dev";
const cwd = process.cwd();
const appDir = join(cwd, "app");
const srcAppDir = join(cwd, "src", "app");
const appPage = join(appDir, "page.tsx");
const backupDir = join(cwd, "app.__qa_backup");
let appDirMoved = false;
function shouldMoveAppDir() {
return existsSync(appDir) && !existsSync(appPage) && existsSync(srcAppDir);
}
function prepareAppDir() {
if (!shouldMoveAppDir()) return;
if (existsSync(backupDir)) {
console.warn(
"[Playwright WebServer] app.__qa_backup already exists; leaving app/ in place. " +
"If tests hit 404 on every route, clear app/ artifacts before running e2e."
);
return;
}
renameSync(appDir, backupDir);
appDirMoved = true;
console.log("[Playwright WebServer] Temporarily moved app/ to app.__qa_backup");
}
function restoreAppDir() {
if (!appDirMoved) return;
if (!existsSync(backupDir) || existsSync(appDir)) return;
renameSync(backupDir, appDir);
console.log("[Playwright WebServer] Restored app/ directory");
}
process.on("exit", restoreAppDir);
process.on("uncaughtException", (error) => {
restoreAppDir();
throw error;
});
prepareAppDir();
const runtimePorts = resolveRuntimePorts();
const args = [
"./node_modules/next/dist/bin/next",
mode,
"--port",
String(runtimePorts.dashboardPort),
];
if (mode === "dev") {
args.splice(2, 0, "--webpack");
}
spawnWithForwardedSignals(process.execPath, args, {
stdio: "inherit",
env: withRuntimePortEnv(process.env, runtimePorts),
});