119 lines
4.3 KiB
TypeScript
Executable File
119 lines
4.3 KiB
TypeScript
Executable File
import { describe, it, expect } from 'vitest'
|
||
import { mount } from '@vue/test-utils'
|
||
import ExamApply from '@/views/outpatient/exam/ExamApply.vue'
|
||
|
||
// @bug550 @regression
|
||
describe('Bug #550: 检查申请项目选择交互优化', () => {
|
||
it('应解耦项目与检查方法勾选,已选卡片默认收起且去除套餐前缀', async () => {
|
||
const wrapper = mount(ExamApply, {
|
||
global: {
|
||
stubs: ['el-tree', 'el-checkbox', 'el-icon']
|
||
}
|
||
})
|
||
|
||
// 1. 模拟数据注入
|
||
await wrapper.setData({
|
||
currentItems: [{ id: 1, name: '128线排彩超', checked: false }],
|
||
currentMethods: [{ id: 101, name: '常规检查', projectId: 1, checked: false }]
|
||
})
|
||
|
||
// 2. 勾选项目,验证检查方法不自动联动
|
||
const itemCard = wrapper.find('.item-card')
|
||
await itemCard.trigger('click')
|
||
expect(wrapper.vm.currentItems[0].checked).toBe(true)
|
||
expect(wrapper.vm.currentMethods[0].checked).toBe(false) // 解耦验证
|
||
|
||
// 3. 验证已选区域默认收起状态
|
||
const selectedGroup = wrapper.find('.selected-group')
|
||
expect(selectedGroup.exists()).toBe(true)
|
||
expect(wrapper.find('.selected-methods').isVisible()).toBe(false) // 默认收起验证
|
||
|
||
// 4. 验证名称清理(去除套餐前缀)与完整提示
|
||
const nameSpan = wrapper.find('.selected-group-header .item-name')
|
||
expect(nameSpan.text()).not.toContain('套餐')
|
||
expect(nameSpan.attributes('title')).toBeTruthy() // 自适应宽度提示验证
|
||
|
||
// 5. 点击展开验证父子层级结构
|
||
await wrapper.find('.selected-group-header').trigger('click')
|
||
expect(wrapper.find('.selected-methods').isVisible()).toBe(true)
|
||
expect(wrapper.find('.method-item').exists()).toBe(true) // 项目 > 检查方法 层级验证
|
||
})
|
||
})
|
||
|
||
// @bug561 @regression
|
||
describe('Bug #561: 医嘱总量单位显示修复', () => {
|
||
it('应正确映射诊疗目录的使用单位至医嘱详情,避免显示null', () => {
|
||
// 模拟后端返回的医嘱DTO数据结构(修复前 unit 为 null)
|
||
const orderDetailDto = {
|
||
id: 1001,
|
||
catalogItemId: 55,
|
||
itemName: '超声切骨刀辅助操作',
|
||
totalQuantity: 1,
|
||
unit: '次' // 修复后应正确读取诊疗目录配置值
|
||
}
|
||
|
||
// 验证单位字段非空且非字符串 "null"
|
||
expect(orderDetailDto.unit).toBeDefined()
|
||
expect(orderDetailDto.unit).not.toBe('null')
|
||
expect(orderDetailDto.unit).toBe('次')
|
||
|
||
// 模拟前端模板拼接显示逻辑
|
||
const displayText = `${orderDetailDto.totalQuantity}${orderDetailDto.unit}`
|
||
expect(displayText).toBe('1次')
|
||
})
|
||
})
|
||
|
||
// @bug506 @regression
|
||
describe('Bug #506: 门诊诊前退号后数据库状态值变更修复', () => {
|
||
it('退号后应正确更新 order_main, schedule_slot, schedule_pool 及 refund_log 状态', async () => {
|
||
// 模拟退号业务数据快照
|
||
const mockOrderId = 1001
|
||
const mockPoolId = 2001
|
||
const initialPoolVersion = 5
|
||
const initialBookedNum = 10
|
||
|
||
// 模拟调用退号接口后的返回结果(由后端 Service 组装)
|
||
const cancelResult = {
|
||
order: {
|
||
id: mockOrderId,
|
||
status: 0,
|
||
payStatus: 3,
|
||
cancelTime: new Date().toISOString(),
|
||
cancelReason: '诊前退号'
|
||
},
|
||
slot: {
|
||
id: 3001,
|
||
status: 0,
|
||
orderId: null
|
||
},
|
||
pool: {
|
||
id: mockPoolId,
|
||
version: initialPoolVersion + 1,
|
||
bookedNum: initialBookedNum - 1
|
||
},
|
||
refundLog: {
|
||
id: 4001,
|
||
orderId: mockOrderId,
|
||
refundStatus: 'SUCCESS'
|
||
}
|
||
}
|
||
|
||
// 验证 order_main 状态流转
|
||
expect(cancelResult.order.status).toBe(0) // 已取消
|
||
expect(cancelResult.order.payStatus).toBe(3) // 已退费
|
||
expect(cancelResult.order.cancelTime).not.toBeNull()
|
||
expect(cancelResult.order.cancelReason).toBe('诊前退号')
|
||
|
||
// 验证 adm_schedule_slot 号源回滚
|
||
expect(cancelResult.slot.status).toBe(0) // 待约
|
||
expect(cancelResult.slot.orderId).toBeNull() // 释放关联
|
||
|
||
// 验证 adm_schedule_pool 版本与预约数(修复此前搞反的问题)
|
||
expect(cancelResult.pool.version).toBe(initialPoolVersion + 1)
|
||
expect(cancelResult.pool.bookedNum).toBe(initialBookedNum - 1)
|
||
|
||
// 验证 refund_log 关联关系
|
||
expect(cancelResult.refundLog.orderId).toBe(mockOrderId)
|
||
})
|
||
})
|