From 74cd8f2bd0a93f9fe71b9ec63c3aa2598e2eaaec Mon Sep 17 00:00:00 2001 From: Tibsfox Date: Sun, 29 Mar 2026 14:42:08 -0700 Subject: [PATCH] test(config): add config-get/set roundtrip and cross-workflow structural tests for use_worktrees Add comprehensive test coverage for the workflow.use_worktrees config toggle: - config-get returns false after setting to false (roundtrip verification) - config-get errors with "Key not found" when not set (validates workflow fallback behavior where `|| echo "true"` provides the default) - config-get returns true after setting to true - Toggle back and forth works correctly - Structural tests verify USE_WORKTREES is wired into quick.md, diagnose-issues.md, execute-plan.md, planning-config.md, and config.cjs Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/config.test.cjs | 55 ++++++++++++++++++++++++++++ tests/execute-phase-wave.test.cjs | 60 +++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) diff --git a/tests/config.test.cjs b/tests/config.test.cjs index 74fa46852..6280df25e 100644 --- a/tests/config.test.cjs +++ b/tests/config.test.cjs @@ -775,3 +775,58 @@ describe('config-set workflow.skip_discuss', () => { assert.strictEqual(output, true); }); }); + +// ─── config-set/config-get workflow.use_worktrees ──────────────────────────── + +describe('config-set/config-get workflow.use_worktrees', () => { + let tmpDir; + + beforeEach(() => { + tmpDir = createTempProject(); + runGsdTools('config-ensure-section', tmpDir, { HOME: tmpDir, USERPROFILE: tmpDir }); + }); + + afterEach(() => { + cleanup(tmpDir); + }); + + test('config-get workflow.use_worktrees returns false after setting to false', () => { + runGsdTools('config-set workflow.use_worktrees false', tmpDir); + const result = runGsdTools('config-get workflow.use_worktrees', tmpDir); + assert.ok(result.success, `Command failed: ${result.error}`); + + const output = JSON.parse(result.output); + assert.strictEqual(output, false); + }); + + test('config-get workflow.use_worktrees errors when not set (default config)', () => { + // config-ensure-section does NOT include use_worktrees in hardcoded defaults, + // so config-get should error with "Key not found". This is the expected behavior + // that workflows rely on: the shell fallback `|| echo "true"` provides the default. + const result = runGsdTools('config-get workflow.use_worktrees', tmpDir); + assert.strictEqual(result.success, false); + assert.ok( + result.error.includes('Key not found'), + `Expected "Key not found" in error: ${result.error}` + ); + }); + + test('config-get workflow.use_worktrees returns true after setting to true', () => { + runGsdTools('config-set workflow.use_worktrees true', tmpDir); + const result = runGsdTools('config-get workflow.use_worktrees', tmpDir); + assert.ok(result.success, `Command failed: ${result.error}`); + + const output = JSON.parse(result.output); + assert.strictEqual(output, true); + }); + + test('use_worktrees can be toggled back and forth', () => { + runGsdTools('config-set workflow.use_worktrees false', tmpDir); + runGsdTools('config-set workflow.use_worktrees true', tmpDir); + const result = runGsdTools('config-get workflow.use_worktrees', tmpDir); + assert.ok(result.success, `Command failed: ${result.error}`); + + const output = JSON.parse(result.output); + assert.strictEqual(output, true); + }); +}); diff --git a/tests/execute-phase-wave.test.cjs b/tests/execute-phase-wave.test.cjs index d00b453db..345bd50cc 100644 --- a/tests/execute-phase-wave.test.cjs +++ b/tests/execute-phase-wave.test.cjs @@ -122,3 +122,63 @@ describe('execute-phase docs: user-facing wave flag', () => { ); }); }); + +describe('use_worktrees config: cross-workflow structural coverage', () => { + const QUICK_PATH = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'quick.md'); + const DIAGNOSE_PATH = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'diagnose-issues.md'); + const EXECUTE_PLAN_PATH = path.join(__dirname, '..', 'get-shit-done', 'workflows', 'execute-plan.md'); + const PLANNING_CONFIG_PATH = path.join(__dirname, '..', 'get-shit-done', 'references', 'planning-config.md'); + const CONFIG_CJS_PATH = path.join(__dirname, '..', 'get-shit-done', 'bin', 'lib', 'config.cjs'); + + test('quick workflow reads USE_WORKTREES from config', () => { + const content = fs.readFileSync(QUICK_PATH, 'utf-8'); + assert.ok( + content.includes('config-get workflow.use_worktrees'), + 'quick.md should read use_worktrees from config' + ); + assert.ok( + content.includes('USE_WORKTREES'), + 'quick.md should reference USE_WORKTREES variable' + ); + }); + + test('diagnose-issues workflow reads USE_WORKTREES from config', () => { + const content = fs.readFileSync(DIAGNOSE_PATH, 'utf-8'); + assert.ok( + content.includes('config-get workflow.use_worktrees'), + 'diagnose-issues.md should read use_worktrees from config' + ); + assert.ok( + content.includes('USE_WORKTREES'), + 'diagnose-issues.md should reference USE_WORKTREES variable' + ); + }); + + test('execute-plan workflow references use_worktrees config', () => { + const content = fs.readFileSync(EXECUTE_PLAN_PATH, 'utf-8'); + assert.ok( + content.includes('workflow.use_worktrees'), + 'execute-plan.md should reference workflow.use_worktrees' + ); + }); + + test('planning-config reference documents use_worktrees', () => { + const content = fs.readFileSync(PLANNING_CONFIG_PATH, 'utf-8'); + assert.ok( + content.includes('workflow.use_worktrees'), + 'planning-config.md should document workflow.use_worktrees' + ); + assert.ok( + content.includes('worktree'), + 'planning-config.md should describe worktree behavior' + ); + }); + + test('config.cjs includes workflow.use_worktrees in VALID_CONFIG_KEYS', () => { + const content = fs.readFileSync(CONFIG_CJS_PATH, 'utf-8'); + assert.ok( + content.includes("'workflow.use_worktrees'"), + 'config.cjs VALID_CONFIG_KEYS should include workflow.use_worktrees' + ); + }); +});