Skip to content

Commit 64a2a5b

Browse files
[fix] Mock release API in browser tests to prevent UI interference (#4310)
1 parent fada8bf commit 64a2a5b

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

browser_tests/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ A template with helpful information can be found in `.env_example`.
2929
### Multiple Tests
3030
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.
3131

32+
### Release API Mocking
33+
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.
34+
35+
To test with real release data, you can disable mocking:
36+
```typescript
37+
await comfyPage.setup({ mockReleases: false });
38+
```
39+
40+
For tests that specifically need to test release functionality, see the example in `tests/releaseNotifications.spec.ts`.
41+
3242
## Running Tests
3343

3444
There are multiple ways to run the tests:

browser_tests/fixtures/ComfyPage.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,35 @@ export class ComfyPage {
268268
return this._history
269269
}
270270

271-
async setup({ clearStorage = true }: { clearStorage?: boolean } = {}) {
271+
async setup({
272+
clearStorage = true,
273+
mockReleases = true
274+
}: {
275+
clearStorage?: boolean
276+
mockReleases?: boolean
277+
} = {}) {
272278
await this.goto()
279+
280+
// Mock release endpoint to prevent changelog popups
281+
if (mockReleases) {
282+
await this.page.route('**/releases**', async (route) => {
283+
const url = route.request().url()
284+
if (
285+
url.includes('api.comfy.org') ||
286+
url.includes('stagingapi.comfy.org')
287+
) {
288+
console.log('Mocking releases API')
289+
await route.fulfill({
290+
status: 200,
291+
contentType: 'application/json',
292+
body: JSON.stringify([])
293+
})
294+
} else {
295+
await route.continue()
296+
}
297+
})
298+
}
299+
273300
if (clearStorage) {
274301
await this.page.evaluate((id) => {
275302
localStorage.clear()
@@ -1086,7 +1113,7 @@ export const comfyPageFixture = base.extend<{
10861113
},
10871114
comfyMouse: async ({ comfyPage }, use) => {
10881115
const comfyMouse = new ComfyMouse(comfyPage)
1089-
use(comfyMouse)
1116+
await use(comfyMouse)
10901117
}
10911118
})
10921119

0 commit comments

Comments
 (0)