From 62106214947e62fb238e7b9e8f8e2a1f36b9652f Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Wed, 17 Jun 2026 11:20:21 -0400 Subject: [PATCH] test(#1377): pin real agent-skills IR contracts in two vacuous tests (#1380) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The empty-IR test asserted `parsed === '' || typeof parsed === 'object'`, which always passes (typeof null === 'object'). Pin the real contract: no agent type → `output('', raw, '')` → the --json IR is the empty string. The nonexistent-skill-path test asserted only `block === ''`. Since #1376 added a warnings[] field to the --json IR, also assert warnings[] names the skipped path so the test guards the silent-drop regression it is named for. Test-only; no product behavior change. Closes #1377 Co-authored-by: Claude Opus 4.8 --- tests/agent-skills.test.cjs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/agent-skills.test.cjs b/tests/agent-skills.test.cjs index 258f83f68..5ae37b5c6 100644 --- a/tests/agent-skills.test.cjs +++ b/tests/agent-skills.test.cjs @@ -211,6 +211,14 @@ describe('agent-skills command', () => { const r = runAgentSkillsJson(['agent-skills', 'gsd-executor'], tmpDir); assert.ok(r.success, 'Command should succeed even with missing skill paths'); assert.strictEqual(r.ir.block, '', 'block must be empty when all skill paths are missing'); + // The --json IR carries a warnings[] field (#1374): a skipped path must not + // be dropped silently. Assert it names the missing path so this test guards + // the silent-drop regression, not merely the empty block. + assert.ok(Array.isArray(r.ir.warnings), 'IR must include a warnings array'); + assert.ok( + r.ir.warnings.some((w) => w.includes('skills/nonexistent')), + `warnings must name the skipped path, got: ${JSON.stringify(r.ir.warnings)}`, + ); }); test('validates path safety — rejects traversal attempts', () => { @@ -226,11 +234,12 @@ describe('agent-skills command', () => { test('returns typed empty IR when no agent type argument provided', () => { const r = runAgentSkillsJson(['agent-skills'], tmpDir); - // With --json and no agent type, the command outputs the empty-string IR assert.ok(r.success, 'Command should succeed'); - // Output is JSON, either empty string or empty object - const parsed = JSON.parse(r.success ? JSON.stringify(r.ir) : '""'); - assert.ok(parsed === '' || (typeof parsed === 'object'), 'Should return empty or empty-agent IR'); + // With --json and no agent type, cmdAgentSkills calls output('', raw, ''), + // so the IR is the JSON-encoded empty string "" which parses to ''. Pin that + // exact contract: the old assertion (=== '' || typeof === 'object') passed + // even for a null IR because typeof null === 'object', so it guarded nothing. + assert.strictEqual(r.ir, '', 'empty IR must be the empty string when no agent type is provided'); }); });