22 lines
1.8 KiB
JavaScript
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/);
|
||
|
|
});
|