diff --git a/test/schedule.test.js b/test/schedule.test.js index 6277f01..fbbec8d 100644 --- a/test/schedule.test.js +++ b/test/schedule.test.js @@ -184,3 +184,19 @@ test('這支腳本完全不碰 Gitea:沒有登入資訊也能算', async () => assert.equal(code, 0); }); + +test('同一個 index 出現兩次時中止,不把兩份定義混在一起算', async () => { + // 混出來的結果會是:相依看後者、標題與人天取前者,而且完全不報錯 + const { code, json } = await run({ + startDate: '2026-09-21', + workPackages: [ + { index: 1, title: '第一份定義', days: 1 }, + { index: 1, title: '第二份定義', days: 100 }, + { index: 2, title: '乙', days: 1, depends: [1] }, + ], + }); + + assert.equal(code, 1); + assert.equal(json.error.code, 'BAD_PLAN'); + assert.match(json.error.message, /不只一次/); +});