- 集成 ServerConnection 组件用于开发环境服务器切换 - 实现多服务器令牌隔离存储机制 - 添加 ArrivalOperation 屏幕处理到货和验收流程 - 支持待登记到货和待验收状态切换 - 优化库存操作界面的字段显示逻辑 - 增强 Excel 文件分片上传支持产品文件识别 - 添加 AI 助手会话滚动跟踪功能 - 实现开发服务器地址持久化存储 - 优化登录界面集成服务器连接组件 - 添加领用出库功能支持项目物资使用 - 改进盘点确认生效的操作流程 - 增强采购到货登记和验收的权限控制 - 优化移动端文件上传的断点续传机制 - 添加服务器切换时的数据清理保护机制 - 实现紧凑金额显示模式减少界面冗余 - 增强库存操作的数量验证和错误提示 - 优化 AI 助手的会话状态同步机制
17 lines
2.6 KiB
JavaScript
17 lines
2.6 KiB
JavaScript
import {expect,it,vi} from 'vitest'
|
|
import {mount} from '@vue/test-utils'
|
|
import ElementPlus from 'element-plus'
|
|
import Files from '../../src/components/ProductAttachments/index.vue'
|
|
const api=vi.hoisted(()=>({list:vi.fn(),upload:vi.fn(),cancel:vi.fn(),remove:vi.fn(),read:vi.fn()}))
|
|
vi.mock('@/api/production/product-editions',()=>({productAttachments:api.list,uploadProductAttachment:api.upload,cancelProductAttachmentTransfer:api.cancel,removeProductAttachment:api.remove,readProductAttachment:api.read}))
|
|
it('pause keeps the selected file, resume displays progress and success, and reopening never leaks another product transfer',async()=>{
|
|
api.list.mockResolvedValue({data:[]});let options
|
|
api.upload.mockImplementationOnce((_id,_file,_uploadId,signal,progress)=>new Promise((_resolve,reject)=>{options={signal,progress};progress({phase:'uploading',percent:50,bytes:10,resumed:false});signal.addEventListener('abort',()=>reject({code:'ERR_CANCELED'}),{once:true})})).mockImplementationOnce(async(_id,_file,_uploadId,_signal,progress)=>{progress({phase:'complete',percent:100,resumed:true});return {data:{id:'native'}}})
|
|
const wrapper=mount(Files,{global:{plugins:[ElementPlus],mocks:{$can:()=>true,$dateTime:()=>''}}})
|
|
await wrapper.vm.open({id:7,itemName:'测试产品'});const file=new File(['续传测试'],'说明.txt'),upload=wrapper.vm.upload({file});await Promise.resolve();expect(wrapper.vm.uploading).toBe(true);wrapper.vm.pauseUpload();await upload;expect(options.signal.aborted).toBe(true);expect(wrapper.vm.busy).toBe(false);expect(wrapper.vm.pendingFile).toBe(file);expect(wrapper.vm.transfer.phase).toBe('paused')
|
|
await wrapper.vm.resumeUpload();await new Promise(resolve=>setTimeout(resolve,0));expect(wrapper.vm.pendingFile).toBe(null);expect(wrapper.vm.transfer.phase).toBe('complete');await wrapper.vm.open({id:8,itemName:'另一个产品'});expect(wrapper.vm.transfer).toBe(null);wrapper.unmount()
|
|
})
|
|
it('cancelling a paused transfer never removes a business attachment',async()=>{
|
|
api.list.mockResolvedValue({data:[]});api.cancel.mockResolvedValue({code:200});const wrapper=mount(Files,{global:{plugins:[ElementPlus],mocks:{$can:()=>true,$dateTime:()=>''}}});await wrapper.vm.open({id:7,itemName:'测试产品'});wrapper.vm.pendingFile=new File(['test'],'说明.txt');wrapper.vm.transfer={phase:'paused',percent:50,sessionId:'11111111-1111-1111-1111-111111111111'};await wrapper.vm.cancelUpload();expect(api.cancel).toHaveBeenCalledWith('11111111-1111-1111-1111-111111111111');expect(api.remove).not.toHaveBeenCalled();expect(wrapper.vm.pendingFile).toBe(null);wrapper.unmount()
|
|
})
|