test(2937): add CLI write-path negative test for invalid context_position (CR nitpick)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user