refactor(測試): 正本的共用檢查抽到 helpers
description 前綴、沒有 frontmatter、不出現平台專屬字樣——這三件事每一份流程 正本都要驗,第二份正本出現時就該抽出來,而不是再抄一次。順帶把讀正本、讀規則 正本、讀模板三個路徑組合也收在同一處。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,12 +7,10 @@
|
||||
*/
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { repoRoot } from './helpers/run-script.js';
|
||||
import { assertNeutralPrompt, readPrompt, readTemplate } from './helpers/prompt-doc.js';
|
||||
|
||||
const template = readFileSync(join(repoRoot, 'templates', 'requirement-issue.md'), 'utf8');
|
||||
const prompt = readFileSync(join(repoRoot, 'prompts', 'sdlc-plan.md'), 'utf8');
|
||||
const template = readTemplate('requirement-issue');
|
||||
const prompt = readPrompt('sdlc-plan');
|
||||
|
||||
/** 需求議題的九個段落,順序即議題裡的順序 */
|
||||
const SECTIONS = [
|
||||
@@ -50,35 +48,8 @@ test('總覽段落預留了總覽網頁的連結佔位', () => {
|
||||
|
||||
// ── 流程正本 ───────────────────────────────────────────────────────
|
||||
|
||||
test('正本的 description 以「僅由 /sdlc-plan 指令叫用。」起頭', () => {
|
||||
const description = prompt.match(/^description:\s*(.+)$/m)?.[1];
|
||||
assert.ok(description, '正本需要一行 description 供轉接檔取用');
|
||||
assert.ok(
|
||||
description.startsWith('僅由 /sdlc-plan 指令叫用。'),
|
||||
`description 前綴不符:${description}`,
|
||||
);
|
||||
});
|
||||
|
||||
test('正本是平台中立的:不出現任何特定助理的語法或名稱', () => {
|
||||
const platformSpecific = [
|
||||
'AskUserQuestion',
|
||||
'Claude',
|
||||
'Codex',
|
||||
'Antigravity',
|
||||
'Copilot',
|
||||
'Kiro',
|
||||
'OpenCode',
|
||||
'oh-my-pi',
|
||||
'.claude',
|
||||
'$sdlc-plan',
|
||||
];
|
||||
for (const token of platformSpecific) {
|
||||
assert.equal(prompt.includes(token), false, `正本不該出現平台專屬字樣:${token}`);
|
||||
}
|
||||
});
|
||||
|
||||
test('正本沒有 YAML frontmatter:那是各平台轉接檔的事', () => {
|
||||
assert.equal(prompt.startsWith('---'), false);
|
||||
test('正本平台中立,description 前綴正確', () => {
|
||||
assertNeutralPrompt(prompt, 'sdlc-plan');
|
||||
});
|
||||
|
||||
test('正本交代了三種輸入都要能吃', () => {
|
||||
|
||||
Reference in New Issue
Block a user