|
|
@@ -28,16 +28,25 @@ export class UserManagementPage {
|
|
|
await this.page.goto('/admin/users');
|
|
|
|
|
|
// 等待页面完全加载 - 使用更可靠的等待条件
|
|
|
- await this.page.waitForLoadState('networkidle');
|
|
|
+ // 先等待domcontentloaded,然后等待表格数据加载
|
|
|
+ await this.page.waitForLoadState('domcontentloaded');
|
|
|
+
|
|
|
+ // 等待用户表格出现,使用更具体的等待条件
|
|
|
+ await this.page.waitForSelector('h1:has-text("用户管理")', { state: 'visible', timeout: 15000 });
|
|
|
+
|
|
|
+ // 等待表格数据加载完成,而不是等待所有网络请求
|
|
|
+ await this.page.waitForSelector('table tbody tr', { state: 'visible', timeout: 20000 });
|
|
|
+
|
|
|
await this.expectToBeVisible();
|
|
|
}
|
|
|
|
|
|
async expectToBeVisible() {
|
|
|
// 等待页面完全加载,使用更精确的选择器
|
|
|
- await this.page.waitForSelector('h1:has-text("用户管理")', { state: 'visible', timeout: 15000 });
|
|
|
- await expect(this.pageTitle).toBeVisible();
|
|
|
- await expect(this.createUserButton).toBeVisible();
|
|
|
- await expect(this.userTable).toBeVisible();
|
|
|
+ await expect(this.pageTitle).toBeVisible({ timeout: 15000 });
|
|
|
+ await expect(this.createUserButton).toBeVisible({ timeout: 10000 });
|
|
|
+
|
|
|
+ // 等待至少一行用户数据加载完成
|
|
|
+ await expect(this.userTable.locator('tbody tr').first()).toBeVisible({ timeout: 20000 });
|
|
|
}
|
|
|
|
|
|
async searchUsers(keyword: string) {
|