feat(platform): filter dashboard by missing source

This commit is contained in:
lingniu
2026-07-04 05:34:17 +08:00
parent 7c3b506fe7
commit 6ac980adad
2 changed files with 63 additions and 1 deletions

View File

@@ -755,6 +755,52 @@ test('filters dashboard coverage by service status', async () => {
expect(screen.getByText('当前筛选:部分来源离线')).toBeInTheDocument();
});
test('filters dashboard coverage by missing source evidence', 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-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);
});
expect(screen.getByText('当前筛选:缺 YUTONG_MQTT')).toBeInTheDocument();
});
test('opens dashboard coverage from service status distribution', async () => {
window.history.replaceState(null, '', '/#/dashboard');
const fetchMock = vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {