@davoodmehraban89 / Factor-easy / commits / 49f5850
Fork 0

سامانه صدور فاکتور و حسابداری

test: capture legacy RPC payload shape behind sync version conflicts (#216)

davoodmehraban89 committed Nov 18, 2026 at 16:00 UTC 49f5850f38c5d9fa981062f93a5320c88ef9f416
1 file changed +2 -2
scripts/accounting-document-workflow.spec.js
+2 -2
@@ -60,7 +60,7 @@ async function installHarness(page,server){
60 return {error:{message:'FINORA_POSTED_SOURCE_VOUCHER_IMMUTABLE',code:'23514'}};
61 if(row.collection==='journalLines'&&parentVoucher&&parentVoucher.data.status==='posted'&&['sale','purchase'].includes(parentVoucher.data.sourceType))
62 return {error:{message:'FINORA_POSTED_SOURCE_VOUCHER_IMMUTABLE',code:'23514'}};
63 - if(Number(row.expected_version||0)!==currentVersion){console.log('FINORA_F0_VERSION_CONFLICT',JSON.stringify({key,expected:row.expected_version,actual:currentVersion,rpcCount:server.rpcCount}));return {error:{message:'FINORA_VERSION_CONFLICT',code:'40001'}};}
63 + if(Number(row.expected_version||0)!==currentVersion){console.log('FINORA_F0_VERSION_CONFLICT',JSON.stringify({key,expected:row.expected_version,actual:currentVersion,rpcCount:server.rpcCount,upsertKeys:Object.keys(row),rpcKeys:Object.keys(args),rawExpectedVersion:row.expectedVersion}));return {error:{message:'FINORA_VERSION_CONFLICT',code:'40001'}};}
64 const version=currentVersion+1;
65 server.records.set(key,{collection:row.collection,id:row.id,data:copy(row.data),version});
66 upserts.push({collection:row.collection,id:row.id,version});
@@ -181,7 +181,7 @@ async function authenticatedMockBrowser(page){
181 window.requireFreshFinoraMembership=async()=>true;
182 sb.rpc=async(name,args)=>{
183 // Both deployed sync RPC entrypoints share the same transactional mock contract.
184 - if(name==='finora_sync_records_v2'||name==='finora_sync_records')return await window.qaF0Write(args);
184 + if(name==='finora_sync_records_v2'||name==='finora_sync_records'){if(name==='finora_sync_records')console.log('FINORA_F0_LEGACY_RPC_SHAPE',JSON.stringify({keys:Object.keys(args||{}),firstUpsert:(args?.p_upserts||[])[0]||null}));return await window.qaF0Write(args);}
185 if(name==='finora_journal_autopost')return await window.qaF0AutoPost(args);
186 if(name==='finora_journal_reverse')return await window.qaF0Reverse(args);
187 throw Error('Unexpected RPC '+name);