|
|
@@ -19,32 +19,21 @@ export class TenantLoginPage {
|
|
|
this.usernameInput = page.getByPlaceholder('请输入用户名');
|
|
|
this.passwordInput = page.getByPlaceholder('请输入密码');
|
|
|
this.submitButton = page.getByRole('button', { name: '登录' });
|
|
|
- this.pageTitle = page.getByRole('heading', { name: /租户.*登录|登录/i });
|
|
|
+ this.pageTitle = page.getByText('管理后台登录');
|
|
|
this.initializingText = page.getByText('应用初始化中');
|
|
|
}
|
|
|
|
|
|
async goto() {
|
|
|
await this.page.goto('/tenant/login');
|
|
|
|
|
|
- // 等待应用初始化完成
|
|
|
- try {
|
|
|
- await expect(this.initializingText).not.toBeVisible({ timeout: 30000 });
|
|
|
- } catch {
|
|
|
- // 如果初始化文本没有出现,继续
|
|
|
- }
|
|
|
+ // 等待页面加载完成 - 先等待输入框出现(更可靠)
|
|
|
+ await this.page.waitForLoadState('domcontentloaded');
|
|
|
|
|
|
- // 等待登录表单可见
|
|
|
- await expect(this.pageTitle).toBeVisible({ timeout: 30000 });
|
|
|
+ // 等待用户名输入框可见作为页面已加载的标志
|
|
|
+ await expect(this.usernameInput).toBeVisible({ timeout: 30000 });
|
|
|
}
|
|
|
|
|
|
async login(username: string, password: string) {
|
|
|
- // 确保应用已初始化
|
|
|
- try {
|
|
|
- await expect(this.initializingText).not.toBeVisible({ timeout: 10000 });
|
|
|
- } catch {
|
|
|
- // 继续尝试
|
|
|
- }
|
|
|
-
|
|
|
// 等待输入框可见
|
|
|
await expect(this.usernameInput).toBeVisible({ timeout: 10000 });
|
|
|
await expect(this.passwordInput).toBeVisible({ timeout: 10000 });
|
|
|
@@ -52,7 +41,10 @@ export class TenantLoginPage {
|
|
|
await this.usernameInput.fill(username);
|
|
|
await this.passwordInput.fill(password);
|
|
|
await this.submitButton.click();
|
|
|
- await this.page.waitForLoadState('networkidle');
|
|
|
+
|
|
|
+ // 等待登录后跳转(等待URL变化或dashboard出现)
|
|
|
+ // 不使用networkidle因为后台可能持续有请求
|
|
|
+ await this.page.waitForURL(/\/tenant\/dashboard/, { timeout: 15000 });
|
|
|
}
|
|
|
|
|
|
async expectLoginSuccess() {
|