feat: 添加异常日志功能并优化UI样式
refactor: 重构后端查询逻辑和API响应处理 fix: 修复用户角色更新和文件上传问题 test: 添加前端性能测试脚本和E2E测试用例 chore: 更新依赖版本和配置文件 docs: 添加环境检查脚本和测试文档 style: 统一表格标签样式和路由命名 perf: 优化前端页面加载速度和响应时间
This commit is contained in:
@@ -13,8 +13,8 @@ export class UserManagementPage {
|
||||
|
||||
constructor(page: Page) {
|
||||
this.page = page;
|
||||
this.table = page.locator('.el-table').or(page.locator('table'));
|
||||
this.createUserButton = page.getByRole('button', { name: '创建用户' }).or(page.locator('button:has-text("创建用户")'));
|
||||
this.table = page.locator('.el-table').first();
|
||||
this.createUserButton = page.getByRole('button', { name: '新增用户' }).or(page.locator('button:has-text("新增用户")'));
|
||||
this.searchInput = page.locator('input[placeholder*="搜索"]').or(page.locator('input[name*="keyword"]'));
|
||||
this.searchButton = page.getByRole('button', { name: '搜索' }).or(page.locator('button:has-text("搜索")'));
|
||||
this.successMessage = page.locator('.el-message--success').or(page.locator('.success-message'));
|
||||
@@ -35,34 +35,53 @@ export class UserManagementPage {
|
||||
|
||||
async fillUserForm(userData: {
|
||||
username: string;
|
||||
nickname?: string;
|
||||
email: string;
|
||||
phone?: string;
|
||||
password: string;
|
||||
confirmPassword: string;
|
||||
confirmPassword?: string;
|
||||
}) {
|
||||
await this.page.locator('input[placeholder*="用户名"]').or(page.locator('input[name*="username"]')).fill(userData.username);
|
||||
await this.page.locator('input[placeholder*="邮箱"]').or(page.locator('input[name*="email"]')).fill(userData.email);
|
||||
if (userData.phone) {
|
||||
await this.page.locator('input[placeholder*="手机号"]').or(page.locator('input[name*="phone"]')).fill(userData.phone);
|
||||
const dialog = this.page.locator('.el-dialog');
|
||||
await dialog.locator('input').first().fill(userData.username);
|
||||
if (userData.nickname) {
|
||||
await dialog.locator('input').nth(1).fill(userData.nickname);
|
||||
}
|
||||
await dialog.locator('input[type="password"]').fill(userData.password);
|
||||
await dialog.locator('input').nth(3).fill(userData.email);
|
||||
if (userData.phone) {
|
||||
const phoneInput = dialog.locator('input[placeholder*="手机号"]');
|
||||
if (await phoneInput.count() > 0) {
|
||||
await phoneInput.fill(userData.phone);
|
||||
} else {
|
||||
const phoneSelect = dialog.locator('.el-select');
|
||||
if (await phoneSelect.count() > 0) {
|
||||
await phoneSelect.first().click();
|
||||
await this.page.waitForTimeout(300);
|
||||
const selectInput = this.page.locator('.el-select-dropdown__input');
|
||||
if (await selectInput.count() > 0) {
|
||||
await selectInput.fill(userData.phone);
|
||||
await this.page.waitForTimeout(300);
|
||||
}
|
||||
await this.page.keyboard.press('Enter');
|
||||
}
|
||||
}
|
||||
}
|
||||
await this.page.locator('input[placeholder*="密码"]').or(page.locator('input[name*="password"]')).first().fill(userData.password);
|
||||
await this.page.locator('input[placeholder*="确认密码"]').or(page.locator('input[name*="confirmPassword"]')).fill(userData.confirmPassword);
|
||||
}
|
||||
|
||||
async submitForm() {
|
||||
await this.page.getByRole('button', { name: '确定' }).or(page.locator('button:has-text("确定")')).click();
|
||||
await this.page.getByRole('button', { name: '确定' }).or(this.page.locator('button:has-text("确定")')).click();
|
||||
}
|
||||
|
||||
async editUser(rowNumber: number) {
|
||||
await this.table.locator(`tbody tr:nth-child(${rowNumber})`).getByRole('button', { name: '编辑' }).or(page.locator(`tbody tr:nth-child(${rowNumber}) .edit-button`)).click();
|
||||
await this.table.locator(`tbody tr:nth-child(${rowNumber})`).getByRole('button', { name: '编辑' }).or(this.page.locator(`tbody tr:nth-child(${rowNumber}) .edit-button`)).click();
|
||||
}
|
||||
|
||||
async deleteUser(rowNumber: number) {
|
||||
await this.table.locator(`tbody tr:nth-child(${rowNumber})`).getByRole('button', { name: '删除' }).or(page.locator(`tbody tr:nth-child(${rowNumber}) .delete-button`)).click();
|
||||
await this.table.locator(`tbody tr:nth-child(${rowNumber})`).getByRole('button', { name: '删除' }).or(this.page.locator(`tbody tr:nth-child(${rowNumber}) .delete-button`)).click();
|
||||
}
|
||||
|
||||
async confirmDelete() {
|
||||
await this.page.getByRole('button', { name: '确定' }).or(page.locator('.confirm-dialog .confirm-button')).click();
|
||||
await this.page.getByRole('button', { name: '确定' }).or(this.page.locator('.confirm-dialog .confirm-button')).click();
|
||||
}
|
||||
|
||||
async search(keyword: string) {
|
||||
@@ -79,7 +98,7 @@ export class UserManagementPage {
|
||||
}
|
||||
|
||||
async getCurrentPage(): Promise<string> {
|
||||
return await this.page.locator('.el-pagination .el-pager li.active').or(page.locator('.pagination .current-page')).textContent() || '1';
|
||||
return await this.page.locator('.el-pagination .el-pager li.active').or(this.page.locator('.pagination .current-page')).textContent() || '1';
|
||||
}
|
||||
|
||||
async getUserCount(): Promise<number> {
|
||||
|
||||
Reference in New Issue
Block a user