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

test(q01): defer filters until row-scoped actions are verified

davoodmehraban89 committed Oct 31, 2026 at 09:49 UTC 66d2e8b37d7b2f6c7d9851d62d34fa4676b15622
1 file changed +32 -13
tests/windows-vm-ui-interaction-audit-browser.js
+32 -13
@@ -36,7 +36,7 @@
36 const safeFilter = /\.(?:_togglePreInvoice|_setStockFilter|_clearFilters|_applyCustom|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|changeStatus|openAdjustModal|_printInvoice|printInvoice|checkHolooMigrationReadiness|runFinancialDiagnostics)\s*\(/;
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*\(/;
40 // A delete/close-period/seed action is safe to probe only up to its
41 // confirmation prompt. The audit must cancel and prove zero database writes.
42 const safeConfirmAction = /\.(?:deleteInvoice|deleteProduct|deleteContact|deleteCheque|deleteTransaction|deleteExpense|deleteAccount|closePeriod|seedChart)\s*\(/;
@@ -578,6 +578,9 @@
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});
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=[];
584 for (const ctx of contexts) {
585 await go(route);
586 if (ctx.tabAction) {
@@ -610,21 +613,13 @@
613 row.status='not-clicked';row.reason='not on audited safe-action allowlist';
614 }
615 }
613 - // Exercise read-only navigation, filters and reversible view settings.
616 + // Queue safe navigation and filter actions for after all contexts.
617 const safeActions=[...new Set(controls
618 .filter(el=>!el.disabled && (safeNavigate.test(handler(el)) || safeFilter.test(handler(el))))
619 .map(el=>handler(el)))];
617 - for (const action of safeActions) {
618 - await go(route);
619 - if (ctx.tabAction) {
620 - const tab=clickables(target()).find(el=>handler(el)===ctx.tabAction);
621 - if(tab){tab.click();await wait(160);}
622 - }
623 - const el=clickables(target()).find(x=>handler(x)===action);
624 - if(!el){failures.push({route,section:ctx.section,kind:'safe-action-vanished',handler:action});continue;}
625 - inventory(route,ctx.section);
626 - await press(el,route,ctx.section,safeNavigate.test(action)?'navigation':'filter');
627 - }
620 + if(safeActions.length) deferredSafeActions.push({
621 + section:ctx.section,tabAction:ctx.tabAction,actions:safeActions
622 + });
623 // Open destructive confirmation prompts, but NEVER approve them here.
624 // Compare every persistent store before/after Cancel to prove no write.
625 const confirmStores=['users','companies','contacts','products','units','categories',
@@ -740,6 +735,30 @@
735 dismiss();
736 }
737 }
738 + // Only now click reversible navigation and filter controls. Keeping this
739 + // after every row-scoped action prevents filters hiding edit/delete targets.
740 + for(const group of deferredSafeActions){
741 + for(const action of group.actions){
742 + window.__Q01_AUDIT_STAGE='safe-action:'+route+':'+action;
743 + await go(route);
744 + if(group.tabAction){
745 + const tab=clickables(target()).find(el=>handler(el)===group.tabAction);
746 + if(!tab){
747 + failures.push({route,section:group.section,kind:'safe-tab-vanished',handler:group.tabAction});
748 + continue;
749 + }
750 + inventory(route,'root');
751 + await press(tab,route,'root','tab');
752 + }
753 + const el=clickables(target()).find(x=>handler(x)===action);
754 + if(!el){
755 + failures.push({route,section:group.section,kind:'safe-action-vanished',handler:action});
756 + continue;
757 + }
758 + inventory(route,group.section);
759 + await press(el,route,group.section,safeNavigate.test(action)?'navigation':'filter');
760 + }
761 + }
762 }
763 await FINORA.Router.go('dashboard');
764 const rows=[...all.values()];