Compare commits

...

7 Commits

Author SHA1 Message Date
snomiao
0e42307e91 Merge branch 'main' into sno-fix-flaky-toggle-link-visibility 2025-09-16 22:04:51 +09:00
snomiao
15568e14d4 Merge branch 'main' into sno-fix-flaky-toggle-link-visibility 2025-09-11 16:38:53 +09:00
snomiao
ee1f176ea8 fix: improve link visibility toggle test stability
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 <noreply@anthropic.com>
2025-09-11 06:53:33 +00:00
snomiao
82acaeceb4 Merge branch 'sno-fix-flaky-toggle-link-visibility' of github.com:Comfy-Org/ComfyUI_frontend into sno-fix-flaky-toggle-link-visibility 2025-09-10 09:10:14 +00:00
snomiao
2dc11d345d Merge branch 'main' into sno-fix-flaky-toggle-link-visibility 2025-09-10 07:32:45 +09:00
snomiao
a6f3709d4a fix: Stabilize flaky link visibility toggle test
The test was flaky because it wasn't properly waiting for the canvas
to update after changing the link render mode setting. The setting
change triggers a canvas redraw via setDirty(), but the actual redraw
happens asynchronously.

Changes:
- Add explicit wait for canvas.links_render_mode to update
- Capture initial link render mode to properly verify state changes
- Add double frame wait plus 100ms delay to ensure canvas redraw completes
- Improve wait condition for visible links to handle undefined initial state
- Add timeout protection to prevent test hanging

This ensures the test reliably waits for both the setting change
and the visual update before taking screenshots, eliminating the
race condition that was causing intermittent failures.
2025-09-09 15:20:17 +09:00
snomiao
f66afd76db fix: Stabilize flaky link visibility toggle test
The test was flaky because it wasn't properly waiting for the canvas
to update after changing the link render mode setting. The setting
change triggers a canvas redraw via setDirty(), but the actual redraw
happens asynchronously.

Changes:
- Add explicit wait for canvas.links_render_mode to update
- Capture initial link render mode to properly verify state changes
- Add double frame wait plus 100ms delay to ensure canvas redraw completes
- Improve wait condition for visible links to handle undefined initial state
- Add timeout protection to prevent test hanging

This ensures the test reliably waits for both the setting change
and the visual update before taking screenshots, eliminating the
race condition that was causing intermittent failures.
2025-09-09 03:57:58 +00:00

View File

@@ -13,25 +13,91 @@ test.describe('Graph Canvas Menu', () => {
test('Can toggle link visibility', async ({ comfyPage }) => {
const button = comfyPage.page.getByTestId('toggle-link-visibility-button')
// Get the initial link render mode and HIDDEN_LINK constant
const { initialMode, hiddenLinkMode } = await comfyPage.page.evaluate(
() => {
return {
initialMode: window['app']?.canvas?.links_render_mode,
hiddenLinkMode: window['LiteGraph'].HIDDEN_LINK
}
}
)
// First click - hide links
await button.click()
await comfyPage.nextFrame()
// Wait for the setting to actually change to hidden
await comfyPage.page.waitForFunction(
(expectedMode) => {
const canvas = window['app']?.canvas
return canvas && canvas.links_render_mode === expectedMode
},
hiddenLinkMode,
{ timeout: 5000 }
)
// 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'
)
const hiddenLinkRenderMode = await comfyPage.page.evaluate(() => {
return window['LiteGraph'].HIDDEN_LINK
})
expect(await comfyPage.getSetting('Comfy.LinkRenderMode')).toBe(
hiddenLinkRenderMode
hiddenLinkMode
)
// Second click - show links again
await button.click()
await comfyPage.nextFrame()
// Wait for the setting to change back to the initial mode
await comfyPage.page.waitForFunction(
({ hiddenMode, initial }) => {
const canvas = window['app']?.canvas
// Check that it's not hidden and matches the expected visible mode
return (
canvas &&
canvas.links_render_mode !== hiddenMode &&
(initial === undefined || canvas.links_render_mode === initial)
)
},
{ hiddenMode: hiddenLinkMode, initial: initialMode },
{ timeout: 5000 }
)
// 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'
)
expect(await comfyPage.getSetting('Comfy.LinkRenderMode')).not.toBe(
hiddenLinkRenderMode
hiddenLinkMode
)
})