feat: optimize mobile access filters

This commit is contained in:
lingniu
2026-07-18 23:07:12 +08:00
parent a7297abdaf
commit c358faf17d
3 changed files with 187 additions and 12 deletions

View File

@@ -191,7 +191,7 @@ test('renders mobile access vehicles as selectable Semi cards', async () => {
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
const view = render(<QueryClientProvider client={client}><MemoryRouter future={ROUTER_FUTURE} initialEntries={['/access']}><AccessPage /></MemoryRouter></QueryClientProvider>);
const action = await screen.findByRole('button', { name: '查看 粤A00001 接入详情' });
let action = await screen.findByRole('button', { name: '查看 粤A00001 接入详情' });
expect(action).toHaveClass('semi-button', 'v2-access-mobile-action');
expect(action.closest('.semi-card')).toHaveClass('v2-access-mobile-card');
expect(view.container.querySelector('.v2-access-table-scroll-v3.is-mobile-scroll')).toHaveAttribute('tabindex', '0');
@@ -202,6 +202,25 @@ test('renders mobile access vehicles as selectable Semi cards', async () => {
expect(screen.queryByLabelText('每页车辆数')).not.toBeInTheDocument();
expect(screen.getByRole('button', { name: '打开接入治理' })).toHaveTextContent('治理');
expect(screen.getByRole('button', { name: '打开接入治理' })).toHaveClass('v2-workspace-mobile-tool-button', 'is-muted');
const filterTrigger = screen.getByRole('button', { name: /修改接入筛选/ });
expect(filterTrigger).toHaveAttribute('aria-expanded', 'false');
fireEvent.click(filterTrigger);
const filterDialog = await screen.findByRole('dialog', { name: '接入车辆筛选' });
expect(document.querySelector('.v2-access-mobile-filter-sidesheet')).toHaveClass('semi-sidesheet-bottom');
expect(document.querySelector('.v2-access-mobile-filter-sidesheet .semi-sidesheet-inner')).toHaveStyle({ height: 'min(76dvh, 640px)' });
expect(within(filterDialog).getByRole('textbox', { name: '车辆' })).toBeInTheDocument();
expect(within(filterDialog).getByRole('combobox', { name: '接入状态' })).toBeInTheDocument();
expect(within(filterDialog).getByRole('combobox', { name: '真实协议' })).toBeInTheDocument();
expect(within(filterDialog).getByRole('combobox', { name: '车辆品牌' })).toBeInTheDocument();
fireEvent.click(within(filterDialog).getByRole('combobox', { name: '接入状态' }));
const attentionOption = (await screen.findAllByText('需关注')).find((element) => element.classList.contains('semi-select-option-text'));
expect(attentionOption).toBeInTheDocument();
fireEvent.click(attentionOption!);
fireEvent.click(within(filterDialog).getByRole('button', { name: '应用并查询' }));
await waitFor(() => expect(mocks.accessVehicles).toHaveBeenLastCalledWith(expect.objectContaining({ connectionState: 'attention' }), expect.anything()));
expect(screen.getByRole('button', { name: /修改接入筛选:已启用 1 项/ })).toHaveAttribute('aria-expanded', 'false');
expect(screen.getByRole('dialog', { name: '接入车辆筛选' })).toHaveClass('semi-sidesheet-animation-content_hide_bottom');
action = await screen.findByRole('button', { name: '查看 粤A00001 接入详情' });
const toolsButton = screen.getByRole('button', { name: '打开接入管理工具' });
expect(toolsButton).toHaveTextContent('工具');
expect(toolsButton).toHaveClass('v2-workspace-mobile-tool-button', 'is-muted');