From 64a2a5b3aedb9814e4bbb4c98f52e9edab0da405 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Mon, 30 Jun 2025 17:36:07 -0700 Subject: [PATCH] [fix] Mock release API in browser tests to prevent UI interference (#4310) --- browser_tests/README.md | 10 ++++++++++ browser_tests/fixtures/ComfyPage.ts | 31 +++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/browser_tests/README.md b/browser_tests/README.md index 0860f8c80..88bd865f8 100644 --- a/browser_tests/README.md +++ b/browser_tests/README.md @@ -29,6 +29,16 @@ A template with helpful information can be found in `.env_example`. ### Multiple Tests If you are running Playwright tests in parallel or running the same test multiple times, the flag `--multi-user` must be added to the main ComfyUI process. +### Release API Mocking +By default, all tests mock the release API (`api.comfy.org/releases`) to prevent release notification popups from interfering with test execution. This is necessary because the release notifications can appear over UI elements and block test interactions. + +To test with real release data, you can disable mocking: +```typescript +await comfyPage.setup({ mockReleases: false }); +``` + +For tests that specifically need to test release functionality, see the example in `tests/releaseNotifications.spec.ts`. + ## Running Tests There are multiple ways to run the tests: diff --git a/browser_tests/fixtures/ComfyPage.ts b/browser_tests/fixtures/ComfyPage.ts index 1c2fbd78c..962f4ae6c 100644 --- a/browser_tests/fixtures/ComfyPage.ts +++ b/browser_tests/fixtures/ComfyPage.ts @@ -268,8 +268,35 @@ export class ComfyPage { return this._history } - async setup({ clearStorage = true }: { clearStorage?: boolean } = {}) { + async setup({ + clearStorage = true, + mockReleases = true + }: { + clearStorage?: boolean + mockReleases?: boolean + } = {}) { await this.goto() + + // Mock release endpoint to prevent changelog popups + if (mockReleases) { + await this.page.route('**/releases**', async (route) => { + const url = route.request().url() + if ( + url.includes('api.comfy.org') || + url.includes('stagingapi.comfy.org') + ) { + console.log('Mocking releases API') + await route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify([]) + }) + } else { + await route.continue() + } + }) + } + if (clearStorage) { await this.page.evaluate((id) => { localStorage.clear() @@ -1086,7 +1113,7 @@ export const comfyPageFixture = base.extend<{ }, comfyMouse: async ({ comfyPage }, use) => { const comfyMouse = new ComfyMouse(comfyPage) - use(comfyMouse) + await use(comfyMouse) } })