- 新增 ArrivalListTools 和 ArrivalCard 组件用于到货列表管理 - 集成 arrivalListQuery 查询逻辑优化数据加载 - 调整页面标题文字样式增加最小宽度和行高 - 更新底部标签栏字体大小和行高设置 - 重构到货操作界面添加键盘避让视图支持 - 优化到货操作按钮状态管理增加次要按钮样式 - 实现助手组件分页功能支持动态页面大小 - 扩展文件存储区域配置支持项目工作空间 - 增加文件流式上传下载方法支持大文件处理 - 优化采购表格单元格键盘输入体验 - 修复移动端到货操作界面键盘遮挡问题 - 调整测试用例数据量验证分页功能正确性
52 lines
3.6 KiB
JavaScript
52 lines
3.6 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import {emptyKpiItem,kpiFilename,kpiIssues,kpiPayload,kpiNextAction,kpiCanEdit,kpiCanAssign,kpiWorkflowSteps,kpiProgress,kpiProgressLabel} from '../../src/utils/kpi.js'
|
|
test('progress distinguishes untouched and partial drafts from personal confirmation',()=>{
|
|
assert.equal(kpiProgress({status:'DRAFT',progress:'NOT_STARTED'}),'NOT_STARTED')
|
|
assert.equal(kpiProgressLabel({status:'DRAFT',progress:'IN_PROGRESS'}),'填写中')
|
|
assert.equal(kpiProgress({status:'SCORED',progress:'NOT_STARTED'}),'CONFIRMED')
|
|
})
|
|
test('KPI filenames follow the requested employee-period convention without unsafe path characters',()=>{
|
|
assert.equal(kpiFilename('李小龙','2026年KPI'),'李小龙-2026年KPI.xlsx')
|
|
assert.equal(kpiFilename('李小龙','2026年第4季度KPI'),'李小龙-2026年第4季度KPI.xlsx')
|
|
assert.equal(kpiFilename('ignored','2026年KPI',true),'2026年KPI.zip')
|
|
assert(!kpiFilename('../员工','../../KPI').includes('/'))
|
|
})
|
|
test('empty drafts are allowed; submit exposes missing template prerequisites without an invented weight rule',()=>{
|
|
assert.deepEqual(kpiIssues({email:'',items:[]}),[])
|
|
assert.equal(kpiIssues({email:'',items:[]},{submit:true}).length,2)
|
|
const item={...emptyKpiItem(),name:'研发任务',weight:15}
|
|
assert.deepEqual(kpiIssues({email:'user@example.com',items:[item]},{submit:true}),[])
|
|
})
|
|
test('blank scores are not zero and negative deduction weights remain valid',()=>{
|
|
const form={version:3,email:' user@example.com ',items:[{...emptyKpiItem(),name:'安全质量',category:'扣分项指标',weight:-5,score:0},{...emptyKpiItem(),name:'工作',score:''}]}
|
|
const value=kpiPayload(form);assert.equal(value.email,'user@example.com');assert.equal(value.items[0].score,0);assert.equal(value.items[1].score,null);assert.equal(value.items[0].weight,-5)
|
|
assert.deepEqual(kpiIssues(form),[])
|
|
})
|
|
test('standards grouped for Excel merging must agree and fields are never silently truncated',()=>{
|
|
const a={...emptyKpiItem(),standardGroup:'同组',metrics:'标准甲'},b={...emptyKpiItem(),standardGroup:'同组',metrics:'标准乙'}
|
|
assert(kpiIssues({email:'',items:[a,b]}).some(v=>v.includes('分组')))
|
|
assert(kpiIssues({email:'',items:[{...a,name:'名'.repeat(201)}]}).some(v=>v.includes('200')))
|
|
assert.equal(emptyKpiItem().sources.length,0)
|
|
})
|
|
test('review submissions require completion and self-score while planning does not',()=>{
|
|
const form={version:1,phase:'REVIEW',email:'kpi@example.com',items:[{...emptyKpiItem(),name:'开发工作'}]}
|
|
assert(kpiIssues(form,{submit:true}).some(v=>v.includes('完成情况')))
|
|
assert(kpiIssues(form,{submit:true}).some(v=>v.includes('自评')))
|
|
form.items[0].completion='完成';form.items[0].selfScore=0
|
|
assert.deepEqual(kpiIssues(form,{submit:true}),[])
|
|
assert.equal(kpiPayload(form).phase,'REVIEW')
|
|
})
|
|
test('the six-step lifecycle exposes only a forward next action and preserves maintenance before ending',()=>{
|
|
for(let i=0;i<kpiWorkflowSteps.length;i++){
|
|
const form={workflowState:kpiWorkflowSteps[i][0],status:'DRAFT',closed:0}
|
|
assert.equal(kpiNextAction(form)?.state,kpiWorkflowSteps[i+1]?.[0])
|
|
}
|
|
assert.equal(kpiCanEdit({workflowState:'CREATED',status:'DRAFT'},true),false)
|
|
assert.equal(kpiCanEdit({workflowState:'PLANNING_CONFIRMED',status:'DRAFT'},true),false)
|
|
assert.equal(kpiCanEdit({workflowState:'REVIEW_CONFIRMED',status:'SUBMITTED'},true),true)
|
|
assert.equal(kpiCanEdit({workflowState:'REVIEW_CONFIRMED',status:'DRAFT'},false),false)
|
|
assert.equal(kpiCanEdit({workflowState:'ENDED',status:'DRAFT'},true),false)
|
|
assert.equal(kpiCanAssign({workflowState:'REVIEW'}),false)
|
|
})
|