feat(platform): link locations to raw evidence
This commit is contained in:
@@ -4583,6 +4583,101 @@ test('opens same-day mileage statistics from history location row', async () =>
|
||||
});
|
||||
});
|
||||
|
||||
test('opens same-day raw evidence from history location row', async () => {
|
||||
window.history.replaceState(null, '', '/#/history?keyword=VIN-HISTORY-RAW&protocol=JT808');
|
||||
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/history/locations')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
items: [{
|
||||
vin: 'VIN-HISTORY-RAW',
|
||||
plate: '粤A原帧核',
|
||||
protocol: 'JT808',
|
||||
longitude: 113.2,
|
||||
latitude: 23.1,
|
||||
speedKmh: 30,
|
||||
socPercent: 0,
|
||||
totalMileageKm: 218.8,
|
||||
lastSeen: '2026-07-03 20:12:10',
|
||||
deviceTime: '2026-07-03 20:12:10',
|
||||
serverTime: '2026-07-03 20:12:11'
|
||||
}],
|
||||
total: 1,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
if (path.includes('/api/history/raw-frames/query')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
items: [{
|
||||
id: 'raw-from-location-001',
|
||||
vin: 'VIN-HISTORY-RAW',
|
||||
plate: '粤A原帧核',
|
||||
protocol: 'JT808',
|
||||
frameType: '0x0200',
|
||||
deviceTime: '2026-07-03 20:12:10',
|
||||
serverTime: '2026-07-03 20:12:11',
|
||||
rawSizeBytes: 128,
|
||||
parsedFields: { 'jt808.location.longitude': 113.2 }
|
||||
}],
|
||||
total: 1,
|
||||
limit: 10,
|
||||
offset: 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-HISTORY-RAW')).length).toBeGreaterThan(0);
|
||||
fireEvent.click(screen.getByRole('button', { name: '核对 RAW' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(window.location.hash.startsWith('#/history?')).toBe(true);
|
||||
});
|
||||
const params = new URLSearchParams(window.location.hash.slice('#/history?'.length));
|
||||
expect(params.get('keyword')).toBe('VIN-HISTORY-RAW');
|
||||
expect(params.get('protocol')).toBe('JT808');
|
||||
expect(params.get('dateFrom')).toBe('2026-07-03');
|
||||
expect(params.get('dateTo')).toBe('2026-07-04');
|
||||
expect(params.get('includeFields')).toBe('true');
|
||||
expect(params.get('tab')).toBe('raw');
|
||||
expect(await screen.findByRole('tab', { name: 'RAW 帧' })).toHaveAttribute('aria-selected', 'true');
|
||||
expect(await screen.findByText('raw-from-location-001')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('opens vehicle service from raw history rows with row source evidence', async () => {
|
||||
window.history.replaceState(null, '', '/#/history?keyword=%E7%B2%A4AG18312&protocol=GB32960');
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
|
||||
Reference in New Issue
Block a user