feat(platform): link quality issues to mileage evidence

This commit is contained in:
lingniu
2026-07-04 11:57:55 +08:00
parent f305066eff
commit fb6d8c323a
3 changed files with 125 additions and 1 deletions

View File

@@ -2589,6 +2589,116 @@ test('opens same-day history evidence from quality issue row', async () => {
});
});
test('opens same-day mileage statistics from quality issue row', 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: 0,
warningCount: 1,
protocols: [{ name: 'JT808', count: 1 }],
issueTypes: [{ name: 'FIELD_MISSING', 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-MILEAGE',
plate: '粤A告警里',
phone: '13307795425',
sourceEndpoint: '115.231.168.135:43625',
protocol: 'JT808',
issueType: 'FIELD_MISSING',
severity: 'warning',
lastSeen: '2026-07-03 20:12:10',
detail: 'JT808 位置帧缺少总里程字段'
}],
total: 1,
limit: 20,
offset: 0
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/mileage/summary')) {
return {
ok: true,
json: async () => ({
data: { vehicleCount: 1, recordCount: 1, sourceCount: 1, totalMileageKm: 18.8, averageMileagePerVin: 18.8 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/mileage/daily')) {
return {
ok: true,
json: async () => ({
data: {
items: [{
vin: 'VIN-QUALITY-MILEAGE',
plate: '粤A告警里',
source: 'JT808',
date: '2026-07-03',
startMileageKm: 200,
endMileageKm: 218.8,
dailyMileageKm: 18.8,
anomalySeverity: 'warning'
}],
total: 1,
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('VIN-QUALITY-MILEAGE')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '核对里程' }));
await waitFor(() => {
expect(window.location.hash).toBe('#/mileage?keyword=VIN-QUALITY-MILEAGE&protocol=JT808&dateFrom=2026-07-03&dateTo=2026-07-04');
});
});
test('drills into quality issues by issue type', async () => {
window.history.replaceState(null, '', '/#/quality');
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {