fix(review publish): 降級處理 Gitea review 批次發布失敗

This commit is contained in:
2026-06-25 15:26:09 +00:00
parent afec5a9387
commit 8272166fde
2 changed files with 46 additions and 1 deletions
+26
View File
@@ -393,4 +393,30 @@ describe('postFindingsReview', () => {
assert.match(reviewCalls[0].comments[0].body, /.*/s);
assert.doesNotMatch(reviewCalls[0].comments[0].body, /.*app\/a\.js:5/s);
});
it('falls back to summary review and per-comment posting when batch review fails', async () => {
const reviewCalls = [];
const inlineCalls = [];
await postFindingsReview([
{ level: 'warning', role: 'Leo', location: 'app/a.js:5', suggestion: '修正 A', is_new: true },
{ level: 'info', role: 'Maya', location: 'app/b.js:9', suggestion: '修正 B', is_new: true },
], {
postReview: async (args) => {
reviewCalls.push(args);
if (args.comments.length > 0) throw new Error('Request failed with status code 500');
},
postInline: async (args) => {
inlineCalls.push(args);
if (args.path === 'app/b.js') throw new Error('line not in diff');
},
postIssue: async () => {
throw new Error('一般 comment 不應被呼叫');
},
});
assert.equal(reviewCalls.length, 2);
assert.equal(reviewCalls[0].comments.length, 2);
assert.equal(reviewCalls[1].comments.length, 0);
assert.deepEqual(inlineCalls.map(c => `${c.path}:${c.line}`), ['app/a.js:5', 'app/b.js:9']);
});
});