fix(platform): keep history source when opening vehicle
This commit is contained in:
@@ -145,7 +145,7 @@ export function History({
|
|||||||
title="历史数据"
|
title="历史数据"
|
||||||
description="按车辆查询位置历史和 RAW 帧历史,数据来源只作为过滤和诊断维度"
|
description="按车辆查询位置历史和 RAW 帧历史,数据来源只作为过滤和诊断维度"
|
||||||
actions={(
|
actions={(
|
||||||
<Button disabled={!currentVehicleKeyword} onClick={() => onOpenVehicle(currentVehicleKeyword)}>
|
<Button disabled={!currentVehicleKeyword} onClick={() => onOpenVehicle(currentVehicleKeyword, currentProtocol)}>
|
||||||
当前车辆服务
|
当前车辆服务
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1707,6 +1707,60 @@ test('opens vehicle service from raw history rows with row source evidence', asy
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('opens current vehicle service from history header with current source evidence', async () => {
|
||||||
|
window.history.replaceState(null, '', '/#/history?keyword=VIN-JT808-HEADER&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/vehicles/resolve')) {
|
||||||
|
return {
|
||||||
|
ok: true,
|
||||||
|
json: async () => ({
|
||||||
|
data: {
|
||||||
|
lookupKey: 'VIN-JT808-HEADER',
|
||||||
|
resolved: true,
|
||||||
|
vin: 'VIN-JT808-HEADER',
|
||||||
|
plate: '粤AG18312',
|
||||||
|
phone: '13307795425',
|
||||||
|
oem: 'G7s',
|
||||||
|
protocols: ['JT808'],
|
||||||
|
online: true,
|
||||||
|
lastSeen: '2026-07-03 20:12:10'
|
||||||
|
},
|
||||||
|
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.findByText('当前来源:JT808')).toBeInTheDocument();
|
||||||
|
fireEvent.click(screen.getByRole('button', { name: '当前车辆服务' }));
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(window.location.hash).toBe('#/detail?keyword=VIN-JT808-HEADER&protocol=JT808');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('opens unified vehicle service from realtime vehicles without primary protocol', async () => {
|
test('opens unified vehicle service from realtime vehicles without primary protocol', async () => {
|
||||||
window.history.replaceState(null, '', '/#/realtime');
|
window.history.replaceState(null, '', '/#/realtime');
|
||||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||||
@@ -2515,7 +2569,7 @@ test('opens source-specific raw history directly from vehicle detail source evid
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('opens unified vehicle service from an empty history query', async () => {
|
test('opens vehicle service from an empty history query with current source evidence', async () => {
|
||||||
window.history.replaceState(null, '', '/#/history?keyword=VIN404&protocol=JT808');
|
window.history.replaceState(null, '', '/#/history?keyword=VIN404&protocol=JT808');
|
||||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||||
const path = String(input);
|
const path = String(input);
|
||||||
@@ -2556,7 +2610,7 @@ test('opens unified vehicle service from an empty history query', async () => {
|
|||||||
fireEvent.click(await screen.findByRole('button', { name: '当前车辆服务' }));
|
fireEvent.click(await screen.findByRole('button', { name: '当前车辆服务' }));
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(window.location.hash).toBe('#/detail?keyword=VIN404');
|
expect(window.location.hash).toBe('#/detail?keyword=VIN404&protocol=JT808');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user