Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

test(native): assert visible folder row

yxlyx8a618ca5423e
diff --git a/apps/native/electron/projects-visual.cjs b/apps/native/electron/projects-visual.cjs
index 790f1629..2573dbc6 100644
--- a/apps/native/electron/projects-visual.cjs
+++ b/apps/native/electron/projects-visual.cjs
@@ -72,7 +72,7 @@ async function runProjectVisuals({ win, origin, output, pressEnter }) {
await js(`window.folderFetchCount=0;window.releaseFolderFetch=[];const folderBaseFetch=window.fetch;window.fetch=(input,options)=>{if(String(input).includes('/api/workspaces')){window.folderFetchCount+=1;const reply=()=>new Response(JSON.stringify({path:'/demo',parent:'/',git:false,home:'/demo',default:'/demo',entries:[{name:'apps',path:'/demo/apps',git:false}]}),{headers:{'content-type':'application/json'}});if(window.folderFetchCount===1)return Promise.resolve(reply());return new Promise(resolve=>window.releaseFolderFetch.push(()=>resolve(reply())));}return folderBaseFetch(input,options);};true`);
await js(`document.querySelector('button[aria-label="Open folder…"]').click()`);
await wait(`document.querySelector('[role="dialog"][aria-label="Open a folder"]')?.textContent.includes('apps')`);
- await js(`(()=>{window.folderListingBlanked=false;window.monitorFolderListing=true;const check=()=>{if(!window.monitorFolderListing)return;const dialog=document.querySelector('[role="dialog"][aria-label="Open a folder"]');if(dialog&&!dialog.textContent.includes('apps'))window.folderListingBlanked=true;requestAnimationFrame(check);};requestAnimationFrame(check);return true;})()`);
+ await js(`(()=>{window.folderListingInvisible=false;window.monitorFolderListing=true;const visible=()=>{const dialog=document.querySelector('[role="dialog"][aria-label="Open a folder"]'),button=dialog&&Array.from(dialog.querySelectorAll('button[title]')).find(b=>b.title==='/demo/apps');if(!dialog||!button||!button.checkVisibility({checkOpacity:true,checkVisibilityCSS:true}))return false;let clip=button.parentElement;while(clip&&clip!==dialog&&!/^(auto|scroll|hidden|clip)$/.test(getComputedStyle(clip).overflowY))clip=clip.parentElement;const r=button.getBoundingClientRect(),c=(clip||dialog).getBoundingClientRect(),d=dialog.getBoundingClientRect();return r.width>0&&r.height>0&&r.right>Math.max(c.left,d.left)&&r.left<Math.min(c.right,d.right)&&r.bottom>Math.max(c.top,d.top)&&r.top<Math.min(c.bottom,d.bottom);};const check=()=>{if(!window.monitorFolderListing)return;if(!visible())window.folderListingInvisible=true;requestAnimationFrame(check);};requestAnimationFrame(check);return true;})()`);
await js(`document.querySelector('[role="dialog"][aria-label="Open a folder"] input[aria-label="Folder path"]').focus()`);
await pressEnter(); await pressEnter(); await pressEnter();
await wait(`window.folderFetchCount===4`);
@@ -80,16 +80,16 @@ async function runProjectVisuals({ win, origin, output, pressEnter }) {
await js(`window.releaseFolderFetch.shift()();new Promise(resolve=>requestAnimationFrame(()=>requestAnimationFrame(resolve)))`);
assert.ok(await js(`document.querySelector('[role="dialog"][aria-label="Open a folder"]')?.textContent.includes('apps')`), 'The first stale navigation response does not clear the listing');
assert.equal(await js(`Array.from(document.querySelectorAll('[role="dialog"][aria-label="Open a folder"] button')).find(b=>b.textContent==='Open folder').disabled`), true, 'The newest folder request remains pending after the first stale response');
- assert.equal(await js(`window.folderListingBlanked`), false, 'No rendered frame blanks the listing after the first stale response');
+ assert.equal(await js(`window.folderListingInvisible`), false, 'The apps row stays visibly rendered after the first stale response');
await js(`window.releaseFolderFetch.shift()();new Promise(resolve=>requestAnimationFrame(()=>requestAnimationFrame(resolve)))`);
assert.ok(await js(`document.querySelector('[role="dialog"][aria-label="Open a folder"]')?.textContent.includes('apps')`), 'The second stale navigation response does not clear the listing');
assert.equal(await js(`Array.from(document.querySelectorAll('[role="dialog"][aria-label="Open a folder"] button')).find(b=>b.textContent==='Open folder').disabled`), true, 'The newest folder request remains pending after both stale responses');
- assert.equal(await js(`window.folderListingBlanked`), false, 'No rendered frame blanks the listing after either stale response');
+ assert.equal(await js(`window.folderListingInvisible`), false, 'The apps row stays visibly rendered after either stale response');
await js(`window.releaseFolderFetch.shift()()`);
await wait(`!Array.from(document.querySelectorAll('[role="dialog"][aria-label="Open a folder"] button')).find(b=>b.textContent==='Open folder').disabled`);
assert.ok(await js(`document.querySelector('[role="dialog"][aria-label="Open a folder"]')?.textContent.includes('apps')`), 'The folder listing remains visible after the newest request settles');
await js(`window.monitorFolderListing=false`);
- assert.equal(await js(`window.folderListingBlanked`), false, 'No rendered frame blanks the listing during repeated submission');
+ assert.equal(await js(`window.folderListingInvisible`), false, 'The apps row stays visibly rendered during repeated submission');
// Unmount the picker before navigating: an in-flight listing + loadURL
// left the renderer unable to run the next suite's scripts.
await js(`document.querySelector('[role="dialog"][aria-label="Open a folder"] button[aria-label="Close"]').click()`);