From 0aa04390611fcd679e819ca5d05d755bf1740c2d Mon Sep 17 00:00:00 2001 From: Jeffery Date: Thu, 17 Sep 2026 06:22:29 +0000 Subject: [PATCH] =?UTF-8?q?test(=E7=B8=BD=E8=A6=BD=E7=B6=B2=E9=A0=81):=20?= =?UTF-8?q?=E9=87=98=E4=BD=8F=E6=A8=A1=E6=9D=BF=E7=B5=90=E6=A7=8B=E8=88=87?= =?UTF-8?q?=E5=85=A9=E4=BB=BD=E6=AD=A3=E6=9C=AC=E7=9A=84=E8=A6=8F=E5=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 模板的檢查重點是「樣式與內容分離」與「全景段落能整段消失」,兩者壞掉時規劃版會 留下空標題或行內樣式散落各處,肉眼不容易發現。 順帶把 work-package 測試的 phase2 切法收斂到第三段之前——原本切到檔尾,第三段 新增的編號清單會混進段落順序的斷言裡。 Co-Authored-By: Claude Opus 5 (1M context) --- test/helpers/prompt-doc.js | 9 ++- test/overview-artifact.test.js | 115 +++++++++++++++++++++++++++++++ test/work-package-assets.test.js | 2 +- 3 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 test/overview-artifact.test.js diff --git a/test/helpers/prompt-doc.js b/test/helpers/prompt-doc.js index 8b405b3..f40e684 100644 --- a/test/helpers/prompt-doc.js +++ b/test/helpers/prompt-doc.js @@ -19,9 +19,14 @@ export function readReference(name) { return readFileSync(join(repoRoot, 'references', `${name}.md`), 'utf8'); } -/** 讀一份輸出模板 */ +/** 讀一份輸出模板(markdown) */ export function readTemplate(name) { - return readFileSync(join(repoRoot, 'templates', `${name}.md`), 'utf8'); + return readTemplateFile(`${name}.md`); +} + +/** 讀 templates/ 底下任一個檔案,含副檔名 */ +export function readTemplateFile(filename) { + return readFileSync(join(repoRoot, 'templates', filename), 'utf8'); } /** diff --git a/test/overview-artifact.test.js b/test/overview-artifact.test.js new file mode 100644 index 0000000..8f24b5d --- /dev/null +++ b/test/overview-artifact.test.js @@ -0,0 +1,115 @@ +/** + * 圖解版總覽網頁:模板本身,以及兩份正本裡產生它、把網址寫回議題的規則。 + */ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { readPrompt, readTemplateFile } from './helpers/prompt-doc.js'; + +const template = readTemplateFile('overview-artifact.html'); +const planPrompt = readPrompt('sdlc-plan'); +const analyzePrompt = readPrompt('sdlc-analyze'); + +/** 模板要填的欄位 */ +const PLACEHOLDERS = ['標題', '來源議題', '總覽', '目標', '流程圖', '工作包全景', '頁尾']; + +// ── 模板 ─────────────────────────────────────────────────────────── + +test('模板以 {{變數}} 佔位,欄位齊全', () => { + const found = new Set([...template.matchAll(/\{\{([^}]+)\}\}/g)].map((m) => m[1])); + for (const name of PLACEHOLDERS) { + assert.ok(found.has(name), `模板缺少佔位 {{${name}}}`); + } +}); + +test('樣式與內容分離:樣式集中在 style 區塊,內文不帶 style 屬性', () => { + const styleBlocks = template.match(/