test: 增强Playwright E2E测试方案 - 新增手术计费/医生站/并发测试用例
- 新增页面对象: SurgeryBillingPage, DoctorStationPage - 新增测试用例: 手术计费防重复(#437), 签发耗材验证(#443), 并发操作测试 - 增强登录测试: 多场景覆盖 - 完善测试数据工具: 支持多角色用户配置 - 清理冗余备份文件
This commit is contained in:
@@ -1,23 +1,41 @@
|
||||
import { Page, expect } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* 登录页面对象模型 (POM)
|
||||
*/
|
||||
export class LoginPage {
|
||||
constructor(private page: Page) {}
|
||||
readonly page: Page;
|
||||
readonly usernameInput = page.locator('input[placeholder*="用户名"], input[placeholder*="账号"]');
|
||||
readonly passwordInput = page.locator('input[placeholder*="密码"]');
|
||||
readonly loginButton = page.locator('button:has-text("登录"), button[type="submit"]');
|
||||
readonly errorMessage = page.locator('.el-message--error');
|
||||
readonly successMessage = page.locator('.el-message--success');
|
||||
|
||||
constructor(page: Page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
async goto() {
|
||||
await this.page.goto('/');
|
||||
await this.page.waitForLoadState('domcontentloaded');
|
||||
}
|
||||
|
||||
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("登录")');
|
||||
await this.usernameInput.fill(username);
|
||||
await this.passwordInput.fill(password);
|
||||
await this.loginButton.click();
|
||||
await this.page.waitForLoadState('networkidle');
|
||||
}
|
||||
|
||||
async expectLoginSuccess() {
|
||||
await expect(this.page).toHaveURL(/.*(dashboard|home).*/);
|
||||
await expect(this.page).toHaveURL(/.*(dashboard|home|index).*/, { timeout: 15000 });
|
||||
}
|
||||
|
||||
async expectLoginFailed() {
|
||||
await expect(this.page.locator('.el-message--error')).toBeVisible();
|
||||
await expect(this.errorMessage).toBeVisible({ timeout: 5000 });
|
||||
}
|
||||
|
||||
async expectOnLoginPage() {
|
||||
await expect(this.usernameInput).toBeVisible();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user