LibreChat/e2e/specs/mock/scenarios/chat-error-event.spec.ts
Marco Beretta 553c5ca63c
🧾 refactor: Drop the Unsent Request/Response Pair From ChatErrorData (#17221)
* refactor: Drop the Request/Response Pair No Emitter Sends From ChatErrorData

No server path writes requestMessage or responseMessage on the SSE error event: handleError writes a string or sendError's error message, and a failed turn's pair travels on the final frame, which already types it as partial. Removing the fields keeps clients from reading data that never arrives.

* test: Cover a Turn That Ends on the Served Stream Error
2026-10-18 20:30:39 +02:00

36 lines
1.4 KiB
TypeScript

import { expect, test } from '@playwright/test';
import {
MOCK_ENDPOINTS,
NEW_CHAT_PATH,
messagesView,
selectMockEndpoint,
sendMessage,
} from '../helpers';
/**
* The fake model throws mid-stream for `E2E_FORCED_ERROR:`, so the server ends the
* turn on the SSE `error` event; the transport parses that body as `ChatErrorData`.
*/
test.describe('served stream error', () => {
test('a turn that fails mid-stream shows the provider error and settles the composer @scenario:failed-turn-shows-served-error', async ({
page,
}) => {
test.setTimeout(90_000);
const label = `served-error-${Date.now()}`;
const providerError = `E2E forced stream error ${label}`;
await page.goto(NEW_CHAT_PATH, { timeout: 15_000 });
await selectMockEndpoint(page, MOCK_ENDPOINTS[0]);
const response = await sendMessage(page, `E2E_FORCED_ERROR:${label}`);
expect(response.ok()).toBeTruthy();
await expect(page).toHaveURL(/\/c\/(?!new)/, { timeout: 15_000 });
await expect(messagesView(page).getByText(providerError)).toBeVisible({ timeout: 30_000 });
await expect(page.getByRole('button', { name: 'Stop generating' })).toHaveCount(0);
await expect(page.getByRole('textbox', { name: 'Message input' })).toBeEnabled();
await page.reload();
await expect(messagesView(page).getByText(providerError)).toBeVisible({ timeout: 30_000 });
});
});