فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

test(q01): verify actionable Markdown gap report and reject untrusted or mismatched native evidence

davoodmehraban89 committed Oct 30, 2026 at 23:50 UTC c864bff0a29b3a81bcefc3b3ddb1ab7b8cf0fda3
1 file changed +28
tests/ui-control-structure.test.mjs
+28
@@ -2,6 +2,7 @@ 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 { createRequire } from 'node:module';
6 import { execFileSync } from 'node:child_process';
7 import path from 'node:path';
8 import { fileURLToPath } from 'node:url';
@@ -173,3 +174,30 @@ test('Q01: native click audit separates unique action signatures from repeated t
174 assert.ok(native.includes("x.status!=='not-clicked' || !!x.reason"),
175 'every unclicked action occurrence must have a reason');
176 });
177 +
178 +test('Q01: unverified-action Markdown respects deduplicated click evidence and fails closed', () => {
179 + const require=createRequire(import.meta.url);
180 + const { buildReport }=require(path.join(root,'scripts','q01-native-action-gap-report.cjs'));
181 + const synthetic={
182 + environment:'installed-Windows-Tauri-WebView2-synthetic-VM',
183 + everyActionVerified:false,customerDataUsed:false,
184 + uniqueActionCount:2,uniqueActionClicked:1,uniqueActionUnverified:1,
185 + uniqueActionDisabled:0,uniqueActionFailed:0,
186 + duplicateInstanceCount:1,inventoryCount:3,
187 + controls:[{},{},{}],
188 + uniqueActions:[
189 + {route:'invoices',tag:'button',label:'ثبت نهایی',handler:'InvoiceForm.save()',
190 + status:'not-clicked',whyNotVerified:'requires synthetic financial fixture'},
191 + {route:'invoices',tag:'button',label:'لغو',handler:'Modal.close()',
192 + status:'clicked',whyNotVerified:''}
193 + ],
194 + problems:[{route:'invoices',kind:'manual-review',label:'fixture needed'}]
195 + };
196 + const md=buildReport(synthetic);
197 + assert.match(md,/ثبت نهایی/);
198 + assert.match(md,/requires synthetic financial fixture/);
199 + assert.match(md,/امضاهای کنترلی متمایز \| 2/);
200 + assert.doesNotMatch(md,/\| لغو \| clicked/,'clicked actions do not belong in gap list');
201 + assert.throws(()=>buildReport({...synthetic,everyActionVerified:true}),/UNVERIFIED_INPUT/);
202 + assert.throws(()=>buildReport({...synthetic,inventoryCount:500}),/COUNT_MISMATCH/);
203 +});