- 新增 PDF 文档支持,包括格式校验和完整性检查 - 扩展 Word、TXT 和 ZIP 格式附件处理能力 - 添加 Excel 附件可选择仅作为业务文件不解析行数据 - 实现业务助手表格布局配置新增库存和预算字段 - 集成通知、反馈通知等新的业务助手动作类型 - 完善部门管理包含父级部门和排序字段支持 - 增强业务规则校验涵盖更多系统管理场景 - 优化附件上传限制提示信息更准确 - 添加生成文件下载的安全性校验机制 - 扩展测试覆盖确保各业务动作规则正确性
47 lines
2.1 KiB
JavaScript
47 lines
2.1 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { purchaseNameChoices } from '../../src/utils/purchase-sheet.js'
|
|
|
|
test('unmatched draft remains an option in open, empty-loading and closed remote menus',()=>{
|
|
const row={materialName:'新物品',materialBrand:'新品牌',materialParams:'型号A',unit:'个',finalUnitPrice:12}
|
|
const before={...row}
|
|
for(const results of [[],[{id:8,productName:'其他物品'}],[]]){
|
|
const choices=purchaseNameChoices(row,results)
|
|
assert.ok(choices.some(item=>!item.id&&item.productName===row.materialName))
|
|
assert.equal(choices[0].spec,'型号A')
|
|
assert.equal(choices[0].brand,'新品牌')
|
|
}
|
|
assert.deepEqual(row,before)
|
|
})
|
|
|
|
test('selected archive is retained when filtered out, without duplicate IDs or hiding same-name variants',()=>{
|
|
const row={productId:9,materialName:'电机',materialParams:'A',materialBrand:'品牌'}
|
|
const selected={id:9,productName:'电机',spec:'A'},other={id:10,productName:'电机',spec:'B'}
|
|
const results=[selected,other]
|
|
assert.equal(purchaseNameChoices(row,results),results)
|
|
assert.deepEqual(purchaseNameChoices(row,[other]).map(item=>item.id),[9,10])
|
|
assert.equal(purchaseNameChoices(row,[])[0].id,9)
|
|
})
|
|
|
|
test('draft and archive with the same name keep distinct selection values; empty drafts stay empty',()=>{
|
|
const archive={id:1,productName:'电机'}
|
|
const choices=purchaseNameChoices({materialName:'电机'},[archive])
|
|
assert.equal(choices.length,2)
|
|
assert.equal(choices[0].id,undefined)
|
|
assert.equal(choices[1],archive)
|
|
assert.deepEqual(purchaseNameChoices({materialName:''},[]),[])
|
|
})
|
|
|
|
test('opening and closing an empty remote result reaches stable visibility instead of a feedback loop',()=>{
|
|
const row={materialName:'档案不存在',materialBrand:'品牌',materialParams:'规格'}
|
|
// ElSelect remote empty-text=false suppresses visibility when options disappear.
|
|
let visible=true,transitions=0
|
|
for(let i=0;i<20;i++){
|
|
const next=purchaseNameChoices(row,visible?[]:[]).length>0
|
|
if(next!==visible)transitions++
|
|
visible=next
|
|
}
|
|
assert.equal(visible,true)
|
|
assert.equal(transitions,0)
|
|
})
|