feat(platform): add quality escalation clock

This commit is contained in:
lingniu
2026-07-04 14:45:39 +08:00
parent b7dd65e435
commit cb49798b6d
2 changed files with 171 additions and 4 deletions

View File

@@ -2705,11 +2705,11 @@ test('shows actionable priority queue on quality page', async () => {
expect(await screen.findByText('处置优先队列')).toBeInTheDocument();
expect(screen.getAllByText('P0').length).toBeGreaterThan(0);
expect(screen.getByText('粤A优先1 / VIN-P0-001')).toBeInTheDocument();
expect(screen.getAllByText('粤A优先1 / VIN-P0-001').length).toBeGreaterThan(0);
expect(screen.getAllByText('确认平台转发').length).toBeGreaterThan(0);
expect(screen.getAllByText('30 分钟确认').length).toBeGreaterThan(0);
expect(screen.getAllByText('P1').length).toBeGreaterThan(0);
expect(screen.getByText('粤A优先2 / 13307795426')).toBeInTheDocument();
expect(screen.getAllByText('粤A优先2 / 13307795426').length).toBeGreaterThan(0);
fireEvent.click(screen.getAllByRole('button', { name: '进入车辆服务' })[0]);
await waitFor(() => {
@@ -2800,8 +2800,8 @@ test('uses backend quality notification plan on quality page', async () => {
render(<App />);
expect(await screen.findByText('后端车辆标签 / VIN-PLAN-001')).toBeInTheDocument();
expect(screen.getByText('后端建议动作')).toBeInTheDocument();
expect((await screen.findAllByText('后端车辆标签 / VIN-PLAN-001')).length).toBeGreaterThan(0);
expect(screen.getAllByText('后端建议动作').length).toBeGreaterThan(0);
expect(screen.getAllByText('10 分钟确认').length).toBeGreaterThan(0);
expect(screen.getByText('后端无来源规则')).toBeInTheDocument();
expect(screen.getByText('后端 P0 通知策略')).toBeInTheDocument();
@@ -3638,6 +3638,93 @@ test('opens same-day history evidence from quality issue row', async () => {
});
});
test('quality page surfaces escalation clock for priority issues', async () => {
window.history.replaceState(null, '', '/#/quality');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const path = String(input);
if (path.includes('/api/ops/health')) {
return {
ok: true,
json: async () => ({
data: { linkHealth: [], kafkaLag: 0, redisOnlineKeys: 0, tdengineWritable: true, mysqlWritable: true, runtime: { requestTimeoutMs: 5000 } },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/quality/summary')) {
return {
ok: true,
json: async () => ({
data: {
issueVehicleCount: 2,
issueRecordCount: 2,
errorCount: 1,
warningCount: 1,
protocols: [{ name: 'VEHICLE_SERVICE', count: 1 }, { name: 'JT808', count: 1 }],
issueTypes: [{ name: 'NO_SOURCE', count: 1 }, { name: 'LINK_GAP', count: 1 }]
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/quality/issues')) {
return {
ok: true,
json: async () => ({
data: {
items: [
{
vin: 'VIN-QUALITY-OVERDUE',
plate: '粤A超时',
phone: '13307790001',
sourceEndpoint: 'vehicle_identity_binding',
protocol: 'VEHICLE_SERVICE',
issueType: 'NO_SOURCE',
severity: 'error',
lastSeen: '2026-07-03 08:00:00',
detail: '绑定车辆无来源'
},
{
vin: 'VIN-QUALITY-RECENT',
plate: '粤A正常',
phone: '13307790002',
sourceEndpoint: '115.231.168.135:43625',
protocol: 'JT808',
issueType: 'LINK_GAP',
severity: 'warning',
lastSeen: new Date().toISOString(),
detail: '最近链路间断'
}
],
total: 2,
limit: 20,
offset: 0
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
return {
ok: true,
json: async () => ({
data: { items: [], total: 0, limit: 20, offset: 0 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
});
render(<App />);
expect(await screen.findByText('告警升级时钟')).toBeInTheDocument();
expect(await screen.findByText('超 SLA')).toBeInTheDocument();
expect(screen.getByText('SLA 正常')).toBeInTheDocument();
expect(screen.getByText('VIN-QUALITY-OVERDUE')).toBeInTheDocument();
});
test('opens same-day raw evidence from quality issue row', async () => {
window.history.replaceState(null, '', '/#/quality');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {