- 新增 user.check 功能用于核对人员是否已有系统账号 - 在 assistant-table-layout.js 中为用户表格添加 checkedIdentity 和 matchResult 字段 - 优化 AssistantConversationService 中的任务记忆和澄清流程 - 支持对草稿特定行进行修改,无需重新填写整张表 - 限制 user.check 操作最大查询数量为 100 条记录 - 实现中断任务恢复机制,保持原始请求上下文 - 添加针对多行数据选择性修改的目标行标识支持
29 lines
1.9 KiB
JavaScript
29 lines
1.9 KiB
JavaScript
import {test,expect,vi,beforeEach} from 'vitest'
|
|
const state=vi.hoisted(()=>({guard:null,user:null,permission:null,lock:{isLock:false}}))
|
|
vi.mock('@/router',()=>({default:{beforeEach:callback=>{state.guard=callback},afterEach:vi.fn()}}))
|
|
vi.mock('@/utils/page-guards',()=>({confirmPageLeave:vi.fn().mockResolvedValue(true)}))
|
|
vi.mock('@/utils/auth',()=>({getToken:()=> 'synthetic-token'}))
|
|
vi.mock('@/utils/request',()=>({isRelogin:{show:false}}))
|
|
vi.mock('@/store/modules/user',()=>({default:()=>state.user}))
|
|
vi.mock('@/store/modules/permission',()=>({default:()=>state.permission}))
|
|
vi.mock('@/store/modules/lock',()=>({default:()=>state.lock}))
|
|
vi.mock('@/store/modules/settings',()=>({default:()=>({setTitle:vi.fn()})}))
|
|
vi.mock('nprogress',()=>({default:{configure:vi.fn(),start:vi.fn(),done:vi.fn()}}))
|
|
import '@/permission'
|
|
beforeEach(()=>{
|
|
state.user={roles:['archive_manager'],getInfo:vi.fn(),logOut:vi.fn()}
|
|
state.permission={canHome:false,landingPath:'/project-archive',generateRoutes:vi.fn().mockResolvedValue([])}
|
|
})
|
|
const target=path=>({path,fullPath:path,meta:{}}),from=target('/login')
|
|
test('an archive-only manager opening Index is redirected once to project documents',async()=>{
|
|
expect(await state.guard(target('/index'),from)).toEqual({path:'/project-archive',replace:true})
|
|
expect(await state.guard(target('/project-archive'),target('/index'))).toBe(true)
|
|
expect(await state.guard(target('/redirect/index'),from)).toEqual({path:'/project-archive',replace:true})
|
|
})
|
|
test('authorized home remains accessible and a no-menu account falls back to profile without a loop',async()=>{
|
|
state.permission.canHome=true;expect(await state.guard(target('/index'),from)).toBe(true)
|
|
state.permission.canHome=false;state.permission.landingPath='/user/profile'
|
|
expect(await state.guard(target('/index'),from)).toEqual({path:'/user/profile',replace:true})
|
|
expect(await state.guard(target('/user/profile'),target('/index'))).toBe(true)
|
|
})
|