fix(review publish): 降級處理 Gitea review 批次發布失敗
This commit is contained in:
@@ -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']);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user