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

22 lines
1.8 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {readFileSync} from 'node:fs';
import ts from 'typescript';
const source=name=>readFileSync(new URL(`../src/${name}`,import.meta.url),'utf8');
test('mobile JSX has no unexpected literal text below a native View',()=>{
for(const file of ['App.tsx','ui.tsx','files.tsx','dialogs.tsx','screens/Account.tsx','screens/Feedback.tsx','screens/Workspace.tsx','screens/Assistant.tsx']){
const parsed=ts.createSourceFile(file,source(file),ts.ScriptTarget.Latest,true,ts.ScriptKind.TSX);
function walk(node){if(ts.isJsxElement(node)&&['View','ScrollView','Pressable','KeyboardAvoidingView','SafeAreaView'].includes(node.openingElement.tagName.getText(parsed)))for(const child of node.children)if(ts.isJsxText(child))assert.equal(child.text.trim(),'',`${file} has bare native text`);ts.forEachChild(node,walk);}walk(parsed);
}
assert.match(source('App.tsx'),/\{!!module\.search&&/,'an empty search key must not render a raw string in View');
});
test('mobile feedback is always scoped to my records and never calls administrative handling',()=>{
const file=source('screens/Feedback.tsx');assert.match(file,/all:false/);assert.doesNotMatch(file,/all:true|\/handle/);
assert.match(file,/setUncertain\(unknown\)/);assert.match(file,/lock\.current\|\|uncertain/);
});
test('AI stays mounted across tab switches; no implicit business submit or reload on update',()=>{
const app=source('App.tsx');assert.match(app,/aiVisited&&ai/);assert.match(app,/display:!page&&tab==='assistant'\?'flex':'none'/);
assert.match(source('screens/Assistant.tsx'),/draftAction\(message\.draft,'execute'\)/);assert.match(source('screens/Assistant.tsx'),/Alert\.alert\('确认执行业务'/);
assert.doesNotMatch(app,/reloadAsync/);
});