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

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

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