feat(platform-web): filter dashboard coverage by service status
This commit is contained in:
@@ -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
|
||||
<Select.Option value="bound">已绑定</Select.Option>
|
||||
<Select.Option value="unbound">未绑定</Select.Option>
|
||||
</Form.Select>
|
||||
<Form.Select field="serviceStatus" label="服务状态" placeholder="全部" style={{ width: 150 }} data-testid="dashboard-service-status-filter">
|
||||
<Select.Option value="healthy">服务正常</Select.Option>
|
||||
<Select.Option value="degraded">部分来源离线</Select.Option>
|
||||
<Select.Option value="offline">车辆离线</Select.Option>
|
||||
<Select.Option value="identity_required">身份未绑定</Select.Option>
|
||||
</Form.Select>
|
||||
<Space>
|
||||
<Button htmlType="submit" theme="solid" type="primary">筛选</Button>
|
||||
<Button onClick={() => loadCoverage()}>重置</Button>
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user