From f78d9891af22b6a68350ea47c527184837a5ba3e Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Thu, 1 Oct 2026 05:08:56 -0700 Subject: [PATCH 1/5] test(agent): pin the HTTP-status fallback in an API error notice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit notice it feeds is user-visible, so pin it black-box: a 5xx whose response carries no reason phrase must leave the chat bubble naming the status rather than ending at a bare colon. Proven red on the pre-fix parent, where the bubble reads "Message failed to send:" and nothing follows. Stubbed at fetch rather than with page.route, which cannot express this condition: Playwright fulfills over HTTP/1.1, where Chromium always supplies a reason phrase, while HTTP/2 — what cloud serves — has none. Retitle the unit case for the same reason; "no error text" read as a condition the browser can reach over HTTP/1.1, which it cannot. --- browser_tests/tests/agent/agentPanel.spec.ts | 45 +++++++++++++++++++ .../services/agent/agentRestClient.test.ts | 6 ++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/browser_tests/tests/agent/agentPanel.spec.ts b/browser_tests/tests/agent/agentPanel.spec.ts index c59d9351b0a..9df39267305 100644 --- a/browser_tests/tests/agent/agentPanel.spec.ts +++ b/browser_tests/tests/agent/agentPanel.spec.ts @@ -376,6 +376,51 @@ test.describe('In-App Agent panel', { tag: '@cloud' }, () => { expect(postCount).toBe(1) }) + test('names the HTTP status when the failure carries no reason phrase', async ({ + agentPanel, + comfyPage + }) => { + // Regression: https://github.com/Comfy-Org/ComfyUI_frontend/pull/18374 + // The notice falls back to `Response.statusText`, and HTTP/2 — what cloud + // serves — has no reason phrase, so a 5xx with an unparseable body left the + // bubble reading "Message failed to send: " with nothing after the colon. + // + // Stubbed at `fetch` rather than with `page.route`, which cannot express + // this: Playwright fulfills over HTTP/1.1, where Chromium always supplies a + // phrase ("Service Unavailable" for 503, "Unknown" for an unassigned code). + // A browser-built `Response` leaves `statusText` empty, as HTTP/2 does. + await agentPanel.open() + await agentPanel.selectWorkflow() + await comfyPage.page.evaluate(() => { + const send = globalThis.fetch + globalThis.fetch = async (input, init) => { + const url = + typeof input === 'string' + ? input + : input instanceof URL + ? input.href + : input.url + const method = + init?.method ?? (input instanceof Request ? input.method : 'GET') + if (method === 'POST' && /\/agent\/threads\/[^/]+\/messages$/.test(url)) + return new Response('', { status: 503 }) + return send(input, init) + } + }) + + await agentPanel.composer.fill('Build a product photo workflow') + await agentPanel.sendButton.click() + + await expect( + agentPanel.root.getByText(enMessages.agent.sendFailed) + ).toBeVisible() + // The status is the assertion: the notice above is already visible without + // the fix, carrying nothing after its colon. + await expect( + agentPanel.root.getByText('Agent request failed (HTTP 503)') + ).toBeVisible() + }) + test.describe('diagnostic report', () => { test.use({ permissions: ['clipboard-read', 'clipboard-write'], diff --git a/src/workbench/extensions/agent/services/agent/agentRestClient.test.ts b/src/workbench/extensions/agent/services/agent/agentRestClient.test.ts index 3617bdcb5ea..acc8c6d3872 100644 --- a/src/workbench/extensions/agent/services/agent/agentRestClient.test.ts +++ b/src/workbench/extensions/agent/services/agent/agentRestClient.test.ts @@ -458,7 +458,11 @@ describe('error mapping', () => { expect(error.body).toBeUndefined() }) - it('falls back to the HTTP status when the response has no error text', async () => { + // `toApiError` falls back to `statusText`, so this branch is only reachable + // when the response carries no reason phrase — which is every HTTP/2 + // response. A `Response` built here leaves `statusText` empty, matching that; + // Chromium over HTTP/1.1 would supply "Service Unavailable" instead. + it('falls back to the HTTP status when the response has no reason phrase', async () => { respond(new Response('', { status: 503 })) const error = await makeClient() From 941a8460ad9fd03a463b0d05b5f809ebc6712523 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Thu, 1 Oct 2026 12:16:18 -0700 Subject: [PATCH 2/5] test(agent): fixture HTTP status fallback mock --- browser_tests/tests/agent/agentPanel.spec.ts | 69 ++++++++------------ browser_tests/tests/agent/agentPanelMocks.ts | 46 ++++++++++++- 2 files changed, 73 insertions(+), 42 deletions(-) diff --git a/browser_tests/tests/agent/agentPanel.spec.ts b/browser_tests/tests/agent/agentPanel.spec.ts index 9df39267305..d7100c03164 100644 --- a/browser_tests/tests/agent/agentPanel.spec.ts +++ b/browser_tests/tests/agent/agentPanel.spec.ts @@ -376,49 +376,36 @@ test.describe('In-App Agent panel', { tag: '@cloud' }, () => { expect(postCount).toBe(1) }) - test('names the HTTP status when the failure carries no reason phrase', async ({ - agentPanel, - comfyPage - }) => { - // Regression: https://github.com/Comfy-Org/ComfyUI_frontend/pull/18374 - // The notice falls back to `Response.statusText`, and HTTP/2 — what cloud - // serves — has no reason phrase, so a 5xx with an unparseable body left the - // bubble reading "Message failed to send: " with nothing after the colon. - // - // Stubbed at `fetch` rather than with `page.route`, which cannot express - // this: Playwright fulfills over HTTP/1.1, where Chromium always supplies a - // phrase ("Service Unavailable" for 503, "Unknown" for an unassigned code). - // A browser-built `Response` leaves `statusText` empty, as HTTP/2 does. - await agentPanel.open() - await agentPanel.selectWorkflow() - await comfyPage.page.evaluate(() => { - const send = globalThis.fetch - globalThis.fetch = async (input, init) => { - const url = - typeof input === 'string' - ? input - : input instanceof URL - ? input.href - : input.url - const method = - init?.method ?? (input instanceof Request ? input.method : 'GET') - if (method === 'POST' && /\/agent\/threads\/[^/]+\/messages$/.test(url)) - return new Response('', { status: 503 }) - return send(input, init) - } - }) + test.describe('HTTP error without a reason phrase', () => { + test.use({ agentMessageHttpErrorStatus: 503 }) - await agentPanel.composer.fill('Build a product photo workflow') - await agentPanel.sendButton.click() + test('names the HTTP status when the failure carries no reason phrase', async ({ + agentPanel + }) => { + // Regression: https://github.com/Comfy-Org/ComfyUI_frontend/pull/18374 + // The notice falls back to `Response.statusText`, and HTTP/2 — what cloud + // serves — has no reason phrase, so a 5xx with an unparseable body left the + // bubble reading "Message failed to send: " with nothing after the colon. + // + // Stubbed at `fetch` rather than with `page.route`, which cannot express + // this: Playwright fulfills over HTTP/1.1, where Chromium always supplies a + // phrase ("Service Unavailable" for 503, "Unknown" for an unassigned code). + // A browser-built `Response` leaves `statusText` empty, as HTTP/2 does. + await agentPanel.open() + await agentPanel.selectWorkflow() - await expect( - agentPanel.root.getByText(enMessages.agent.sendFailed) - ).toBeVisible() - // The status is the assertion: the notice above is already visible without - // the fix, carrying nothing after its colon. - await expect( - agentPanel.root.getByText('Agent request failed (HTTP 503)') - ).toBeVisible() + await agentPanel.composer.fill('Build a product photo workflow') + await agentPanel.sendButton.click() + + await expect( + agentPanel.root.getByText(enMessages.agent.sendFailed) + ).toBeVisible() + // The status is the assertion: the notice above is already visible without + // the fix, carrying nothing after its colon. + await expect( + agentPanel.root.getByText('Agent request failed (HTTP 503)') + ).toBeVisible() + }) }) test.describe('diagnostic report', () => { diff --git a/browser_tests/tests/agent/agentPanelMocks.ts b/browser_tests/tests/agent/agentPanelMocks.ts index 4a1c76dde1a..4bb894b3f49 100644 --- a/browser_tests/tests/agent/agentPanelMocks.ts +++ b/browser_tests/tests/agent/agentPanelMocks.ts @@ -278,7 +278,10 @@ async function mockAgentBoot( objectInfo, postedMessages, vueNodes - }: Omit & { + }: Omit< + AgentFixtures, + 'agentMessageHttpErrorMock' | 'agentMessageHttpErrorStatus' | 'agentPanel' + > & { initialFeatureFlags: Record initialSettings: Record vueNodes: boolean @@ -530,6 +533,8 @@ type AgentFixtures = { agentConsentSave: { status: number; pending?: Promise } agentConsentWrites: boolean[] agentFlagEnabled: boolean + agentMessageHttpErrorMock: void + agentMessageHttpErrorStatus: number | undefined agentPanel: AgentPanel agentPanelInitiallyOpen: boolean agentOnboardingCompleted: boolean @@ -559,6 +564,45 @@ export const agentTest = comfyPageFixture.extend({ await use([]) }, agentFlagEnabled: [true, { option: true }], + agentMessageHttpErrorMock: [ + async ({ comfyPage, agentMessageHttpErrorStatus }, use) => { + if (agentMessageHttpErrorStatus === undefined) { + await use() + return + } + await comfyPage.page.evaluate((status) => { + const originalFetch = globalThis.fetch + globalThis.fetch = async (input, init) => { + const url = + typeof input === 'string' + ? input + : input instanceof URL + ? input.href + : input.url + const method = + init?.method ?? (input instanceof Request ? input.method : 'GET') + if ( + method === 'POST' && + /\/agent\/threads\/[^/]+\/messages$/.test(url) + ) + return new Response('', { status }) + return originalFetch(input, init) + } + Reflect.set(globalThis, '__agentTestOriginalFetch', originalFetch) + }, agentMessageHttpErrorStatus) + await use() + await comfyPage.page.evaluate(() => { + const originalFetch = Reflect.get( + globalThis, + '__agentTestOriginalFetch' + ) as typeof globalThis.fetch | undefined + if (originalFetch) globalThis.fetch = originalFetch + Reflect.deleteProperty(globalThis, '__agentTestOriginalFetch') + }) + }, + { auto: true } + ], + agentMessageHttpErrorStatus: [undefined, { option: true }], agentPanel: async ({ comfyPage }, use) => { await use(new AgentPanel(comfyPage.page)) }, From 467377750529c236c4c72dfefbda29326f958ce4 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Thu, 1 Oct 2026 13:16:06 -0700 Subject: [PATCH 3/5] test(agent): isolate HTTP fallback E2E --- .../tests/agent/agentHttpError.spec.ts | 38 ++++++++++ browser_tests/tests/agent/agentPanel.spec.ts | 32 --------- browser_tests/tests/agent/agentPanelMocks.ts | 71 ++++++++----------- 3 files changed, 66 insertions(+), 75 deletions(-) create mode 100644 browser_tests/tests/agent/agentHttpError.spec.ts diff --git a/browser_tests/tests/agent/agentHttpError.spec.ts b/browser_tests/tests/agent/agentHttpError.spec.ts new file mode 100644 index 00000000000..d88a428e8bf --- /dev/null +++ b/browser_tests/tests/agent/agentHttpError.spec.ts @@ -0,0 +1,38 @@ +import { expect } from '@playwright/test' + +import enMessages from '@/locales/en/main.json' with { type: 'json' } + +import { agentTest as test } from '@e2e/tests/agent/agentPanelMocks' + +test( + 'names the HTTP status when the failure carries no reason phrase', + { tag: '@cloud' }, + async ({ + agentMessageHttpErrorMock: _agentMessageHttpErrorMock, + agentPanel + }) => { + // Regression: https://github.com/Comfy-Org/ComfyUI_frontend/pull/18374 + // The notice falls back to `Response.statusText`, and HTTP/2 — what cloud + // serves — has no reason phrase, so a 5xx with an unparseable body left the + // bubble reading "Message failed to send: " with nothing after the colon. + // + // Stubbed at `fetch` rather than with `page.route`, which cannot express + // this: Playwright fulfills over HTTP/1.1, where Chromium always supplies a + // phrase ("Service Unavailable" for 503, "Unknown" for an unassigned code). + // A browser-built `Response` leaves `statusText` empty, as HTTP/2 does. + await agentPanel.open() + await agentPanel.selectWorkflow() + + await agentPanel.composer.fill('Build a product photo workflow') + await agentPanel.sendButton.click() + + await expect( + agentPanel.root.getByText(enMessages.agent.sendFailed) + ).toBeVisible() + // The status is the assertion: the notice above is already visible without + // the fix, carrying nothing after its colon. + await expect( + agentPanel.root.getByText('Agent request failed (HTTP 503)') + ).toBeVisible() + } +) diff --git a/browser_tests/tests/agent/agentPanel.spec.ts b/browser_tests/tests/agent/agentPanel.spec.ts index d7100c03164..c59d9351b0a 100644 --- a/browser_tests/tests/agent/agentPanel.spec.ts +++ b/browser_tests/tests/agent/agentPanel.spec.ts @@ -376,38 +376,6 @@ test.describe('In-App Agent panel', { tag: '@cloud' }, () => { expect(postCount).toBe(1) }) - test.describe('HTTP error without a reason phrase', () => { - test.use({ agentMessageHttpErrorStatus: 503 }) - - test('names the HTTP status when the failure carries no reason phrase', async ({ - agentPanel - }) => { - // Regression: https://github.com/Comfy-Org/ComfyUI_frontend/pull/18374 - // The notice falls back to `Response.statusText`, and HTTP/2 — what cloud - // serves — has no reason phrase, so a 5xx with an unparseable body left the - // bubble reading "Message failed to send: " with nothing after the colon. - // - // Stubbed at `fetch` rather than with `page.route`, which cannot express - // this: Playwright fulfills over HTTP/1.1, where Chromium always supplies a - // phrase ("Service Unavailable" for 503, "Unknown" for an unassigned code). - // A browser-built `Response` leaves `statusText` empty, as HTTP/2 does. - await agentPanel.open() - await agentPanel.selectWorkflow() - - await agentPanel.composer.fill('Build a product photo workflow') - await agentPanel.sendButton.click() - - await expect( - agentPanel.root.getByText(enMessages.agent.sendFailed) - ).toBeVisible() - // The status is the assertion: the notice above is already visible without - // the fix, carrying nothing after its colon. - await expect( - agentPanel.root.getByText('Agent request failed (HTTP 503)') - ).toBeVisible() - }) - }) - test.describe('diagnostic report', () => { test.use({ permissions: ['clipboard-read', 'clipboard-write'], diff --git a/browser_tests/tests/agent/agentPanelMocks.ts b/browser_tests/tests/agent/agentPanelMocks.ts index 4bb894b3f49..e07a6680d0d 100644 --- a/browser_tests/tests/agent/agentPanelMocks.ts +++ b/browser_tests/tests/agent/agentPanelMocks.ts @@ -278,10 +278,7 @@ async function mockAgentBoot( objectInfo, postedMessages, vueNodes - }: Omit< - AgentFixtures, - 'agentMessageHttpErrorMock' | 'agentMessageHttpErrorStatus' | 'agentPanel' - > & { + }: Omit & { initialFeatureFlags: Record initialSettings: Record vueNodes: boolean @@ -534,7 +531,6 @@ type AgentFixtures = { agentConsentWrites: boolean[] agentFlagEnabled: boolean agentMessageHttpErrorMock: void - agentMessageHttpErrorStatus: number | undefined agentPanel: AgentPanel agentPanelInitiallyOpen: boolean agentOnboardingCompleted: boolean @@ -564,45 +560,34 @@ export const agentTest = comfyPageFixture.extend({ await use([]) }, agentFlagEnabled: [true, { option: true }], - agentMessageHttpErrorMock: [ - async ({ comfyPage, agentMessageHttpErrorStatus }, use) => { - if (agentMessageHttpErrorStatus === undefined) { - await use() - return + agentMessageHttpErrorMock: async ({ comfyPage }, use) => { + await comfyPage.page.evaluate((status) => { + const originalFetch = globalThis.fetch + globalThis.fetch = async (input, init) => { + const url = + typeof input === 'string' + ? input + : input instanceof URL + ? input.href + : input.url + const method = + init?.method ?? (input instanceof Request ? input.method : 'GET') + if (method === 'POST' && /\/agent\/threads\/[^/]+\/messages$/.test(url)) + return new Response('', { status }) + return originalFetch(input, init) } - await comfyPage.page.evaluate((status) => { - const originalFetch = globalThis.fetch - globalThis.fetch = async (input, init) => { - const url = - typeof input === 'string' - ? input - : input instanceof URL - ? input.href - : input.url - const method = - init?.method ?? (input instanceof Request ? input.method : 'GET') - if ( - method === 'POST' && - /\/agent\/threads\/[^/]+\/messages$/.test(url) - ) - return new Response('', { status }) - return originalFetch(input, init) - } - Reflect.set(globalThis, '__agentTestOriginalFetch', originalFetch) - }, agentMessageHttpErrorStatus) - await use() - await comfyPage.page.evaluate(() => { - const originalFetch = Reflect.get( - globalThis, - '__agentTestOriginalFetch' - ) as typeof globalThis.fetch | undefined - if (originalFetch) globalThis.fetch = originalFetch - Reflect.deleteProperty(globalThis, '__agentTestOriginalFetch') - }) - }, - { auto: true } - ], - agentMessageHttpErrorStatus: [undefined, { option: true }], + Reflect.set(globalThis, '__agentTestOriginalFetch', originalFetch) + }, 503) + await use() + await comfyPage.page.evaluate(() => { + const originalFetch = Reflect.get( + globalThis, + '__agentTestOriginalFetch' + ) as typeof globalThis.fetch | undefined + if (originalFetch) globalThis.fetch = originalFetch + Reflect.deleteProperty(globalThis, '__agentTestOriginalFetch') + }) + }, agentPanel: async ({ comfyPage }, use) => { await use(new AgentPanel(comfyPage.page)) }, From 6a41cdc6616ee7dac87c87c9a5b464443912f74a Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Thu, 1 Oct 2026 14:33:28 -0700 Subject: [PATCH 4/5] test(agent): address HTTP fallback review --- .../tests/agent/agentHttpError.spec.ts | 48 ++++++++++--------- browser_tests/tests/agent/agentPanelMocks.ts | 31 +----------- .../services/agent/agentRestClient.test.ts | 6 +-- 3 files changed, 28 insertions(+), 57 deletions(-) diff --git a/browser_tests/tests/agent/agentHttpError.spec.ts b/browser_tests/tests/agent/agentHttpError.spec.ts index d88a428e8bf..08fe04bbf3d 100644 --- a/browser_tests/tests/agent/agentHttpError.spec.ts +++ b/browser_tests/tests/agent/agentHttpError.spec.ts @@ -4,35 +4,39 @@ import enMessages from '@/locales/en/main.json' with { type: 'json' } import { agentTest as test } from '@e2e/tests/agent/agentPanelMocks' +test.beforeEach(async ({ comfyPage }) => { + await comfyPage.page.evaluate((status) => { + const originalFetch = globalThis.fetch + globalThis.fetch = async (input, init) => { + const url = + typeof input === 'string' + ? input + : input instanceof URL + ? input.href + : input.url + const method = + init?.method ?? (input instanceof Request ? input.method : 'GET') + if (method === 'POST' && /\/agent\/threads\/[^/]+\/messages$/.test(url)) + return new Response('', { status }) + return originalFetch(input, init) + } + }, 503) +}) + test( - 'names the HTTP status when the failure carries no reason phrase', + 'shows the HTTP status when a failed send has no error message', { tag: '@cloud' }, - async ({ - agentMessageHttpErrorMock: _agentMessageHttpErrorMock, - agentPanel - }) => { - // Regression: https://github.com/Comfy-Org/ComfyUI_frontend/pull/18374 - // The notice falls back to `Response.statusText`, and HTTP/2 — what cloud - // serves — has no reason phrase, so a 5xx with an unparseable body left the - // bubble reading "Message failed to send: " with nothing after the colon. - // - // Stubbed at `fetch` rather than with `page.route`, which cannot express - // this: Playwright fulfills over HTTP/1.1, where Chromium always supplies a - // phrase ("Service Unavailable" for 503, "Unknown" for an unassigned code). - // A browser-built `Response` leaves `statusText` empty, as HTTP/2 does. + async ({ agentPanel }) => { await agentPanel.open() await agentPanel.selectWorkflow() - await agentPanel.composer.fill('Build a product photo workflow') - await agentPanel.sendButton.click() + await agentPanel.sendMessage('Build a product photo workflow') await expect( - agentPanel.root.getByText(enMessages.agent.sendFailed) - ).toBeVisible() - // The status is the assertion: the notice above is already visible without - // the fix, carrying nothing after its colon. - await expect( - agentPanel.root.getByText('Agent request failed (HTTP 503)') + agentPanel.root.getByText( + `${enMessages.agent.sendFailed}: Agent request failed (HTTP 503)`, + { exact: true } + ) ).toBeVisible() } ) diff --git a/browser_tests/tests/agent/agentPanelMocks.ts b/browser_tests/tests/agent/agentPanelMocks.ts index e07a6680d0d..4a1c76dde1a 100644 --- a/browser_tests/tests/agent/agentPanelMocks.ts +++ b/browser_tests/tests/agent/agentPanelMocks.ts @@ -278,7 +278,7 @@ async function mockAgentBoot( objectInfo, postedMessages, vueNodes - }: Omit & { + }: Omit & { initialFeatureFlags: Record initialSettings: Record vueNodes: boolean @@ -530,7 +530,6 @@ type AgentFixtures = { agentConsentSave: { status: number; pending?: Promise } agentConsentWrites: boolean[] agentFlagEnabled: boolean - agentMessageHttpErrorMock: void agentPanel: AgentPanel agentPanelInitiallyOpen: boolean agentOnboardingCompleted: boolean @@ -560,34 +559,6 @@ export const agentTest = comfyPageFixture.extend({ await use([]) }, agentFlagEnabled: [true, { option: true }], - agentMessageHttpErrorMock: async ({ comfyPage }, use) => { - await comfyPage.page.evaluate((status) => { - const originalFetch = globalThis.fetch - globalThis.fetch = async (input, init) => { - const url = - typeof input === 'string' - ? input - : input instanceof URL - ? input.href - : input.url - const method = - init?.method ?? (input instanceof Request ? input.method : 'GET') - if (method === 'POST' && /\/agent\/threads\/[^/]+\/messages$/.test(url)) - return new Response('', { status }) - return originalFetch(input, init) - } - Reflect.set(globalThis, '__agentTestOriginalFetch', originalFetch) - }, 503) - await use() - await comfyPage.page.evaluate(() => { - const originalFetch = Reflect.get( - globalThis, - '__agentTestOriginalFetch' - ) as typeof globalThis.fetch | undefined - if (originalFetch) globalThis.fetch = originalFetch - Reflect.deleteProperty(globalThis, '__agentTestOriginalFetch') - }) - }, agentPanel: async ({ comfyPage }, use) => { await use(new AgentPanel(comfyPage.page)) }, diff --git a/src/workbench/extensions/agent/services/agent/agentRestClient.test.ts b/src/workbench/extensions/agent/services/agent/agentRestClient.test.ts index acc8c6d3872..5d0938fd8bd 100644 --- a/src/workbench/extensions/agent/services/agent/agentRestClient.test.ts +++ b/src/workbench/extensions/agent/services/agent/agentRestClient.test.ts @@ -458,11 +458,7 @@ describe('error mapping', () => { expect(error.body).toBeUndefined() }) - // `toApiError` falls back to `statusText`, so this branch is only reachable - // when the response carries no reason phrase — which is every HTTP/2 - // response. A `Response` built here leaves `statusText` empty, matching that; - // Chromium over HTTP/1.1 would supply "Service Unavailable" instead. - it('falls back to the HTTP status when the response has no reason phrase', async () => { + it('falls back to the HTTP status when the response has no error body or status text', async () => { respond(new Response('', { status: 503 })) const error = await makeClient() From c72053e408eb0867ed3a81d3a6c19a312d0a0cae Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Mon, 12 Oct 2026 08:37:14 +0000 Subject: [PATCH 5/5] test(agent): simplify HTTP fallback fetch stub The agent client always calls fetch with a URL string and an init that carries the method, so match on those directly and inline the status. --- .../tests/agent/agentHttpError.spec.ts | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/browser_tests/tests/agent/agentHttpError.spec.ts b/browser_tests/tests/agent/agentHttpError.spec.ts index 08fe04bbf3d..9ab0f81836a 100644 --- a/browser_tests/tests/agent/agentHttpError.spec.ts +++ b/browser_tests/tests/agent/agentHttpError.spec.ts @@ -5,22 +5,14 @@ import enMessages from '@/locales/en/main.json' with { type: 'json' } import { agentTest as test } from '@e2e/tests/agent/agentPanelMocks' test.beforeEach(async ({ comfyPage }) => { - await comfyPage.page.evaluate((status) => { + await comfyPage.page.evaluate(() => { const originalFetch = globalThis.fetch - globalThis.fetch = async (input, init) => { - const url = - typeof input === 'string' - ? input - : input instanceof URL - ? input.href - : input.url - const method = - init?.method ?? (input instanceof Request ? input.method : 'GET') - if (method === 'POST' && /\/agent\/threads\/[^/]+\/messages$/.test(url)) - return new Response('', { status }) - return originalFetch(input, init) - } - }, 503) + globalThis.fetch = async (input, init) => + init?.method === 'POST' && + /\/agent\/threads\/[^/]+\/messages$/.test(String(input)) + ? new Response('', { status: 503 }) + : originalFetch(input, init) + }) }) test(