cmvr-wms/mobile-app/tests/ui-contract.test.mjs
lixiaolong 6b43b0104f feat(app): 优化移动端应用配置和功能实现
- 添加生产环境服务器地址配置支持内外网切换
- 实现采购列表只看我创建的功能开关
- 更新构建脚本中的默认生产环境API地址
- 优化采购单表格单元格编辑体验改用自动补全组件
- 调整应用更新检查逻辑增强生产环境兼容性
- 修复开发服务器切换时的一些验证问题
- 增强应用启动时的服务地址配置灵活性
2026-10-30 15:02:54 +08:00

22 lines
2.2 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','AppUpdates.tsx','AppUpdateDialog.tsx','VersionUpdates.tsx','UpdateNotes.tsx','PackageUpdates.tsx','ui.tsx','files.tsx','dialogs.tsx','screens/Account.tsx','screens/Feedback.tsx','screens/Workspace.tsx','screens/Assistant.tsx','screens/ArrivalOperation.tsx','screens/ArrivalActions.tsx','screens/ArrivalListParts.tsx','screens/ServerConnection.tsx','screens/BusinessList.tsx','screens/BatchOperation.tsx','screens/NoticeContent.tsx','screens/FileLibrary.tsx','controls/Choice.tsx','controls/DateField.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('screens/BusinessList.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'),/onAction=\{draftAction\}/);assert.match(source('screens/Assistant.tsx'),/onAction\(draft,'execute'\)/);assert.match(source('screens/Assistant.tsx'),/Alert\.alert\('确认执行业务'/);
assert.doesNotMatch(app,/reloadAsync/);
});