Skip to content

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

Python

test: observe pane animation starts without timing-dependent polling

Rach Pradhan8e20a2d33c30
diff --git a/apps/native/electron/pane-motion-observer.cjs b/apps/native/electron/pane-motion-observer.cjs
new file mode 100644
index 00000000..220e7cdf
--- /dev/null
+++ b/apps/native/electron/pane-motion-observer.cjs
@@ -0,0 +1,32 @@
+const { attachTestDebugger } = require('./test-desktop.cjs');
+
+// Observe native animation starts, including animations that finish before the
+// test process gets its next IPC turn. Do not alter playback or the app's code.
+async function observePaneMotion(wc) {
+ attachTestDebugger(wc);
+ const started = [];
+ const listener = (_event, method, params) => {
+ if (method === 'Animation.animationStarted' && params.animation.type === 'WebAnimation')
+ started.push(params.animation);
+ };
+ wc.debugger.on('message', listener);
+ await wc.debugger.sendCommand('Animation.enable');
+ return {
+ async assertStarted() {
+ for (let attempt = 0; attempt < 100; attempt++) {
+ for (const animation of started.splice(0)) {
+ if (!(animation.source?.duration > 1) || !animation.source.backendNodeId) continue;
+ const { node } = await wc.debugger.sendCommand('DOM.describeNode', { backendNodeId: animation.source.backendNodeId });
+ if (node.attributes?.some((value, i) => i % 2 === 0 && value === 'data-chat')) return;
+ }
+ await new Promise(resolve => setTimeout(resolve, 50));
+ }
+ throw Error('The downward drop did not start a native pane animation');
+ },
+ async stop() {
+ wc.debugger.removeListener('message', listener);
+ await wc.debugger.sendCommand('Animation.disable');
+ },
+ };
+}
+module.exports = { observePaneMotion };
diff --git a/apps/native/electron/tab-drag-visual.cjs b/apps/native/electron/tab-drag-visual.cjs
index 7f82c396..c0ec0538 100644
--- a/apps/native/electron/tab-drag-visual.cjs
+++ b/apps/native/electron/tab-drag-visual.cjs
@@ -102,6 +102,7 @@ async function runTabDrag({win, origin, output}) {
const [first,second]=await tabs();
const bottom=await js(`(()=>{const r=document.querySelector('[data-chat]').getBoundingClientRect();return {x:Math.round(r.left+r.width/2),y:Math.round(r.bottom-22)}})()`);
const stopRecording = await require('./tab-motion-capture.cjs').recordTabMotion(wc, output);
+ const motion = await require('./pane-motion-observer.cjs').observePaneMotion(wc);
try {
const from = await down(first);
for (let i=1;i<=36;i++) {
@@ -112,10 +113,10 @@ async function runTabDrag({win, origin, output}) {
await new Promise(resolve=>setTimeout(resolve,220));
fs.writeFileSync(path.join(output,'tabs-drop-below-preview.png'),(await wc.capturePage()).toPNG());
await up(bottom);await wait(`document.querySelectorAll('[data-chat]').length===2`);
- assert.ok(await js(`Array.from(document.querySelectorAll('[data-chat]')).some(p=>p.getAnimations().some(a=>a.playState==='running'))`), 'The downward drop should animate into its committed layout');
await wait(`!Array.from(document.querySelectorAll('[data-chat]')).some(p=>p.getAnimations().some(a=>a.playState==='running'))`);
+ await motion.assertStarted(); // Start evidence remains valid after playback ends.
await new Promise(resolve=>setTimeout(resolve,300));
- } finally { await stopRecording(); }
+ } finally { await motion.stop(); await stopRecording(); }
assert.deepEqual(await panes(),[second,first]);
assert.equal(await js(`document.querySelector('[data-chat="${first}"] textarea').value`),'Plan the next release');
assert.equal(await js(`getComputedStyle(document.querySelector('[data-chat-layout]')).flexDirection`),'column');