feat(小宝预警): 自动生成 AI 风险解读
This commit is contained in:
@@ -5,6 +5,7 @@ import type { XiaobaoRiskSnapshot } from './xiaobao-risk-trend';
|
||||
import {
|
||||
buildRiskInsightSignature,
|
||||
buildRiskInterpretRequest,
|
||||
findPreviousRiskSnapshot,
|
||||
shouldRequestRiskInsight,
|
||||
} from './xiaobao-risk-ai';
|
||||
|
||||
@@ -243,3 +244,18 @@ test('buildRiskInterpretRequest compresses frontend risk evidence for the backen
|
||||
assert.deepEqual(payload.dailyEvidence.needsProgressItems, ['Backend task has no update.']);
|
||||
assert.equal(payload.silentRisks[0].detail, 'No update for 5 days.');
|
||||
});
|
||||
|
||||
test('findPreviousRiskSnapshot returns latest snapshot before today for the version', () => {
|
||||
const previous = findPreviousRiskSnapshot(
|
||||
[
|
||||
snapshot({ versionId: 'ver-1', date: '2026-06-29', riskScore: 70, createdAt: '2026-06-29T10:00:00.000Z' }),
|
||||
snapshot({ versionId: 'ver-1', date: '2026-06-28', riskScore: 52, createdAt: '2026-06-28T10:00:00.000Z' }),
|
||||
snapshot({ versionId: 'ver-1', date: '2026-06-27', riskScore: 38, createdAt: '2026-06-27T10:00:00.000Z' }),
|
||||
snapshot({ versionId: 'ver-2', date: '2026-06-28', riskScore: 90, createdAt: '2026-06-28T11:00:00.000Z' }),
|
||||
],
|
||||
'ver-1',
|
||||
'2026-06-29',
|
||||
);
|
||||
|
||||
assert.equal(previous?.riskScore, 52);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user