refactor(測試): 模板結構的三項檢查抽到共用斷言
段落順序、正本的編號清單、圖表段落不寫死圍欄——這三件事需求議題與工作包議題 都要驗,第二份模板出現時就該抽出來。兩份測試原本各抄一份,其中佔位數的斷言 還悄悄長成不同寫法(一邊 >=、一邊 ==);抽出來之後這種分歧會被逼著講清楚。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,14 @@
|
||||
*/
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { assertNeutralPrompt, readPrompt, readTemplate } from './helpers/prompt-doc.js';
|
||||
import {
|
||||
assertDiagramPlaceholderOnly,
|
||||
assertNeutralPrompt,
|
||||
assertPromptListsSections,
|
||||
assertTemplateSections,
|
||||
readPrompt,
|
||||
readTemplate,
|
||||
} from './helpers/prompt-doc.js';
|
||||
|
||||
const template = readTemplate('requirement-issue');
|
||||
const prompt = readPrompt('sdlc-plan');
|
||||
@@ -28,8 +35,7 @@ const SECTIONS = [
|
||||
// ── 輸出模板 ───────────────────────────────────────────────────────
|
||||
|
||||
test('模板依序包含九個段落', () => {
|
||||
const headings = [...template.matchAll(/^## (.+)$/gm)].map((m) => m[1].trim());
|
||||
assert.deepEqual(headings, SECTIONS);
|
||||
assertTemplateSections(template, SECTIONS);
|
||||
});
|
||||
|
||||
test('模板以 {{變數}} 佔位,不留任何空白待填欄位', () => {
|
||||
@@ -82,14 +88,11 @@ test('正本指名由 issue-create 寫入,並提醒先以 --dry-run 檢查', (
|
||||
|
||||
test('正本逐一交代九個段落,且順序與模板一致', () => {
|
||||
// 只看「組出議題內容」那份編號清單,不看散落在行文裡的提及
|
||||
const listed = [...prompt.matchAll(/^\d+\.\s+\*\*(.+?)\*\*/gm)].map((m) => m[1].trim());
|
||||
assert.deepEqual(listed, SECTIONS);
|
||||
assertPromptListsSections(prompt, SECTIONS);
|
||||
});
|
||||
|
||||
test('模板不把 mermaid 圍欄寫死:不畫圖時才不會留下渲染失敗的空區塊', () => {
|
||||
assert.equal(template.includes('```mermaid'), false);
|
||||
const section = template.slice(template.indexOf('## 流程圖'), template.indexOf('## 驗收標準'));
|
||||
assert.match(section.trim(), /^## 流程圖\s+\{\{流程圖\}\}$/);
|
||||
assertDiagramPlaceholderOnly(template, '流程圖', '驗收標準');
|
||||
});
|
||||
|
||||
test('正本交代了畫與不畫兩種情況各該填什麼', () => {
|
||||
|
||||
Reference in New Issue
Block a user