Each test builds its pages in its own sandbox folder (search tests use a random word), so tests no longer rely on earlier tests' leftovers and run alone, in any order, or in parallel. The seed is just the home page. Parallel load hid the htmx settle race from the timing-based tests, so a dedicated test now submits a dialog in the task right after it is inserted, which fails deterministically without the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 lines
1.2 KiB
JavaScript
28 lines
1.2 KiB
JavaScript
// Builds datascape, seeds a throwaway wiki and runs the server in the
|
|
// foreground. Playwright's webServer starts this and kills it after the run.
|
|
import { execFileSync, spawn } from "node:child_process";
|
|
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
const tmp = join(here, ".tmp");
|
|
const wiki = join(tmp, "wiki");
|
|
const bin = join(tmp, process.platform === "win32" ? "datascape.exe" : "datascape");
|
|
const port = process.env.E2E_PORT || "8765";
|
|
|
|
rmSync(tmp, { recursive: true, force: true });
|
|
mkdirSync(wiki, { recursive: true });
|
|
|
|
execFileSync("go", ["build", "-o", bin, "."], { cwd: join(here, ".."), stdio: "inherit" });
|
|
|
|
// Tests create their own pages (see sandbox in tests/pages.spec.js); the seed
|
|
// is only the home page.
|
|
writeFileSync(join(wiki, "index.md"), "# Home\n\nWelcome.\n");
|
|
|
|
const srv = spawn(bin, ["-dir", wiki, "-cache", join(tmp, "cache"), "-addr", "127.0.0.1:" + port, "-calendars", ""], {
|
|
stdio: "inherit",
|
|
});
|
|
srv.on("exit", (code) => process.exit(code ?? 0));
|
|
for (const sig of ["SIGINT", "SIGTERM"]) process.on(sig, () => srv.kill());
|