cmvr-wms/ruoyi-ui-vue3/tests/unit/supplier-quotation.test.mjs
lixiaolong a82258561b feat(auth): 添加认证cookie名称配置并优化表单布局
- 在 .env.production 中新增 VITE_AUTH_COOKIE_NAME 配置项用于设置认证cookie名称
- 将 AcceptanceException.vue 中的表单标签宽度从固定90px改为自动适配
- 在 ActionDialog.vue 中将多个表单项标记为必填项并调整标签宽度为自动适配
- 重构 ActionHistory.vue 中的按钮布局结构并添加表格列样式类名
- 更新 api-contract-audit.cjs 添加生产任务和BOM相关接口的契约测试
- 修改 auth.js 使用动态认证cookie键名替换硬编码的Admin-Token
- 调整系统角色授权用户页面的表单布局和表格样式类名
- 优化 ReceiptDialog Batch 组件的对话框尺寸、表单验证和分页功能
2026-10-16 15:30:10 +08:00

29 lines
2.7 KiB
JavaScript

import test from 'node:test'
import assert from 'node:assert/strict'
import fs from 'node:fs'
import {supplierInquiryRows,quotationReady,quotationSummary,quotationUploadError} from '../../src/utils/supplier-quotation.js'
test('supplier inquiry merges only eligible same-item rows across projects without modifying original data',()=>{
const row={productCode:'A',materialName:'垫片',materialParams:'M4',materialBrand:'品牌',unit:'包',quantity:0.1,projectId:1}
const source=[row,{...row,quantity:0.2,projectId:2},{...row,receivedQuantity:1},{...row,historical:true},{...row,purchaseStatus:5},{...row,productCode:'B',materialParams:'M5',quantity:2}]
const groups=supplierInquiryRows(source);assert.equal(groups.length,2);assert.equal(groups[0].quantity,0.3);assert.equal(groups[0].rowCount,2);assert.equal(groups[1].spec,'M5');assert.equal(source[0].quantity,0.1)
})
test('blank, invalid and unmatchable prices cannot be applied while a real zero price can',()=>{
const valid={unitPrice:0,rowIds:[1,2],error:null},skip={...valid,unitPrice:null,skipped:true},bad={...valid,error:'错误'}
assert.equal(quotationReady(valid),true);for(const row of [skip,bad,{...valid,rowIds:[]},...[undefined,'',' ',false,-1,'abc'].map(unitPrice=>({...valid,unitPrice}))])assert.equal(quotationReady(row),false)
assert.deepEqual(quotationSummary([valid,skip,bad]),{ready:1,errors:1,skipped:1})
})
test('quote upload validates type and size and accepts ordinary Excel files',()=>{
for(const name of ['报价.xlsx','报价.XLS'])assert.equal(quotationUploadError({name,size:1024}),'')
for(const file of [{name:'报价.pdf',size:1},{name:'报价.xlsx',size:0},{name:'报价.xlsx',size:10485761}])assert.ok(quotationUploadError(file))
})
test('supplier workflow uses readable identity columns, a real Excel export, a single preview and explicit partial confirmation',()=>{
const dialog=fs.readFileSync(new URL('../../src/components/PurchaseSheet/SupplierQuotation.vue',import.meta.url),'utf8')
assert.match(dialog,/inquiry-export/);assert.match(dialog,/上传供应商报价/);assert.match(dialog,/物品名称/);assert.match(dialog,/规格型号/)
assert.doesNotMatch(dialog,/label="物品编码"/);assert.equal((dialog.match(/<el-dialog\b/g)||[]).length,1)
assert.match(dialog,/summary\.errors>0 && !allowPartial/);assert.match(dialog,/保存清单/)
assert.ok(dialog.indexOf('label="供应商报价"')<dialog.indexOf('label="原报价"'))
const parent=fs.readFileSync(new URL('../../src/components/PurchaseSheet/index.vue',import.meta.url),'utf8')
assert.match(parent,/导出询价单/);assert.match(parent,/回填供应商报价/);assert.doesNotMatch(parent,/复制填写格式/)
assert.match(parent,/supplierName\(\)\{return this\.sheet\?\.batch\?\.supplierName/)
})