test(install): replace source-grep prompt assertions with structured checks

Two test files were asserting installer prompt behavior by regex/.includes()
against bin/install.js source. Per CONTRIBUTING.md "no-source-grep"
testing standard, replace with structured assertions:

- tests/kilo-install.test.cjs: import runtimeMap and buildRuntimePromptText
  from the install module; assert runtimeMap['11'] === 'kilo' and that the
  rendered prompt lists Kilo above OpenCode without marketing copy.

- tests/multi-runtime-select.test.cjs: import runtimeMap, allRuntimes,
  parseRuntimeInput, buildRuntimePromptText. Assert exported runtimeMap
  matches the canonical option list, allRuntimes contains every runtime
  exactly once, prompt text lists Hermes (10), Qwen Code (13), Trae (14),
  All (16), and parser splits/dedupes by exercising parseRuntimeInput
  rather than regexing source code.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-04-30 21:30:48 -04:00
parent bd0511988b
commit 861a7d972b
2 changed files with 96 additions and 103 deletions

View File

@@ -225,12 +225,29 @@ describe('Source code integration (Kilo)', () => {
});
test('promptRuntime runtimeMap has Kilo as option 11', () => {
assert.ok(src.includes("'11': 'kilo'"), 'runtimeMap has 11 -> kilo');
// Structural assertion against exported runtimeMap rather than source-grep.
process.env.GSD_TEST_MODE = '1';
delete require.cache[require.resolve(path.join(__dirname, '..', 'bin', 'install.js'))];
const { runtimeMap } = require(path.join(__dirname, '..', 'bin', 'install.js'));
assert.strictEqual(runtimeMap['11'], 'kilo', 'runtimeMap has 11 -> kilo');
});
test('prompt text shows Kilo above OpenCode without marketing copy', () => {
assert.ok(src.includes('11${reset}) Kilo'), 'prompt lists Kilo as option 11');
assert.ok(!src.includes('the #1 AI coding platform on OpenRouter'), 'prompt does not include marketing tagline');
// Call the exported prompt builder; assert against rendered text, not raw source.
process.env.GSD_TEST_MODE = '1';
delete require.cache[require.resolve(path.join(__dirname, '..', 'bin', 'install.js'))];
const { buildRuntimePromptText } = require(path.join(__dirname, '..', 'bin', 'install.js'));
const promptText = buildRuntimePromptText();
// Strip ANSI color codes so assertions don't depend on terminal escapes.
// eslint-disable-next-line no-control-regex
const plain = promptText.replace(/\x1b\[[0-9;]*m/g, '');
assert.ok(/\b11\)\s*Kilo\b/.test(plain), 'prompt lists Kilo as option 11');
const kiloIdx = plain.indexOf('11) Kilo');
const opencodeIdx = plain.indexOf('OpenCode');
assert.ok(kiloIdx > -1 && opencodeIdx > -1 && kiloIdx < opencodeIdx,
'Kilo appears above OpenCode in prompt');
assert.ok(!plain.includes('the #1 AI coding platform on OpenRouter'),
'prompt does not include marketing tagline');
});
test('hooks are skipped for Kilo', () => {