test: 增强Playwright E2E测试方案 - 新增手术计费/医生站/并发测试用例
- 新增页面对象: SurgeryBillingPage, DoctorStationPage - 新增测试用例: 手术计费防重复(#437), 签发耗材验证(#443), 并发操作测试 - 增强登录测试: 多场景覆盖 - 完善测试数据工具: 支持多角色用户配置 - 清理冗余备份文件
This commit is contained in:
32
openhis-ui-vue3/tests/e2e/pages/DoctorStationPage.ts
Normal file
32
openhis-ui-vue3/tests/e2e/pages/DoctorStationPage.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Page, expect } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* 门诊医生站页面对象模型
|
||||
*/
|
||||
export class DoctorStationPage {
|
||||
readonly page: Page;
|
||||
readonly categoryItems = page.locator('.el-collapse-item, .category-item');
|
||||
readonly patientSearch = page.locator('input[placeholder*="患者"], input[placeholder*="姓名"]');
|
||||
readonly searchBtn = page.locator('button:has-text("搜索"), button:has-text("查询")');
|
||||
|
||||
constructor(page: Page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
async goto() {
|
||||
await this.page.goto('/doctorstation');
|
||||
await this.page.waitForLoadState('networkidle');
|
||||
}
|
||||
|
||||
async expandCategory(index: number = 0) {
|
||||
const item = this.categoryItems.nth(index);
|
||||
await item.click();
|
||||
await this.page.waitForTimeout(500);
|
||||
}
|
||||
|
||||
async searchPatient(name: string) {
|
||||
await this.patientSearch.fill(name);
|
||||
await this.searchBtn.click();
|
||||
await this.page.waitForLoadState('networkidle');
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
49
openhis-ui-vue3/tests/e2e/pages/SurgeryBillingPage.ts
Normal file
49
openhis-ui-vue3/tests/e2e/pages/SurgeryBillingPage.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { Page, expect } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* 手术计费页面对象模型
|
||||
* 覆盖:手术计费、耗材签发、防重复提交
|
||||
*/
|
||||
export class SurgeryBillingPage {
|
||||
readonly page: Page;
|
||||
readonly surgeryList = page.locator('el-table, .el-table');
|
||||
readonly generateBtn = page.locator('button:has-text("生成"), button:has-text("生成收费项")');
|
||||
readonly addBtn = page.locator('button:has-text("新增")');
|
||||
readonly saveBtn = page.locator('button:has-text("保存"), button:has-text("提交")');
|
||||
readonly signBtn = page.locator('button:has-text("签发")');
|
||||
readonly successMessage = page.locator('.el-message--success');
|
||||
readonly errorMessage = page.locator('.el-message--error');
|
||||
|
||||
constructor(page: Page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
async goto() {
|
||||
await this.page.goto('/operatingroom');
|
||||
await this.page.waitForLoadState('networkidle');
|
||||
}
|
||||
|
||||
async generateCharges() {
|
||||
await this.generateBtn.click();
|
||||
await this.page.waitForLoadState('networkidle');
|
||||
}
|
||||
|
||||
async rapidClickGenerate(times: number = 5) {
|
||||
for (let i = 0; i < times; i++) {
|
||||
await this.generateBtn.click().catch(() => {});
|
||||
}
|
||||
await this.page.waitForLoadState('networkidle');
|
||||
}
|
||||
|
||||
async getDialogCount(): Promise<number> {
|
||||
return await this.page.locator('.el-dialog, .el-message-box').count();
|
||||
}
|
||||
|
||||
async expectNoLocationIdError() {
|
||||
await expect(this.page.locator('text=发放库房为空')).toHaveCount(0, { timeout: 5000 });
|
||||
}
|
||||
|
||||
async expectSaveSuccess() {
|
||||
await expect(this.successMessage).toBeVisible({ timeout: 10000 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user