fix(小宝预警): 保留可复用小宝建议
This commit is contained in:
@@ -361,6 +361,74 @@ test('getReusableInsight reuses legacy signatures with volatile forecast timesta
|
||||
assert.equal(getReusableInsight([legacy], current)?.insight.summary, legacy.insight.summary);
|
||||
});
|
||||
|
||||
test('getReusableInsight keeps showing cached insight when only refresh-volatile fields drift', () => {
|
||||
const cachedRisk = risk({
|
||||
riskLevel: 'likely_delayed',
|
||||
riskScore: 100,
|
||||
confidence: 65,
|
||||
forecastReleaseDate: '2026-07-14T03:37:15.903Z',
|
||||
signals: { ...risk().signals, failedTestCount: 14, silentRiskCount: 58, daysToExpectedRelease: 1 },
|
||||
dailyEvidence: {
|
||||
...risk().dailyEvidence!,
|
||||
recentActivityCount: 12,
|
||||
lastActivityAt: '2026-06-29T03:37:15.903Z',
|
||||
todayProgress: [
|
||||
{ id: 'ev-2', title: 'Progress', summary: 'Fixed login issue.', occurredAt: '2026-06-29T03:37:15.903Z' },
|
||||
],
|
||||
},
|
||||
currentSnapshot: snapshot({ riskScore: 100, failedTestCount: 14, silentRiskCount: 58 }),
|
||||
});
|
||||
const current = risk({
|
||||
riskLevel: 'likely_delayed',
|
||||
riskScore: 100,
|
||||
confidence: 65,
|
||||
forecastReleaseDate: '2026-07-15T06:21:38.597Z',
|
||||
signals: { ...risk().signals, failedTestCount: 14, silentRiskCount: 58, daysToExpectedRelease: 0 },
|
||||
dailyEvidence: {
|
||||
...risk().dailyEvidence!,
|
||||
recentActivityCount: 13,
|
||||
lastActivityAt: '2026-06-29T06:21:38.597Z',
|
||||
todayProgress: [
|
||||
{ id: 'ev-2', title: 'Progress', summary: 'Fixed login issue.', occurredAt: '2026-06-29T06:21:38.597Z' },
|
||||
],
|
||||
},
|
||||
currentSnapshot: snapshot({ riskScore: 100, failedTestCount: 14, silentRiskCount: 58 }),
|
||||
});
|
||||
const cached = insight({
|
||||
riskSignature: buildRiskInsightSignature(cachedRisk),
|
||||
insight: { ...insight().insight, summary: 'Cached Xiaobao advice stays visible.' },
|
||||
generatedAt: '2026-06-29T08:00:00.000Z',
|
||||
});
|
||||
|
||||
assert.equal(getReusableInsight([cached], current)?.insight.summary, 'Cached Xiaobao advice stays visible.');
|
||||
assert.equal(
|
||||
shouldRequestRiskInsightWithCacheGate(true, [cached], current, snapshot({ riskScore: 70 }), new Date('2026-06-29T09:00:00.000Z')),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('getReusableInsight does not reuse cached insight when core risk facts change', () => {
|
||||
const cachedRisk = risk({
|
||||
riskLevel: 'likely_delayed',
|
||||
riskScore: 100,
|
||||
confidence: 65,
|
||||
forecastReleaseDate: '2026-07-14T03:37:15.903Z',
|
||||
signals: { ...risk().signals, failedTestCount: 14, silentRiskCount: 58, daysToExpectedRelease: 1 },
|
||||
currentSnapshot: snapshot({ riskScore: 100, failedTestCount: 14, silentRiskCount: 58 }),
|
||||
});
|
||||
const current = risk({
|
||||
riskLevel: 'likely_delayed',
|
||||
riskScore: 100,
|
||||
confidence: 65,
|
||||
forecastReleaseDate: '2026-07-15T06:21:38.597Z',
|
||||
signals: { ...risk().signals, failedTestCount: 15, silentRiskCount: 58, daysToExpectedRelease: 0 },
|
||||
currentSnapshot: snapshot({ riskScore: 100, failedTestCount: 15, silentRiskCount: 58 }),
|
||||
});
|
||||
const cached = insight({ riskSignature: buildRiskInsightSignature(cachedRisk) });
|
||||
|
||||
assert.equal(getReusableInsight([cached], current), undefined);
|
||||
});
|
||||
|
||||
test('buildRiskInterpretRequest compresses frontend risk evidence for the backend AI contract', () => {
|
||||
const payload = buildRiskInterpretRequest(risk());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user