cmvr-wms/ruoyi-ui-vue3/tests/runtime/home-menu-store.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

37 lines
3.1 KiB
JavaScript

import {test,expect,vi,beforeAll,beforeEach} from 'vitest'
import {createPinia,setActivePinia,defineStore} from 'pinia'
import {reactive} from 'vue'
const data=vi.hoisted(()=>({user:null,getRouters:vi.fn(),remove:vi.fn()}))
vi.mock('@/store/modules/user',()=>({default:()=>data.user}))
vi.mock('@/api/menu',()=>({getRouters:data.getRouters}))
vi.mock('@/plugins/auth',()=>({default:{hasPermiOr:()=>false,hasRoleOr:()=>false}}))
vi.mock('@/router',()=>({default:{addRoute:vi.fn()},dynamicRoutes:[],constantRoutes:[{path:'',children:[{path:'/index',name:'Index',meta:{title:'首页',affix:true,homePage:true}}]},{path:'/user',hidden:true,children:[{path:'profile',name:'Profile'}]}]}))
vi.mock('@/layout/index',()=>({default:{}}))
vi.mock('@/components/ParentView',()=>({default:{}}))
vi.mock('@/layout/components/InnerLink',()=>({default:{}}))
vi.mock('@/store/modules/settings',()=>({default:()=>({tagsViewPersist:true})}))
vi.mock('@/plugins/cache',()=>({default:{local:{getJSON:()=>[],setJSON:vi.fn(),remove:data.remove}}}))
let permissionStore,tagsStore
beforeAll(async()=>{vi.stubGlobal('defineStore',defineStore);permissionStore=(await import('@/store/modules/permission')).default;tagsStore=(await import('@/store/modules/tagsView')).default})
beforeEach(()=>{
setActivePinia(createPinia());data.user=reactive({roles:['archive_manager'],permissions:['archive:project:list']})
data.getRouters.mockResolvedValue({data:[{path:'/',component:'Layout',children:[{path:'index',component:'businessHome/index',meta:{title:'首页'}}]},{path:'/',component:'Layout',children:[{path:'project-archive',component:'archive/index',meta:{title:'项目资料'}}]}]})
})
test('the actual permission store excludes homepage from sidebar and topbar and selects documents as landing',async()=>{
const store=permissionStore();await store.generateRoutes()
expect(store.canHome).toBe(false);expect(store.landingPath).toBe('/project-archive')
expect(store.routes.flatMap(r=>r.children||[]).some(r=>r.meta?.homePage)).toBe(false)
expect(store.sidebarRouters.flatMap(r=>r.children||[]).some(r=>r.path==='index'||r.path==='/index')).toBe(false)
expect(store.topbarRouters.some(r=>r.path==='/index')).toBe(false)
})
test('authorized users receive exactly one homepage rather than a duplicate database route',async()=>{
data.user.permissions=['business:home:view'];const store=permissionStore();await store.generateRoutes()
expect(store.canHome).toBe(true);expect(store.landingPath).toBe('/index')
expect(store.routes.flatMap(r=>r.children||[]).filter(r=>r.path==='index'||r.path==='/index')).toHaveLength(1)
expect(store.topbarRouters.filter(r=>r.path==='/index')).toHaveLength(1)
})
test('account switching clears cached and persisted page tabs, not business records',()=>{
const store=tagsStore();store.visitedViews=[{path:'/index',meta:{affix:true}},{path:'/warehouse/stock'}];store.cachedViews=['/index','/warehouse/stock'];store.iframeViews=[{path:'/private'}]
store.resetUserViews();expect(store.visitedViews).toEqual([]);expect(store.cachedViews).toEqual([]);expect(store.iframeViews).toEqual([]);expect(data.remove).toHaveBeenCalledWith('tags-view-visited')
})