cc-libs/tools/trap-sandbox/test-integration/full-boot.test.ts

28 lines
1.2 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { formatFailure, startCraftos, startFakeOpencode, startSandbox } from "./harness.js";
// Full-boot e2e: a real CraftOS computer runs the real servers/sandbox.lua daemon
// (driven by sandbox.* settings) and the real `sandbox health` program against the
// real gateway, with a healthy fake-opencode behind it.
test("full boot: settings -> daemon -> sandbox health prints sandboxOk/opencodeOk true", async () => {
const opencode = await startFakeOpencode({ status: 200 });
const sandbox = await startSandbox({ sandboxPassword: "boot-secret", opencodeUrl: opencode.url });
const craftos = startCraftos("full-boot.lua", {
computerId: 11,
computerLabel: "boot",
shellArgs: [sandbox.baseUrl, "boot-secret"],
timeoutMs: 20_000,
});
try {
const result = await craftos.done;
assert.match(result.output, /sandboxOk:\s*true/, formatFailure("expected sandboxOk: true", result.output));
assert.match(result.output, /opencodeOk:\s*true/, formatFailure("expected opencodeOk: true", result.output));
} finally {
craftos.abort();
await craftos.done.catch(() => undefined);
await sandbox.close();
await opencode.close();
}
});