Files
his/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts
2026-05-26 23:05:26 +08:00

105 lines
4.8 KiB
TypeScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { test, expect } from '@playwright/test';
// 原有测试用例省略...
test.describe('Bug #589 Regression: 出院带药医嘱类型与交互', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/login');
await page.fill('input[name="username"]', 'doctor1');
await page.fill('input[name="password"]', '123456');
await page.click('button[type="submit"]');
await page.waitForURL(/\/inpatient/);
await page.click('.patient-list-item:first-child');
await page.click('text=临床医嘱');
await page.click('text=新增');
});
test('@bug589 @regression 验证出院带药类型存在且联动临时医嘱', async ({ page }) => {
await page.click('.order-type-select .el-input__inner');
await expect(page.locator('.el-select-dropdown__item:has-text("出院带药")')).toBeVisible();
await page.click('.el-select-dropdown__item:has-text("出院带药")');
// 验证长期/临时单选框强制选中临时且禁用
await expect(page.locator('input[name="orderFrequency"][value="临时"]')).toBeChecked();
await expect(page.locator('input[name="orderFrequency"][value="长期"]')).toBeDisabled();
// 验证专属面板展开
await expect(page.locator('.discharge-med-panel')).toBeVisible();
});
test('@bug589 @regression 验证用药天数校验逻辑(普通<=7, 慢病<=30)', async ({ page }) => {
await page.click('.order-type-select .el-input__inner');
await page.click('.el-select-dropdown__item:has-text("出院带药")');
// 模拟输入普通药天数8
await page.fill('input[name="medicationDays"]', '8');
await page.click('.discharge-med-panel .el-button--primary');
await expect(page.locator('.el-message--error')).toContainText('非慢性病出院带药天数不得超过7天');
// 模拟慢病药天数31
await page.click('label:has-text("慢性病")');
await page.fill('input[name="medicationDays"]', '31');
await page.click('.discharge-med-panel .el-button--primary');
await expect(page.locator('.el-message--error')).toContainText('慢性病出院带药天数不得超过30天');
});
test('@bug589 @regression 验证总量自动计算与必填拦截', async ({ page }) => {
await page.click('.order-type-select .el-input__inner');
await page.click('.el-select-dropdown__item:has-text("出院带药")');
await page.fill('input[name="singleDosage"]', '2');
await page.fill('input[name="frequency"]', '3');
await page.fill('input[name="medicationDays"]', '5');
// 验证自动计算: 2 * 3 * 5 = 30
await expect(page.locator('input[name="totalAmount"]')).toHaveValue('30');
// 清空总量触发必填校验
await page.fill('input[name="totalAmount"]', '');
await page.click('.discharge-med-panel .el-button--primary');
await expect(page.locator('.el-message--error')).toContainText('总量为必填项');
});
});
test.describe('Bug #506 Regression: 门诊诊前退号状态与数据一致性', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/login');
await page.fill('input[name="username"]', 'admin');
await page.fill('input[name="password"]', '123456');
await page.click('button[type="submit"]');
await page.waitForURL(/\/outpatient/);
});
test('@bug506 @regression 验证门诊诊前退号后多表状态变更符合PRD定义', async ({ page }) => {
await page.goto('/outpatient/registration');
// 选择已缴费已签到患者
await page.click('text=压力山大');
await page.waitForSelector('button:has-text("退号")');
// 拦截退号API请求验证后端返回数据与PRD一致
const cancelResponsePromise = page.waitForResponse(res =>
res.url().includes('/api/appointment/cancel') && res.status() === 200
);
await page.click('button:has-text("退号")');
await page.click('button:has-text("确认退费")');
const response = await cancelResponsePromise;
const body = await response.json();
// 验证后端返回状态符合PRD预期
expect(body.code).toBe(200);
expect(body.data.orderStatus).toBe(0); // order_main.status = 0 (已取消)
expect(body.data.payStatus).toBe(3); // order_main.pay_status = 3 (已退费)
expect(body.data.cancelReason).toBe('诊前退号');
expect(body.data.slotStatus).toBe(0); // adm_schedule_slot.status = 0 (待约)
expect(body.data.slotOrderId).toBeNull(); // adm_schedule_slot.order_id = NULL
expect(body.data.poolVersionIncrement).toBe(1); // adm_schedule_pool.version + 1
expect(body.data.poolBookedDecrement).toBe(1); // adm_schedule_pool.booked_num - 1
expect(body.data.refundLogOrderId).toBeDefined(); // refund_log.order_id 关联成功
// 验证前端成功提示
await expect(page.locator('.el-message--success')).toContainText('退号成功');
});
});