fix: correct phone field filling logic in UserManagementPage

- Fix fillUserForm method to use correct input indices
- Add localStorage cleanup in beforeEach hook
- Update all tests to use e2e_test_user account
- Add debug and simple login tests for troubleshooting

Root cause: Phone field was not being filled correctly, causing 400 error
from backend with message '手机号不能为空'
This commit is contained in:
张翔
2026-04-03 19:09:45 +08:00
parent e430865d8f
commit 229fb77e76
4 changed files with 175 additions and 11 deletions
@@ -43,17 +43,31 @@ export class UserManagementPage {
status?: string;
}) {
const dialog = this.page.locator('.el-dialog');
const isCreateMode = !userData.hasOwnProperty('id');
// 表单字段顺序:
// 创建模式:用户名(0), 密码(1), 昵称(2), 邮箱(3), 手机号(4)
// 编辑模式:用户名(0), 昵称(1), 邮箱(2), 手机号(3)
await dialog.locator('input').first().fill(userData.username);
if (userData.nickname) {
await dialog.locator('input').nth(1).fill(userData.nickname);
if (isCreateMode && userData.password) {
await dialog.locator('input[type="password"]').fill(userData.password);
}
await dialog.locator('input[type="password"]').fill(userData.password);
await dialog.locator('input').nth(3).fill(userData.email);
if (userData.nickname) {
const nicknameIndex = isCreateMode ? 2 : 1;
await dialog.locator('input').nth(nicknameIndex).fill(userData.nickname);
}
if (userData.email) {
const emailIndex = isCreateMode ? 3 : 2;
await dialog.locator('input').nth(emailIndex).fill(userData.email);
}
if (userData.phone) {
const phoneInput = dialog.locator('input[placeholder*="手机号"]');
if (await phoneInput.count() > 0) {
await phoneInput.fill(userData.phone);
}
const phoneIndex = isCreateMode ? 4 : 3;
await dialog.locator('input').nth(phoneIndex).fill(userData.phone);
}
if (userData.status) {