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:
@@ -5,7 +5,7 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { runScript } from './helpers/run-script.js';
|
||||
import { healthyRoutes, stubEnv as envFor, withStubGitea } from './helpers/stub-gitea.js';
|
||||
import { healthyRoutes, stubEnv as envFor, withStubGitea, patchOf } from './helpers/stub-gitea.js';
|
||||
|
||||
const REPO = 'plugins/tea-sdlc';
|
||||
const INDEX = 12;
|
||||
@@ -39,7 +39,6 @@ const run = (args, stub) =>
|
||||
env: envFor(stub),
|
||||
});
|
||||
|
||||
const patchOf = (stub) => stub.requests.find((r) => r.method === 'PATCH' && !r.path.endsWith('/0'));
|
||||
|
||||
// ── Milestone ─────────────────────────────────────────────────────
|
||||
|
||||
@@ -132,7 +131,24 @@ test('估算沒有變時不重寫 body', async (t) => {
|
||||
|
||||
await run(['--estimate-days', '3'], stub);
|
||||
|
||||
assert.equal('body' in patchOf(stub).body, false, '沒變就不該把 body 塞進 PATCH');
|
||||
assert.equal(
|
||||
patchOf(stub),
|
||||
undefined,
|
||||
'沒有任何欄位要改就整個 PATCH 都不發:空的 PATCH 會把議題的 updated_at 推新,'
|
||||
+ '在列表上浮起來像是有人動過',
|
||||
);
|
||||
});
|
||||
|
||||
test('有別的欄位要改時照樣發 PATCH,但沒變的 body 不跟著被重寫', async (t) => {
|
||||
const stub = await withStub(t, {}, {
|
||||
body: '## 關聯\n\n需求議題:#1\n估算人天:3\n',
|
||||
});
|
||||
|
||||
await run(['--estimate-days', '3', '--milestone', '第一階段'], stub);
|
||||
|
||||
const patch = patchOf(stub);
|
||||
assert.equal(patch.body.milestone, 3);
|
||||
assert.equal('body' in patch.body, false, '估算沒變,body 就不該被塞進去');
|
||||
});
|
||||
|
||||
test('人天必須是正數', async (t) => {
|
||||
@@ -305,7 +321,7 @@ test('連結沒變時不重寫 body', async (t) => {
|
||||
|
||||
await run(['--overview-url', 'https://example.com/a'], stub);
|
||||
|
||||
assert.equal('body' in patchOf(stub).body, false);
|
||||
assert.equal(patchOf(stub), undefined, '連結沒變、也沒有別的欄位要改,就不發 PATCH');
|
||||
});
|
||||
|
||||
test('不是網址時擋在打 Gitea 之前', async (t) => {
|
||||
|
||||
Reference in New Issue
Block a user