From 7c08a155eaebc2d89520d9c4035c7d86a1c85508 Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Sun, 26 Apr 2026 11:21:54 -0400 Subject: [PATCH] test(graphify): tighten call-sequence assertions per coderabbit review Adds explicit call-count and ordering assertions to version-check tests: - Success path: exactly 1 spawnSync (graphify --version only, no python fallback) - Failure path: graphify --version attempted first, python3 fallback second Addresses coderabbit nitpick on PR #2739. --- tests/graphify.test.cjs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/graphify.test.cjs b/tests/graphify.test.cjs index afef9edb0..2cf697400 100644 --- a/tests/graphify.test.cjs +++ b/tests/graphify.test.cjs @@ -392,9 +392,9 @@ describe('checkGraphifyVersion', () => { }); checkGraphifyVersion(); - assert.ok(calls.length >= 1, 'at least one spawnSync call'); + assert.strictEqual(calls.length, 1, 'exactly one spawnSync call — no python3 fallback'); assert.strictEqual(calls[0].cmd, 'graphify'); - assert.deepStrictEqual(calls[0].args, ['--version']); + assert.ok(calls[0].args.includes('--version'), 'graphify called with --version'); }); test('falls back to python3 importlib.metadata when graphify --version fails', () => { @@ -411,9 +411,11 @@ describe('checkGraphifyVersion', () => { const result = checkGraphifyVersion(); assert.strictEqual(result.version, '0.4.3'); assert.strictEqual(result.compatible, true); - const pythonCall = calls.find(c => c.cmd === 'python3'); - assert.ok(pythonCall, 'python3 should be called as fallback'); - assert.ok(pythonCall.args.some(arg => arg.includes('importlib.metadata'))); + assert.ok(calls.length >= 2, 'at least two spawnSync calls (graphify attempt + python3 fallback)'); + assert.ok(calls[0].args.includes('--version'), 'graphify --version attempted first'); + const lastCall = calls[calls.length - 1]; + assert.strictEqual(lastCall.cmd, 'python3', 'python3 fallback fires last'); + assert.ok(lastCall.args.some(arg => arg.includes('importlib.metadata'))); }); });