diff --git a/browser_tests/tests/agent/agentHttpError.spec.ts b/browser_tests/tests/agent/agentHttpError.spec.ts new file mode 100644 index 00000000000..9ab0f81836a --- /dev/null +++ b/browser_tests/tests/agent/agentHttpError.spec.ts @@ -0,0 +1,34 @@ +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.beforeEach(async ({ comfyPage }) => { + await comfyPage.page.evaluate(() => { + const originalFetch = globalThis.fetch + globalThis.fetch = async (input, init) => + init?.method === 'POST' && + /\/agent\/threads\/[^/]+\/messages$/.test(String(input)) + ? new Response('', { status: 503 }) + : originalFetch(input, init) + }) +}) + +test( + 'shows the HTTP status when a failed send has no error message', + { tag: '@cloud' }, + async ({ agentPanel }) => { + await agentPanel.open() + await agentPanel.selectWorkflow() + + await agentPanel.sendMessage('Build a product photo workflow') + + await expect( + agentPanel.root.getByText( + `${enMessages.agent.sendFailed}: Agent request failed (HTTP 503)`, + { exact: true } + ) + ).toBeVisible() + } +) diff --git a/src/workbench/extensions/agent/services/agent/agentRestClient.test.ts b/src/workbench/extensions/agent/services/agent/agentRestClient.test.ts index ed5c3ea3e78..b72d0a8d897 100644 --- a/src/workbench/extensions/agent/services/agent/agentRestClient.test.ts +++ b/src/workbench/extensions/agent/services/agent/agentRestClient.test.ts @@ -584,7 +584,7 @@ describe('error mapping', () => { expect(error.body).toBeUndefined() }) - it('falls back to the HTTP status when the response has no error text', 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()