فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(q01): fix modal audit instance deduplication
davoodmehraban89 committed
Oct 31, 2026 at 21:43 UTC
8da70a55fdaa3ae7650a9715eb13a9c6122bee6a
1 file changed
+18
-11
tests/windows-vm-ui-interaction-audit-browser.js
+18
-11
@@ -131,11 +131,14 @@
131
}
132
return {detected:true,valid:typeof obj==='function',callee:m[1]};
133
}
134
- const seenClick = new Set();
134
+ // De-duplicate a physical DOM node, not a handler signature. The same
135
+ // action is intentionally exercised in several freshly opened modal
136
+ // instances; signature-level de-duplication skipped those clicks and made
137
+ // later instances look broken even though only the first was exercised.
138
+ const seenClick = new WeakSet();
139
async function press(el, route, section, category) {
136
- const k=sig(el,route,section);
137
- if (seenClick.has(k)) return;
138
- seenClick.add(k);
140
+ if (seenClick.has(el)) return;
141
+ seenClick.add(el);
142
const row=all.get(k);
143
const before=target().innerHTML;
144
const beforeModal=!!document.querySelector('.modal-backdrop');
@@ -784,12 +787,15 @@
787
const initialRows=itemsBody.querySelectorAll('tr').length;
788
registerControl(addRow,route,ctx.section+'/modal');
789
await press(addRow,route,ctx.section+'/modal','open');
787
- const afterAdd=itemsBody.querySelectorAll('tr').length;
790
+ // _renderItems replaces tbody.innerHTML. Re-query the live node;
791
+ // the original itemsBody reference is detached after a render.
792
+ const currentItemsBody=overlay.querySelector('#itemsBody');
793
+ const afterAdd=currentItemsBody?.querySelectorAll('tr').length ?? 0;
794
if(afterAdd!==initialRows+1){
795
failures.push({route,section:ctx.section,kind:'invoice-draft-add-row-failed',
796
initialRows,afterAdd});
797
} else {
792
- const lastRow=itemsBody.querySelector('tr:last-child');
798
+ const lastRow=currentItemsBody.querySelector('tr:last-child');
799
const removeLast=clickables(lastRow).find(x=>
800
/InvoiceFormView\._removeRow\s*\(\d+\)/.test(handler(x)));
801
if(!removeLast){
@@ -797,20 +803,21 @@
803
} else {
804
registerControl(removeLast,route,ctx.section+'/modal');
805
await press(removeLast,route,ctx.section+'/modal','open');
800
- const afterRestore=itemsBody.querySelectorAll('tr').length;
806
+ const afterRestore=overlay.querySelector('#itemsBody')?.querySelectorAll('tr').length ?? 0;
807
if(afterRestore!==initialRows){
808
failures.push({route,section:ctx.section,kind:'invoice-draft-row-count-not-restored',
809
initialRows,afterRestore});
810
}
811
}
812
}
807
- const remainingFirst=clickables(itemsBody).find(x=>
813
+ const remainingBody=overlay.querySelector('#itemsBody');
814
+ const remainingFirst=clickables(remainingBody).find(x=>
815
/InvoiceFormView\._removeRow\(0\)/.test(handler(x)));
809
- if(remainingFirst && itemsBody.querySelectorAll('tr').length===1){
816
+ if(remainingFirst && remainingBody.querySelectorAll('tr').length===1){
817
registerControl(remainingFirst,route,ctx.section+'/modal');
811
- const beforeGuard=itemsBody.querySelectorAll('tr').length;
818
+ const beforeGuard=remainingBody.querySelectorAll('tr').length;
819
await press(remainingFirst,route,ctx.section+'/modal','open');
813
- const afterGuard=itemsBody.querySelectorAll('tr').length;
820
+ const afterGuard=overlay.querySelector('#itemsBody')?.querySelectorAll('tr').length ?? 0;
821
if(afterGuard!==beforeGuard){
822
failures.push({route,section:ctx.section,kind:'invoice-last-row-removal-not-blocked',
823
beforeGuard,afterGuard});