08ea5fbe98
添加用户管理视图、API和状态管理文件
119 lines
3.4 KiB
TypeScript
119 lines
3.4 KiB
TypeScript
import { test, expect } from '../test-fixtures';
|
|
|
|
test.describe('数据管理器测试', () => {
|
|
test.beforeEach(async ({ testDataManager, testLogger }) => {
|
|
testLogger.startTest('数据管理器测试');
|
|
});
|
|
|
|
test.afterEach(async ({ testDataManager, testLogger }) => {
|
|
await testDataManager.cleanup();
|
|
testLogger.endTest('数据管理器测试', 'passed');
|
|
});
|
|
|
|
test('@smoke 创建测试用户', async ({ testDataManager, testLogger }) => {
|
|
testLogger.startStep('创建测试用户');
|
|
|
|
const userData = {
|
|
username: 'test_user_001',
|
|
realName: '测试用户001',
|
|
email: 'test001@example.com',
|
|
phone: '13800138001',
|
|
status: 1
|
|
};
|
|
|
|
const user = await testDataManager.createTestUserFromGenerator(userData);
|
|
|
|
expect(user).toBeTruthy();
|
|
expect(user.username).toBe(userData.username);
|
|
expect(user.realName).toBe(userData.realName);
|
|
|
|
testLogger.endStep('创建测试用户', 'passed');
|
|
});
|
|
|
|
test('@smoke 创建测试角色', async ({ testDataManager, testLogger }) => {
|
|
testLogger.startStep('创建测试角色');
|
|
|
|
const roleData = {
|
|
roleName: '测试角色001',
|
|
roleCode: 'test_role_001',
|
|
description: '测试角色描述',
|
|
status: 1
|
|
};
|
|
|
|
const role = await testDataManager.createTestRole(roleData);
|
|
|
|
expect(role).toBeTruthy();
|
|
expect(role.roleName).toBe(roleData.roleName);
|
|
expect(role.roleCode).toBe(roleData.roleCode);
|
|
|
|
testLogger.endStep('创建测试角色', 'passed');
|
|
});
|
|
|
|
test('@smoke 创建测试菜单', async ({ testDataManager, testLogger }) => {
|
|
testLogger.startStep('创建测试菜单');
|
|
|
|
const menuData = {
|
|
name: '测试菜单001',
|
|
code: 'test_menu_001',
|
|
path: '/test/menu/001',
|
|
icon: 'SettingOutlined',
|
|
sortOrder: 1,
|
|
status: 1,
|
|
parentId: 0
|
|
};
|
|
|
|
const menu = await testDataManager.createTestMenu(menuData);
|
|
|
|
expect(menu).toBeTruthy();
|
|
expect(menu.name).toBe(menuData.name);
|
|
expect(menu.code).toBe(menuData.code);
|
|
|
|
testLogger.endStep('创建测试菜单', 'passed');
|
|
});
|
|
|
|
test('@regression 批量创建测试数据', async ({ testDataManager, testLogger }) => {
|
|
testLogger.startStep('批量创建测试用户');
|
|
|
|
const users = [];
|
|
for (let i = 0; i < 5; i++) {
|
|
const userData = {
|
|
username: `test_user_${i}`,
|
|
realName: `测试用户${i}`,
|
|
email: `test${i}@example.com`,
|
|
phone: `1380013800${i}`,
|
|
status: 1
|
|
};
|
|
|
|
const user = await testDataManager.createTestUserFromGenerator(userData);
|
|
users.push(user);
|
|
}
|
|
|
|
expect(users.length).toBe(5);
|
|
expect(users.every(u => u.username.startsWith('test_user_'))).toBeTruthy();
|
|
|
|
testLogger.endStep('批量创建测试用户', 'passed');
|
|
});
|
|
|
|
test('@regression 清理测试数据', async ({ testDataManager, testLogger }) => {
|
|
testLogger.startStep('创建测试用户');
|
|
|
|
const userData = {
|
|
username: 'test_user_cleanup',
|
|
realName: '测试用户清理',
|
|
email: 'test_cleanup@example.com',
|
|
phone: '13800138099',
|
|
status: 1
|
|
};
|
|
|
|
const user = await testDataManager.createTestUserFromGenerator(userData);
|
|
expect(user).toBeTruthy();
|
|
|
|
testLogger.endStep('创建测试用户', 'passed');
|
|
testLogger.startStep('清理测试数据');
|
|
|
|
await testDataManager.cleanup();
|
|
|
|
testLogger.endStep('清理测试数据', 'passed');
|
|
});
|
|
});
|