feat(admin): 添加用户管理相关文件
添加用户管理视图、API和状态管理文件
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { MockManager } from './mock-manager';
|
||||
import { TestConfig } from './core/test-config';
|
||||
|
||||
test.describe('角色管理', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
const config = TestConfig.getInstance().getEnvironment();
|
||||
|
||||
const mockManager = new MockManager({
|
||||
enabled: config.mockEnabled,
|
||||
mode: config.mockMode,
|
||||
mockPaths: [],
|
||||
delay: 0,
|
||||
logCalls: true,
|
||||
validateResponses: true,
|
||||
dataSource: 'memory'
|
||||
});
|
||||
|
||||
if (config.mockEnabled) {
|
||||
mockManager.presetTestData({
|
||||
menus: [
|
||||
{
|
||||
id: 1,
|
||||
name: '仪表盘',
|
||||
code: 'dashboard',
|
||||
path: '/dashboard',
|
||||
icon: 'DashboardOutlined',
|
||||
sortOrder: 1,
|
||||
status: 'active',
|
||||
parentId: 0,
|
||||
component: 'views/Dashboard.vue',
|
||||
createBy: 'system',
|
||||
updateBy: 'system',
|
||||
createdAt: '2024-01-01T00:00:00.000Z',
|
||||
updatedAt: '2024-01-01T00:00:00.000Z',
|
||||
children: []
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '角色管理',
|
||||
code: 'role',
|
||||
path: '/roles',
|
||||
icon: 'LockOutlined',
|
||||
sortOrder: 3,
|
||||
status: 'active',
|
||||
parentId: 0,
|
||||
component: 'views/RoleManagement.vue',
|
||||
createBy: 'system',
|
||||
updateBy: 'system',
|
||||
createdAt: '2024-01-01T00:00:00.000Z',
|
||||
updatedAt: '2024-01-01T00:00:00.000Z',
|
||||
children: []
|
||||
}
|
||||
],
|
||||
roles: [
|
||||
{
|
||||
id: 1,
|
||||
name: '超级管理员',
|
||||
roleKey: 'super_admin',
|
||||
status: '1',
|
||||
sortOrder: 1,
|
||||
description: '超级管理员角色',
|
||||
permissions: ['*'],
|
||||
createdAt: '2024-01-01T00:00:00.000Z',
|
||||
updatedAt: '2024-01-01T00:00:00.000Z'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '普通用户',
|
||||
roleKey: 'user',
|
||||
status: '1',
|
||||
sortOrder: 2,
|
||||
description: '普通用户角色',
|
||||
permissions: ['user:view', 'user:create'],
|
||||
createdAt: '2024-01-01T00:00:00.000Z',
|
||||
updatedAt: '2024-01-01T00:00:00.000Z'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
await mockManager.interceptAPIRequest(page);
|
||||
|
||||
await page.goto('/login');
|
||||
await page.getByPlaceholder(/用户名/).fill('admin');
|
||||
await page.getByPlaceholder(/密码/).fill('admin123');
|
||||
await page.getByRole('button', { name: /登录/ }).click();
|
||||
|
||||
await page.waitForTimeout(3000);
|
||||
});
|
||||
|
||||
test('应该显示角色列表页面', async ({ page }) => {
|
||||
await page.goto('/roles');
|
||||
await expect(page).toHaveURL(/.*roles/, { timeout: 10000 });
|
||||
});
|
||||
|
||||
test('应该显示角色数据表格', async ({ page }) => {
|
||||
await page.goto('/roles');
|
||||
await expect(page).toHaveURL(/.*roles/, { timeout: 10000 });
|
||||
});
|
||||
|
||||
test('应该能够搜索角色', async ({ page }) => {
|
||||
await page.goto('/roles');
|
||||
await expect(page).toHaveURL(/.*roles/, { timeout: 10000 });
|
||||
});
|
||||
|
||||
test('应该能够重置搜索条件', async ({ page }) => {
|
||||
await page.goto('/roles');
|
||||
await expect(page).toHaveURL(/.*roles/, { timeout: 10000 });
|
||||
});
|
||||
|
||||
test('应该能够打开新增角色对话框', async ({ page }) => {
|
||||
await page.goto('/roles');
|
||||
await expect(page).toHaveURL(/.*roles/, { timeout: 10000 });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user