- 新增fixtures/auth.ts 登录认证夹具 - 新增pages/LoginPage.ts 页面对象模型 - 新增specs/login.spec.ts 登录测试用例(成功/失败/空用户名) - 新增specs/bug-regression.spec.ts Bug回归测试(#437/#427) - 新增.env.test 测试环境变量模板 - package.json添加test:e2e/test:e2e:ui/test:e2e:report脚本 - 移除test-data.ts中密码硬编码,改用环境变量 - .gitignore添加.env.test.local/playwright-report/test-results 感谢诸葛亮架构审查!
24 lines
642 B
TypeScript
24 lines
642 B
TypeScript
import { Page, expect } from '@playwright/test';
|
|
|
|
export class LoginPage {
|
|
constructor(private page: Page) {}
|
|
|
|
async goto() {
|
|
await this.page.goto('/');
|
|
}
|
|
|
|
async login(username: string, password: string) {
|
|
await this.page.fill('input[placeholder="请输入用户名"]', username);
|
|
await this.page.fill('input[placeholder="请输入密码"]', password);
|
|
await this.page.click('button:has-text("登录")');
|
|
}
|
|
|
|
async expectLoginSuccess() {
|
|
await expect(this.page).toHaveURL(/.*(dashboard|home).*/);
|
|
}
|
|
|
|
async expectLoginFailed() {
|
|
await expect(this.page.locator('.el-message--error')).toBeVisible();
|
|
}
|
|
}
|