import { mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { resolve } from "node:path"; import { describe, expect, it } from "vitest"; import { waitForFile } from "./process-readiness.mjs"; describe("process endpoint readiness", () => { it("allows a cold endpoint to start after the legacy 30-second boundary", async () => { const path = resolve(mkdtempSync(resolve(tmpdir(), "peach-ready-test-")), "port"); const child = { exitCode: null, diagnostics: { stdout: "gradle startup", stderr: "" } }; setTimeout(() => writeFileSync(path, "49142"), 35); await expect(waitForFile(path, child, 90, 1)).resolves.toBe("49142"); }); it("includes endpoint output when readiness times out", async () => { const path = resolve(mkdtempSync(resolve(tmpdir(), "peach-ready-test-")), "port"); const child = { exitCode: null, diagnostics: { stdout: "gradle startup", stderr: "daemon busy" } }; await expect(waitForFile(path, child, 5, 1)).rejects.toThrow(/gradle startup.*daemon busy/); }); });