47 lines
2.0 KiB
TypeScript
Executable File
47 lines
2.0 KiB
TypeScript
Executable File
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('HIS 业务逻辑回归测试', () => {
|
|
// ... 其他已有测试用例 ...
|
|
|
|
// @bug505 @regression
|
|
test('Bug #505: 已发药药品医嘱不可直接退回', async ({ page }) => {
|
|
// 1. 模拟护士登录
|
|
await page.goto('/login');
|
|
await page.fill('input[name="username"]', 'wx');
|
|
await page.fill('input[name="password"]', '123456');
|
|
await page.click('button[type="submit"]');
|
|
await page.waitForURL('/dashboard');
|
|
|
|
// 2. 进入医嘱校对模块
|
|
await page.goto('/nurse/order-verification');
|
|
await page.waitForSelector('.el-tabs__item:has-text("已校对")');
|
|
await page.click('.el-tabs__item:has-text("已校对")');
|
|
|
|
// 3. 模拟数据加载(实际环境由后端返回)
|
|
// 假设列表中存在一条状态为“已发药”的药品医嘱
|
|
const dispensedRow = page.locator('tr').filter({ hasText: '头孢哌酮钠舒巴坦钠' }).filter({ hasText: '已发药' });
|
|
await expect(dispensedRow).toBeVisible();
|
|
|
|
// 4. 勾选该医嘱
|
|
await dispensedRow.locator('input[type="checkbox"]').check();
|
|
|
|
// 5. 验证【退回】按钮置灰不可点击
|
|
const returnBtn = page.locator('button:has-text("退回")');
|
|
await expect(returnBtn).toBeDisabled();
|
|
|
|
// 6. 验证若强制调用接口,后端应拦截并返回指定错误提示
|
|
// (此处通过拦截网络请求模拟前端未置灰时的兜底校验)
|
|
await page.route('**/api/order/return', async (route) => {
|
|
await route.fulfill({
|
|
status: 400,
|
|
contentType: 'application/json',
|
|
body: JSON.stringify({ code: 400, message: '该药品已由药房发放,请先执行退药处理,不可直接退回' })
|
|
});
|
|
});
|
|
|
|
// 若按钮未置灰,点击后应弹出错误提示
|
|
await returnBtn.click({ force: true });
|
|
await expect(page.locator('.el-message--error')).toContainText('该药品已由药房发放,请先执行退药处理,不可直接退回');
|
|
});
|
|
});
|