feat(platform-web): link analysis pages to vehicle service

This commit is contained in:
lingniu
2026-07-04 01:35:15 +08:00
parent 9886fe2481
commit dc3e12328e
5 changed files with 91 additions and 8 deletions

View File

@@ -398,3 +398,48 @@ test('opens history with the currently selected vehicle detail source', async ()
expect(window.location.hash).toBe('#/history?keyword=VIN001&protocol=JT808');
});
});
test('opens vehicle service from an empty history query with the current filters', async () => {
window.history.replaceState(null, '', '/#/history?keyword=VIN404&protocol=JT808');
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const path = String(input);
if (path.includes('/api/vehicles/resolve')) {
return {
ok: true,
json: async () => ({
data: {
lookupKey: 'VIN404',
resolved: true,
vin: 'VIN404',
plate: '',
phone: '',
oem: '',
protocols: ['JT808'],
online: false,
lastSeen: ''
},
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: 10, offset: 0 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
});
render(<App />);
fireEvent.click(await screen.findByRole('button', { name: '当前车辆服务' }));
await waitFor(() => {
expect(window.location.hash).toBe('#/detail?keyword=VIN404&protocol=JT808');
});
});