From f028c0938d072afc2868aede3eba390ba4191f50 Mon Sep 17 00:00:00 2001 From: Tibsfox Date: Mon, 6 Apr 2026 22:30:02 -0700 Subject: [PATCH] test: add regression test for discuss-slice structured questions conditional Co-Authored-By: Claude Opus 4.6 (1M context) --- ...discuss-slice-structured-questions.test.ts | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/resources/extensions/gsd/tests/discuss-slice-structured-questions.test.ts diff --git a/src/resources/extensions/gsd/tests/discuss-slice-structured-questions.test.ts b/src/resources/extensions/gsd/tests/discuss-slice-structured-questions.test.ts new file mode 100644 index 000000000..a52114df6 --- /dev/null +++ b/src/resources/extensions/gsd/tests/discuss-slice-structured-questions.test.ts @@ -0,0 +1,46 @@ +/** + * Regression test for discuss-slice structured questions availability + * + * The guided-discuss-slice.md template must use the structuredQuestionsAvailable + * template variable to conditionally switch between ask_user_questions tool + * calls and plain-text questions, so the prompt works correctly when the + * structured questions tool is not available. + */ + +import { describe, it } from 'node:test' +import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' +import { resolve } from 'node:path' + +const template = readFileSync( + resolve(process.cwd(), 'src', 'resources', 'extensions', 'gsd', 'prompts', 'guided-discuss-slice.md'), + 'utf-8', +) + +describe('discuss-slice structuredQuestionsAvailable template variable', () => { + it('template references structuredQuestionsAvailable variable', () => { + assert.ok( + template.includes('{{structuredQuestionsAvailable}}'), + 'guided-discuss-slice.md must use {{structuredQuestionsAvailable}} template variable', + ) + }) + + it('template handles both true and false cases', () => { + const trueCase = template.includes('`{{structuredQuestionsAvailable}}` is `true`') + const falseCase = template.includes('`{{structuredQuestionsAvailable}}` is `false`') + + assert.ok(trueCase, 'template must have a branch for structuredQuestionsAvailable=true') + assert.ok(falseCase, 'template must have a branch for structuredQuestionsAvailable=false') + }) + + it('false case instructs plain text questions', () => { + const falseIdx = template.indexOf('`{{structuredQuestionsAvailable}}` is `false`') + assert.ok(falseIdx !== -1) + + const afterFalse = template.slice(falseIdx, falseIdx + 300) + assert.ok( + afterFalse.includes('plain text'), + 'when structuredQuestionsAvailable is false, questions should be in plain text', + ) + }) +})