feat(platform): guide mileage anomaly handling

This commit is contained in:
lingniu
2026-07-04 10:17:19 +08:00
parent 56f07c3488
commit e0de4b353a
2 changed files with 93 additions and 0 deletions

View File

@@ -3235,6 +3235,71 @@ test('opens vehicle service from mileage row with row source evidence', async ()
});
});
test('shows mileage anomaly action guidance', async () => {
window.history.replaceState(null, '', '/#/mileage?keyword=VIN-MILEAGE-ANOMALY&protocol=GB32960');
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/mileage/summary')) {
return {
ok: true,
json: async () => ({
data: { vehicleCount: 1, recordCount: 1, sourceCount: 1, totalMileageKm: -3.2, averageMileagePerVin: -3.2 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
if (path.includes('/api/mileage/daily')) {
return {
ok: true,
json: async () => ({
data: {
items: [{
vin: 'VIN-MILEAGE-ANOMALY',
plate: '粤A异常1',
source: 'GB32960',
date: '2026-07-03',
startMileageKm: 100,
endMileageKm: 96.8,
dailyMileageKm: -3.2,
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-MILEAGE-ANOMALY')).toBeInTheDocument();
expect(screen.getByText('核对里程来源')).toBeInTheDocument();
expect(screen.getByText('日里程异常,优先核对当天首末总里程、来源断链和补传数据。')).toBeInTheDocument();
});
test('opens vehicle service from history results with row source evidence', async () => {
window.history.replaceState(null, '', '/#/history?keyword=%E7%B2%A4AG18312&protocol=JT808');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input, init) => {