From 97fa128999f1d43a0c43559c4db5604831a25d89 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Thu, 11 Dec 2025 11:48:02 -0800 Subject: [PATCH] fix: flaky e2e test for dropping assets on nodes (#7352) Fix flaky "Can drag-and-drop animated webp image" test that was reading the widget value before the upload completed, causing intermittent failures where filenames appeared truncated. Added `waitForUpload` option to `dragAndDropFile` helper that waits for the `/upload/` response before returning. This is opt-in since not all drag-and-drop operations trigger uploads (e.g., loading workflows from media files). --- browser_tests/fixtures/ComfyPage.ts | 23 +++++++++++++++++++++-- browser_tests/tests/widget.spec.ts | 3 ++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/browser_tests/fixtures/ComfyPage.ts b/browser_tests/fixtures/ComfyPage.ts index e29f6ea5bc..782af9921a 100644 --- a/browser_tests/fixtures/ComfyPage.ts +++ b/browser_tests/fixtures/ComfyPage.ts @@ -585,9 +585,15 @@ export class ComfyPage { fileName?: string url?: string dropPosition?: Position + waitForUpload?: boolean } = {} ) { - const { dropPosition = { x: 100, y: 100 }, fileName, url } = options + const { + dropPosition = { x: 100, y: 100 }, + fileName, + url, + waitForUpload = false + } = options if (!fileName && !url) throw new Error('Must provide either fileName or url') @@ -624,6 +630,14 @@ export class ComfyPage { // Dropping a URL (e.g., dropping image across browser tabs in Firefox) if (url) evaluateParams.url = url + // Set up response waiter for file uploads before triggering the drop + const uploadResponsePromise = waitForUpload + ? this.page.waitForResponse( + (resp) => resp.url().includes('/upload/') && resp.status() === 200, + { timeout: 10000 } + ) + : null + // Execute the drag and drop in the browser await this.page.evaluate(async (params) => { const dataTransfer = new DataTransfer() @@ -690,12 +704,17 @@ export class ComfyPage { } }, evaluateParams) + // Wait for file upload to complete + if (uploadResponsePromise) { + await uploadResponsePromise + } + await this.nextFrame() } async dragAndDropFile( fileName: string, - options: { dropPosition?: Position } = {} + options: { dropPosition?: Position; waitForUpload?: boolean } = {} ) { return this.dragAndDropExternalResource({ fileName, ...options }) } diff --git a/browser_tests/tests/widget.spec.ts b/browser_tests/tests/widget.spec.ts index 7afa823e35..002ad29242 100644 --- a/browser_tests/tests/widget.spec.ts +++ b/browser_tests/tests/widget.spec.ts @@ -252,7 +252,8 @@ test.describe('Animated image widget', () => { // Drag and drop image file onto the load animated webp node await comfyPage.dragAndDropFile('animated_webp.webp', { - dropPosition: { x, y } + dropPosition: { x, y }, + waitForUpload: true }) // Expect the filename combo value to be updated