refine Semi UI access difference workspace

This commit is contained in:
lingniu
2026-07-18 13:14:39 +08:00
parent ad81d108a7
commit c7123f6fbd
3 changed files with 197 additions and 10 deletions

View File

@@ -66,6 +66,21 @@ test('removes old access rows immediately when the vehicle filter scope changes'
expect(within(filterActions!).getByRole('button', { name: '重置' })).toBeInTheDocument();
expect(view.container.querySelector('.v2-access-semi-table.semi-table-wrapper')).toBeInTheDocument();
expect(view.container.querySelector('.v2-access-table-scroll-v3 > table')).not.toBeInTheDocument();
const desktopAccessScroll = view.container.querySelector<HTMLElement>('.v2-access-table-scroll-v3');
expect(desktopAccessScroll).toHaveAttribute('tabindex', '0');
expect(desktopAccessScroll).toHaveAttribute('aria-label', '车辆接入表格,可使用左右方向键浏览协议来源');
const desktopTableScroller = desktopAccessScroll?.querySelector<HTMLElement>('.semi-table-body');
expect(desktopTableScroller).toBeInTheDocument();
Object.defineProperty(desktopAccessScroll!, 'clientWidth', { configurable: true, value: 760 });
Object.defineProperty(desktopAccessScroll!, 'scrollWidth', { configurable: true, value: 760 });
const scrollBy = vi.fn();
Object.defineProperty(desktopTableScroller!, 'scrollBy', { configurable: true, value: scrollBy });
fireEvent.keyDown(desktopAccessScroll!, { key: 'ArrowRight' });
expect(scrollBy).toHaveBeenCalledWith({ left: 260, behavior: 'smooth' });
fireEvent.keyDown(desktopAccessScroll!, { key: 'ArrowLeft' });
expect(scrollBy).toHaveBeenCalledWith({ left: -260, behavior: 'smooth' });
expect(screen.getByRole('columnheader', { name: '车辆' })).toHaveClass('semi-table-cell-fixed-left', 'v2-access-vehicle-column');
expect(screen.getByRole('columnheader', { name: '品牌 / 车型' })).toHaveClass('semi-table-cell-fixed-left', 'v2-access-model-column');
const desktopRow = screen.getByTestId('access-row-OLDVIN');
expect(desktopRow).toHaveAttribute('role', 'button');
expect(desktopRow).toHaveAttribute('aria-expanded', 'false');
@@ -154,6 +169,7 @@ test('renders mobile access vehicles as selectable Semi cards', async () => {
expect(within(action).getByText('32960')).toBeInTheDocument();
expect(within(action).getByText('808')).toBeInTheDocument();
expect(within(action).getByText('宇通')).toBeInTheDocument();
expect(screen.queryByLabelText('每页车辆数')).not.toBeInTheDocument();
expect(action).toHaveAttribute('aria-pressed', 'false');
expect(action).toHaveAttribute('aria-expanded', 'false');
fireEvent.click(action);
@@ -166,4 +182,19 @@ test('renders mobile access vehicles as selectable Semi cards', async () => {
expect(dialog.querySelector('.v2-access-inspector-summary.semi-descriptions')).toBeInTheDocument();
expect(dialog.querySelector('.v2-access-protocol-details.semi-card-group')).toBeInTheDocument();
expect(dialog.querySelectorAll('.v2-access-protocol-detail.semi-card')).toHaveLength(3);
expect(document.querySelector('.v2-access-detail-sidesheet')).toHaveClass('semi-sidesheet-bottom');
expect(document.querySelector('.v2-access-detail-sidesheet .semi-sidesheet-inner')).toHaveStyle({ height: 'min(84dvh, 740px)' });
fireEvent.click(within(dialog).getByRole('button', { name: '关闭车辆接入详情' }));
expect(action).toHaveAttribute('aria-pressed', 'false');
expect(action).toHaveAttribute('aria-expanded', 'false');
expect(document.body.style.overflow).not.toBe('hidden');
const governanceButton = screen.getByRole('button', { name: /接入治理/ });
fireEvent.click(governanceButton);
const governanceDialog = await screen.findByRole('dialog', { name: '接入治理配置' });
expect(document.querySelector('.v2-access-governance-sidesheet')).toHaveClass('semi-sidesheet-bottom');
expect(document.querySelector('.v2-access-governance-sidesheet .semi-sidesheet-inner')).toHaveStyle({ height: 'min(86dvh, 760px)' });
fireEvent.click(within(governanceDialog).getByRole('button', { name: '关闭接入治理配置' }));
expect(governanceButton).toHaveAttribute('aria-expanded', 'false');
expect(document.body.style.overflow).not.toBe('hidden');
});