test(ai-review): 補日誌 input/output/result helper 與誤報裁決、usage 解析、parseBot 健壯性測試

This commit is contained in:
Jeffery
2026-06-23 15:15:24 +08:00
parent 374bb4ec75
commit 756b2cd4ef
4 changed files with 51 additions and 1 deletions
+14
View File
@@ -211,6 +211,20 @@ describe('findings exclusions', () => {
assert.deepEqual(result.map(f => f.location), ['a.js:1']); // a 失敗→保守保留;b 誤報→剔除
});
it('keeps findings when the defender returns malformed verdicts (conservative)', async () => {
const findings = [
{ level: 'warning', role: 'Mage', location: 'a.js:1', problem: 'p', suggestion: 's' },
{ level: 'warning', role: 'Leo', location: 'b.js:2', problem: 'p', suggestion: 's' },
];
// 回傳 null / 無 verdict 欄位 / 非預期結構 → 皆非 false_positive,保守保留
const responses = [null, { foo: 'bar' }];
let i = 0;
const chatFn = async () => responses[i++ % responses.length];
const result = await filterFalsePositivesWithAI(findings, [], chatFn);
assert.equal(result.length, 2);
});
it('logs exclusions file metadata and repo state when loading exclusions', () => {
const fullPath = path.join(workspace, EXCLUSIONS_PATH);
fs.mkdirSync(path.dirname(fullPath), { recursive: true });