feat(platform): link realtime rows to quality evidence

This commit is contained in:
lingniu
2026-07-04 12:06:46 +08:00
parent 276da59194
commit 4ef71c37f2
3 changed files with 147 additions and 3 deletions

View File

@@ -5100,6 +5100,137 @@ test('opens amap coordinate and trajectory playback from realtime map service qu
expect(window.location.hash).toBe('#/history?keyword=VIN-MAP-LINK&protocol=GB32960');
});
test('opens quality issues from realtime vehicle row with source evidence', async () => {
window.history.replaceState(null, '', '/#/realtime?protocol=JT808');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const path = String(input);
if (path.includes('/api/realtime/vehicles')) {
return {
ok: true,
json: async () => ({
data: {
items: [{
vin: 'VIN-RT-QUALITY',
plate: '粤A质量1',
phone: '13307795425',
oem: 'G7s',
protocols: ['JT808'],
sourceStatus: [
{ protocol: 'JT808', online: false, lastSeen: '2026-07-03 20:12:10', hasRealtime: true, hasHistory: true, hasRaw: true, hasMileage: false }
],
sourceCount: 1,
onlineSourceCount: 0,
online: false,
primaryProtocol: 'JT808',
longitude: 113.2,
latitude: 23.1,
speedKmh: 0,
socPercent: 70,
totalMileageKm: 100,
lastSeen: '2026-07-03 20:12:10',
bindingStatus: 'bound',
serviceStatus: {
status: 'offline',
severity: 'error',
title: '车辆离线',
detail: 'JT808 离线',
sourceCount: 1,
onlineSourceCount: 0
}
}],
total: 1,
limit: 50,
offset: 0
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/quality/summary')) {
return {
ok: true,
json: async () => ({
data: {
issueVehicleCount: 1,
issueRecordCount: 1,
errorCount: 1,
warningCount: 0,
protocols: [{ name: 'JT808', count: 1 }],
issueTypes: [{ 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-RT-QUALITY',
plate: '粤A质量1',
phone: '13307795425',
sourceEndpoint: '115.29.187.205:808',
protocol: 'JT808',
issueType: 'LINK_GAP',
severity: 'error',
title: 'JT808 离线',
detail: '实时来源不可用',
firstSeen: '2026-07-03 20:12:10',
lastSeen: '2026-07-03 20:12:10'
}],
total: 1,
limit: 50,
offset: 0
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/ops/health')) {
return {
ok: true,
json: async () => ({
data: {
linkHealth: [],
kafkaLag: 0,
activeConnections: 1,
capacityFindings: [],
redisOnlineKeys: 1,
tdengineWritable: true,
mysqlWritable: true,
runtime: { requestTimeoutMs: 0 }
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
return {
ok: true,
json: async () => ({
data: { items: [], total: 0, limit: 10, offset: 0 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
});
render(<App />);
expect((await screen.findAllByText('VIN-RT-QUALITY')).length).toBeGreaterThan(0);
fireEvent.click(screen.getAllByRole('button', { name: '质量问题' })[0]);
await waitFor(() => {
expect(window.location.hash).toBe('#/quality?keyword=VIN-RT-QUALITY&protocol=JT808');
});
expect(await screen.findByRole('heading', { name: '告警通知' })).toBeInTheDocument();
});
test('loads realtime vehicles from shareable source filter hash', async () => {
window.history.replaceState(null, '', '/#/realtime?keyword=%E7%B2%A4ART002&protocol=JT808&online=online&serviceStatus=degraded');
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {