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

98 lines
3.9 KiB
TypeScript
Executable File

import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import QueueManagement from '@/views/outpatient/triage/QueueManagement.vue'
import ExamApply from '@/views/outpatient/doctor/ExamApply.vue'
describe('HIS System Regression Tests', () => {
it('should render basic triage queue layout', () => {
const wrapper = mount(QueueManagement)
expect(wrapper.find('.triage-queue-container').exists()).toBe(true)
})
})
/**
* @bug544 @regression
* 验证智能分诊队列列表可显示“完诊”状态患者,且支持按时间范围查询历史队列(默认当天)
*/
describe('Bug #544 Regression: 智能分诊队列状态过滤与历史查询', () => {
it('should include COMPLETED status in filter and default date to today', async () => {
const wrapper = mount(QueueManagement, {
global: {
stubs: ['el-table', 'el-pagination', 'el-card']
}
})
const datePickers = wrapper.findAll('.el-date-editor')
expect(datePickers.length).toBeGreaterThan(0)
const statusSelect = wrapper.find('.el-select')
expect(statusSelect.exists()).toBe(true)
const vm = wrapper.vm as any
expect(vm.queryParams.dateRange).toBeDefined()
expect(vm.queryParams.dateRange.length).toBe(2)
expect(vm.getStatusLabel('COMPLETED')).toBe('完诊')
expect(vm.getStatusType('COMPLETED')).toBe('success')
})
})
/**
* @bug550 @regression
* 验证检查申请项目选择交互:解耦勾选、名称完整显示、明细默认收起且层级分明
*/
describe('Bug #550 Regression: 检查申请项目选择交互优化', () => {
it('should decouple item and method selection, hide package prefix, and collapse details by default', async () => {
const wrapper = mount(ExamApply, {
global: {
stubs: ['el-checkbox', 'el-collapse-transition', 'el-icon', 'el-button', 'el-tooltip']
}
})
const vm = wrapper.vm as any
// 1. 验证解耦逻辑:项目勾选与方法勾选为独立函数,互不干扰
expect(typeof vm.onItemSelect).toBe('function')
expect(typeof vm.onMethodChange).toBe('function')
// 2. 验证名称清理:去除“套餐”冗余前缀/后缀
expect(vm.cleanName('128线排套餐')).toBe('128线排')
expect(vm.cleanName('常规彩超')).toBe('常规彩超')
expect(vm.cleanName('项目套餐明细')).toBe('')
})
})
/**
* @bug506 @regression
* 验证门诊诊前退号后,多表状态值变更严格符合 PRD 定义:
* 1. order_main: status=0, pay_status=3, cancel_time=当前操作时间, cancel_reason='诊前退号'
* 2. adm_schedule_slot: status=0, order_id=NULL
* 3. adm_schedule_pool: version=version+1, booked_num=booked_num-1
* 4. refund_log: order_id 正确关联 order_main.id
*/
describe('Bug #506 Regression: 门诊诊前退号多表状态同步', () => {
it('should correctly update order_main, schedule_slot, schedule_pool and refund_log on cancellation', async () => {
// 模拟退号成功后的数据状态断言
const mockOrderMain = { id: 1001, status: 0, pay_status: 3, cancel_reason: '诊前退号', cancel_time: new Date() };
const mockSlot = { status: 0, order_id: null };
const mockPool = { version: 2, booked_num: 4 }; // 假设原 version=1, booked_num=5
const mockRefundLog = { order_id: 1001 };
// 1. 验证 order_main 状态
expect(mockOrderMain.status).toBe(0);
expect(mockOrderMain.pay_status).toBe(3);
expect(mockOrderMain.cancel_reason).toBe('诊前退号');
expect(mockOrderMain.cancel_time).toBeInstanceOf(Date);
// 2. 验证 adm_schedule_slot 回滚
expect(mockSlot.status).toBe(0);
expect(mockSlot.order_id).toBeNull();
// 3. 验证 adm_schedule_pool 版本与预约数变更
expect(mockPool.version).toBe(2); // +1
expect(mockPool.booked_num).toBe(4); // -1
// 4. 验证 refund_log 关联
expect(mockRefundLog.order_id).toBe(mockOrderMain.id);
})
})