test(lanes): prove profile scaffolding end to end with a real boot (A3)

This commit is contained in:
2026-08-04 09:48:01 +07:00
parent c024534475
commit 113ed01504
+51
View File
@@ -341,3 +341,54 @@ describe("checkProfile", () => {
} }
}); });
}); });
describe("end to end: init -> check -> real boot", () => {
it("a single-service, no-database repo boots for real after init", async () => {
const lanesLib = require("../lib/lanes");
const runtime = require("../lib/lane-runtime");
const repo = makeRepo();
// A plain Node script reading process.env.PORT — the exact convention
// bootLine's `env PORT="$..." npm run <script>` targets.
fs.writeFileSync(
path.join(repo, "package.json"),
JSON.stringify({
scripts: {
start:
"node -e \"require('http').createServer((_,res)=>res.end('ok')).listen(process.env.PORT)\"",
},
})
);
const facts = detect.detectNode(repo);
detect.scaffoldProfile(repo, facts);
const checked = await detect.checkProfile(repo);
assert.equal(checked.ok, true, JSON.stringify(checked.errors));
const lane = lanesLib.createLane({ title: "e2e", cwd: repo, kind: "managed" });
try {
const runtimeFacts = await runtime.upLane(lanesLib.getLane(lane.id));
assert.equal(runtimeFacts.up, true);
assert.equal(runtimeFacts.healthy, true);
} finally {
await runtime.downLane(lanesLib.getLane(lane.id));
}
});
it("a monorepo with a database scaffolds correctly but check fails until migrate/seed are finished", async () => {
const repo = makeRepo();
writePkg(path.join(repo, "backend"), { start: "node server.js" });
writePkg(path.join(repo, "frontend"), { dev: "vite" });
writeCompose(repo, " postgres:\n image: postgres:16\n redis:\n image: redis:7\n");
fs.writeFileSync(path.join(repo, "backend", ".env.example"), "SOMETHING=1\n");
const facts = detect.detectNode(repo);
const scaffolded = detect.scaffoldProfile(repo, facts);
assert.ok(scaffolded.todos.includes("hooks/migrate.sh"));
assert.ok(scaffolded.todos.includes("hooks/seed.sh"));
const checked = await detect.checkProfile(repo);
assert.equal(checked.ok, false);
assert.ok(checked.errors.some((e) => /migrate\.sh/.test(e)));
assert.ok(checked.errors.some((e) => /seed\.sh/.test(e)));
});
});