import { mount } from '@vue/test-utils';
|
import Antd from 'ant-design-vue';
|
import { describe, expect, it } from 'vitest';
|
|
import StepDirectory from '../../src/components/StepDirectory.vue';
|
|
describe('StepDirectory', () => {
|
it('filters globally ordered steps and emits the selected step', async () => {
|
const wrapper = mount(StepDirectory, {
|
global: { plugins: [Antd] },
|
props: {
|
currentStepId: 'step-prepare',
|
progress: [
|
{ missingCount: 1, problemCount: 0, status: 'in-progress', step: { id: 'step-prepare', name: '样品准备', order: 1 } },
|
{ missingCount: 0, problemCount: 1, status: 'problem', step: { id: 'step-test', name: '结果检验', order: 2 } },
|
{ missingCount: 0, problemCount: 0, status: 'complete', step: { id: 'step-finish', name: '结束记录', order: 3 } },
|
],
|
},
|
});
|
|
expect(wrapper.text()).toContain('当前');
|
expect(wrapper.text()).toContain('填写中');
|
expect(wrapper.text()).toContain('有问题');
|
expect(wrapper.text()).toContain('已完整');
|
|
await wrapper.get('[aria-label="返回当前步骤"]').trigger('click');
|
expect(wrapper.emitted('close')).toEqual([[]]);
|
|
await wrapper.get('input[aria-label="搜索步骤"]').setValue('检验');
|
expect(wrapper.text()).not.toContain('样品准备');
|
expect(wrapper.text()).toContain('结果检验');
|
|
await wrapper.get('[data-step-id="step-test"]').trigger('click');
|
expect(wrapper.emitted('select')).toEqual([['step-test']]);
|
});
|
});
|