Treasury & Bank Transfer Management System — سامانه مدیریت خزانه‌داری و حواله‌های بانکی

test(windows): verify synthetic SQLite durability through installed Next HTTP after native Electron restart

davoodmehraban89 committed Oct 17, 2026 at 02:10 UTC 2cfbc14bba3cebbc7758557ca5d8027e41963967
1 file changed +21 -10
qa/windows/electron-native-gui-smoke.mjs
+21 -10
@@ -10,7 +10,7 @@ assert(exe&&existsSync(exe),'real installed TreasuryFlow.exe required');
10 assert(reportDir,'evidence output directory required');
11 mkdirSync(reportDir,{recursive:true});
12 const port=9345;
13 -const report={mode:'REAL_INSTALLED_ELECTRON_CDP',exe:basename(exe),cdp:false,localOrigin:false,integrations:false,queryEditor:false,copyQuery:false,copyExactlyEditedSql:false,clipboardMode:'INTERCEPTED_API_NOT_WINDOWS_CLIPBOARD',screenshot:false,stage:'connect',cdpReconnections:0,localEntry:false,visitedRoutes:[],syntheticAccount:false,syntheticBeneficiary:false,syntheticDraft:false,appReopened:false,durableData:false,auditPersisted:false,upgrade:'NOT_RUN_NO_BASELINE',outcome:'NOT_RUN'};
13 +const report={mode:'REAL_INSTALLED_ELECTRON_CDP',exe:basename(exe),cdp:false,localOrigin:false,integrations:false,queryEditor:false,copyQuery:false,copyExactlyEditedSql:false,clipboardMode:'INTERCEPTED_API_NOT_WINDOWS_CLIPBOARD',screenshot:false,stage:'connect',cdpReconnections:0,localEntry:false,visitedRoutes:[],syntheticAccount:false,syntheticBeneficiary:false,syntheticDraft:false,appReopened:false,persistenceEvidenceMethod:'NOT_RUN',postRestartRoutes:[],durableData:false,auditPersisted:false,upgrade:'NOT_RUN_NO_BASELINE',outcome:'NOT_RUN'};
14 const sleep=ms=>new Promise(r=>setTimeout(r,ms));
15 async function wait(fn,timeout=75000){let error;const until=Date.now()+timeout;while(Date.now()<until){try{const x=await fn();if(x)return x;}catch(e){error=e;}await sleep(400);}throw error||Error('CDP_WAIT_TIMEOUT');}
16 async function connect(url){
@@ -180,16 +180,27 @@ try{
180 return targets.find(p=>p.type==='page'&&p.url?.startsWith(origin)&&p.webSocketDebuggerUrl)?.webSocketDebuggerUrl;
181 },75000);
182 conn=await connect(second);report.appReopened=true;
183 - await go('/accounts','حساب‌های بانکی');
184 - assert(await conn.evaluate("document.body.innerText.includes('VM-SYNTHETIC-SOURCE')"),'NATIVE_ACCOUNT_NOT_DURABLE');
185 - await go('/beneficiaries','طرف‌حساب‌ها');
186 - assert(await conn.evaluate("document.body.innerText.includes('VM-SYNTHETIC-BENEFICIARY')"),'NATIVE_BENEFICIARY_NOT_DURABLE');
187 - await go('/payments','حواله‌ها');
188 - assert(await conn.evaluate("document.body.innerText.includes('VM-DRAFT-')"),'NATIVE_DRAFT_NOT_DURABLE');
183 + report.persistenceEvidenceMethod='INSTALLED_ELECTRON_HTTP_AFTER_CDP_REOPEN';
184 + report.postRestartRoutes=[];
185 + const pageHtml=async(route,marker)=>{
186 + report.stage='post-restart-http:'+route;
187 + const html=await wait(async()=>{
188 + if(proc.exitCode!==null)throw Error('RESTARTED_ELECTRON_EXITED_'+proc.exitCode);
189 + const response=await fetch(origin+route,{signal:AbortSignal.timeout(4000)});
190 + if(response.status!==200)return null;
191 + const body=await response.text();
192 + return body.includes(marker)?body:null;
193 + },30000);
194 + report.postRestartRoutes.push({route,markerVerified:true});
195 + return html;
196 + };
197 + await pageHtml('/accounts','VM-SYNTHETIC-SOURCE');
198 + await pageHtml('/beneficiaries','VM-SYNTHETIC-BENEFICIARY');
199 + await pageHtml('/payments','VM-DRAFT-');
200 report.durableData=true;
190 - await go('/audit','رویدادهای حسابرسی');
191 - report.auditPersisted=await conn.evaluate("document.body.innerText.includes('ACCOUNT_CREATED')&&document.body.innerText.includes('PAYMENT_CREATED')");
192 - assert(report.auditPersisted,'NATIVE_AUDIT_NOT_DURABLE');
201 + const auditHtml=await pageHtml('/audit','ACCOUNT_CREATED');
202 + report.auditPersisted=auditHtml.includes('PAYMENT_CREATED');
203 + assert(report.auditPersisted,'AUDIT_NOT_PERSISTED_AFTER_RESTART');
204 report.outcome='REAL_INSTALLED_ELECTRON_GUI_PASS';
205 }catch(e){report.outcome='FAILED';report.errorCode=(e?.message||'UNKNOWN').slice(0,140);process.exitCode=1;}
206 finally{