test: add regression test for discuss-slice structured questions conditional
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
dd527ce08e
commit
f028c0938d
1 changed files with 46 additions and 0 deletions
|
|
@ -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',
|
||||
)
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Reference in a new issue