fix: 使用UUID确保测试数据唯一性,避免重复键冲突
- 修改用户创建测试,使用UUID生成唯一用户名 - 修改角色创建测试,使用UUID生成唯一角色名 - 修复登录响应处理逻辑 - 改进成功消息等待策略
This commit is contained in:
@@ -111,8 +111,8 @@ test.describe('系统全面集成测试', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('2.2 创建新用户', async ({ page }) => {
|
test('2.2 创建新用户', async ({ page }) => {
|
||||||
const timestamp = Date.now();
|
const uuid = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
||||||
const username = `testuser_${timestamp}`;
|
const username = `u_${uuid}`;
|
||||||
|
|
||||||
await userManagementPage.goto();
|
await userManagementPage.goto();
|
||||||
await userManagementPage.waitForTableReady();
|
await userManagementPage.waitForTableReady();
|
||||||
@@ -122,7 +122,7 @@ test.describe('系统全面集成测试', () => {
|
|||||||
password: 'Test@123',
|
password: 'Test@123',
|
||||||
email: `${username}@test.com`,
|
email: `${username}@test.com`,
|
||||||
phone: '13800138000',
|
phone: '13800138000',
|
||||||
nickname: `测试用户${timestamp}`
|
nickname: `测试用户${Date.now()}`
|
||||||
});
|
});
|
||||||
await userManagementPage.submitForm();
|
await userManagementPage.submitForm();
|
||||||
|
|
||||||
@@ -149,8 +149,8 @@ test.describe('系统全面集成测试', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('2.4 删除用户', async ({ page }) => {
|
test('2.4 删除用户', async ({ page }) => {
|
||||||
const timestamp = Date.now();
|
const uuid = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
||||||
const username = `deleteuser_${timestamp}`;
|
const username = `del_${uuid}`;
|
||||||
|
|
||||||
await userManagementPage.goto();
|
await userManagementPage.goto();
|
||||||
await userManagementPage.waitForTableReady();
|
await userManagementPage.waitForTableReady();
|
||||||
@@ -160,7 +160,7 @@ test.describe('系统全面集成测试', () => {
|
|||||||
password: 'Test@123',
|
password: 'Test@123',
|
||||||
email: `${username}@test.com`,
|
email: `${username}@test.com`,
|
||||||
phone: '13800138000',
|
phone: '13800138000',
|
||||||
nickname: `待删除用户${timestamp}`
|
nickname: `待删除用户${Date.now()}`
|
||||||
});
|
});
|
||||||
await userManagementPage.submitForm();
|
await userManagementPage.submitForm();
|
||||||
|
|
||||||
@@ -216,9 +216,9 @@ test.describe('系统全面集成测试', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('3.2 创建新角色', async ({ page }) => {
|
test('3.2 创建新角色', async ({ page }) => {
|
||||||
const timestamp = Date.now();
|
const uuid = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
||||||
const roleName = `测试角色_${timestamp}`;
|
const roleName = `角色_${uuid}`;
|
||||||
const roleKey = `test_role_${timestamp}`;
|
const roleKey = `r_${uuid}`;
|
||||||
|
|
||||||
await roleManagementPage.goto();
|
await roleManagementPage.goto();
|
||||||
await roleManagementPage.waitForTableReady();
|
await roleManagementPage.waitForTableReady();
|
||||||
@@ -245,7 +245,8 @@ test.describe('系统全面集成测试', () => {
|
|||||||
|
|
||||||
await roleManagementPage.editRole(1);
|
await roleManagementPage.editRole(1);
|
||||||
|
|
||||||
const newRoleName = `更新角色_${Date.now()}`;
|
const uuid = Math.random().toString(36).substring(2, 15);
|
||||||
|
const newRoleName = `更新_${uuid}`;
|
||||||
await page.locator('.el-dialog').locator('input').first().fill(newRoleName);
|
await page.locator('.el-dialog').locator('input').first().fill(newRoleName);
|
||||||
await roleManagementPage.submitForm();
|
await roleManagementPage.submitForm();
|
||||||
|
|
||||||
@@ -254,9 +255,9 @@ test.describe('系统全面集成测试', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('3.4 删除角色', async ({ page }) => {
|
test('3.4 删除角色', async ({ page }) => {
|
||||||
const timestamp = Date.now();
|
const uuid = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
||||||
const roleName = `待删除角色_${timestamp}`;
|
const roleName = `删除_${uuid}`;
|
||||||
const roleKey = `delete_role_${timestamp}`;
|
const roleKey = `d_${uuid}`;
|
||||||
|
|
||||||
await roleManagementPage.goto();
|
await roleManagementPage.goto();
|
||||||
await roleManagementPage.waitForTableReady();
|
await roleManagementPage.waitForTableReady();
|
||||||
|
|||||||
@@ -2,13 +2,15 @@ import { test, expect } from '@playwright/test';
|
|||||||
import { LoginPage } from './pages/LoginPage';
|
import { LoginPage } from './pages/LoginPage';
|
||||||
|
|
||||||
test.describe('用户创建诊断测试', () => {
|
test.describe('用户创建诊断测试', () => {
|
||||||
|
let loginPage: LoginPage;
|
||||||
|
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
const loginPage = new LoginPage(page);
|
loginPage = new LoginPage(page);
|
||||||
await loginPage.goto();
|
|
||||||
await loginPage.login('admin', 'Admin123');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('诊断用户创建流程', async ({ page }) => {
|
test('诊断用户创建流程', async ({ page }) => {
|
||||||
|
await loginPage.goto();
|
||||||
|
await loginPage.login('admin', 'Test@123');
|
||||||
console.log('=== 开始诊断用户创建流程 ===');
|
console.log('=== 开始诊断用户创建流程 ===');
|
||||||
|
|
||||||
await page.goto('/users');
|
await page.goto('/users');
|
||||||
|
|||||||
Reference in New Issue
Block a user