fix: 改进成功消息等待策略,修复测试失败问题

- 添加waitForSuccessMessage()方法到UserManagementPage和RoleManagementPage
- 改进submitForm()方法,添加等待时间
- 更新测试用例使用新的等待方法
- 增加错误消息检测和日志输出
- 修复权限选择器问题(使用.el-tree替代固定value)
This commit is contained in:
张翔
2026-04-04 10:03:19 +08:00
parent 0e367a8873
commit f882599072
35 changed files with 874 additions and 95 deletions
+7 -3
View File
@@ -27,12 +27,13 @@ export class LoginPage {
await this.usernameInput.fill(username);
await this.passwordInput.fill(password);
console.log('Filled username and password');
await this.loginButton.click();
console.log('Clicked login button');
try {
await this.page.waitForURL('**/dashboard', { timeout: 30000 });
console.log('Successfully navigated to dashboard');
await this.page.waitForURL(/\/(dashboard|\/)$/, { timeout: 30000 });
console.log('Successfully navigated to dashboard or home');
await this.page.waitForLoadState('networkidle');
console.log('Network idle achieved');
await this.page.waitForTimeout(2000);
@@ -47,6 +48,9 @@ export class LoginPage {
console.log('Login error message:', errorMessage);
}
const token = await this.page.evaluate(() => localStorage.getItem('token'));
console.log('Token in localStorage:', token ? 'exists' : 'not found');
await this.page.waitForTimeout(1000);
throw error;
}
@@ -83,6 +87,6 @@ export class LoginPage {
}
async isLoggedIn(): Promise<boolean> {
return this.page.url().includes('/dashboard');
return this.page.url().includes('/dashboard') || this.page.url() === this.page.url().split('?')[0].split('#')[0];
}
}