feat: 创建Page Object Model基础结构
新增文件: - e2e/pages/AdminLoginPage.ts - 管理员登录页面对象 - e2e/pages/AdminContentPage.ts - 内容管理页面对象 - e2e/pages/AdminUserPage.ts - 用户管理页面对象 - e2e/pages/FrontendNewsPage.ts - 前端新闻页面对象 - e2e/pages/FrontendProductPage.ts - 前端产品页面对象 - e2e/pages/index.ts - 导出索引文件 功能特性: - 封装页面交互逻辑,减少测试代码重复 - 提供清晰的API接口,提升测试可读性 - 支持内容创建、删除、验证等核心操作 - 统一等待策略,提升测试稳定性
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { Page, expect } from '@playwright/test';
|
||||
|
||||
export class AdminLoginPage {
|
||||
constructor(private page: Page) {}
|
||||
|
||||
async goto() {
|
||||
await this.page.goto('/admin/login');
|
||||
await this.page.waitForLoadState('networkidle');
|
||||
}
|
||||
|
||||
async login(email: string, password: string) {
|
||||
await this.page.fill('#email', email);
|
||||
await this.page.fill('#password', password);
|
||||
await this.page.click('button[type="submit"]');
|
||||
await this.page.waitForURL(/\/admin(?!\/login)/);
|
||||
}
|
||||
|
||||
async expectLoginSuccess() {
|
||||
await expect(this.page).toHaveURL(/\/admin(?!\/login)/);
|
||||
}
|
||||
|
||||
async expectLoginError() {
|
||||
await expect(this.page.locator('[role="alert"]')).toBeVisible();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user