refine Semi UI account workspace

This commit is contained in:
lingniu
2026-07-18 05:02:31 +08:00
parent 800d956159
commit 80f6880488
4 changed files with 354 additions and 44 deletions

View File

@@ -57,13 +57,14 @@ test('deduplicates vehicle candidates by VIN and renders granted vehicles plate
expect(customer.closest('.semi-list-item')).toHaveClass('v2-user-list-row');
expect(customer).toHaveAttribute('aria-pressed', 'false');
expect(customer).toHaveAttribute('aria-expanded', 'false');
expect(view.container.querySelector('.v2-user-editor.semi-card')).not.toBeInTheDocument();
expect(document.querySelector('.v2-user-editor-sidesheet')).not.toBeInTheDocument();
fireEvent.click(customer);
await waitFor(() => expect(customer).toHaveAttribute('aria-expanded', 'true'));
expect(view.container.querySelector('.v2-user-editor.semi-card')).toBeInTheDocument();
expect(view.container.querySelector('.v2-user-editor-tabs.semi-tabs')).toBeInTheDocument();
expect(document.querySelector('.v2-user-editor-sidesheet .semi-sidesheet-inner')).toHaveAttribute('aria-label', '客户账号详情');
expect(document.querySelector('.v2-user-editor-sidesheet .v2-user-editor-tabs.semi-tabs')).toBeInTheDocument();
expect(document.querySelector('.v2-user-editor-form')).toHaveAttribute('id', 'v2-user-editor-form');
expect(screen.getAllByRole('tab')).toHaveLength(3);
expect(view.container.querySelector('.v2-user-vehicle-section.semi-card')).toBeInTheDocument();
expect(document.querySelector('.v2-user-vehicle-section.semi-card')).toBeInTheDocument();
fireEvent.click(screen.getByRole('tab', { name: /菜单权限/ }));
expect(screen.getByText('客户开放菜单').closest('.semi-tag')).toBeInTheDocument();
fireEvent.click(screen.getByRole('tab', { name: /车辆权限/ }));
@@ -126,7 +127,7 @@ test('pages and filters large vehicle grants without nesting a vehicle-list scro
expect(screen.getAllByRole('button', { name: /^移除 / })).toHaveLength(10);
expect(screen.getByText('第 110 条,共 12 辆')).toBeInTheDocument();
expect(view.container.querySelector('.v2-assigned-pagination')).toBeInTheDocument();
expect(document.querySelector('.v2-assigned-pagination')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: 'Next' }));
expect(await screen.findByRole('button', { name: '移除 粤A00012' })).toBeInTheDocument();
expect(screen.getAllByRole('button', { name: /^移除 / })).toHaveLength(2);
@@ -156,12 +157,12 @@ test('keeps the customer directory visible on mobile and opens details on demand
expect(filterToggle).toHaveAttribute('aria-expanded', 'false');
fireEvent.click(filterToggle);
expect(screen.getByRole('button', { name: '收起账号范围:全部状态' })).toHaveAttribute('aria-expanded', 'true');
expect(view.container.querySelector('.v2-user-editor')).not.toBeInTheDocument();
expect(document.querySelector('.v2-user-editor-sidesheet')).not.toBeInTheDocument();
fireEvent.click(customer);
expect(await screen.findByRole('button', { name: '关闭账号详情' })).toBeInTheDocument();
expect(customer).toHaveAttribute('aria-expanded', 'true');
fireEvent.click(screen.getByRole('button', { name: '关闭账号详情' }));
expect(view.container.querySelector('.v2-user-editor')).not.toBeInTheDocument();
await waitFor(() => expect(document.querySelector('.v2-user-editor-form')).not.toBeInTheDocument());
expect(customer).toHaveAttribute('aria-expanded', 'false');
expect(screen.getAllByRole('button', { name: '新建客户账号' })).toHaveLength(1);
});
@@ -210,7 +211,7 @@ test('uses a standard Semi empty state when no customer account exists', async (
expect(await screen.findByText('还没有客户账号')).toBeInTheDocument();
expect(view.container.querySelector('.v2-user-list-empty.semi-empty')).toBeInTheDocument();
expect(view.container.querySelector('.v2-user-editor')).not.toBeInTheDocument();
expect(document.querySelector('.v2-user-editor-sidesheet')).not.toBeInTheDocument();
expect(screen.getAllByRole('button', { name: '创建第一个客户账号' })).toHaveLength(1);
});