feat(platform): link quality issues to realtime status

This commit is contained in:
lingniu
2026-07-04 12:10:28 +08:00
parent 4ef71c37f2
commit 2465bd7f16
3 changed files with 100 additions and 3 deletions

View File

@@ -5283,6 +5283,93 @@ test('loads realtime vehicles from shareable source filter hash', async () => {
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('/api/realtime/vehicles?limit=50&offset=0&keyword=%E7%B2%A4ART002&protocol=JT808&online=online&serviceStatus=degraded'), undefined);
});
test('opens realtime status from quality issue row with source evidence', 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: 1,
issueRecordCount: 1,
errorCount: 1,
warningCount: 0,
protocols: [{ name: 'JT808', count: 1 }],
issueTypes: [{ name: 'VIN_MISSING', count: 1 }]
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/quality/issues')) {
return {
ok: true,
json: async () => ({
data: {
items: [{
vin: '',
plate: '粤AG18312',
phone: '13307795425',
sourceEndpoint: '115.231.168.135:43625',
protocol: 'JT808',
issueType: 'VIN_MISSING',
severity: 'error',
lastSeen: '2026-07-03 20:12:10',
detail: 'JT808 数据缺少 VIN 映射'
}],
total: 1,
limit: 20,
offset: 0
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/realtime/vehicles')) {
return {
ok: true,
json: async () => ({
data: { items: [], total: 0, limit: 50, 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('13307795425')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '实时状态' }));
await waitFor(() => {
expect(window.location.hash).toBe('#/realtime?keyword=%E7%B2%A4AG18312&protocol=JT808');
});
expect(await screen.findByRole('heading', { name: '实时监控' })).toBeInTheDocument();
});
test('shows and clears current realtime service filters', 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) => {