刘光辉
8 小时以前 cf11e63b659afcc9792ab3e395f1b45d844431a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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']]);
  });
});