From 3c2a252e1432747dd959caf6b37753061f72aac1 Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Thu, 14 May 2026 16:38:05 -0400 Subject: [PATCH] test(2937): add CLI write-path negative test for invalid context_position (CR nitpick) --- ...-2937-statusline-context-position.test.cjs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/enh-2937-statusline-context-position.test.cjs b/tests/enh-2937-statusline-context-position.test.cjs index 24365fb58..d8454923c 100644 --- a/tests/enh-2937-statusline-context-position.test.cjs +++ b/tests/enh-2937-statusline-context-position.test.cjs @@ -18,6 +18,7 @@ const assert = require('node:assert/strict'); const { composeStatusline } = require('../hooks/gsd-statusline.js'); const { VALID_CONFIG_KEYS } = require('../get-shit-done/bin/lib/config-schema.cjs'); +const { runGsdTools, createTempProject, cleanup } = require('./helpers.cjs'); // ── Parity guard ───────────────────────────────────────────────────────────── @@ -119,3 +120,30 @@ test('gsdUpdate warning is leftmost in "front" mode', () => { const out = composeStatusline({ gsdUpdate, model: 'Claude', dirname: 'proj', ctx, position: 'front' }); assert.ok(out.startsWith(gsdUpdate), `gsdUpdate should be leftmost in front mode; got: ${out}`); }); + +// ── CLI write-path enforcement (config-set rejects invalid enum) ───────────── +// Locked design: hard reject at config-set time AND silent fallback at runtime. +// The runtime fallback is covered by the "Invalid position value silently falls +// back" tests above. This test covers the other half — that the CLI write path +// actually refuses to persist an invalid value in the first place. + +test('config-set rejects invalid statusline.context_position', () => { + const tmpDir = createTempProject(); + try { + const r = runGsdTools( + ['config-set', 'statusline.context_position', 'middle'], + tmpDir, + ); + assert.equal( + r.success, + false, + `config-set should exit non-zero on invalid enum; got success=${r.success}, output=${r.output}`, + ); + assert.ok( + /statusline\.context_position|Invalid/i.test(r.error), + `stderr must reference key or "Invalid"; got: ${r.error}`, + ); + } finally { + cleanup(tmpDir); + } +});