test(ai-review): 補使用量統計與 resolve 安全與邊界測試

This commit is contained in:
Jeffery
2026-06-23 12:58:43 +08:00
parent f23d015e62
commit a27555b35a
3 changed files with 247 additions and 0 deletions
+24
View File
@@ -281,6 +281,30 @@ describe('postFindingsReview', () => {
assert.match(reviewCalls[0].comments[0].body, /.*C/s);
});
it('appends the usage section to the review body when provided', async () => {
const reviewCalls = [];
await postFindingsReview([
{ level: 'warning', role: 'Leo', location: 'app/b.js:20', suggestion: 'W', is_new: true },
], {
postReview: async (args) => { reviewCalls.push(args); },
usageSection: '## 🤖 AI 助理使用量\n\n本次:120 token',
});
assert.match(reviewCalls[0].body, /## AI Code Review 統計/);
assert.match(reviewCalls[0].body, /## 🤖 AI 助理使用量\n\n本次:120 token$/);
});
it('omits the usage section when not provided', async () => {
const reviewCalls = [];
await postFindingsReview([
{ level: 'warning', role: 'Leo', location: 'app/b.js:20', suggestion: 'W', is_new: true },
], {
postReview: async (args) => { reviewCalls.push(args); },
});
assert.doesNotMatch(reviewCalls[0].body, /AI 助理使用量/);
});
it('separates old and new findings in default review statistics', async () => {
const reviewCalls = [];
await postFindingsReview([