From ee1f176ea82ce256e8c8493b720175577445a2ca Mon Sep 17 00:00:00 2001 From: snomiao Date: Thu, 11 Sep 2025 06:53:33 +0000 Subject: [PATCH] fix: improve link visibility toggle test stability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace fixed delays with frame counter monitoring to ensure canvas has completed rendering before taking screenshots. This eliminates race conditions and makes the test more reliable. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- browser_tests/tests/graphCanvasMenu.spec.ts | 39 +++++++++++++++------ 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/browser_tests/tests/graphCanvasMenu.spec.ts b/browser_tests/tests/graphCanvasMenu.spec.ts index 3c100dd30..43f020157 100644 --- a/browser_tests/tests/graphCanvasMenu.spec.ts +++ b/browser_tests/tests/graphCanvasMenu.spec.ts @@ -37,11 +37,21 @@ test.describe('Graph Canvas Menu', () => { { timeout: 5000 } ) - // Wait for canvas to complete rendering with hidden links - // Use multiple frames and a small delay to ensure canvas is fully updated - await comfyPage.nextFrame() - await comfyPage.nextFrame() - await comfyPage.page.waitForTimeout(100) // Small delay for canvas rendering + // Wait for canvas to complete rendering by monitoring the frame counter + // The canvas increments its frame counter after each draw cycle + const frameBeforeRender = await comfyPage.page.evaluate(() => { + return window['app']?.canvas?.frame || 0 + }) + + await comfyPage.page.waitForFunction( + (initialFrame) => { + const canvas = window['app']?.canvas + // Wait for at least one frame to be rendered after the change + return canvas && canvas.frame > initialFrame + }, + frameBeforeRender, + { timeout: 5000 } + ) await expect(comfyPage.canvas).toHaveScreenshot( 'canvas-with-hidden-links.png' @@ -68,11 +78,20 @@ test.describe('Graph Canvas Menu', () => { { timeout: 5000 } ) - // Wait for canvas to complete rendering with visible links - // Use multiple frames and a small delay to ensure canvas is fully updated - await comfyPage.nextFrame() - await comfyPage.nextFrame() - await comfyPage.page.waitForTimeout(100) // Small delay for canvas rendering + // Wait for canvas to complete rendering by monitoring the frame counter + const frameBeforeSecondRender = await comfyPage.page.evaluate(() => { + return window['app']?.canvas?.frame || 0 + }) + + await comfyPage.page.waitForFunction( + (initialFrame) => { + const canvas = window['app']?.canvas + // Wait for at least one frame to be rendered after the change + return canvas && canvas.frame > initialFrame + }, + frameBeforeSecondRender, + { timeout: 5000 } + ) await expect(comfyPage.canvas).toHaveScreenshot( 'canvas-with-visible-links.png'