سامانه صدور فاکتور و حسابداری
Test financial sync conflict reconciliation
davoodmehraban89 committed
Sep 29, 2026 at 22:25 UTC
a060e38bcdc01684f7a875047c0dc3099846ba8b
1 file changed
+6
scripts/phase5-behavior-check.mjs
+6
@@ -17,4 +17,10 @@ let restoreRejected=false;try{vm.runInContext("absorbRecords({products:[{id:'P1'
17
const atomicState=vm.runInContext("({product:datastore.products.find(x=>x.id==='P1').name,debit:datastore.journalLines.find(x=>x.id==='JL1').debit})",syncCtx);if(atomicState.product!=='Before'||atomicState.debit!==100)throw new Error('failed restore was not atomic');
18
vm.runInContext("absorbRecords({products:[{id:'P1',name:'After'}]})",syncCtx);if(vm.runInContext("datastore.products.find(x=>x.id==='P1').name",syncCtx)!=='After')throw new Error('safe mutable restore merge failed');
19
console.log('Phase 5 restore atomicity and posted-history protection passed.');
20
+syncCtx.pullAllCalls=0;vm.runInContext("pullAll=async()=>{pullAllCalls++;};refreshAllSurfaces=()=>{};alert=()=>{};",syncCtx);
21
+await vm.runInContext("handleSyncError({code:'23505',message:'duplicate key value violates unique constraint'})",syncCtx);
22
+if(syncCtx.pullAllCalls!==1||vm.runInContext("syncPending",syncCtx)!==false)throw new Error('concurrent unique conflict was not reconciled from server');
23
+syncCtx.pullAllCalls=0;await vm.runInContext("handleSyncError({code:'P0001',message:'posted/reversed journal voucher is immutable'})",syncCtx);
24
+if(syncCtx.pullAllCalls!==1||vm.runInContext("syncPending",syncCtx)!==false)throw new Error('immutable-history conflict was not reconciled from server');
25
+console.log('Phase 5 financial sync conflict reconciliation passed.');
26