test(逐項實作): 覆蓋勾選的五種危險、兩份規則正本與正本第二段

勾選的測試全部繞著「會不會改錯行」打轉,五種都是 code review 抓出來的實際缺陷:
圍欄裡長得像 checkbox 的那一行不會被改到、不同段落的同一句話靠 --section 分得開、
大寫 [X] 重跑是 no-op、方框後沒有空白照樣勾得到、沒有方框的項目給的是指路的錯誤
而不是謊報已勾過。

另外釘住抽取端與勾選端的一致性:wp-extract 交得出來的每一種 raw,--tick 都要收得下。

patchOf 收進 helpers——它先前在三個測試檔裡各有一份一模一樣的定義。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-17 07:39:54 +00:00
co-authored by Claude Opus 5
parent a45e981c95
commit 8ea6a2a8b3
6 changed files with 630 additions and 8 deletions
+10
View File
@@ -103,3 +103,13 @@ export async function withStubGitea(t, routes) {
/** 把腳本指向這台假 Gitea 的環境變數 */
export const stubEnv = (stub) => ({ TEA_SDLC_API_BASE: stub.base, TEA_SDLC_TOKEN: 'stub-token' });
/**
* 找出腳本真正發出的那一個 PATCH。
* 前置檢查對 `issues/0` 的探針也是 PATCH,但它打在一顆不存在的議題上、不改動任何東西,
* 不該被當成腳本的寫入(見 lib.js 的 checkIssueWrite)。
* @returns {object|undefined} 沒發出寫入時為 undefined
*/
export function patchOf(stub) {
return stub.requests.find((r) => r.method === 'PATCH' && !r.path.endsWith('/issues/0'));
}