feat(platform): filter vehicles by service status

This commit is contained in:
lingniu
2026-07-04 01:54:30 +08:00
parent b7de38605d
commit 14408d135d
7 changed files with 120 additions and 2 deletions

View File

@@ -294,6 +294,44 @@ test('shows vehicle service status in vehicle list', async () => {
expect(screen.getByText('部分来源离线')).toBeInTheDocument();
});
test('filters vehicle list by service status', async () => {
window.history.replaceState(null, '', '/#/vehicles');
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const path = String(input);
if (path.includes('/api/vehicles/coverage')) {
return {
ok: true,
json: async () => ({
data: { items: [], total: 0, limit: 20, offset: 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: 10, offset: 0 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
});
render(<App />);
await screen.findByRole('heading', { name: '车辆服务' });
fireEvent.click(screen.getByTestId('service-status-filter'));
fireEvent.click(await screen.findByText('部分来源离线'));
fireEvent.click(screen.getByRole('button', { name: '查询' }));
await waitFor(() => {
expect(fetchMock).toHaveBeenCalledWith(expect.stringContaining('serviceStatus=degraded'), undefined);
});
});
test('switches vehicle detail to a source from the coverage cards', async () => {
window.history.replaceState(null, '', '/#/detail?keyword=VIN001');
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {