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

18 lines
1.6 KiB
JavaScript

import {expect,it,vi} from 'vitest'
import {mount,flushPromises} from '@vue/test-utils'
import ElementPlus from 'element-plus'
import Cost from '@/views/archive/ArchiveCost.vue'
const api=vi.hoisted(()=>({archiveCost:vi.fn(),archiveCostPeople:vi.fn()}))
vi.mock('@/api/archive',()=>api)
it('the real select keeps its query when loading hides and reopens the dropdown',async()=>{
vi.useFakeTimers();let wrapper
try{
const users=[{id:1,name:'管理员',account:'admin',rate:1000},{id:2,name:'李一',account:'liyi',rate:1000},{id:3,name:'王一',account:'wangyi',rate:1000}]
api.archiveCostPeople.mockImplementation(async(_id,{keyword})=>{if(keyword)await new Promise(resolve=>setTimeout(resolve,10));return {data:users}})
wrapper=mount(Cost,{props:{projectId:21,version:3,editable:true,cost:{complete:true,data:{formatVersion:3,income:1000,labor:[{userId:2,name:'李一',duty:'研发',days:1,rate:1000}]}}},attachTo:document.body,global:{plugins:[ElementPlus]}})
await flushPromises();const input=wrapper.get('input[aria-label="项目参与人员"]');await input.trigger('focus');await wrapper.get('.el-select__wrapper').trigger('click');await flushPromises();await input.setValue('王');await vi.advanceTimersByTimeAsync(700);await flushPromises()
expect(wrapper.vm.$.setupState.personKeyword).toBe('王');expect(wrapper.vm.$.setupState.matchingPeople.map(person=>person.name)).toEqual(['王一']);expect(api.archiveCostPeople.mock.calls.at(-1)[1].keyword).toBe('王')
expect([...document.querySelectorAll('.el-select-dropdown__item')].map(element=>element.textContent)).toEqual(['王一 / wangyi'])
}finally{wrapper?.unmount();vi.useRealTimers()}
})