Files
hms/apps/web/e2e/pages/health-data.page.ts
iven c6e8048bc5
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled
test(web+mp): E2E 测试全量实施 — Web 5 flow + MP 4 flow + 基础设施
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),全部就绪
2026-04-29 04:58:01 +08:00

50 lines
1.8 KiB
TypeScript

// apps/web/e2e/pages/health-data.page.ts
import type { Page } from '@playwright/test';
export class HealthDataPage {
readonly page: Page;
constructor(page: Page) {
this.page = page;
}
async clickAddVitalSigns() {
await this.page.click('button:has-text("录入体征"), button:has-text("新增")');
await this.page.waitForSelector('.ant-modal, .ant-drawer', { timeout: 5000 });
}
async fillVitalSignsForm(data: {
systolic_bp?: number;
diastolic_bp?: number;
heart_rate?: number;
temperature?: number;
spo2?: number;
}) {
if (data.systolic_bp) await this.page.fill('#systolic_bp, input[placeholder*="收缩压"]', String(data.systolic_bp));
if (data.diastolic_bp) await this.page.fill('#diastolic_bp, input[placeholder*="舒张压"]', String(data.diastolic_bp));
if (data.heart_rate) await this.page.fill('#heart_rate, input[placeholder*="心率"]', String(data.heart_rate));
if (data.temperature) await this.page.fill('#temperature, input[placeholder*="体温"]', String(data.temperature));
if (data.spo2) await this.page.fill('#spo2, input[placeholder*="血氧"]', String(data.spo2));
}
async submitVitalSigns() {
await this.page.click('.ant-modal button[type="submit"], .ant-btn-primary');
await this.page.waitForSelector('.ant-message-success', { timeout: 10000 });
}
async getVitalSignsList(): Promise<string[]> {
const rows = this.page.locator('.ant-table-tbody tr');
const count = await rows.count();
const texts: string[] = [];
for (let i = 0; i < count; i++) {
texts.push(await rows.nth(i).textContent() ?? '');
}
return texts;
}
async trendChartIsVisible(): Promise<boolean> {
const chart = this.page.locator('canvas, .recharts-wrapper, [class*="chart"]');
return chart.isVisible();
}
}