feat(版本详情): 完善任务流程与风险预警
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import type { Bug } from './bug';
|
||||
import { calcXiaobaoVersionRisk } from './xiaobao-risk';
|
||||
import { buildRiskSignature, summarizeRiskTrend } from './xiaobao-risk-trend';
|
||||
import type { XiaobaoRiskSnapshot } from './xiaobao-risk-trend';
|
||||
|
||||
@@ -38,3 +40,55 @@ test('buildRiskSignature changes when score and bug counts change', () => {
|
||||
|
||||
assert.notEqual(base, changed);
|
||||
});
|
||||
|
||||
test('calcXiaobaoVersionRisk uses all open bugs in the current trend snapshot signature', () => {
|
||||
const now = new Date('2026-07-02T01:00:00.000Z');
|
||||
const risk = calcXiaobaoVersionRisk({
|
||||
version: {
|
||||
id: 'ver-1',
|
||||
name: 'V1.0',
|
||||
expectedReleaseDate: '2026-07-03T10:00:00.000Z',
|
||||
members: [{ name: 'Alice' }],
|
||||
},
|
||||
devTasks: [],
|
||||
testCases: [],
|
||||
bugs: [bug({ severity: 'major', priority: 'P2' })],
|
||||
now,
|
||||
});
|
||||
const currentSignature = (risk.trend as { currentSignature?: string }).currentSignature;
|
||||
|
||||
assert.equal(risk.signals.openBugCount, 1);
|
||||
assert.equal(risk.signals.criticalBugCount, 0);
|
||||
assert.equal(currentSignature, buildRiskSignature({
|
||||
versionId: risk.versionId,
|
||||
date: now.toISOString().slice(0, 10),
|
||||
riskScore: risk.riskScore,
|
||||
riskLevel: risk.riskLevel,
|
||||
forecastReleaseDate: risk.forecastReleaseDate,
|
||||
openBugCount: 1,
|
||||
failedTestCount: 0,
|
||||
blockedCount: 0,
|
||||
silentRiskCount: 0,
|
||||
confidence: risk.confidence,
|
||||
createdAt: now.toISOString(),
|
||||
}));
|
||||
});
|
||||
|
||||
function bug(patch: Partial<Bug> = {}): Bug {
|
||||
return {
|
||||
id: 'bug-1',
|
||||
bugNo: 'BUG-001',
|
||||
versionId: 'ver-1',
|
||||
testCaseId: 'tc-1',
|
||||
title: 'Non-critical open bug',
|
||||
description: 'Open but not critical.',
|
||||
severity: 'major',
|
||||
priority: 'P2',
|
||||
reportedBy: 'qa-1',
|
||||
assigneeId: 'dev-1',
|
||||
status: 'open',
|
||||
createdAt: '2026-07-01T09:00:00.000Z',
|
||||
updatedAt: '2026-07-01T09:00:00.000Z',
|
||||
...patch,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user