فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(q01): reject misclassification of finance writes as safe UI navigation in generated audit catalog
davoodmehraban89 committed
Oct 30, 2026 at 23:45 UTC
2b122282f770fc90abea48ae84943f84cb1676cd
1 file changed
+32
tests/ui-control-structure.test.mjs
+32
@@ -1,6 +1,8 @@
1
import test from 'node:test';
2
import assert from 'node:assert/strict';
3
import fs from 'node:fs';
4
+import os from 'node:os';
5
+import { execFileSync } from 'node:child_process';
6
import path from 'node:path';
7
import { fileURLToPath } from 'node:url';
8
@@ -126,3 +128,33 @@ test('Q01: installed WebView2 must click synthetic modal Cancel/Confirm and trap
128
'modalKeyboard.syntheticConfirmRunsExactlyOnce'
129
]) assert.ok(native.includes(check),'installed native runner must assert: '+check);
130
});
131
+
132
+test('Q01: financial mutations are not mislabeled safe by the static control catalog', () => {
133
+ const dir=fs.mkdtempSync(path.join(os.tmpdir(),'q01-source-catalog-'));
134
+ try {
135
+ const output=path.join(dir,'catalog.json');
136
+ execFileSync(process.execPath,[path.join(root,'scripts','q01-ui-control-catalog.cjs'),output],{
137
+ cwd:root,encoding:'utf8',timeout:20000,stdio:['ignore','pipe','pipe']
138
+ });
139
+ const catalog=JSON.parse(fs.readFileSync(output,'utf8'));
140
+ assert.ok(catalog.eventBindings>=200,'unexpectedly few view event bindings');
141
+ assert.ok(catalog.sensitiveBindings>=40,
142
+ 'financial actions were not classified conservatively; check verb+suffix matcher');
143
+ assert.equal(catalog.allButtonsClicked,false);
144
+ for (const name of ['saveJournal','postDraft','deleteDraft',
145
+ 'confirmOpeningPosting','saveCheque','saveProduct','restoreBackup','confirmWipe']) {
146
+ const matches=catalog.controls.filter(x=>x.action.includes('.'+name+'('));
147
+ assert.ok(matches.length>0,'sensitive action not discovered: '+name);
148
+ assert.ok(matches.every(x=>x.category==='sensitive-write-or-export'),
149
+ 'sensitive action incorrectly marked navigation: '+name);
150
+ assert.ok(matches.every(x=>x.runtimeClicked===false),
151
+ 'source catalog must not claim runtime interaction: '+name);
152
+ }
153
+ const safe=catalog.controls.filter(x=>/\.(?:switchTab|_switchTab)\s*\(/.test(x.action));
154
+ assert.ok(safe.length>0,'navigation controls not discovered');
155
+ assert.ok(safe.some(x=>x.category==='navigation-or-other'),
156
+ 'all menu actions incorrectly categorized as financial writes');
157
+ } finally {
158
+ fs.rmSync(dir,{recursive:true,force:true});
159
+ }
160
+});