Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

test(api): capture malformed CLI response step [A2, C7]

Corey Olsonc44ea9b4cf77
diff --git a/test/api.test.js b/test/api.test.js
index bb4f8139..79113ca3 100644
--- a/test/api.test.js
+++ b/test/api.test.js
@@ -244,14 +244,17 @@ function fixtureCommandEvidence(step, result, env) {
}
/** Run a named CLI JSON step and retain its stdout, exit code and timing for assertions. */
-function fixtureJsonStep(box, step, cwd, command, args = [], expectedStatus = 0) {
+function fixtureJsonStep(box, step, cwd, command, args = [], expectedStatus = 0, onEvidence) {
const result = box.run(cwd, command, ...args, '--json');
const evidence = fixtureCommandEvidence(step, result, box.env);
+ onEvidence?.(evidence);
assert.equal(result.status, expectedStatus, evidence);
assert.equal(result.stderr, '', evidence);
let document;
try { document = JSON.parse(result.stdout); }
catch (error) { assert.fail(`${evidence}\ninvalid JSON: ${error.message}`); }
+ assert.ok(document !== null && typeof document === 'object' && !Array.isArray(document),
+ `${step} JSON response must be an object\n${evidence}`);
assert.equal(document.version, 1, evidence);
if (expectedStatus === 0) {
assertRequiredShape(document, shapeFor(command).required, `${step} JSON\n${evidence}`);
@@ -1173,10 +1176,9 @@ test('[A2] local HTTP v1 versions state and moves, authenticates, and preserves
return result;
}
/** Retain CLI step evidence before downstream JSON inspection. */
- function observedFixtureStep(...args) {
- const result = fixtureJsonStep(...args);
- lastStepEvidence = result.evidence;
- return result;
+ function observedFixtureStep(box, step, cwd, command, args = [], expectedStatus = 0) {
+ return fixtureJsonStep(box, step, cwd, command, args, expectedStatus,
+ (evidence) => { lastStepEvidence = evidence; });
}
try {
const api = await startApi(t, box);