fix(platform): keep vehicle list source filter
This commit is contained in:
@@ -2447,6 +2447,80 @@ test('shows vehicle service status in vehicle list', async () => {
|
||||
expect(screen.getByText('部分来源离线')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('opens vehicle service from source-filtered vehicle list with source evidence', async () => {
|
||||
window.history.replaceState(null, '', '/#/vehicles?protocol=JT808');
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
const path = String(input);
|
||||
if (path.includes('/api/vehicles/coverage')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
items: [{
|
||||
vin: 'VIN-LIST-JT808',
|
||||
plate: '粤A列表1',
|
||||
phone: '13307795425',
|
||||
oem: 'G7s',
|
||||
protocols: ['JT808'],
|
||||
sourceCount: 1,
|
||||
onlineSourceCount: 1,
|
||||
online: true,
|
||||
lastSeen: '2026-07-03 20:12:10',
|
||||
bindingStatus: 'bound'
|
||||
}],
|
||||
total: 1,
|
||||
limit: 20,
|
||||
offset: 0
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
if (path.includes('/api/vehicle-service/overview')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
vin: 'VIN-LIST-JT808',
|
||||
plate: '粤A列表1',
|
||||
sourceCount: 1,
|
||||
onlineSourceCount: 1,
|
||||
coverageStatus: 'online',
|
||||
primaryProtocol: 'JT808',
|
||||
lastSeen: '2026-07-03 20:12:10',
|
||||
historyCount: 0,
|
||||
rawCount: 0,
|
||||
mileageCount: 0,
|
||||
qualityIssueCount: 0
|
||||
},
|
||||
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: 20, offset: 0 },
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
});
|
||||
|
||||
render(<App />);
|
||||
|
||||
expect(await screen.findByText('VIN-LIST-JT808')).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: '车辆服务' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(window.location.hash).toBe('#/detail?keyword=VIN-LIST-JT808&protocol=JT808');
|
||||
});
|
||||
});
|
||||
|
||||
test('filters vehicle list by service status', async () => {
|
||||
window.history.replaceState(null, '', '/#/vehicles');
|
||||
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
|
||||
|
||||
Reference in New Issue
Block a user