- test-data: 接口对齐后端 DTO(VitalSigns/AlertRule/Schedule/FollowUp) - api-client: 增强 HTTP 错误处理(parseJson 统一防护非 JSON 响应) - auth.fixture: 每个测试获取新 token,避免共享 token 过期 - patient-detail: tab 名称修正为 '健康数据' → '体征数据' - patient-list: DrawerForm 选择器适配(无 phone 字段、保存按钮在 extra) - vital-signs-flow: API 录入 + 页面验证,避免复杂 DatePicker 交互 - alert-flow: 简化为规则 CRUD + 页面导航,condition_params 对齐后端格式 - follow-up-template handler: 权限码从 health.follow-up-template.* 修正为 health.follow-up.* - playwright.config: workers=1 串行执行避免并发登录 - check-readiness: 健康端点路径修正为 /api/v1/health
67 lines
2.3 KiB
TypeScript
67 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 }) {
|
|
const drawer = this.page.locator('.ant-drawer');
|
|
await drawer.locator('input').first().waitFor({ state: 'visible' });
|
|
await this.page.locator('.ant-drawer [name="name"] input, .ant-drawer input').first().fill(data.name);
|
|
if (data.gender) {
|
|
await drawer.locator('.ant-select').first().click();
|
|
await this.page.locator(`.ant-select-item-option:has-text("${data.gender === 'male' ? '男' : '女'}")`).first().click();
|
|
}
|
|
if (data.birth_date) {
|
|
await drawer.locator('[name="birth_date"] input, input[placeholder*="出生"]').fill(data.birth_date);
|
|
}
|
|
}
|
|
|
|
async submitForm() {
|
|
await this.page.click('.ant-drawer button.ant-btn-primary, button:has-text("保存"), .ant-modal .ant-btn-primary');
|
|
await this.page.waitForSelector('.ant-message-success', { timeout: 10000 });
|
|
}
|
|
|
|
async searchPatient(name: string) {
|
|
const searchInput = this.page.locator('input[placeholder*="搜索"]').first();
|
|
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;
|
|
}
|
|
}
|