feat(platform): preserve history source evidence
This commit is contained in:
@@ -191,7 +191,7 @@ export function History({ initialVin, initialProtocol, onOpenVehicle }: { initia
|
||||
title: '操作',
|
||||
width: 110,
|
||||
render: (_: unknown, row: HistoryLocationRow) => (
|
||||
<Button disabled={!canOpenVehicle(row.vin)} onClick={() => onOpenVehicle(row.vin)}>车辆服务</Button>
|
||||
<Button disabled={!canOpenVehicle(row.vin)} onClick={() => onOpenVehicle(row.vin, row.protocol)}>车辆服务</Button>
|
||||
)
|
||||
}
|
||||
]}
|
||||
@@ -225,7 +225,7 @@ export function History({ initialVin, initialProtocol, onOpenVehicle }: { initia
|
||||
render: (_: unknown, row: RawFrameRow) => (
|
||||
<Space>
|
||||
<Button onClick={() => setSelectedRaw(row)}>字段</Button>
|
||||
<Button disabled={!canOpenVehicle(row.vin)} onClick={() => onOpenVehicle(row.vin)}>车辆服务</Button>
|
||||
<Button disabled={!canOpenVehicle(row.vin)} onClick={() => onOpenVehicle(row.vin, row.protocol)}>车辆服务</Button>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1332,7 +1332,7 @@ test('shows vehicle and source scope on mileage hash', async () => {
|
||||
expect(screen.getByText('当前来源:GB32960')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('opens unified vehicle service from history results without row protocol', async () => {
|
||||
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) => {
|
||||
const path = String(input);
|
||||
@@ -1409,7 +1409,97 @@ test('opens unified vehicle service from history results without row protocol',
|
||||
fireEvent.click(screen.getAllByRole('button', { name: '车辆服务' })[0]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(window.location.hash).toBe('#/detail?keyword=VIN-JT808-001');
|
||||
expect(window.location.hash).toBe('#/detail?keyword=VIN-JT808-001&protocol=JT808');
|
||||
});
|
||||
});
|
||||
|
||||
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) => {
|
||||
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: [], total: 0, 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-gb32960-001',
|
||||
vin: 'VIN-GB32960-001',
|
||||
plate: '粤AG18312',
|
||||
protocol: 'GB32960',
|
||||
frameType: 'REALTIME',
|
||||
deviceTime: '2026-07-03 20:12:10',
|
||||
serverTime: '2026-07-03 20:12:11',
|
||||
rawSizeBytes: 256,
|
||||
parsedFields: {}
|
||||
}],
|
||||
total: 1,
|
||||
limit: 10,
|
||||
offset: 0
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
if (path.includes('/api/vehicles/resolve')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
lookupKey: 'VIN-GB32960-001',
|
||||
resolved: true,
|
||||
vin: 'VIN-GB32960-001',
|
||||
plate: '粤AG18312',
|
||||
phone: '',
|
||||
oem: 'G7s',
|
||||
protocols: ['GB32960'],
|
||||
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 />);
|
||||
|
||||
fireEvent.click(await screen.findByRole('tab', { name: 'RAW 帧' }));
|
||||
expect(await screen.findByText('raw-gb32960-001')).toBeInTheDocument();
|
||||
fireEvent.click(screen.getAllByRole('button', { name: '车辆服务' })[0]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(window.location.hash).toBe('#/detail?keyword=VIN-GB32960-001&protocol=GB32960');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user