From a18802d465be0e886a43af882687f50198a67668 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 26 Jun 2026 14:14:30 +0800 Subject: [PATCH] =?UTF-8?q?test(calculate-version):=20=E8=A3=9C=E5=9B=9E?= =?UTF-8?q?=E6=87=89=E7=89=87=E6=AE=B5=E6=88=AA=E6=96=B7=E8=A1=8C=E7=82=BA?= =?UTF-8?q?=E6=B8=AC=E8=A9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增超長無法解析回應的測試,斷言錯誤訊息中的片段截斷至 200 字元內。 Co-Authored-By: Claude Opus 4.8 (1M context) --- app/test/releases.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/test/releases.test.js b/app/test/releases.test.js index 13a386e..3f24e04 100644 --- a/app/test/releases.test.js +++ b/app/test/releases.test.js @@ -77,6 +77,24 @@ test('fetchReleases 對無法解析的 JSON 回應拋錯', async () => { ); }); +test('fetchReleases 解析失敗時截斷過長的回應片段', async () => { + const huge = `{${'x'.repeat(5000)}`; + await withFetch( + async () => jsonResponse(huge, true), + async () => { + await assert.rejects( + () => fetchReleases('https://gitea.example.com/api'), + (err) => { + const match = err.message.match(/片段:「([\s\S]*)」$/); + assert.ok(match, '錯誤訊息應包含回應內容片段'); + assert.ok(Array.from(match[1]).length <= 200, '片段應截斷至 200 字元內'); + return true; + }, + ); + }, + ); +}); + test('fetchReleases 對非陣列回應拋錯', async () => { await withFetch( async () => jsonResponse({ message: 'oops' }),