cmvr-wms/mobile-app/tests/operation-guide.test.mjs

24 lines
1.4 KiB
JavaScript
Raw Normal View History

import test from 'node:test';
import assert from 'node:assert/strict';
import {modules} from '../src/core/modules.ts';
import {readFile} from 'node:fs/promises';
test('only dependency-sensitive mobile pages have concise operation guidance', () => {
assert.deepEqual(modules.filter(m=>m.guide).map(m=>m.key), ['arrival','use','move','count','stock','purchase','pending','loans','check','production']);
for(const m of modules.filter(m=>m.guide)) {
assert.ok(m.guide.length <= 80, `${m.key} should not become a manual`);
assert.ok(!m.guide.includes('\n'));
}
});
test('mobile guide belongs to a header action, not a permanent list banner', async()=>{
const app=await readFile(new URL('../src/App.tsx',import.meta.url),'utf8');
assert.ok(app.includes("accessibilityLabel={selected.title+'操作指引'}"));
assert.ok(app.includes("Alert.alert(selected.title+' · 操作指引',selected.guide)"));
assert.ok(!app.slice(app.indexOf('function BusinessList')).includes('module.guide'));
});
test('guidance distinguishes creating records from changing actual stock', () => {
assert.match(modules.find(m=>m.key==='pending').guide, /确认后,才计入库存/);
assert.match(modules.find(m=>m.key==='check').guide, /不是差异数量.*确认后才调整库存/);
assert.match(modules.find(m=>m.key==='production').guide, /物品、产品和 BOM.*生产任务/);
});