42 lines
2.4 KiB
JavaScript
42 lines
2.4 KiB
JavaScript
|
|
import { mount, flushPromises } from '@vue/test-utils'
|
||
|
|
import { test, expect, vi } from 'vitest'
|
||
|
|
import ElementPlus from 'element-plus'
|
||
|
|
import Query from '@/components/BusinessAssistant/AssistantQuery.vue'
|
||
|
|
|
||
|
|
vi.mock('@/store/modules/businessAssistant', () => ({ default: () => ({ generation: 1, open: true }) }))
|
||
|
|
vi.mock('@/api/warehouse/assistant', () => ({ getAssistantGeneratedFile: vi.fn() }))
|
||
|
|
|
||
|
|
const query = {
|
||
|
|
action: 'user.check', label: '人员账号核对', status: 'SUCCEEDED',
|
||
|
|
fields: [{ key: 'keyword', label: '待核对姓名或账号' }, { key: 'pageNum', label: '页码' }],
|
||
|
|
rows: [{ keyword: '模拟甲', pageNum: 1 }, { keyword: '模拟乙', pageNum: 1 }],
|
||
|
|
results: [{ status: 'SUCCEEDED', data: {
|
||
|
|
columns: ['checkedIdentity', 'matchResult', 'nickName', 'userName', 'deptName', 'status'].map((key, index) => ({ key, label: ['待核对姓名/账号', '核对结果', '用户姓名', '登录账号', '部门', '状态'][index] })),
|
||
|
|
rows: [{ checkedIdentity: '模拟甲', matchResult: '已找到', nickName: '模拟甲', userName: 'synthetic_a', deptName: '测试部', status: '正常' },
|
||
|
|
{ checkedIdentity: '模拟乙', matchResult: '当前可见范围内未找到', nickName: '', userName: '', deptName: '', status: '' }],
|
||
|
|
total: 2, hasMore: false, message: '查询完成'
|
||
|
|
} }]
|
||
|
|
}
|
||
|
|
|
||
|
|
test('a batch identity result displays one table with an explicit row even for an unmatched person', async () => {
|
||
|
|
const wrapper = mount(Query, { props: { query }, global: { plugins: [ElementPlus] } })
|
||
|
|
try {
|
||
|
|
await flushPromises()
|
||
|
|
expect(wrapper.findAll('.el-table')).toHaveLength(1)
|
||
|
|
expect(wrapper.findAll('.el-table__body tbody tr')).toHaveLength(2)
|
||
|
|
expect(wrapper.text()).toContain('当前可见范围内未找到')
|
||
|
|
expect(wrapper.text()).toContain('synthetic_a')
|
||
|
|
expect(wrapper.find('.assistant-query-conditions').text()).toContain('2 项姓名/账号')
|
||
|
|
expect(wrapper.find('.assistant-query-conditions').text()).not.toContain('页码')
|
||
|
|
expect(wrapper.text()).not.toContain('没有符合条件的数据')
|
||
|
|
} finally { wrapper.unmount() }
|
||
|
|
})
|
||
|
|
|
||
|
|
test('a denied historical check never renders account rows', () => {
|
||
|
|
const wrapper = mount(Query, { props: { query: { ...query, permissionDenied: true } }, global: { plugins: [ElementPlus] } })
|
||
|
|
try {
|
||
|
|
expect(wrapper.findAll('.el-table')).toHaveLength(0)
|
||
|
|
expect(wrapper.text()).not.toContain('synthetic_a')
|
||
|
|
} finally { wrapper.unmount() }
|
||
|
|
})
|