cmvr-wms/mobile-app/tests/modules.test.mjs
lixiaolong 149bde836f feat(assistant): 扩展业务助手功能支持更多文档类型和业务场景
- 新增 PDF 文档支持,包括格式校验和完整性检查
- 扩展 Word、TXT 和 ZIP 格式附件处理能力
- 添加 Excel 附件可选择仅作为业务文件不解析行数据
- 实现业务助手表格布局配置新增库存和预算字段
- 集成通知、反馈通知等新的业务助手动作类型
- 完善部门管理包含父级部门和排序字段支持
- 增强业务规则校验涵盖更多系统管理场景
- 优化附件上传限制提示信息更准确
- 添加生成文件下载的安全性校验机制
- 扩展测试覆盖确保各业务动作规则正确性
2026-10-18 08:49:30 +08:00

20 lines
1.7 KiB
JavaScript

import test from 'node:test';import assert from 'node:assert/strict';import {readFile} from 'node:fs/promises';
import {modules,routeComponents,validDate,recordDisplay} from '../src/core/modules.ts';
test('native module fields agree with backend DTO names, not guessed desktop labels',async()=>{
const purchase=modules.find(m=>m.key==='purchase'),out=modules.find(m=>m.key==='out');
assert.ok(purchase.fields.some(([key])=>key==='purchaseBatchNo'));assert.ok(out.fields.some(([key])=>key==='usageProjectName'));
for(const [module,file] of [[purchase,'PurchaseRequest'],[out,'OutRecord']]){
const source=await readFile(new URL(`../../ruoyi-system/src/main/java/com/ruoyi/warehouse/domain/${file}.java`,import.meta.url),'utf8');
for(const [key] of module.fields)assert.ok(source.includes(`get${key[0].toUpperCase()+key.slice(1)}(`),`Missing backend getter ${file}.${key}`);
}
});
test('page-level production access comes from authorized server routes, not a made-up permission',()=>{
const production=modules.find(m=>m.key==='production');assert.ok(production.pages.includes('production/tasks/index'));
assert.ok(!production.permissions.flat().includes('production:entry'));
assert.deepEqual(routeComponents([{component:'Layout',children:[{component:'production/tasks/index'}]}]),['Layout','production/tasks/index']);
assert.equal(recordDisplay(production,'status','SETTLED'),'已结算');
});
test('date validation rejects silent calendar rollover and accepts leap dates',()=>{
assert.equal(validDate('2026-02-31'),false);assert.equal(validDate('2026-13-01'),false);assert.equal(validDate('2026-10-17'),true);assert.equal(validDate('2024-02-29'),true);assert.equal(validDate('2026-02-29'),false);
});