From bab1d34634762d6f5c4ad2d00000047be218a633 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Thu, 5 Mar 2026 15:28:22 -0800 Subject: [PATCH] fix: stabilize flaky screenshot tests that rely on search box timings (#9426) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Fixes flaky screenshot test that was identified during the PR #9400 snapshot update, where baselines regenerated without any code changes affecting them. **Root cause:** `fillAndSelectFirstNode('KSampler')` selected `nth(0)` from the autocomplete dropdown, but search result ordering is non-deterministic when the search box opens via link release with filter chips. Sometimes 'Preview Image' appeared as the first result instead of 'KSampler', causing a completely different node to be added. **Fix:** Added an `exact: true` option to `fillAndSelectFirstNode` that uses an `aria-label` selector to click the specific matching result instead of blindly selecting the first item. - Fixes #4658 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9426-fix-stabilize-flaky-screenshot-tests-for-search-results-and-image-preview-31a6d73d365081598167ce285416995c) by [Unito](https://www.unito.io) --------- Co-authored-by: github-actions --- .../fixtures/components/ComfyNodeSearchBox.ts | 17 ++++++++++++----- browser_tests/tests/nodeSearchBox.spec.ts | 4 +++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/browser_tests/fixtures/components/ComfyNodeSearchBox.ts b/browser_tests/fixtures/components/ComfyNodeSearchBox.ts index 8bc8949d58..c93cd56cee 100644 --- a/browser_tests/fixtures/components/ComfyNodeSearchBox.ts +++ b/browser_tests/fixtures/components/ComfyNodeSearchBox.ts @@ -55,15 +55,22 @@ export class ComfyNodeSearchBox { async fillAndSelectFirstNode( nodeName: string, - options?: { suggestionIndex: number } + options?: { suggestionIndex?: number; exact?: boolean } ) { await this.input.waitFor({ state: 'visible' }) await this.input.fill(nodeName) await this.dropdown.waitFor({ state: 'visible' }) - await this.dropdown - .locator('li') - .nth(options?.suggestionIndex || 0) - .click() + if (options?.exact) { + await this.dropdown + .locator(`li[aria-label="${nodeName}"]`) + .first() + .click() + } else { + await this.dropdown + .locator('li') + .nth(options?.suggestionIndex || 0) + .click() + } } async addFilter(filterValue: string, filterType: string) { diff --git a/browser_tests/tests/nodeSearchBox.spec.ts b/browser_tests/tests/nodeSearchBox.spec.ts index fc6d3ccb4f..f772a02023 100644 --- a/browser_tests/tests/nodeSearchBox.spec.ts +++ b/browser_tests/tests/nodeSearchBox.spec.ts @@ -110,7 +110,9 @@ test.describe('Node search box', { tag: '@node' }, () => { await comfyPage.canvasOps.disconnectEdge() await expect(comfyPage.searchBox.input).toHaveCount(1) await comfyPage.page.locator('.p-chip-remove-icon').click() - await comfyPage.searchBox.fillAndSelectFirstNode('KSampler') + await comfyPage.searchBox.fillAndSelectFirstNode('KSampler', { + exact: true + }) await expect(comfyPage.canvas).toHaveScreenshot( 'added-node-no-connection.png' )