diff --git a/browser_tests/fixtures/utils/litegraphUtils.ts b/browser_tests/fixtures/utils/litegraphUtils.ts index ea5a0b78f3..9cff2f7889 100644 --- a/browser_tests/fixtures/utils/litegraphUtils.ts +++ b/browser_tests/fixtures/utils/litegraphUtils.ts @@ -1,4 +1,5 @@ -import type { Page } from '@playwright/test' +import { expect } from '@playwright/test'; +import type { Page } from '@playwright/test'; import type { NodeId } from '../../../src/platform/workflow/validation/schemas/workflowSchema' import { ManageGroupNode } from '../../helpers/manageGroupNode' @@ -458,13 +459,14 @@ export class NodeReference { { x: nodePos.x + 20, y: nodePos.y + titleHeight + 5 } ] - let isInSubgraph = false - let attempts = 0 - const maxAttempts = 3 - - while (!isInSubgraph && attempts < maxAttempts) { - attempts++ + const checkIsInSubgraph = async () => { + return this.comfyPage.page.evaluate(() => { + const graph = window['app'].canvas.graph + return graph?.constructor?.name === 'Subgraph' + }) + } + await expect(async () => { for (const position of clickPositions) { // Clear any selection first await this.comfyPage.canvas.click({ @@ -477,24 +479,9 @@ export class NodeReference { await this.comfyPage.canvas.dblclick({ position, force: true }) await this.comfyPage.nextFrame() - // Check if we successfully entered the subgraph - isInSubgraph = await this.comfyPage.page.evaluate(() => { - const graph = window['app'].canvas.graph - return graph?.constructor?.name === 'Subgraph' - }) - - if (isInSubgraph) break + if (await checkIsInSubgraph()) return } - - if (!isInSubgraph && attempts < maxAttempts) { - await this.comfyPage.page.waitForTimeout(500) - } - } - - if (!isInSubgraph) { - throw new Error( - 'Failed to navigate into subgraph after ' + attempts + ' attempts' - ) - } + throw new Error('Not in subgraph yet') + }).toPass({ timeout: 5000, intervals: [100, 200, 500] }) } } diff --git a/browser_tests/tests/remoteWidgets.spec.ts b/browser_tests/tests/remoteWidgets.spec.ts index cc7cad64f2..d5890e122a 100644 --- a/browser_tests/tests/remoteWidgets.spec.ts +++ b/browser_tests/tests/remoteWidgets.spec.ts @@ -257,13 +257,11 @@ test.describe('Remote COMBO Widget', { tag: '@widget' }, () => { await addRemoteWidgetNode(comfyPage, nodeName) await waitForWidgetUpdate(comfyPage) - // Wait for timeout and backoff, then force re-render, repeat - const requestTimeout = 512 - await comfyPage.page.waitForTimeout(requestTimeout) - await waitForWidgetUpdate(comfyPage) - await comfyPage.page.waitForTimeout(requestTimeout * 2) - await waitForWidgetUpdate(comfyPage) - await comfyPage.page.waitForTimeout(requestTimeout * 3) + // Wait for exponential backoff retries to accumulate timestamps + await expect(async () => { + await waitForWidgetUpdate(comfyPage) + expect(timestamps.length).toBeGreaterThanOrEqual(3) + }).toPass({ timeout: 10000, intervals: [500, 1000, 1500] }) // Verify exponential backoff between retries const intervals = timestamps.slice(1).map((t, i) => t - timestamps[i]) diff --git a/browser_tests/tests/sidebar/nodeLibrary.spec.ts b/browser_tests/tests/sidebar/nodeLibrary.spec.ts index 4f476376ac..8bdd67a9bf 100644 --- a/browser_tests/tests/sidebar/nodeLibrary.spec.ts +++ b/browser_tests/tests/sidebar/nodeLibrary.spec.ts @@ -336,8 +336,6 @@ test.describe('Node library sidebar', () => { const tab = comfyPage.menu.nodeLibraryTab await tab.nodeLibrarySearchBoxInput.fill('KSampler') - // Node search box is debounced and may take some time to update. - await comfyPage.page.waitForTimeout(1000) - expect(await tab.getNode('KSampler (Advanced)').count()).toBe(2) + await expect(tab.getNode('KSampler (Advanced)')).toHaveCount(2) }) }) diff --git a/browser_tests/tests/subgraph.spec.ts b/browser_tests/tests/subgraph.spec.ts index 1719ba0596..20e0d6e752 100644 --- a/browser_tests/tests/subgraph.spec.ts +++ b/browser_tests/tests/subgraph.spec.ts @@ -754,7 +754,7 @@ test.describe('Subgraph Operations', { tag: ['@slow', '@subgraph'] }, () => { // Reload the page await comfyPage.page.reload() - await comfyPage.page.waitForTimeout(1024) + await comfyPage.setup() // Navigate into subgraph const subgraphNode = await comfyPage.getNodeRefById('2') diff --git a/browser_tests/tests/widget.spec.ts b/browser_tests/tests/widget.spec.ts index a0dfb0a6ea..4c1f90cfd0 100644 --- a/browser_tests/tests/widget.spec.ts +++ b/browser_tests/tests/widget.spec.ts @@ -52,10 +52,10 @@ test.describe('Combo text widget', { tag: ['@screenshot', '@widget'] }, () => { await comfyPage.page.keyboard.press('r') // Wait for nodes' widgets to be updated - await comfyPage.page.waitForTimeout(500) - - const refreshedComboValues = await getComboValues() - expect(refreshedComboValues).not.toEqual(initialComboValues) + await expect(async () => { + const refreshedComboValues = await getComboValues() + expect(refreshedComboValues).not.toEqual(initialComboValues) + }).toPass({ timeout: 5000 }) }) test('Should refresh combo values of nodes with v2 combo input spec', async ({