Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
test(windows): verify actual Electron query-copy handler copies edited SQL via intercepted clipboard API
davoodmehraban89 committed
Oct 16, 2026 at 22:12 UTC
51ca752bd5a4fc3b99a7329d57a64e2335cb203c
1 file changed
+24
-1
qa/windows/electron-native-gui-smoke.mjs
+24
-1
@@ -8,7 +8,7 @@ assert(exe&&existsSync(exe),'real installed TreasuryFlow.exe required');
8
assert(reportDir,'evidence output directory required');
9
mkdirSync(reportDir,{recursive:true});
10
const port=9345;
11
-const report={mode:'REAL_INSTALLED_ELECTRON_CDP',exe:basename(exe),cdp:false,localOrigin:false,integrations:false,queryEditor:false,copyQuery:false,screenshot:false,outcome:'NOT_RUN'};
11
+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,outcome:'NOT_RUN'};
12
const sleep=ms=>new Promise(r=>setTimeout(r,ms));
13
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');}
14
async function connect(url){
@@ -47,6 +47,29 @@ try{
47
report.integrations=true;report.queryEditor=page.editor;report.copyQuery=page.copy;
48
assert(report.queryEditor,'QUERY_EDITOR_MISSING_IN_NATIVE_APP');
49
assert(report.copyQuery,'COPY_BUTTON_MISSING_IN_NATIVE_APP');
50
+ const editedSql='SELECT TOP (7) 7 AS CopyProbe';
51
+ const prepared=await conn.evaluate(`(() => {
52
+ const field=document.querySelector('textarea[name="query"]') || document.querySelector('textarea');
53
+ const button=[...document.querySelectorAll('button')].find(b=>b.textContent.includes('کپی کوئری'));
54
+ if(!field || !button) return false;
55
+ window.__tfCapturedQuery=null;
56
+ Object.defineProperty(navigator,'clipboard',{configurable:true,value:{writeText:async value=>{window.__tfCapturedQuery=value;}}});
57
+ const descriptor=Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,'value');
58
+ descriptor.set.call(field, ${JSON.stringify(editedSql)});
59
+ field.dispatchEvent(new Event('input',{bubbles:true}));
60
+ return true;
61
+ })()`);
62
+ assert(prepared,'QUERY_COPY_SETUP_FAILED');
63
+ await sleep(300);
64
+ const clicked=await conn.evaluate(`(() => {
65
+ const button=[...document.querySelectorAll('button')].find(b=>b.textContent.includes('کپی کوئری'));
66
+ if(!button) return false;
67
+ button.click();
68
+ return true;
69
+ })()`);
70
+ assert(clicked,'QUERY_COPY_BUTTON_NOT_CLICKABLE');
71
+ report.copyExactlyEditedSql=await wait(()=>conn.evaluate('window.__tfCapturedQuery === '+JSON.stringify(editedSql)),10000);
72
+ assert(report.copyExactlyEditedSql,'EDITED_QUERY_NOT_COPIED_EXACTLY');
73
const png=await conn.command('Page.captureScreenshot',{format:'png',captureBeyondViewport:false});
74
assert(png.data,'NATIVE_SCREENSHOT_MISSING');
75
writeFileSync(join(reportDir,'treasuryflow-installed-ui.png'),Buffer.from(png.data,'base64'));report.screenshot=true;