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

test(q01): separate real tabs from presets and reset default tab before filter probes

davoodmehraban89 committed Oct 31, 2026 at 10:06 UTC 581452202985b840288bbce45256ebf143f4d96d
1 file changed +24 -6
tests/windows-vm-ui-interaction-audit-browser.js
+24 -6
@@ -32,9 +32,9 @@
32 handler(el).replace(/\s+/g,' ').slice(0,180)
33 ].join('|');
34 const dangerous = /(?:^|[.\s])(?:_?(?:save|delete|wipe|restore|post|submit|confirm|activate|seed|commit|final|approve|logout|export|import|download|print|settle|apply|reset|changeStatus|remove)\w*)\s*\(/i;
35 - const safeTab = /\.(?:_switchTab|switchTab|_switchPeriod|_setPreset)\s*\(/;
35 + const safeTab = /\.(?:_switchTab|switchTab)\s*\(/;
36 const safeNavigate = /FINORA\.Router\.go\s*\(/;
37 - const safeFilter = /\.(?:_togglePreInvoice|_setStockFilter|_clearFilters|_applyCustom|refresh|setTheme)\s*\(/;
37 + const safeFilter = /\.(?:_togglePreInvoice|_setStockFilter|_clearFilters|_applyCustom|_switchPeriod|_setPreset|refresh|setTheme)\s*\(/;
38 // These handlers only open an editor/preview/diagnostic dialog. The audit
39 // closes it without saving; a separate fixture-backed test owns commits.
40 const safeOpen = /\.(?:openNewInvoice|openProductModal|openUnitModal|openCategoryModal|openContactModal|openExpenseModal|openChequeModal|openAccountModal|openReceiptModal|openPaymentModal|openTransferModal|openCompanyModal|openCompanySwitcher|openExportSectionModal|openSignedLicenseModal|openAuditTrail|openWipeModal|openRestoreModal|openPeriodModal|openJournalModal|openWarehouse|openStocktakeCreate|openTransfer|openReversal|_openQuickProduct|_openQuickContact|openLedger|openKardex|openStocktake|showJournal|editInvoice|editProduct|editContact|editCheque|editAccount|openAdjustModal|printInvoice|checkHolooMigrationReadiness|runFinancialDiagnostics)\s*\(/;
@@ -577,8 +577,8 @@
577 // Evaluate each known safe top-level tab. The router is reset between
578 // clicks to avoid mutating references after HTML rerendering.
579 const tabActions=[...new Set(tabs.map(el=>handler(el)))];
580 - const contexts=[{section:'root',tabAction:null}];
581 - for (const action of tabActions) contexts.push({section:'tab-'+contexts.length,tabAction:action});
580 + const contexts=[{section:'root',tabAction:tabActions[0]||null}];
581 + for (const action of tabActions.slice(1)) contexts.push({section:'tab-'+contexts.length,tabAction:action});
582 // Delay filters until all row-scoped edit and confirmation actions have
583 // been inspected. A filter can hide the very rows needed by later probes.
584 const deferredSafeActions=[];
@@ -743,7 +743,12 @@
743 // Only now click reversible navigation and filter controls. Keeping this
744 // after every row-scoped action prevents filters hiding edit/delete targets.
745 for(const group of deferredSafeActions){
746 - for(const action of group.actions){
746 + const pending=[...group.actions];
747 + const seen=new Set(pending.map(action=>JSON.stringify([
748 + action.tag,action.label,action.handler
749 + ])));
750 + for(let index=0;index<pending.length;index++){
751 + const action=pending[index];
752 window.__Q01_AUDIT_STAGE='safe-action:'+route+':'+action.handler;
753 await go(route);
754 if(group.tabAction){
@@ -753,7 +758,7 @@
758 continue;
759 }
760 inventory(route,'root');
756 - tab.click();await wait(160);
761 + tab.click();await wait(320);
762 }
763 const el=clickables(target()).find(x=>
764 handler(x)===action.handler && name(x)===action.label &&
@@ -766,6 +771,19 @@
771 inventory(route,group.section);
772 await press(el,route,group.section,
773 safeNavigate.test(action.handler)?'navigation':'filter');
774 + // Preset/toggle controls can reveal a second safe control (for example
775 + // the custom-report Apply button). Discover and verify that state too.
776 + if(safeFilter.test(action.handler)){
777 + await wait(80);
778 + inventory(route,group.section);
779 + for(const candidate of clickables(target()).filter(x=>
780 + !x.disabled && safeFilter.test(handler(x)))){
781 + const next={handler:handler(candidate),label:name(candidate),
782 + tag:candidate.tagName.toLowerCase()};
783 + const key=JSON.stringify([next.tag,next.label,next.handler]);
784 + if(!seen.has(key)){seen.add(key);pending.push(next);}
785 + }
786 + }
787 }
788 }
789 }