e8f51309e5
- 更新 Page Object 模型适配新字段名 - 新增 UAT 测试套件与 journey 测试用例 - 优化测试辅助工具与数据工厂 - 更新 playwright 认证状态
124 lines
4.0 KiB
TypeScript
124 lines
4.0 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { LoginPage } from '../pages/LoginPage';
|
|
import { UserManagementPage } from '../pages/UserManagementPage';
|
|
import { RoleManagementPage } from '../pages/RoleManagementPage';
|
|
import { MenuManagementPage } from '../pages/MenuManagementPage';
|
|
|
|
test.describe('UAT: 系统管理功能验收', () => {
|
|
const timestamp = Date.now();
|
|
|
|
test('UAT-SYS-01: 用户管理 - 新增用户表单验证', async ({ page }) => {
|
|
const loginPage = new LoginPage(page);
|
|
const userPage = new UserManagementPage(page);
|
|
|
|
await loginPage.goto();
|
|
await loginPage.login('admin', 'Test@123');
|
|
await userPage.goto();
|
|
await userPage.clickCreateUser();
|
|
|
|
await test.step('空表单提交应显示验证错误', async () => {
|
|
await userPage.submitForm();
|
|
await expect(page.locator('.ant-form-item-explain-error').first()).toBeVisible({ timeout: 5000 });
|
|
});
|
|
});
|
|
|
|
test('UAT-SYS-02: 用户管理 - 完整 CRUD', async ({ page }) => {
|
|
const loginPage = new LoginPage(page);
|
|
const userPage = new UserManagementPage(page);
|
|
const username = `uat_user_${timestamp}`;
|
|
|
|
await loginPage.goto();
|
|
await loginPage.login('admin', 'Test@123');
|
|
|
|
await test.step('创建用户', async () => {
|
|
await userPage.goto();
|
|
await userPage.clickCreateUser();
|
|
await userPage.fillUserForm({
|
|
username,
|
|
password: 'Uat@123456',
|
|
nickname: `UAT用户_${timestamp}`,
|
|
email: `uat_${timestamp}@test.com`,
|
|
phone: '13900139000',
|
|
});
|
|
await userPage.submitForm();
|
|
const success = await userPage.waitForSuccessMessage();
|
|
expect(success).toBe(true);
|
|
});
|
|
|
|
await test.step('验证用户出现在列表中', async () => {
|
|
await userPage.goto();
|
|
await userPage.waitForTableReady();
|
|
const exists = await userPage.containsText(username);
|
|
expect(exists).toBe(true);
|
|
});
|
|
|
|
await test.step('编辑用户', async () => {
|
|
await userPage.editUser(1);
|
|
const modal = page.locator('.ant-modal').filter({ hasText: /编辑用户/ });
|
|
const nicknameInput = modal.locator('.ant-form-item').filter({ hasText: '昵称' }).locator('input');
|
|
await nicknameInput.clear();
|
|
await nicknameInput.fill(`UAT修改_${timestamp}`);
|
|
await userPage.submitForm();
|
|
});
|
|
});
|
|
|
|
test('UAT-SYS-03: 角色管理 - 新增角色', async ({ page }) => {
|
|
const loginPage = new LoginPage(page);
|
|
const rolePage = new RoleManagementPage(page);
|
|
const roleName = `UAT角色_${timestamp}`;
|
|
const roleKey = `uat_role_${timestamp}`;
|
|
|
|
await loginPage.goto();
|
|
await loginPage.login('admin', 'Test@123');
|
|
|
|
await test.step('创建角色', async () => {
|
|
await rolePage.goto();
|
|
await rolePage.clickCreateRole();
|
|
await rolePage.fillRoleForm({
|
|
roleName,
|
|
roleKey,
|
|
roleSort: 50,
|
|
status: 'ACTIVE',
|
|
});
|
|
await rolePage.submitForm();
|
|
});
|
|
|
|
await test.step('验证角色出现在列表中', async () => {
|
|
await rolePage.goto();
|
|
const exists = await rolePage.containsText(roleName);
|
|
expect(exists).toBe(true);
|
|
});
|
|
});
|
|
|
|
test('UAT-SYS-04: 菜单管理 - 新增菜单', async ({ page }) => {
|
|
const loginPage = new LoginPage(page);
|
|
const menuPage = new MenuManagementPage(page);
|
|
const menuName = `UAT菜单_${timestamp}`;
|
|
|
|
await loginPage.goto();
|
|
await loginPage.login('admin', 'Test@123');
|
|
|
|
await test.step('创建菜单', async () => {
|
|
await menuPage.goto();
|
|
await menuPage.clickCreateMenu();
|
|
await menuPage.fillMenuForm({
|
|
name: menuName,
|
|
type: 'menu',
|
|
path: `/uat-test-${timestamp}`,
|
|
icon: 'setting',
|
|
component: `uat/Test_${timestamp}`,
|
|
permission: `uat:test_${timestamp}`,
|
|
sort: 50,
|
|
status: 'ACTIVE',
|
|
});
|
|
await menuPage.submitForm();
|
|
});
|
|
|
|
await test.step('验证菜单出现在列表中', async () => {
|
|
await menuPage.goto();
|
|
const exists = await menuPage.containsText(menuName);
|
|
expect(exists).toBe(true);
|
|
});
|
|
});
|
|
});
|