cmvr-wms/ruoyi-ui-vue3/tests/runtime/warehouse-completion.spec.js
lixiaolong cd86623061 feat(app): 添加服务器连接管理和到货操作功能
- 集成 ServerConnection 组件用于开发环境服务器切换
- 实现多服务器令牌隔离存储机制
- 添加 ArrivalOperation 屏幕处理到货和验收流程
- 支持待登记到货和待验收状态切换
- 优化库存操作界面的字段显示逻辑
- 增强 Excel 文件分片上传支持产品文件识别
- 添加 AI 助手会话滚动跟踪功能
- 实现开发服务器地址持久化存储
- 优化登录界面集成服务器连接组件
- 添加领用出库功能支持项目物资使用
- 改进盘点确认生效的操作流程
- 增强采购到货登记和验收的权限控制
- 优化移动端文件上传的断点续传机制
- 添加服务器切换时的数据清理保护机制
- 实现紧凑金额显示模式减少界面冗余
- 增强库存操作的数量验证和错误提示
- 优化 AI 助手的会话状态同步机制
2026-10-20 10:04:17 +08:00

40 lines
3.1 KiB
JavaScript

import {expect,it,vi} from 'vitest'
import {shallowMount} from '@vue/test-utils'
import Operations from '../../src/components/Production/StockOperations.vue'
import Sheet from '../../src/components/PurchaseSheet/index.vue'
import Correction from '../../src/components/PurchaseSheet/PriceCorrection.vue'
vi.mock('@/utils/request',()=>({default:vi.fn()}))
vi.mock('@/store/modules/user',()=>({default:()=>({permissions:['*:*:*']})}))
vi.mock('@/store/modules/app',()=>({default:()=>({size:'default'})}))
vi.mock('@/utils/use-compact-layout',()=>({useCompactLayout:()=>({compact:false})}))
it('the completed dialog renders a finish button, removes submit and reports success',()=>{
const wrapper=shallowMount(Operations,{data:()=>({visible:true,rows:[{done:true,quantity:1,stockNum:18,productName:'隔离测试物品'}],runRows:[{done:true,quantity:1}]}),global:{stubs:{ElTable:{template:'<div/>'},ElTableColumn:true,ElDialog:{template:'<div><slot/><slot name="footer"/></div>'},ElButton:{template:'<button><slot/></button>'},DialogWorkspace:{template:'<div><slot name="header"/><slot :tableHeight="180"/></div>'}}}})
expect(wrapper.text()).toContain('成功 1 项');expect(wrapper.text()).toContain('完成');expect(wrapper.text()).not.toContain('本次 0 项');expect(wrapper.findAll('button').some(button=>button.text()==='确认')).toBe(false)
wrapper.unmount()
})
it('successful inventory operations keep a completed summary instead of reporting zero selected items',()=>{
const row={done:true,quantity:1,failed:false},vm={rows:[row],displayRows:[row],runRows:[row]}
expect(Operations.computed.resultSummary.call(vm)).toBe('成功 1 项')
expect(Operations.computed.allCompleted.call(vm)).toBe(true)
vm.rows.push({done:false,failed:true,quantity:2})
expect(Operations.computed.resultSummary.call(vm)).toBe('成功 1 项 · 失败 1 项')
expect(Operations.computed.allCompleted.call(vm)).toBe(false)
vm.rows[1].failed=false
expect(Operations.computed.resultSummary.call(vm)).toBe('成功 1 项 · 待处理 1 项')
})
it('confirmed but not arrived purchases allow both prices; arrival locks quote while reference remains editable',()=>{
const vm={isEditing:true,saving:false,compactAmounts:false,readonly:Sheet.methods.readonly,fieldLocked:Sheet.methods.fieldLocked,canEditCategory:()=>true}
const row={id:1,purchaseStatus:1,priceLocked:true,acceptedQuantity:0,pendingArrivalQuantity:0,receivedQuantity:0}
expect(Sheet.methods.editableCell.call(vm,row,'finalUnitPrice')).toBe(true)
expect(Sheet.methods.editableCell.call(vm,row,'actualUnitPrice')).toBe(true)
row.pendingArrivalQuantity=1;expect(Sheet.methods.editableCell.call(vm,row,'finalUnitPrice')).toBe(false)
expect(Sheet.methods.editableCell.call(vm,row,'actualUnitPrice')).toBe(true)
row.historical=true;expect(Sheet.methods.editableCell.call(vm,row,'finalUnitPrice')).toBe(false)
})
it('changing a correction input invalidates the preview and historical acknowledgement',()=>{
const vm={preview:{version:'old'},acknowledgeArchiveOnly:true};Correction.methods.invalidate.call(vm)
expect(vm.preview).toBeNull();expect(vm.acknowledgeArchiveOnly).toBe(false)
})