AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
test(frontend/copilot): add SSE streaming integration test infrastructure (#13098)
### Why / What / How
**Why:** The CoPilot frontend streams responses through AI SDK v6 via
SSE, but we had no integration tests exercising the streaming pipeline
end-to-end. The existing `CopilotPage.test.tsx` stubs out
`ChatContainer` entirely, so the wiring between user-message → transport
→ AI-SDK runtime → DOM-rendered assistant text was untested.
**What:** Adds two pieces of test infrastructure plus a happy-path
integration test:
1. `src/tests/integrations/copilot-sse.ts` — a reusable MSW-compatible
SSE response builder that emits AI-SDK v6 `UIMessageChunk` frames
(`text-start` / `text-delta` / `text-end` / `finish-step` / `finish`)
wrapped in the `text/event-stream` + `x-vercel-ai-ui-message-stream: v1`
wire format, terminated with `data: [DONE]`.
2. `copilotStreamHandler({ baseUrl, sessionId, chunks })` — convenience
factory that returns an MSW `http.post` handler matching the CoPilot
transport's absolute backend URL (the transport bypasses the Next.js
proxy to dodge Vercel's 800s function-timeout).
3. `copilotStream.integration.test.tsx` — happy-path test: mounts a tiny
harness component that wires `useCopilotStream` exactly like
`CopilotChatHost` does, clicks send, and asserts the streamed assistant
text renders.
**How:** The SSE helper builds a `ReadableStream<Uint8Array>` by
JSON-encoding each `UIMessageChunk` as a `data: …\n\n` frame. MSW v2
accepts `ReadableStream` bodies on `HttpResponse`, so no node-streams
adapter is needed. The test only mocks `getCopilotAuthHeaders` (to skip
Supabase) and overrides `environment.getAGPTServerBaseUrl()` to a fixed
host so the absolute URL is deterministic — everything else (transport,
AI SDK `Chat` runtime, registry, dedup, watchdogs) is real.
### Changes 🏗️
- New: `autogpt_platform/frontend/src/tests/integrations/copilot-sse.ts`
— `streamSseResponse`, `assistantTextChunks`, `copilotStreamHandler`.
- New:
`autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/copilotStream.integration.test.tsx`
— two tests covering single-delta and multi-delta concatenation.
### Checklist 📋
#### For code changes:
- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [x] I have tested my changes according to the test plan:
- [x] `pnpm exec vitest run
src/app/(platform)/copilot/__tests__/copilotStream.integration.test.tsx`
— 2 tests pass in <1s.
- [x] `pnpm exec vitest run src/app/(platform)/copilot` — full CoPilot
suite (884 tests across 56 files) still green.
- [x] `pnpm exec tsc --noEmit` — clean.
- [x] `pnpm prettier --write` applied to new files.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> U
Ubbe committed
3073d443af3f1268394d4c4680cf1e96701f519b
Parent: cee8796
Committed by GitHub <noreply@github.com>
on 5/13/2026, 12:56:24 PM