Files
张翔 08ea5fbe98 feat(admin): 添加用户管理相关文件
添加用户管理视图、API和状态管理文件
2026-03-28 14:37:29 +08:00

52 lines
1.5 KiB
TypeScript

import { Page, Locator } from '@playwright/test';
export class UserPage {
readonly page: Page;
readonly userInfoCard: Locator;
readonly loginButton: Locator;
readonly logoutButton: Locator;
readonly navigationBar: Locator;
constructor(page: Page) {
this.page = page;
this.userInfoCard = page.locator('[data-testid="user-info-card"], .user-info-card');
this.loginButton = page.locator('[data-testid="login-button"], .login-button');
this.logoutButton = page.locator('[data-testid="logout-button"], .logout-button');
this.navigationBar = page.locator('.uni-tabbar, [class*="tabbar"]');
}
async goto() {
await this.page.goto('/#/pages/user/index');
await this.page.waitForLoadState('networkidle');
}
async isUserInfoVisible(): Promise<boolean> {
return await this.userInfoCard.isVisible().catch(() => false);
}
async isLoginButtonVisible(): Promise<boolean> {
return await this.loginButton.isVisible().catch(() => false);
}
async isLogoutButtonVisible(): Promise<boolean> {
return await this.logoutButton.isVisible().catch(() => false);
}
async clickLogin() {
await this.loginButton.click();
}
async clickLogout() {
await this.logoutButton.click();
}
async navigateToTab(tabName: string) {
await this.navigationBar.locator(`text=${tabName}`).click();
await this.page.waitForLoadState('networkidle');
}
async takeScreenshot(path: string) {
await this.page.screenshot({ path, fullPage: true });
}
}