test: E2E 测试用例更新与新增

- 更新 Page Object 模型适配新字段名
- 新增 UAT 测试套件与 journey 测试用例
- 优化测试辅助工具与数据工厂
- 更新 playwright 认证状态
This commit is contained in:
张翔
2026-05-06 14:17:51 +08:00
parent 0b246b3e24
commit bd21e2d1f7
47 changed files with 1764 additions and 1226 deletions
@@ -21,20 +21,20 @@ test.describe('管理员完整工作流', () => {
await test.step('点击创建角色按钮', async () => {
await page.locator('button:has-text("新增角色")').click();
await page.waitForSelector('.el-dialog', { state: 'visible', timeout: 5000 });
await page.waitForSelector('.ant-modal', { state: 'visible', timeout: 5000 });
});
await test.step('填写角色信息', async () => {
const dialog = page.locator('.el-dialog');
const dialog = page.locator('.ant-modal');
await dialog.locator('input').first().fill(roleName);
await dialog.locator('input').nth(1).fill(roleKey);
await dialog.locator('.el-input-number .el-input__inner').fill('99');
await dialog.locator('.ant-input-number .ant-input__inner').fill('99');
});
await test.step('提交表单', async () => {
await page.locator('.el-dialog button:has-text("确定")').click();
await page.waitForSelector('.el-dialog', { state: 'hidden', timeout: 10000 });
await expect(page.locator('.el-message--success')).toBeVisible({ timeout: 5000 });
await page.locator('.ant-modal button:has-text("确定")').click();
await page.waitForSelector('.ant-modal', { state: 'hidden', timeout: 10000 });
await expect(page.locator('.ant-message-success')).toBeVisible({ timeout: 5000 });
});
});
@@ -51,11 +51,11 @@ test.describe('管理员完整工作流', () => {
await test.step('点击创建用户按钮', async () => {
await page.locator('button:has-text("新增用户")').click();
await page.waitForSelector('.el-dialog', { state: 'visible', timeout: 5000 });
await page.waitForSelector('.ant-modal', { state: 'visible', timeout: 5000 });
});
await test.step('填写用户信息', async () => {
const dialog = page.locator('.el-dialog');
const dialog = page.locator('.ant-modal');
await dialog.locator('input').first().fill(username);
await dialog.locator('input[type="password"]').fill('Test@123');
await dialog.locator('input').nth(2).fill(`测试用户${timestamp}`);
@@ -64,9 +64,9 @@ test.describe('管理员完整工作流', () => {
});
await test.step('提交表单', async () => {
await page.locator('.el-dialog button:has-text("确定")').click();
await page.waitForSelector('.el-dialog', { state: 'hidden', timeout: 10000 });
await expect(page.locator('.el-message--success')).toBeVisible({ timeout: 5000 });
await page.locator('.ant-modal button:has-text("确定")').click();
await page.waitForSelector('.ant-modal', { state: 'hidden', timeout: 10000 });
await expect(page.locator('.ant-message-success')).toBeVisible({ timeout: 5000 });
});
await test.step('搜索新创建的用户', async () => {
@@ -85,13 +85,13 @@ test.describe('管理员完整工作流', () => {
await expect(userRow).toBeVisible({ timeout: 10000 });
await userRow.locator('button:has-text("分配角色")').click();
await page.waitForSelector('.el-dialog:has-text("分配角色")', { state: 'visible', timeout: 5000 });
await page.waitForSelector('.ant-modal:has-text("分配角色")', { state: 'visible', timeout: 5000 });
const transfer = page.locator('.el-transfer');
const leftPanel = transfer.locator('.el-transfer-panel').first();
const rightPanel = transfer.locator('.el-transfer-panel').last();
const transfer = page.locator('.ant-transfer');
const leftPanel = transfer.locator('.ant-transfer-list').first();
const rightPanel = transfer.locator('.ant-transfer-list').last();
const rightPanelItems = await rightPanel.locator('.el-checkbox').all();
const rightPanelItems = await rightPanel.locator('.ant-checkbox').all();
let hasSuperAdminRole = false;
for (const item of rightPanelItems) {
@@ -103,7 +103,7 @@ test.describe('管理员完整工作流', () => {
}
if (!hasSuperAdminRole) {
const leftPanelItems = await leftPanel.locator('.el-checkbox').all();
const leftPanelItems = await leftPanel.locator('.ant-checkbox').all();
let superAdminCheckbox = null;
for (const item of leftPanelItems) {
@@ -121,7 +121,7 @@ test.describe('管理员完整工作流', () => {
await page.waitForTimeout(500);
}
const moveToRightButton = transfer.locator('.el-transfer__buttons button').nth(1);
const moveToRightButton = transfer.locator('.ant-transfer-operation button').nth(1);
if (await moveToRightButton.isEnabled()) {
await moveToRightButton.click();
await page.waitForTimeout(500);
@@ -129,9 +129,9 @@ test.describe('管理员完整工作流', () => {
}
}
await page.locator('.el-dialog:has-text("分配角色") button:has-text("确定")').click();
await page.waitForSelector('.el-dialog:has-text("分配角色")', { state: 'hidden', timeout: 10000 });
await expect(page.locator('.el-message--success').last()).toBeVisible({ timeout: 5000 });
await page.locator('.ant-modal:has-text("分配角色") button:has-text("确定")').click();
await page.waitForSelector('.ant-modal:has-text("分配角色")', { state: 'hidden', timeout: 10000 });
await expect(page.locator('.ant-message-success').last()).toBeVisible({ timeout: 5000 });
});
});
@@ -140,7 +140,7 @@ test.describe('管理员完整工作流', () => {
await page.goto('/dashboard');
await page.waitForLoadState('networkidle');
const avatarButton = page.locator('.el-avatar').first();
const avatarButton = page.locator('.ant-avatar').first();
await avatarButton.click({ timeout: 10000 });
await page.waitForTimeout(500);
@@ -166,7 +166,7 @@ test.describe('管理员完整工作流', () => {
await page.goto('/dashboard');
await page.waitForLoadState('networkidle');
const avatarButton = page.locator('.el-avatar').first();
const avatarButton = page.locator('.ant-avatar').first();
if (await avatarButton.isVisible()) {
await avatarButton.click();
await page.waitForTimeout(500);
@@ -187,7 +187,7 @@ test.describe('管理员完整工作流', () => {
await page.waitForTimeout(1000);
await page.locator('button:has-text("删除")').first().click();
await page.locator('button:has-text("确定")').click();
await expect(page.locator('.el-message--success')).toBeVisible({ timeout: 5000 });
await expect(page.locator('.ant-message-success')).toBeVisible({ timeout: 5000 });
});
await test.step('删除测试角色', async () => {
@@ -197,7 +197,7 @@ test.describe('管理员完整工作流', () => {
await page.waitForTimeout(1000);
await page.locator('button:has-text("删除")').first().click();
await page.locator('button:has-text("确定")').click();
await expect(page.locator('.el-message--success')).toBeVisible({ timeout: 5000 });
await expect(page.locator('.ant-message-success')).toBeVisible({ timeout: 5000 });
});
});
});