Files
his/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts
2026-05-27 03:52:16 +08:00

111 lines
4.6 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 { describe, it, beforeEach } from 'cypress'
describe('Bug Regression Tests', () => {
beforeEach(() => {
cy.clearCookies()
cy.clearLocalStorage()
})
// @bug562 @regression
it('Bug #562: 待写病历数据加载时间应小于2秒且无持续加载状态', () => {
cy.login('doctor1', '123456')
cy.visit('/outpatient/pending-medical-record')
const startTime = Date.now()
// 验证加载状态出现后迅速消失
cy.get('[data-cy="pending-record-table"]').should('be.visible')
cy.get('[data-cy="loading-spinner"]').should('not.exist')
const loadTime = Date.now() - startTime
expect(loadTime).to.be.lessThan(2000, `加载耗时 ${loadTime}ms 超过 2 秒限制`)
// 验证分页组件已渲染,说明数据已按需加载
cy.get('.el-pagination').should('be.visible')
cy.get('[data-cy="pending-record-table"] tbody tr').should('have.length.greaterThan', 0)
})
// @bug550 @regression
it('Bug #550: 检查申请项目选择交互应解耦、卡片默认收起且名称完整', () => {
cy.login('doctor1', '123456')
cy.visit('/outpatient/examination-apply')
// 1. 模拟选择分类和项目
cy.get('[data-cy="category-tree"]').contains('彩超').click()
cy.get('[data-cy="item-list"]').find('[data-cy="item-checkbox-128"]').check()
// 2. 验证已选择区域卡片默认收起,且方法未被自动勾选
cy.get('[data-cy="selected-panel"]').within(() => {
cy.get('.selected-card').should('have.length', 1)
cy.get('[data-cy="selected-card-detail"]').should('not.be.visible')
cy.get('[data-cy^="method-checkbox-"]').should('not.be.checked')
})
// 3. 验证名称清理(去除“套餐”冗余字样)
cy.get('[data-cy="selected-card-name"]').should('not.contain', '套餐')
// 4. 验证点击展开/收起交互
cy.get('.card-header').first().click()
cy.get('[data-cy="selected-card-detail"]').should('be.visible')
cy.get('.card-header').first().click()
cy.get('[data-cy="selected-card-detail"]').should('not.be.visible')
// 5. 验证项目与方法勾选完全解耦
cy.get('.card-header').first().click() // 展开
cy.get('[data-cy^="method-checkbox-"]').first().check()
cy.get('.card-header .el-checkbox').first().should('be.checked') // 项目状态独立
cy.get('.card-header .el-checkbox').first().uncheck()
cy.get('[data-cy^="method-checkbox-"]').first().should('be.checked') // 取消项目不影响已选方法
})
// @bug505 @regression
it('Bug #505: 已发药医嘱禁止护士直接退回,应拦截并提示退药流程', () => {
// 前置:医生开临时医嘱
cy.login('doctor1', '123456')
cy.visit('/inpatient/order-entry')
cy.get('[data-cy="add-order-btn"]').click()
cy.get('[data-cy="drug-search-input"]').type('头孢哌酮钠舒巴坦钠')
cy.get('[data-cy="drug-option-1"]').click()
cy.get('[data-cy="submit-order-btn"]').click()
cy.contains('提交成功').should('be.visible')
// 步骤1护士校对并执行
cy.login('wx', '123456')
cy.visit('/inpatient/order-verify')
cy.get('[data-cy="tab-pending"]').click()
cy.get('[data-cy="order-checkbox-1"]').check()
cy.get('[data-cy="btn-verify"]').click()
cy.get('[data-cy="tab-executed"]').click()
cy.get('[data-cy="order-checkbox-1"]').check()
cy.get('[data-cy="btn-execute"]').click()
cy.contains('执行成功').should('be.visible')
// 步骤2药房发药
cy.login('ykk1', '123456')
cy.visit('/pharmacy/dispense')
cy.get('[data-cy="dispense-list-item"]').first().click()
cy.get('[data-cy="btn-confirm-dispense"]').click()
cy.contains('发药成功').should('be.visible')
// 步骤3护士尝试退回已发药医嘱
cy.login('wx', '123456')
cy.visit('/inpatient/order-verify')
cy.get('[data-cy="tab-executed"]').click()
cy.get('[data-cy="order-checkbox-1"]').check()
// 验证退回按钮交互:理想状态置灰,若未置灰则点击拦截
cy.get('[data-cy="btn-return"]').then($btn => {
if ($btn.is(':disabled')) {
cy.wrap($btn).should('be.disabled')
} else {
cy.wrap($btn).click({ force: true })
// 验证核心拦截提示
cy.contains('该药品已由药房发放,请先执行退药处理,不可直接退回').should('be.visible')
// 验证状态未发生流转(仍停留在已校对/已执行页签)
cy.get('[data-cy="tab-executed"]').should('have.class', 'is-active')
cy.get('[data-cy="tab-returned"]').should('not.have.class', 'is-active')
}
})
})
})