refine Semi UI account permission workspace

This commit is contained in:
lingniu
2026-07-18 08:28:23 +08:00
parent aca0edf130
commit 9a49d015cf
4 changed files with 153 additions and 15 deletions

View File

@@ -169,6 +169,42 @@ test('keeps the customer directory visible on mobile and opens details on demand
expect(screen.getAllByRole('button', { name: '新建客户账号' })).toHaveLength(1);
});
test('keeps granted vehicles primary and reveals mobile assignment tools on demand', async () => {
layout.mobile = true;
const vehicles = Array.from({ length: 5 }, (_, index) => ({
vin: `VIN${String(index + 1).padStart(3, '0')}`,
plate: `粤A${String(index + 1).padStart(5, '0')}`,
validFrom: '2026-06-05T00:00:00+08:00',
sourceSystem: 'manual',
grantedBy: '平台管理员'
}));
mocks.adminUsers.mockResolvedValue([{
id: 7, username: 'customer-east', displayName: '华东客户', userType: 'customer', status: 'enabled',
customerRef: '', tenantRef: '', authProvider: 'local', menuKeys: ['monitor', 'vehicles', 'tracks', 'statistics'],
vehicleVins: vehicles.map((vehicle) => vehicle.vin), vehicles, grantHistory: [],
createdAt: '2026-07-16T00:00:00Z', updatedAt: '2026-07-16T00:00:00Z'
}]);
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
render(<QueryClientProvider client={client}><UsersPage /></QueryClientProvider>);
fireEvent.click(await screen.findByRole('button', { name: /选择客户 华东客户/ }));
const toggle = await screen.findByRole('button', { name: '添加授权车辆' });
expect(toggle).toHaveAttribute('aria-expanded', 'false');
expect(document.querySelector('.v2-user-vehicle-section')).toHaveClass('is-composer-collapsed');
expect(screen.queryByRole('textbox', { name: '按车牌或 VIN 搜索' })).not.toBeInTheDocument();
expect(screen.getAllByRole('button', { name: /^移除 / })).toHaveLength(4);
expect(screen.getByText('第 14 条,共 5 辆')).toBeInTheDocument();
expect(document.querySelector('.v2-user-editor-last-login')).toHaveTextContent('最近登录');
fireEvent.click(toggle);
expect(screen.getByRole('button', { name: '收起添加车辆' })).toHaveAttribute('aria-expanded', 'true');
expect(document.querySelector('.v2-user-vehicle-section')).not.toHaveClass('is-composer-collapsed');
expect(screen.getByRole('textbox', { name: '按车牌或 VIN 搜索' })).toBeInTheDocument();
expect(document.querySelector('#v2-user-vehicle-composer')).toBeInTheDocument();
});
test('filters the customer directory by status and exposes the active result scope', async () => {
mocks.adminUsers.mockResolvedValue([
{