feat(ai-review 對話收斂): 讀 PR review 留言判斷解決狀態並收斂 findings #42
@@ -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 },
|
||||
]);
|
||||
|
admin marked this conversation as resolved
Outdated
|
||||
});
|
||||
|
||||
it('propagates errors thrown by chatFn to the caller', async () => {
|
||||
await assert.rejects(
|
||||
() => judgeConversationsResolved([{ idx: 0 }], async () => { throw new Error('LLM down'); }),
|
||||
|
||||
@@ -123,6 +123,14 @@ describe('fetchAccountQuota', () => {
|
||||
assert.equal(q.available, false);
|
||||
assert.match(q.reason, /未支援/);
|
||||
});
|
||||
|
||||
it('degrades gracefully when apiKeys is empty or undefined', async () => {
|
||||
const get = async () => { throw new Error('should not be called'); };
|
||||
// 空陣列 / 未提供 key 都不應丟錯,依平台回報無法取得或不適用
|
||||
assert.equal((await fetchAccountQuota('openai', { apiKeys: [], baseURL: 'https://api.openai.com/v1' }, { get })).available, false);
|
||||
assert.equal((await fetchAccountQuota('ollama', { apiKeys: [] }, { get })).available, false);
|
||||
assert.equal((await fetchAccountQuota('claude', {}, { get })).available, false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('recordRateLimit / getRateLimit', () => {
|
||||
@@ -178,6 +186,12 @@ describe('resolveRemainingPercent', () => {
|
||||
assert.equal(pct.percent, null);
|
||||
assert.match(pct.reason, /無上限/);
|
||||
});
|
||||
|
||||
it('does not divide by zero when quota.limit is 0', () => {
|
||||
const pct = resolveRemainingPercent({ available: true, used: 5, limit: 0, currency: 'USD' }, { hasData: false });
|
||||
assert.equal(pct.percent, null); // limit > 0 守衛擋掉除以零
|
||||
assert.ok(typeof pct.reason === 'string' && pct.reason.length > 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('formatUsageStats', () => {
|
||||
|
||||
Reference in New Issue
Block a user
嚴重等級:🔵 建議
審查員:Maya
問題:
judgeConversations的測試中,未對「AI 回傳空陣列」或「所有 Verdict 皆為空」的情境進行邊界驗證。建議:補上邊界測試,驗證該情境下是否將所有對話歸類為
open(保守保留)。