54 lines
2.4 KiB
TypeScript
54 lines
2.4 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { mount } from '@vue/test-utils';
|
|
import LabRequest from '@/views/inpatientdoctorstation/lab/LabRequest.vue';
|
|
|
|
// @bug466 @regression
|
|
describe('Bug #466: 检验申请单核心质控字段及联动逻辑', () => {
|
|
it('应默认显示申请类型、标本类型、执行时间字段', () => {
|
|
const wrapper = mount(LabRequest, {
|
|
global: { stubs: ['el-dialog', 'el-tree', 'el-checkbox-group', 'el-radio-group', 'el-input', 'el-date-picker'] }
|
|
});
|
|
expect(wrapper.find('[data-cy="application-type"]').exists()).toBe(true);
|
|
expect(wrapper.find('[data-cy="specimen-type"]').exists()).toBe(true);
|
|
expect(wrapper.find('[data-cy="execution-time"]').exists()).toBe(true);
|
|
});
|
|
|
|
it('申请类型应默认选中普通,支持切换急诊', () => {
|
|
const wrapper = mount(LabRequest, {
|
|
global: { stubs: ['el-dialog', 'el-tree', 'el-checkbox-group', 'el-radio-group', 'el-input', 'el-date-picker'] }
|
|
});
|
|
const radioGroup = wrapper.find('[data-cy="application-type"]');
|
|
expect(radioGroup.vm.modelValue).toBe('1'); // 1: 普通
|
|
radioGroup.vm.$emit('update:modelValue', '2');
|
|
expect(radioGroup.vm.modelValue).toBe('2'); // 2: 急诊
|
|
});
|
|
|
|
it('勾选检验项目后应自动带出标本类型', async () => {
|
|
const wrapper = mount(LabRequest, {
|
|
global: { stubs: ['el-dialog', 'el-tree', 'el-checkbox-group', 'el-radio-group', 'el-input', 'el-date-picker'] }
|
|
});
|
|
// 模拟左侧勾选项目
|
|
wrapper.vm.selectedItemIds = [101];
|
|
wrapper.vm.itemList = [{ id: 101, name: '血常规', specimenType: '血液' }];
|
|
await wrapper.vm.$nextTick();
|
|
wrapper.vm.onItemSelectChange([101]);
|
|
await wrapper.vm.$nextTick();
|
|
expect(wrapper.vm.specimenType).toBe('血液');
|
|
});
|
|
|
|
it('执行时间早于当前时间时应拦截并提示', async () => {
|
|
const wrapper = mount(LabRequest, {
|
|
global: { stubs: ['el-dialog', 'el-tree', 'el-checkbox-group', 'el-radio-group', 'el-input', 'el-date-picker'] }
|
|
});
|
|
const pastTime = new Date();
|
|
pastTime.setFullYear(pastTime.getFullYear() - 1);
|
|
wrapper.vm.executionTime = pastTime;
|
|
await wrapper.vm.$nextTick();
|
|
|
|
const mockAlert = vi.fn();
|
|
wrapper.vm.$alert = mockAlert;
|
|
wrapper.vm.handleSubmit();
|
|
expect(mockAlert).toHaveBeenCalledWith('执行时间不可早于当前时间', '提示', { type: 'warning' });
|
|
});
|
|
});
|