feat(platform-web): filter dashboard coverage by service status

This commit is contained in:
lingniu
2026-07-04 02:13:53 +08:00
parent 4c27cfa28d
commit b36d0480ee
2 changed files with 52 additions and 0 deletions

View File

@@ -172,6 +172,51 @@ test('shows row service status in dashboard vehicle previews', async () => {
expect(screen.getByText('实时车辆离线')).toBeInTheDocument();
});
test('filters dashboard coverage by service status', async () => {
window.history.replaceState(null, '', '/#/dashboard');
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {
const path = String(input);
if (path.includes('/api/dashboard/summary')) {
return {
ok: true,
json: async () => ({
data: {
onlineVehicles: 3,
activeToday: 4,
frameToday: 1286320,
issueVehicles: 7,
kafkaLag: 0,
protocols: [],
serviceStatuses: [],
linkHealth: []
},
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
}
return {
ok: true,
json: async () => ({
data: { items: [], total: 0, limit: 8, offset: 0 },
traceId: 'trace-test',
timestamp: 1783094400000
})
} as Response;
});
render(<App />);
expect(await screen.findByText('车辆服务覆盖')).toBeInTheDocument();
fireEvent.click(screen.getByTestId('dashboard-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('opens vehicle detail from shareable hash', async () => {
window.history.replaceState(null, '', '/#/detail?keyword=%E7%B2%A4AG18312');
vi.spyOn(globalThis, 'fetch').mockResolvedValue({