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 #585 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.waitForSelector('.surgery-apply-history'); }); test('@bug585 @regression 验证状态列存在且位于申请者与操作列之间', async ({ page }) => { const headers = page.locator('.el-table__header th .cell'); await expect(headers.nth(5)).toHaveText('申请者'); await expect(headers.nth(6)).toHaveText('状态'); await expect(headers.nth(7)).toHaveText('操作'); }); test('@bug585 @regression 验证状态标签颜色与文本映射正确', async ({ page }) => { // 模拟不同状态数据渲染(依赖后端Mock或测试数据) const statusMap = [ { code: 1, text: '待签发', color: 'info' }, { code: 2, text: '已签发', color: 'primary' }, { code: 3, text: '已校对', color: 'primary' }, { code: 4, text: '已执行', color: 'primary' }, { code: 5, text: '已安排', color: 'warning' }, { code: 6, text: '已完成', color: 'success' }, { code: 10, text: '已撤销', color: 'danger' } ]; for (const s of statusMap) { // 验证状态筛选下拉框包含对应选项 await page.locator('.filter-bar .el-select__input').click(); await expect(page.locator(`.el-select-dropdown__item:has-text("${s.text}")`)).toBeVisible(); } }); test('@bug585 @regression 验证状态筛选功能可用', async ({ page }) => { await page.locator('.filter-bar .el-select__input').click(); await page.locator('.el-select-dropdown__item:has-text("待签发")').click(); await page.click('.filter-bar .el-button--primary'); await page.waitForTimeout(500); // 验证列表仅展示待签发状态数据(通过检查Tag类型) const tags = page.locator('.el-table__body .el-tag--info'); await expect(tags.first()).toBeVisible(); }); });