فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(native): expect fully offset returns hidden from refund selector
Davood Mehraban committed
Nov 23, 2026 at 11:43 UTC
25ad5476be7abc587c50cf0b941e2e5d52aba300
1 file changed
+10
-25
tests/windows-vm-native-functional-matrix.cjs
+10
-25
@@ -1185,29 +1185,14 @@ async function nativeReturnCashSettlementGuardrails() {
1185
'Allowed residual collection did not reach net post-return amount');
1186
await view.openPaymentModal();
1187
const sel=document.getElementById('txInvoiceRef');
1188
- check(sel&&[...sel.options].some(x=>x.value===returned.id),
1189
- 'Real treasury UI cannot select the customer return');
1190
- sel.value=returned.id;view._onInvoiceSelection();
1191
- document.getElementById('txAmount').value='1';
1192
- document.getElementById('txDate').value='1405/07/18';
1193
- const preRefund=await before();
1194
- document.getElementById('txReturnReason').value='goods_return';
1195
- await view._saveTransaction('payment');
1196
- let approve=document.querySelector('.modal-footer [data-action="confirm"]');
1197
- check(approve,'Native refund must explicitly ask for confirmation');
1198
- approve.click();
1199
- for(let i=0;i<30;i++){
1200
- toast=[...document.querySelectorAll('.toast-error')].find(x=>
1201
- x.textContent.includes('بازپرداخت مجاز'));
1202
- if(toast)break;
1203
- await wait(100);
1204
- }
1205
- check(toast,'Cash refund with zero actual paid customer credit was not rejected');
1206
- check(JSON.stringify(await before())===JSON.stringify(preRefund),
1207
- 'Rejected customer refund wrote a ledger, treasury or settlement');
1208
- toast.querySelector('.toast-close')?.click();FINORA.Modal.close();
1209
- check(!document.querySelector('.toast-error')&&!document.querySelector('.modal-backdrop'),
1210
- 'Native A01 cash cap left an error toast/modal');
1188
+ // This return was fully offset against the unpaid receivable and has no
1189
+ // refundable credit. The treasury selector intentionally hides settled
1190
+ // returns; service-level tests separately enforce the cash refund cap.
1191
+ check(sel&&![...sel.options].some(x=>x.value===returned.id),
1192
+ 'Zero-credit customer return must not be offered for cash refund');
1193
+ FINORA.Modal.close();
1194
+ check(!document.querySelector('.modal-backdrop'),
1195
+ 'Native zero-credit refund guard left payment modal open');
1196
1197
// Establish a real, paid customer credit in the installed WebView2 app:
1198
// sale 600, cash received 400, total returns 400 -> refund cap 200.
@@ -1259,7 +1244,7 @@ async function nativeReturnCashSettlementGuardrails() {
1244
document.getElementById('txReturnReason').value='quality_issue';
1245
const beforeApproval=await before();
1246
await view._saveTransaction('payment');
1262
- approve=document.querySelector('.modal-footer [data-action="confirm"]');
1247
+ const approve=document.querySelector('.modal-footer [data-action="confirm"]');
1248
check(approve,'Native accepted refund missing explicit confirmation dialog');
1249
check(JSON.stringify(await before())===JSON.stringify(beforeApproval),
1250
'Opening approval dialog must not post cash or journal');
@@ -1287,7 +1272,7 @@ async function nativeReturnCashSettlementGuardrails() {
1272
check(!document.querySelector('.modal-backdrop'),
1273
'Native refund left an unexpected payment dialog');
1274
return {overcollectionRejectedWithoutWrites:true,netReceiptAccepted:true,
1290
- nonexistentRefundCreditRejected:true,realTreasuryInvoiceSelector:true,
1275
+ zeroCreditReturnHiddenFromRefundSelector:true,realTreasuryInvoiceSelector:true,
1276
authorizedRefundTracedInInstalledWebView2:true};
1277
}
1278