Web 端 (Playwright): - fixtures: test-data 工厂 + API Client (乐观锁 version) + 增强 auth fixture - pages: LoginPage, PatientListPage, PatientDetailPage, HealthDataPage, AppointmentPage - flows: 患者全流程, 体征数据链路, 预约排班链路, 随访管理链路, 告警处理链路 - smoke tests 迁移到 smoke/ 目录,import 路径更新 - playwright.config.ts 更新: globalSetup 环境检查, 60s timeout, video retain 小程序端 (Vitest + miniprogram-automator): - helpers: AutomatorClient, MpApiClient, MpAuthHelper, MpNavigator - flows: 患者健康数据查看, 体征数据录入, 积分签到兑换, 积分商城浏览 - vitest.config.ts + check-readiness.ts - vitest 4.1.5 依赖安装 Playwright 发现 15 个测试 (5 flow + 10 smoke),全部就绪
68 lines
2.3 KiB
TypeScript
68 lines
2.3 KiB
TypeScript
// apps/web/e2e/pages/patient-list.page.ts
|
|
import type { Page } from '@playwright/test';
|
|
|
|
export class PatientListPage {
|
|
readonly page: Page;
|
|
|
|
constructor(page: Page) {
|
|
this.page = page;
|
|
}
|
|
|
|
async goto() {
|
|
await this.page.goto('/#/health/patients');
|
|
await this.page.waitForSelector('.ant-table', { timeout: 15000 });
|
|
}
|
|
|
|
async clickCreate() {
|
|
await this.page.click('button:has-text("新增"), button:has-text("新建"), button:has-text("创建")');
|
|
await this.page.waitForSelector('.ant-modal, .ant-drawer', { timeout: 5000 });
|
|
}
|
|
|
|
async fillCreateForm(data: { name: string; gender?: string; birth_date?: string; phone?: string }) {
|
|
await this.page.fill('#name, input[id="name"]', data.name);
|
|
if (data.phone) {
|
|
await this.page.fill('#phone, input[id="phone"]', data.phone);
|
|
}
|
|
if (data.gender) {
|
|
await this.page.click('.ant-select[id="gender"], .ant-select:has-text("性别")');
|
|
await this.page.click(`.ant-select-item-option:has-text("${data.gender === 'male' ? '男' : '女'}")`);
|
|
}
|
|
if (data.birth_date) {
|
|
await this.page.fill('#birth_date, input[placeholder*="出生"]', data.birth_date);
|
|
}
|
|
}
|
|
|
|
async submitForm() {
|
|
await this.page.click('.ant-modal button[type="submit"], .ant-drawer button[type="submit"]');
|
|
await this.page.waitForSelector('.ant-message-success', { timeout: 10000 });
|
|
}
|
|
|
|
async searchPatient(name: string) {
|
|
const searchInput = this.page.locator('input[placeholder*="搜索"], input[placeholder*="姓名"]');
|
|
await searchInput.fill(name);
|
|
await searchInput.press('Enter');
|
|
await this.page.waitForTimeout(1000);
|
|
}
|
|
|
|
async clickPatientRow(row: number) {
|
|
const rows = this.page.locator('.ant-table-tbody tr');
|
|
await rows.nth(row).click();
|
|
}
|
|
|
|
async clickPatientByName(name: string) {
|
|
await this.searchPatient(name);
|
|
const row = this.page.locator(`.ant-table-tbody tr:has-text("${name}")`).first();
|
|
await row.click();
|
|
}
|
|
|
|
async getTableRowCount(): Promise<number> {
|
|
return this.page.locator('.ant-table-tbody tr').count();
|
|
}
|
|
|
|
async hasPatientInTable(name: string): Promise<boolean> {
|
|
await this.searchPatient(name);
|
|
const count = await this.page.locator(`.ant-table-tbody tr:has-text("${name}")`).count();
|
|
return count > 0;
|
|
}
|
|
}
|