feat(platform): link vehicle rows to quality evidence

This commit is contained in:
lingniu
2026-07-04 12:01:28 +08:00
parent fb6d8c323a
commit 276da59194
3 changed files with 117 additions and 3 deletions

View File

@@ -5612,6 +5612,109 @@ test('opens vehicle service from source-filtered vehicle list with source eviden
});
});
test('opens quality issues from source-filtered vehicle list with source evidence', async () => {
window.history.replaceState(null, '', '/#/vehicles?protocol=JT808');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const path = String(input);
if (path.includes('/api/vehicles/coverage')) {
return {
ok: true,
json: async () => ({
data: {
items: [{
vin: 'VIN-LIST-QUALITY',
plate: '粤A列表质',
phone: '13307795425',
oem: 'G7s',
protocols: ['JT808'],
sourceCount: 1,
onlineSourceCount: 0,
online: false,
lastSeen: '2026-07-03 20:12:10',
bindingStatus: 'bound',
serviceStatus: {
status: 'offline',
severity: 'error',
title: '车辆离线',
detail: 'JT808 来源离线',
sourceCount: 1,
onlineSourceCount: 0
}
}],
total: 1,
limit: 20,
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-LIST-QUALITY',
plate: '粤A列表质',
phone: '13307795425',
sourceEndpoint: '115.231.168.135:43625',
protocol: 'JT808',
issueType: 'LINK_GAP',
severity: 'error',
lastSeen: '2026-07-03 20:12:10',
detail: 'JT808 来源离线'
}],
total: 1,
limit: 20,
offset: 0
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
return {
ok: true,
json: async () => ({
data: path.includes('/api/ops/health')
? { linkHealth: [], kafkaLag: 0, redisOnlineKeys: 0, tdengineWritable: true, mysqlWritable: true, runtime: { requestTimeoutMs: 5000 } }
: { items: [], total: 0, limit: 20, offset: 0 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
});
render(<App />);
expect(await screen.findByText('VIN-LIST-QUALITY')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '质量问题' }));
await waitFor(() => {
expect(window.location.hash).toBe('#/quality?keyword=VIN-LIST-QUALITY&protocol=JT808');
});
expect(await screen.findByRole('heading', { name: '告警通知' })).toBeInTheDocument();
});
test('filters vehicle list by service status', async () => {
window.history.replaceState(null, '', '/#/vehicles');
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {