mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-07 22:20:03 +00:00
fix: stabilize flaky screenshot tests that rely on search box timings (#9426)
## 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 <github-actions@github.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user