cmvr-wms/ruoyi-ui-vue3/tests/runtime/assistant-user-check.spec.js
lixiaolong ebac97185e feat(assistant): 新增用户核对功能并优化对话流程
- 新增 user.check 功能用于核对人员是否已有系统账号
- 在 assistant-table-layout.js 中为用户表格添加 checkedIdentity 和 matchResult 字段
- 优化 AssistantConversationService 中的任务记忆和澄清流程
- 支持对草稿特定行进行修改,无需重新填写整张表
- 限制 user.check 操作最大查询数量为 100 条记录
- 实现中断任务恢复机制,保持原始请求上下文
- 添加针对多行数据选择性修改的目标行标识支持
2026-10-23 17:00:47 +08:00

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() }
})