develop #1

Merged
zhangxiang merged 60 commits from develop into main 2026-04-05 10:28:15 +08:00
Showing only changes of commit 0e367a8873 - Show all commits
@@ -103,9 +103,11 @@ test.describe('系统全面集成测试', () => {
test('2.1 查询用户列表', async ({ page }) => { test('2.1 查询用户列表', async ({ page }) => {
await userManagementPage.goto(); await userManagementPage.goto();
await userManagementPage.waitForTableReady();
await expect(page.locator('.user-table')).toBeVisible({ timeout: 5000 }); await expect(userManagementPage.table).toBeVisible({ timeout: 5000 });
await expect(page.locator('.user-row')).toHaveCount(await page.locator('.user-row').count()); const userCount = await userManagementPage.getUserCount();
expect(userCount).toBeGreaterThan(0);
}); });
test('2.2 创建新用户', async ({ page }) => { test('2.2 创建新用户', async ({ page }) => {
@@ -113,6 +115,7 @@ test.describe('系统全面集成测试', () => {
const username = `testuser_${timestamp}`; const username = `testuser_${timestamp}`;
await userManagementPage.goto(); await userManagementPage.goto();
await userManagementPage.waitForTableReady();
await userManagementPage.clickCreateUser(); await userManagementPage.clickCreateUser();
await userManagementPage.fillUserForm({ await userManagementPage.fillUserForm({
username: username, username: username,
@@ -121,25 +124,27 @@ test.describe('系统全面集成测试', () => {
phone: '13800138000', phone: '13800138000',
nickname: `测试用户${timestamp}` nickname: `测试用户${timestamp}`
}); });
await userManagementPage.submitUserForm(); await userManagementPage.submitForm();
await expect(page.locator('.success-message')).toBeVisible({ timeout: 5000 }); await expect(userManagementPage.successMessage).toBeVisible({ timeout: 5000 });
await userManagementPage.searchUser(username); await userManagementPage.search(username);
await expect(page.locator('.user-row').first()).toContainText(username); await page.waitForTimeout(1000);
const found = await userManagementPage.containsText(username);
expect(found).toBeTruthy();
}); });
test('2.3 编辑用户信息', async ({ page }) => { test('2.3 编辑用户信息', async ({ page }) => {
await userManagementPage.goto(); await userManagementPage.goto();
await userManagementPage.waitForTableReady();
const firstUser = page.locator('.user-row').first(); await userManagementPage.clickEditButton(1);
await firstUser.locator('[data-testid="edit-button"]').click();
const newNickname = `更新昵称_${Date.now()}`; const newNickname = `更新昵称_${Date.now()}`;
await page.fill('[name="nickname"]', newNickname); await userManagementPage.fillNickname(newNickname);
await page.click('[data-testid="submit-button"]'); await userManagementPage.submitForm();
await expect(page.locator('.success-message')).toBeVisible({ timeout: 5000 }); await expect(userManagementPage.successMessage).toBeVisible({ timeout: 5000 });
}); });
test('2.4 删除用户', async ({ page }) => { test('2.4 删除用户', async ({ page }) => {
@@ -147,6 +152,7 @@ test.describe('系统全面集成测试', () => {
const username = `deleteuser_${timestamp}`; const username = `deleteuser_${timestamp}`;
await userManagementPage.goto(); await userManagementPage.goto();
await userManagementPage.waitForTableReady();
await userManagementPage.clickCreateUser(); await userManagementPage.clickCreateUser();
await userManagementPage.fillUserForm({ await userManagementPage.fillUserForm({
username: username, username: username,
@@ -155,45 +161,36 @@ test.describe('系统全面集成测试', () => {
phone: '13800138000', phone: '13800138000',
nickname: `待删除用户${timestamp}` nickname: `待删除用户${timestamp}`
}); });
await userManagementPage.submitUserForm(); await userManagementPage.submitForm();
await expect(page.locator('.success-message')).toBeVisible({ timeout: 5000 }); await expect(userManagementPage.successMessage).toBeVisible({ timeout: 5000 });
await userManagementPage.searchUser(username); await userManagementPage.search(username);
const userRow = page.locator('.user-row').first(); await page.waitForTimeout(1000);
await userRow.locator('[data-testid="delete-button"]').click(); await userManagementPage.clickDeleteButton(1);
await userManagementPage.confirmDelete();
page.on('dialog', dialog => dialog.accept()); await expect(userManagementPage.successMessage).toBeVisible({ timeout: 5000 });
await page.click('[data-testid="confirm-delete-button"]');
await expect(page.locator('.success-message')).toBeVisible({ timeout: 5000 });
}); });
test('2.5 分配用户角色', async ({ page }) => { test('2.5 分配用户角色', async ({ page }) => {
await userManagementPage.goto(); await userManagementPage.goto();
await userManagementPage.waitForTableReady();
const firstUser = page.locator('.user-row').first(); await userManagementPage.clickEditButton(1);
await firstUser.locator('[data-testid="assign-role-button"]').click(); await userManagementPage.selectRole('管理员');
await userManagementPage.submitForm();
await page.check('[data-testid="role-admin"]'); await expect(userManagementPage.successMessage).toBeVisible({ timeout: 5000 });
await page.click('[data-testid="submit-button"]');
await expect(page.locator('.success-message')).toBeVisible({ timeout: 5000 });
}); });
test('2.6 启用/禁用用户', async ({ page }) => { test('2.6 启用/禁用用户', async ({ page }) => {
await userManagementPage.goto(); await userManagementPage.goto();
await userManagementPage.waitForTableReady();
const firstUser = page.locator('.user-row').first(); await userManagementPage.clickStatusButton(1);
const statusButton = firstUser.locator('[data-testid="toggle-status-button"]');
const currentStatus = await statusButton.getAttribute('data-status');
await statusButton.click(); await expect(userManagementPage.successMessage).toBeVisible({ timeout: 5000 });
await expect(page.locator('.success-message')).toBeVisible({ timeout: 5000 });
const newStatus = await statusButton.getAttribute('data-status');
expect(newStatus).not.toBe(currentStatus);
}); });
}); });
@@ -206,9 +203,10 @@ test.describe('系统全面集成测试', () => {
test('3.1 查询角色列表', async ({ page }) => { test('3.1 查询角色列表', async ({ page }) => {
await roleManagementPage.goto(); await roleManagementPage.goto();
await roleManagementPage.waitForTableReady();
await expect(page.locator('.role-table')).toBeVisible({ timeout: 5000 }); await expect(roleManagementPage.table).toBeVisible({ timeout: 5000 });
const roleCount = await page.locator('.role-row').count(); const roleCount = await roleManagementPage.table.locator('tbody tr').count();
expect(roleCount).toBeGreaterThan(0); expect(roleCount).toBeGreaterThan(0);
}); });
@@ -218,31 +216,34 @@ test.describe('系统全面集成测试', () => {
const roleKey = `test_role_${timestamp}`; const roleKey = `test_role_${timestamp}`;
await roleManagementPage.goto(); await roleManagementPage.goto();
await roleManagementPage.waitForTableReady();
await roleManagementPage.clickCreateRole(); await roleManagementPage.clickCreateRole();
await roleManagementPage.fillRoleForm({ await roleManagementPage.fillRoleForm({
roleName: roleName, roleName: roleName,
roleKey: roleKey, roleKey: roleKey,
roleSort: '99' roleSort: '99'
}); });
await roleManagementPage.submitRoleForm(); await roleManagementPage.submitForm();
await expect(page.locator('.success-message')).toBeVisible({ timeout: 5000 }); await expect(roleManagementPage.successMessage).toBeVisible({ timeout: 5000 });
await roleManagementPage.searchRole(roleName); await roleManagementPage.search(roleName);
await expect(page.locator('.role-row').first()).toContainText(roleName); await page.waitForTimeout(1000);
const found = await roleManagementPage.containsText(roleName);
expect(found).toBeTruthy();
}); });
test('3.3 编辑角色', async ({ page }) => { test('3.3 编辑角色', async ({ page }) => {
await roleManagementPage.goto(); await roleManagementPage.goto();
await roleManagementPage.waitForTableReady();
const firstRole = page.locator('.role-row').first(); await roleManagementPage.editRole(1);
await firstRole.locator('[data-testid="edit-button"]').click();
const newRoleName = `更新角色_${Date.now()}`; const newRoleName = `更新角色_${Date.now()}`;
await page.fill('[name="roleName"]', newRoleName); await page.locator('.el-dialog').locator('input').first().fill(newRoleName);
await page.click('[data-testid="submit-button"]'); await roleManagementPage.submitForm();
await expect(page.locator('.success-message')).toBeVisible({ timeout: 5000 }); await expect(roleManagementPage.successMessage).toBeVisible({ timeout: 5000 });
}); });
test('3.4 删除角色', async ({ page }) => { test('3.4 删除角色', async ({ page }) => {
@@ -251,36 +252,35 @@ test.describe('系统全面集成测试', () => {
const roleKey = `delete_role_${timestamp}`; const roleKey = `delete_role_${timestamp}`;
await roleManagementPage.goto(); await roleManagementPage.goto();
await roleManagementPage.waitForTableReady();
await roleManagementPage.clickCreateRole(); await roleManagementPage.clickCreateRole();
await roleManagementPage.fillRoleForm({ await roleManagementPage.fillRoleForm({
roleName: roleName, roleName: roleName,
roleKey: roleKey, roleKey: roleKey,
roleSort: '99' roleSort: '99'
}); });
await roleManagementPage.submitRoleForm(); await roleManagementPage.submitForm();
await expect(page.locator('.success-message')).toBeVisible({ timeout: 5000 }); await expect(roleManagementPage.successMessage).toBeVisible({ timeout: 5000 });
await roleManagementPage.searchRole(roleName); await roleManagementPage.search(roleName);
const roleRow = page.locator('.role-row').first(); await page.waitForTimeout(1000);
await roleRow.locator('[data-testid="delete-button"]').click(); await roleManagementPage.deleteRole(1);
await roleManagementPage.confirmDelete();
page.on('dialog', dialog => dialog.accept()); await expect(roleManagementPage.successMessage).toBeVisible({ timeout: 5000 });
await page.click('[data-testid="confirm-delete-button"]');
await expect(page.locator('.success-message')).toBeVisible({ timeout: 5000 });
}); });
test('3.5 分配角色权限', async ({ page }) => { test('3.5 分配角色权限', async ({ page }) => {
await roleManagementPage.goto(); await roleManagementPage.goto();
await roleManagementPage.waitForTableReady();
const firstRole = page.locator('.role-row').first(); await roleManagementPage.clickPermissionButton(1);
await firstRole.locator('[data-testid="assign-permission-button"]').click(); await page.waitForTimeout(500);
await roleManagementPage.selectPermission('user:manage');
await roleManagementPage.savePermissions();
await page.check('[data-testid="permission-user-manage"]'); await expect(roleManagementPage.successMessage).toBeVisible({ timeout: 5000 });
await page.click('[data-testid="submit-button"]');
await expect(page.locator('.success-message')).toBeVisible({ timeout: 5000 });
}); });
}); });