From 66e4ef14cd04adb61bb2b62288baf173d1aa1a3d Mon Sep 17 00:00:00 2001 From: Jeffery Date: Thu, 17 Sep 2026 14:05:19 +0800 Subject: [PATCH] =?UTF-8?q?test(project-add):=20=E6=8A=8A=E3=80=8C?= =?UTF-8?q?=E4=B8=8D=E5=BB=BA=E7=AB=8B=E5=B0=88=E6=A1=88=E3=80=8D=E6=94=B9?= =?UTF-8?q?=E6=88=90=E9=A9=97=E5=BE=97=E5=87=BA=E6=9D=B1=E8=A5=BF=E7=9A=84?= =?UTF-8?q?=E6=96=B7=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原本的條件是「沒有非 GET 請求打到路徑含 project 的端點」,但 Gitea 的專案根本 沒有 API 路徑,這個條件恆真,壞掉的實作也會通過。改成斷言真正的寫入只有議題本身 那一次 PATCH、而且只帶 projects 欄位。 Co-Authored-By: Claude Opus 5 (1M context) --- test/project-add.test.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/project-add.test.js b/test/project-add.test.js index ff3ec3c..43e6231 100644 --- a/test/project-add.test.js +++ b/test/project-add.test.js @@ -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 ─────────────────────────────────────────────────────