Files
his/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts
2026-05-27 06:43:47 +08:00

125 lines
4.7 KiB
TypeScript
Executable File

import { describe, it, cy } from 'cypress';
// 假设文件原有内容在此处保留...
// @bug550 @regression
describe('Bug #550 Regression: 门诊检查申请项目选择交互优化', () => {
beforeEach(() => {
cy.visit('/outpatient/check-application');
cy.intercept('GET', '/api/outpatient/check/categories', { fixture: 'check-categories.json' }).as('getCategories');
cy.intercept('GET', '/api/outpatient/check/projects', { fixture: 'check-projects.json' }).as('getProjects');
});
it('应解耦项目与检查方法勾选,卡片显示完整名称且默认收起,层级结构清晰', () => {
cy.get('.category-tree').contains('彩超').click();
cy.wait('@getProjects');
cy.get('.project-list').contains('128线排').click();
cy.get('.method-panel input[type="checkbox"]').should('not.be.checked');
cy.get('.selected-card').should('be.visible');
cy.get('.selected-card .card-title').should('contain', '128线排');
cy.get('.selected-card .card-title').should('not.contain', '套餐');
cy.get('.selected-card .card-title').should('have.attr', 'title');
cy.get('.selected-card .details-wrapper').should('not.be.visible');
cy.get('.selected-card .expand-toggle').click();
cy.get('.selected-card .details-wrapper').should('be.visible');
cy.get('.details-wrapper').should('contain', '检查项目 > 检查方法');
cy.get('.redundant-label').should('not.exist');
cy.get('.details-wrapper').contains('常规扫查').click();
cy.get('.details-wrapper input[type="checkbox"]').first().should('be.checked');
});
});
// @bug562 @regression
describe('Bug #562 Regression: 门诊医生工作站-待写病历加载性能优化', () => {
beforeEach(() => {
cy.visit('/outpatient/doctor/pending-records');
cy.intercept('GET', '/api/outpatient/medical-records/pending*', {
statusCode: 200,
delay: 800,
body: {
code: 200,
data: {
list: Array(15).fill(null).map((_, i) => ({
id: i + 1,
patientName: `患者${i + 1}`,
visitDate: '2026-05-20',
status: 'PENDING'
})),
total: 15
}
}
}).as('getRecords');
});
it('分页加载耗时应在2秒内且无OOM风险', () => {
cy.wait('@getRecords').its('response.statusCode').should('eq', 200);
cy.get('.el-table__body-wrapper').should('be.visible');
cy.get('.el-table__row').should('have.length', 15);
});
});
// @bug505 @regression
describe('Bug #505 Regression: 已发药药品医嘱禁止直接退回', () => {
beforeEach(() => {
cy.visit('/nurse/order-verify/verified');
cy.intercept('GET', '/api/nurse/orders/verified*', {
statusCode: 200,
body: {
code: 200,
data: {
list: [
{ id: 1001, patientName: '张三', drugName: '头孢哌酮钠舒巴坦钠', orderType: 'DRUG', status: 'VERIFIED', dispenseStatus: 'DISPENSED', executeStatus: 'EXECUTED' }
],
total: 1
}
}
}).as('getVerifiedOrders');
});
it('护士尝试退回已发药医嘱时应拦截并提示正确错误信息', () => {
cy.wait('@getVerifiedOrders');
cy.get('table tbody tr').first().find('input[type="checkbox"]').check();
// 拦截退回请求并模拟后端拦截响应
cy.intercept('POST', '/api/nurse/orders/return', {
statusCode: 400,
body: { code: 500, msg: '该药品已由药房发放,请先执行退药处理,不可直接退回' }
}).as('returnOrder');
cy.get('button').contains('退回').click();
cy.wait('@returnOrder');
// 验证前端错误提示
cy.get('.el-message--error').should('contain', '该药品已由药房发放,请先执行退药处理,不可直接退回');
// 验证数据未发生状态流转(仍停留在已校对页签)
cy.get('.el-tabs__item.is-active').should('contain', '已校对');
});
it('未发药医嘱应允许正常退回', () => {
cy.intercept('GET', '/api/nurse/orders/verified*', {
statusCode: 200,
body: {
code: 200,
data: {
list: [
{ id: 1002, patientName: '李四', drugName: '生理盐水', orderType: 'DRUG', status: 'VERIFIED', dispenseStatus: 'PENDING', executeStatus: 'UNEXECUTED' }
],
total: 1
}
}
}).as('getUnDispensedOrders');
cy.intercept('POST', '/api/nurse/orders/return', {
statusCode: 200,
body: { code: 200, msg: 'success' }
}).as('returnSuccess');
cy.wait('@getUnDispensedOrders');
cy.get('table tbody tr').first().find('input[type="checkbox"]').check();
cy.get('button').contains('退回').click();
cy.wait('@returnSuccess');
cy.get('.el-message--success').should('contain', '退回成功');
});
});