feat(platform): filter vehicles by missing source
This commit is contained in:
@@ -337,6 +337,85 @@ test('filters vehicle list from result summary actions', async () => {
|
||||
expect(window.location.hash).toBe('#/vehicles?online=online');
|
||||
});
|
||||
|
||||
test('filters vehicle list by missing source evidence', async () => {
|
||||
window.history.replaceState(null, '', '/#/vehicles');
|
||||
const fetchMock = 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/coverage/summary')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
totalVehicles: 1,
|
||||
onlineVehicles: 0,
|
||||
singleSourceVehicles: 0,
|
||||
multiSourceVehicles: 1,
|
||||
noDataVehicles: 0,
|
||||
unboundVehicles: 0
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
if (path.includes('/api/vehicles/coverage')) {
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
items: [{
|
||||
vin: 'VIN001',
|
||||
plate: '粤AG18312',
|
||||
phone: '13307795425',
|
||||
oem: 'G7s',
|
||||
protocols: ['GB32960', 'JT808'],
|
||||
sourceCount: 2,
|
||||
onlineSourceCount: 0,
|
||||
online: false,
|
||||
lastSeen: '2026-07-03 20:12:10',
|
||||
bindingStatus: 'bound'
|
||||
}],
|
||||
total: 1,
|
||||
limit: 20,
|
||||
offset: 0
|
||||
},
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
}
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: { items: [], total: 0, limit: 20, offset: 0 },
|
||||
traceId: 'trace-test',
|
||||
timestamp: 1783094400000
|
||||
})
|
||||
} as Response;
|
||||
});
|
||||
|
||||
render(<App />);
|
||||
|
||||
expect(await screen.findByText('缺失来源')).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByTestId('missing-protocol-filter'));
|
||||
fireEvent.click(await screen.findByText('缺 YUTONG_MQTT'));
|
||||
fireEvent.click(screen.getByRole('button', { name: '查询' }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('missingProtocol=YUTONG_MQTT'), undefined);
|
||||
});
|
||||
});
|
||||
|
||||
test('copies shareable vehicle service filter link', async () => {
|
||||
window.history.replaceState(null, '', '/#/vehicles?keyword=%E7%B2%A4A&coverage=multi&serviceStatus=degraded');
|
||||
const writeText = vi.fn(() => Promise.resolve());
|
||||
|
||||
Reference in New Issue
Block a user