فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
qa(ui): export source-level per-file event catalog including hidden and sensitive controls
davoodmehraban89 committed
Oct 30, 2026 at 23:23 UTC
77eddc4023ef8c7fc300a736f60cff8179066863
1 file changed
+51
scripts/q01-ui-control-catalog.cjs
new
+51
@@ -0,0 +1,51 @@
1
+'use strict';
2
+// Q01 source-level inventory. This is NOT a runtime click test and is
3
+// intentionally separate from the installed WebView2 native-click report.
4
+const fs=require('node:fs'),path=require('node:path');
5
+const root=path.resolve(__dirname,'..');
6
+const paths=['index.html',...fs.readdirSync(path.join(root,'src','views'))
7
+ .filter(x=>x.endsWith('.js')).sort().map(x=>'src/views/'+x)];
8
+const controls=[],summary=[];
9
+const risk=/\b(?:delete|wipe|remove|restore|save|post|submit|confirm|activate|seed|commit|final|approve|closePeriod|logout|export|import|download|print|settle|apply|reset|changeStatus|_save|_apply|_commit)\s*\(/i;
10
+const line=(s,i)=>s.slice(0,i).split('\n').length;
11
+for(const file of paths){
12
+ const source=fs.readFileSync(path.join(root,file),'utf8');
13
+ const matches=[...source.matchAll(/on(?:click|change|input|submit|mousedown|blur|focus|keyup|keydown)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)];
14
+ let highRisk=0;
15
+ for(const hit of matches){
16
+ const action=hit[1]||hit[2]||'';
17
+ const risky=risk.test(action);
18
+ if(risky)highRisk++;
19
+ controls.push({file,line:line(source,hit.index),action:action.slice(0,250),
20
+ category:risky?'sensitive-write-or-export':'navigation-or-other',
21
+ evidence:'declared-source-handler',runtimeClicked:false,
22
+ warning:'source reference does not prove successful click'});
23
+ }
24
+ // Controls without inline handlers may use event listeners/delegation.
25
+ // Keep them in the inventory instead of incorrectly calling them dead.
26
+ let noInline=0;
27
+ for(const hit of source.matchAll(/<button\b[^>]*>/g)){
28
+ const tag=hit[0];
29
+ if(!/\bon(?:click|change|input|submit)\s*=/.test(tag))noInline++;
30
+ }
31
+ const mainNav=[...source.matchAll(/data-page="([a-z]+)"/g)]
32
+ .map(hit=>({route:hit[1],line:line(source,hit.index)}));
33
+ summary.push({file,inlineEventBindings:matches.length,sensitiveBindings:highRisk,
34
+ buttonsWithoutInlineEvents:noInline,mainNav});
35
+}
36
+const report={
37
+ kind:'Q01 static UI source inventory, not click coverage',
38
+ filesScanned:paths.length,
39
+ eventBindings:controls.length,
40
+ sensitiveBindings:controls.filter(x=>x.category==='sensitive-write-or-export').length,
41
+ buttonsWithoutInlineEvents:summary.reduce((n,x)=>n+x.buttonsWithoutInlineEvents,0),
42
+ controlStatus:'source-declared-only',
43
+ allButtonsClicked:false,
44
+ sourceFiles:summary,controls
45
+};
46
+const filename=process.argv[2]||path.join(root,'q01-ui-static-catalog.json');
47
+fs.writeFileSync(filename,JSON.stringify(report,null,2),'utf8');
48
+process.stdout.write(JSON.stringify({file:path.basename(filename),filesScanned:report.filesScanned,
49
+ eventBindings:report.eventBindings,sensitiveBindings:report.sensitiveBindings,
50
+ buttonsWithoutInlineEvents:report.buttonsWithoutInlineEvents,
51
+ allButtonsClicked:false})+'\n');