Bladeren bron

✅ test(e2e): improve stability of admin login and user management tests

- add network idle wait and timeout after admin login to ensure page loads completely
- enhance user management page visibility check with more precise selector and longer timeout
yourname 2 maanden geleden
bovenliggende
commit
577ef2b541
2 gewijzigde bestanden met toevoegingen van 6 en 2 verwijderingen
  1. 4 0
      tests/e2e/pages/admin/auth/login.page.ts
  2. 2 2
      tests/e2e/pages/admin/user-management.page.ts

+ 4 - 0
tests/e2e/pages/admin/auth/login.page.ts

@@ -24,6 +24,10 @@ export class AdminLoginPage {
     await this.usernameInput.fill(username);
     await this.usernameInput.fill(username);
     await this.passwordInput.fill(password);
     await this.passwordInput.fill(password);
     await this.loginButton.click();
     await this.loginButton.click();
+
+    // 等待登录完成
+    await this.page.waitForLoadState('networkidle');
+    await this.page.waitForTimeout(2000);
   }
   }
 
 
   async expectLoginSuccess() {
   async expectLoginSuccess() {

+ 2 - 2
tests/e2e/pages/admin/user-management.page.ts

@@ -34,8 +34,8 @@ export class UserManagementPage {
   }
   }
 
 
   async expectToBeVisible() {
   async expectToBeVisible() {
-    // 等待页面完全加载
-    await this.page.waitForSelector('text=用户管理', { state: 'visible', timeout: 10000 });
+    // 等待页面完全加载,使用更精确的选择器
+    await this.page.waitForSelector('h1:has-text("用户管理")', { state: 'visible', timeout: 15000 });
     await expect(this.pageTitle).toBeVisible();
     await expect(this.pageTitle).toBeVisible();
     await expect(this.createUserButton).toBeVisible();
     await expect(this.createUserButton).toBeVisible();
     await expect(this.userTable).toBeVisible();
     await expect(this.userTable).toBeVisible();