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

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

davoodmehraban89 committed Oct 31, 2026 at 10:05 UTC 055fb39a6e4da431835d8c99117a2a6ee8b801ba
1 file changed +24 -6
tests/windows-vm-ui-interaction-audit-browser.js
+24 -6
@@ -31,9 +31,9 @@
31 handler(el).replace(/\s+/g,' ').slice(0,180)
32 ].join('|');
33 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;
34 - const safeTab = /\.(?:_switchTab|switchTab|_switchPeriod|_setPreset)\s*\(/;
34 + const safeTab = /\.(?:_switchTab|switchTab)\s*\(/;
35 const safeNavigate = /FINORA\.Router\.go\s*\(/;
36 - const safeFilter = /\.(?:_togglePreInvoice|_setStockFilter|_clearFilters|_applyCustom|refresh|setTheme)\s*\(/;
36 + const safeFilter = /\.(?:_togglePreInvoice|_setStockFilter|_clearFilters|_applyCustom|_switchPeriod|_setPreset|refresh|setTheme)\s*\(/;
37 // These handlers only open an editor/preview/diagnostic dialog. The audit
38 // closes it without saving; a separate fixture-backed test owns commits.
39 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*\(/;
@@ -576,8 +576,8 @@
576 // Evaluate each known safe top-level tab. The router is reset between
577 // clicks to avoid mutating references after HTML rerendering.
578 const tabActions=[...new Set(tabs.map(el=>handler(el)))];
579 - const contexts=[{section:'root',tabAction:null}];
580 - for (const action of tabActions) contexts.push({section:'tab-'+contexts.length,tabAction:action});
579 + const contexts=[{section:'root',tabAction:tabActions[0]||null}];
580 + for (const action of tabActions.slice(1)) contexts.push({section:'tab-'+contexts.length,tabAction:action});
581 // Delay filters until all row-scoped edit and confirmation actions have
582 // been inspected. A filter can hide the very rows needed by later probes.
583 const deferredSafeActions=[];
@@ -740,7 +740,12 @@
740 // Only now click reversible navigation and filter controls. Keeping this
741 // after every row-scoped action prevents filters hiding edit/delete targets.
742 for(const group of deferredSafeActions){
743 - for(const action of group.actions){
743 + const pending=[...group.actions];
744 + const seen=new Set(pending.map(action=>JSON.stringify([
745 + action.tag,action.label,action.handler
746 + ])));
747 + for(let index=0;index<pending.length;index++){
748 + const action=pending[index];
749 window.__Q01_AUDIT_STAGE='safe-action:'+route+':'+action.handler;
750 await go(route);
751 if(group.tabAction){
@@ -750,7 +755,7 @@
755 continue;
756 }
757 inventory(route,'root');
753 - tab.click();await wait(160);
758 + tab.click();await wait(320);
759 }
760 const el=clickables(target()).find(x=>
761 handler(x)===action.handler && name(x)===action.label &&
@@ -763,6 +768,19 @@
768 inventory(route,group.section);
769 await press(el,route,group.section,
770 safeNavigate.test(action.handler)?'navigation':'filter');
771 + // Preset/toggle controls can reveal a second safe control (for example
772 + // the custom-report Apply button). Discover and verify that state too.
773 + if(safeFilter.test(action.handler)){
774 + await wait(80);
775 + inventory(route,group.section);
776 + for(const candidate of clickables(target()).filter(x=>
777 + !x.disabled && safeFilter.test(handler(x)))){
778 + const next={handler:handler(candidate),label:name(candidate),
779 + tag:candidate.tagName.toLowerCase()};
780 + const key=JSON.stringify([next.tag,next.label,next.handler]);
781 + if(!seen.has(key)){seen.add(key);pending.push(next);}
782 + }
783 + }
784 }
785 }
786 }