- 登录 doctor1/123456, tenantId=1 - 通过侧边栏导航到门诊医生站 - 验证现诊患者标签可见 - 验证无错误弹窗 - 测试环境无患者数据,需手动验证点击患者场景
84 lines
3.0 KiB
TypeScript
84 lines
3.0 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
||
|
||
/**
|
||
* Bug #630: [门诊医生站] 点击选择现诊患者列表报错
|
||
* 禅道信息:
|
||
* - 登录:doctor1 / 123456,租户=中联医院(tenantId=1)
|
||
* - 步骤:进入门诊医生站 → 点击左侧现诊患者 → 观察右侧加载
|
||
*/
|
||
test.describe('🐛 Bug#630 门诊医生站现诊患者列表', () => {
|
||
test('#630 点击现诊患者不应报错 @bug630 @regression', async ({ page }) => {
|
||
// 1. 登录
|
||
await page.goto('http://localhost:81/');
|
||
const loginResp = await page.request.post('http://localhost:18082/openhis/login', {
|
||
data: { username: 'doctor1', password: '123456', tenantId: '1', code: '', uuid: '' }
|
||
});
|
||
const loginData = await loginResp.json();
|
||
expect(loginData.code).toBe(200);
|
||
await page.context().addCookies([{
|
||
name: 'Admin-Token', value: loginData.token, domain: 'localhost', path: '/'
|
||
}]);
|
||
|
||
// 2. 进入首页
|
||
await page.goto('http://localhost:81/index');
|
||
await page.waitForLoadState('networkidle');
|
||
await page.waitForTimeout(3000);
|
||
|
||
// 3. 通过侧边栏导航到门诊医生站
|
||
await page.locator('text=门诊医生工作站').first().click();
|
||
await page.waitForTimeout(1000);
|
||
await page.locator('text=门诊医生站').first().click();
|
||
await page.waitForTimeout(5000);
|
||
|
||
// 4. 验证"现诊患者"标签存在
|
||
const patientLabel = page.locator('text=现诊患者');
|
||
await expect(patientLabel).toBeVisible({ timeout: 10000 });
|
||
console.log('✅ 现诊患者标签可见');
|
||
|
||
// 5. 截图:门诊医生站页面
|
||
await page.screenshot({ path: 'test-results/bug-630-step1.png', fullPage: true });
|
||
|
||
// 6. 查找患者列表项(可能是表格行或列表项)
|
||
const patientSelectors = [
|
||
'.el-table__body tr',
|
||
'.patient-item',
|
||
'.current-patient',
|
||
'[class*="patient-list"] li',
|
||
'.list-item',
|
||
];
|
||
|
||
let clickedPatient = false;
|
||
for (const selector of patientSelectors) {
|
||
const items = page.locator(selector);
|
||
const count = await items.count();
|
||
if (count > 0) {
|
||
console.log(`找到 ${count} 个患者 (${selector})`);
|
||
try {
|
||
await items.first().click({ timeout: 5000 });
|
||
clickedPatient = true;
|
||
console.log('✅ 已点击患者');
|
||
break;
|
||
} catch {
|
||
console.log(`点击失败 (${selector})`);
|
||
}
|
||
}
|
||
}
|
||
|
||
if (!clickedPatient) {
|
||
console.log('⚠️ 没有患者数据,测试环境可能无数据');
|
||
}
|
||
|
||
// 7. 等待右侧加载
|
||
await page.waitForTimeout(5000);
|
||
await page.screenshot({ path: 'test-results/bug-630-step2.png', fullPage: true });
|
||
|
||
// 8. 验证没有错误弹窗
|
||
const errorPopups = page.locator('.el-message--error');
|
||
const errorCount = await errorPopups.count();
|
||
console.log('错误弹窗:', errorCount);
|
||
|
||
await page.screenshot({ path: 'test-results/bug-630-final.png', fullPage: true });
|
||
expect(errorCount).toBe(0);
|
||
});
|
||
});
|