test(project-add): 把「不建立專案」改成驗得出東西的斷言
原本的條件是「沒有非 GET 請求打到路徑含 project 的端點」,但 Gitea 的專案根本 沒有 API 路徑,這個條件恆真,壞掉的實作也會通過。改成斷言真正的寫入只有議題本身 那一次 PATCH、而且只帶 projects 欄位。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -131,15 +131,20 @@ test('已經在目標看板上時不重發 PATCH', async (t) => {
|
||||
|
||||
// ── 不建立專案 ─────────────────────────────────────────────────────
|
||||
|
||||
test('不建立專案:沒有任何非 GET 請求打到專案相關端點', async (t) => {
|
||||
test('不建立專案:唯一的寫入是議題本身的 PATCH,且只帶 projects', async (t) => {
|
||||
// 用「路徑含 project」當條件是空話——Gitea 的專案根本沒有 API 路徑
|
||||
const stub = await withStub(t);
|
||||
|
||||
await run(['--project', '開發看板'], stub);
|
||||
|
||||
const creations = stub.requests.filter(
|
||||
(r) => r.method !== 'GET' && /project/i.test(r.path),
|
||||
// 前置檢查的寫入權探針也是 PATCH,但它打在不存在的 /issues/0 上,不算真正的寫入
|
||||
const writes = stub.requests.filter(
|
||||
(r) => r.method !== 'GET' && !r.path.endsWith('/issues/0'),
|
||||
);
|
||||
assert.deepEqual(creations, []);
|
||||
assert.equal(writes.length, 1);
|
||||
assert.equal(writes[0].method, 'PATCH');
|
||||
assert.equal(writes[0].path, `/api/v1/repos/${REPO}/issues/${INDEX}`);
|
||||
assert.deepEqual(Object.keys(writes[0].body), ['projects']);
|
||||
});
|
||||
|
||||
// ── --dry-run ─────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user