test(ai-review): 補非整數 idx、空 apiKeys 與 limit 為 0 的邊界測試

This commit is contained in:
Jeffery
2026-06-23 13:34:41 +08:00
parent ff075c8438
commit 1f9e0d906c
2 changed files with 25 additions and 0 deletions
+11
View File
@@ -122,6 +122,17 @@ describe('judgeConversationsResolved', () => {
]);
});
it('ignores entries whose idx is not an integer (e.g. a string)', async () => {
const items = [{ idx: 0 }, { idx: 1 }];
// 字串 idx '0' 不可冒充整數 idx 0 把它改成 resolved
const chatFn = async () => [{ idx: '0', resolved: true }, { idx: 1.5, resolved: true }, { idx: 1, resolved: true }];
const verdicts = await judgeConversationsResolved(items, chatFn);
assert.deepEqual(verdicts, [
{ idx: 0, resolved: false },
{ idx: 1, resolved: true },
]);
});
it('propagates errors thrown by chatFn to the caller', async () => {
await assert.rejects(
() => judgeConversationsResolved([{ idx: 0 }], async () => { throw new Error('LLM down'); }),