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

27 lines
2.5 KiB
JavaScript

import {test,expect,vi,beforeEach} from 'vitest'
import {shallowMount,flushPromises} from '@vue/test-utils'
import Home from '@/views/businessHome/index.vue'
const request=vi.hoisted(()=>vi.fn())
vi.mock('@/utils/request',()=>({default:request}))
beforeEach(()=>{request.mockReset();request.mockResolvedValue({data:{overview:{budget:12345,statuses:[]},warehouse:{stockTotal:8},queues:[{key:'quote',rows:[],count:0}]}})})
function page(perms){const held=new Set(perms);return shallowMount(Home,{global:{directives:{loading:()=>{}},mocks:{$auth:{hasPermi:p=>held.has(p),hasPermiOr:ps=>ps.some(p=>held.has(p))},$router:{getRoutes:()=>[],push:vi.fn()},parseTime:()=>''},stubs:{BusinessPageHeader:true,BusinessIcon:true,ElEmpty:true,ElAlert:true,ElSelect:true,ElRadioGroup:true,ElRadioButton:true,ElButton:true,ElProgress:true}}})}
test('business permissions alone do not request or render homepage data',async()=>{
const w=page(['project:project:list','warehouse:stock:list','warehouse:purchase:list']);await flushPromises()
expect(request).not.toHaveBeenCalled();expect(w.vm.metrics).toEqual([]);expect(w.vm.queues).toEqual([]);expect(w.vm.shortcuts).toEqual([]);w.unmount()
})
test('warehouse authorization cannot expose project funds or business queues',async()=>{
const w=page(['business:home:view','business:home:warehouse','warehouse:stock:list','project:project:list','warehouse:purchase:list']);await flushPromises()
expect(request).toHaveBeenCalledOnce();expect(w.vm.inventoryMetrics.map(c=>c.key)).toEqual(['stock']);expect(w.vm.projectMetrics).toEqual([]);expect(w.vm.queues).toEqual([]);expect(w.vm.canProjects).toBe(false);w.unmount()
})
test('project statistics and todo authorization are independent and still require business rights',async()=>{
const w=page(['business:home:view','business:home:project','project:project:list']);await flushPromises()
expect(w.vm.projectMetrics.map(c=>c.key)).toEqual(['projects','budget']);expect(w.vm.inventoryMetrics).toEqual([]);expect(w.vm.queues).toEqual([]);w.unmount()
request.mockClear();const none=page(['business:home:view','business:home:project','business:home:warehouse','business:home:todo']);await flushPromises()
expect(request).not.toHaveBeenCalled();expect(none.vm.metrics).toEqual([]);expect(none.vm.queues).toEqual([]);none.unmount()
})
test('a todo-only user has no inventory or project statistics',async()=>{
const w=page(['business:home:view','business:home:todo','warehouse:purchase:list']);await flushPromises()
expect(w.vm.queues.map(q=>q.key)).toEqual(['quote']);expect(w.vm.metrics).toEqual([]);w.unmount()
})