From b36d0480ee5f709a38ceb05be6b5bc06f0d32765 Mon Sep 17 00:00:00 2001 From: lingniu Date: Sat, 4 Jul 2026 02:13:53 +0800 Subject: [PATCH] feat(platform-web): filter dashboard coverage by service status --- .../apps/web/src/pages/Dashboard.tsx | 7 +++ .../apps/web/src/test/App.test.tsx | 45 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/vehicle-data-platform/apps/web/src/pages/Dashboard.tsx b/vehicle-data-platform/apps/web/src/pages/Dashboard.tsx index 70ead08b..730481fe 100644 --- a/vehicle-data-platform/apps/web/src/pages/Dashboard.tsx +++ b/vehicle-data-platform/apps/web/src/pages/Dashboard.tsx @@ -54,6 +54,7 @@ export function Dashboard({ onOpenVehicle, onOpenQuality }: { onOpenVehicle: (vi if (values?.coverage) params.set('coverage', values.coverage); if (values?.online) params.set('online', values.online); if (values?.bindingStatus) params.set('bindingStatus', values.bindingStatus); + if (values?.serviceStatus) params.set('serviceStatus', values.serviceStatus); api.vehicleCoverage(params) .then((page) => setCoverage(page.items)) .catch((error: Error) => Toast.error(error.message)) @@ -193,6 +194,12 @@ export function Dashboard({ onOpenVehicle, onOpenQuality }: { onOpenVehicle: (vi 已绑定 未绑定 + + 服务正常 + 部分来源离线 + 车辆离线 + 身份未绑定 + diff --git a/vehicle-data-platform/apps/web/src/test/App.test.tsx b/vehicle-data-platform/apps/web/src/test/App.test.tsx index 6a7bbe8f..c3ff78a7 100644 --- a/vehicle-data-platform/apps/web/src/test/App.test.tsx +++ b/vehicle-data-platform/apps/web/src/test/App.test.tsx @@ -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(); + + 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({