- 集成 ServerConnection 组件用于开发环境服务器切换 - 实现多服务器令牌隔离存储机制 - 添加 ArrivalOperation 屏幕处理到货和验收流程 - 支持待登记到货和待验收状态切换 - 优化库存操作界面的字段显示逻辑 - 增强 Excel 文件分片上传支持产品文件识别 - 添加 AI 助手会话滚动跟踪功能 - 实现开发服务器地址持久化存储 - 优化登录界面集成服务器连接组件 - 添加领用出库功能支持项目物资使用 - 改进盘点确认生效的操作流程 - 增强采购到货登记和验收的权限控制 - 优化移动端文件上传的断点续传机制 - 添加服务器切换时的数据清理保护机制 - 实现紧凑金额显示模式减少界面冗余 - 增强库存操作的数量验证和错误提示 - 优化 AI 助手的会话状态同步机制
33 lines
1.9 KiB
JavaScript
33 lines
1.9 KiB
JavaScript
import {expect,it,vi} from 'vitest'
|
|
import {readFileSync} from 'node:fs'
|
|
import {parse} from '@vue/compiler-sfc'
|
|
import {baseParse} from '@vue/compiler-dom'
|
|
import {defineComponent} from 'vue'
|
|
import {mount} from '@vue/test-utils'
|
|
|
|
it('purchase editing removes the entire fixed operations column and restores it after editing',async()=>{
|
|
const source=readFileSync('src/components/PurchaseSheet/index.vue','utf8')
|
|
const template=parse(source).descriptor.template.content
|
|
let column
|
|
function find(node){
|
|
if(node.tag==='el-table-column'&&node.props.some(p=>p.name==='key'&&p.value?.content==='operations'))column=node
|
|
for(const child of node.children||[])find(child)
|
|
}
|
|
find(baseParse(template));expect(column).toBeTruthy()
|
|
const actual=template.slice(column.loc.start.offset,column.loc.end.offset)
|
|
const records=vi.fn()
|
|
const host=defineComponent({template:`<div>${actual}</div>`,data:()=>({isEditing:false,saving:false,canEdit:true}),methods:{canArrive:()=>false,records}})
|
|
const tableColumn=defineComponent({props:['label','width'],template:'<section class="operations"><strong>{{label}}</strong><slot :row="row"/></section>',data:()=>({row:{id:1,purchaseStatus:0,pendingArrivalQuantity:0,acceptedQuantity:0}})})
|
|
const button=defineComponent({emits:['click'],template:'<button @click="$emit(\'click\')"><slot/></button>'})
|
|
const wrapper=mount(host,{global:{stubs:{ElTableColumn:tableColumn,ElButton:button},mocks:{$can:()=>false}}})
|
|
expect(wrapper.get('.operations').text()).toContain('操作')
|
|
await wrapper.get('button').trigger('click');expect(records).toHaveBeenCalledOnce()
|
|
await wrapper.setData({isEditing:true})
|
|
expect(wrapper.find('.operations').exists()).toBe(false)
|
|
expect(wrapper.find('button').exists()).toBe(false)
|
|
await wrapper.setData({isEditing:false})
|
|
expect(wrapper.get('.operations').text()).toContain('到货记录')
|
|
expect(wrapper.findComponent(tableColumn).props('width')).toBe('270')
|
|
wrapper.unmount()
|
|
})
|