Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

README.md

399 lines26.8 KB

1# TanStack AI E2E Tests
2​
3End-to-end tests for TanStack AI using Playwright and [aimock](https://github.com/CopilotKit/aimock) for deterministic LLM mocking.
4​
5**Architecture:** Playwright drives a TanStack Start app (`testing/e2e/`) which routes requests through provider adapters pointing at aimock. Fixtures define mock responses. No real API keys needed. All scenarios (including tool execution flows) use aimock fixtures. Tests run in parallel with per-test `X-Test-Id` isolation.
6​
7**Providers tested in CI:** openai, anthropic, gemini, vertex, vertex-grok, vertex-mistral, ollama, groq, grok, openrouter, openrouter-responses, vercel-gateway, vercel-gateway-responses, lovable, lovable-responses, bedrock, bedrock-responses, openai-compatible, openai-compatible-legacy, mistral, byteplus, elevenlabs, llmgateway, cloudflare
8​
9**Local `pnpm test:e2e`** runs openai, anthropic, and gemini. If none of those providers support a feature, the feature still runs on the providers that do. An explicit `E2E_PROVIDERS` list runs only those providers. Use `E2E_PROVIDERS=*` for the full matrix, or `E2E_PROVIDERS=grok` (comma-separated) to pick providers. Playwright does not retry or record video locally; CI retries twice and keeps the video of a failed test.
10​
11> **Claude Code (`@tanstack/ai-claude-code`) is excluded from the standard matrix.** It's a harness adapter that spawns the Claude Code runtime as a subprocess, so aimock's per-test `X-Test-Id` header isolation can't be injected into its requests. It's covered by unit tests in the package plus a gated live smoke test in `tests/claude-code.spec.ts` — run it with `CLAUDE_CODE_E2E=1` and an `ANTHROPIC_API_KEY` (or a local `claude login`).
12​
13## What's tested
14​
15### Provider-coverage tests
16​
17Each test iterates over supported providers using `providersFor('feature')`:
18​
19| Feature | Providers | Spec file |
20| ------------------------ | --------- | ---------------------------------------- |
21| chat | 7 | `tests/chat.spec.ts` |
22| one-shot-text | 7 | `tests/one-shot-text.spec.ts` |
23| multi-turn | 7 | `tests/multi-turn.spec.ts` |
24| structured-output | 7 | `tests/structured-output.spec.ts` |
25| structured-output-stream | 4 | `tests/structured-output-stream.spec.ts` |
26| tool-calling | 7 | `tests/tool-calling.spec.ts` |
27| parallel-tool-calls | 6 | `tests/parallel-tool-calls.spec.ts` |
28| tool-approval | 6 | `tests/tool-approval.spec.ts` |
29| text-tool-text | 6 | `tests/text-tool-text.spec.ts` |
30| agentic-structured | 7 | `tests/agentic-structured.spec.ts` |
31| reasoning | 8 | `tests/reasoning.spec.ts` |
32| multimodal-image | 5 | `tests/multimodal-image.spec.ts` |
33| multimodal-document | 1 | `tests/multimodal-document.spec.ts` |
34| multimodal-structured | 5 | `tests/multimodal-structured.spec.ts` |
35| summarize | 6 | `tests/summarize.spec.ts` |
36| summarize-stream | 6 | `tests/summarize-stream.spec.ts` |
37| image-gen | 7 | `tests/image-gen.spec.ts` |
38| image-to-image | 1 | `tests/image-to-image.spec.ts` |
39| image-to-video | 1 | `tests/image-to-video.spec.ts` |
40| tts | 3 | `tests/tts.spec.ts` |
41| transcription | 3 | `tests/transcription.spec.ts` |
42| audio-gen | 1 | `tests/audio-gen.spec.ts` |
43| video-understanding | 1 | `tests/video-understanding.spec.ts` |
44​
45### Tools-test page
46​
47Deterministic scenarios covering tool execution flows:
48​
49| Spec file | Tests | What it covers |
50| ------------------------------------------------- | ----- | -------------------------------------------------------- |
51| `tests/tools-test/chat-flow.spec.ts` | 5 | Text-only, server tool, client tool, tool call structure |
52| `tests/tools-test/approval-flow.spec.ts` | 6 | Approve, deny, sequential, parallel, mixed flows |
53| `tests/tools-test/client-tool.spec.ts` | 5 | Single, sequential, parallel, triple, server+client |
54| `tests/tools-test/race-conditions.spec.ts` | 8 | No blocking, no deadlocks, timing, mixed flows |
55| `tests/tools-test/server-client-sequence.spec.ts` | 5 | Server→client, parallel server, ordering |
56​
57### Interrupt playground
58​
59Deterministic coverage of every AG-UI interrupt shape, ported from the
60`ts-react-chat` wildlife example (route `/interrupts-test`, scenarios in
61`src/lib/interrupt-scenario-tools.ts`). Each scenario isolates one interrupt
62behavior — server/client × boolean, shared payload, branch payload, edited
63args, plus a generic (non-tool) interrupt and batch sets — and is exercised
64across allow / deny / cancel via both per-item (`interrupt.resolveInterrupt` /
65`interrupt.cancel`) and root batch (`resolveInterrupts` / `cancelInterrupts`)
66resolution.
67​
68| Spec file | Tests | What it covers |
69| ---------------------------------------- | ----- | ---------------------------------------------------------------------- |
70| `tests/interrupts-test/per-item.spec.ts` | 24 | Approve / deny / cancel each single scenario via the bound interrupt |
71| `tests/interrupts-test/generic.spec.ts` | 2 | Generic interrupt resolve-with-payload and cancel |
72| `tests/interrupts-test/batch.spec.ts` | 5 | Root approve-all / deny-all / cancel-all, per-item, and mixed resolver |
73​
74Notes:
75​
76- Server tool results are **not** surfaced to the client as message parts, so
77 server execution is asserted via the `approval-responded` state; server
78 edited-args are verified through a `emitCustomEvent` echo.
79- A shared `approvalSchema` requires a payload on the **deny** decision too, so
80 those scenarios carry a `denyPayload`.
81​
82### Advanced feature tests
83​
84| Spec file | What it covers |
85| ------------------------------ | --------------------------------------------------------- |
86| `tests/abort.spec.ts` | Stop button cancels in-flight generation |
87| `tests/lazy-tools.spec.ts` | `__lazy__tool__discovery__` discovers and uses lazy tools |
88| `tests/custom-events.spec.ts` | Server tool `emitCustomEvent` received by client |
89| `tests/middleware.spec.ts` | `onChunk` transform, `onBeforeToolCall` skip |
90| `tests/error-handling.spec.ts` | Server RUN_ERROR, aimock error fixture |
91| `tests/tool-error.spec.ts` | Tool throws error, agentic loop continues |
92| `tests/activity.spec.ts` | AG-UI activity snapshot, send filter, reconstruct hydrate |
93​
94### Durable / detachable run tests
95​
96| Spec file | What it covers |
97| -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
98| `tests/delivery-durability.spec.ts` | Transport layer: offset-tagged log, `Last-Event-ID` reconnect, second-tab join, SSE + NDJSON |
99| `tests/persistence-durability.spec.ts` | Client layer: a browser refresh restores the conversation and any pending interrupt |
100| `tests/join-run-client-tool.spec.ts` | Mid-run reload: `joinRun` replay that ends on a client tool drains the continuation (issue #1058) |
101| `tests/sandbox-durability.spec.ts` | Sandbox instances: a second run resumes the persisted sandbox |
102| `tests/durable-takeover.spec.ts` | Takeover with log alignment, detach-on-disconnect, out-of-band cancel in both bands, cancel-vs-disconnect divergence, and the superseded-driver epoch fence |
103​
104`durable-takeover.spec.ts` drives `/api/durable-takeover`, a provider-free harness
105whose fake agent journal advances only on an explicit `?action=tick`, so every
106disconnect happens at a known point in the stream. Two things to know before
107extending it:
108​
109- **The disconnect is injected server-side** (`?action=drop`, a plain abort with
110 no reason) — a genuine precondition, not a workaround. A client `fetch` abort
111 does not propagate to the server through this app's dev server, so a test
112 cannot otherwise produce a mid-stream socket close the run observes; the spec
113 documents this in the `SseStream` comments (around lines 141-146).
114- **`?action=seed` is also used, and is still legitimate**: it lets a test reach
115 the cross-host takeover case — attaching from a process that never held the
116 original connection — which a single test process cannot otherwise produce.
117 A detached run's log now stays open for takeover: `RunDetachedCapability` and
118 `packages/ai/src/delivery-detach.ts` carry the run's detach verdict to the
119 sink, which skips both the synthetic `RUN_ERROR` and `durability.close()` for
120 an unrequested disconnect on a detachable run. That path is pinned by
121 `'a real disconnect, then an attach, continues the stream'` — a normal
122 passing test, not a `test.fail()` case.
123​
124## What to add for your change
125​
126E2E coverage is mandatory for every feature, bug fix, or behavior change (see the root `CLAUDE.md`). Mirror of that table, kept in sync here:
127​
128| Change type | What E2E test to add |
129| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
130| New provider adapter | Add provider to `feature-support.ts` + `test-matrix.ts`. Existing feature tests auto-run. |
131| New feature (e.g., new generation type) | Add feature to types, feature config, support matrix. Create fixture + spec file. |
132| Bug fix in chat/streaming | Add a test case to `chat.spec.ts` or `tools-test/` that reproduces the bug. |
133| Tool system change | Add scenario to `tools-test-scenarios.ts` + test in `tools-test/` specs. |
134| Middleware change | Add test to `middleware.spec.ts` with appropriate scenario. |
135| Client-side change (useChat, etc.) | Add test covering the observable behavior change. |
136| joinRun + client-tool continuation | Add a spec that reloads mid-run, tails with `joinRun`, and asserts the client-tool result POSTs after replay (see `tests/join-run-client-tool.spec.ts`). |
137| Durable/detachable run + takeover | Add a spec that disconnects mid-stream, reconnects with the same `runId`, and asserts the resumed stream continues from the aligned offset instead of restarting the agent. |
138| Out-of-band cancel vs. plain disconnect | Add a case distinguishing `requestRunCancel`/`wasCancelRequested` (durable cancel — record ends `'aborted'`) from an unrequested disconnect on a detachable run (record stays `'running'`, resumable). |
139| New run-store backend | Run `runPersistenceConformance` from `packages/ai-persistence/src/testkit/` against it; it now pins `undefined` vs. explicit `false` on `cancelRequested` and absent vs. explicit `undefined` on `update`. |
140| New sandbox provider | Run the journal conformance suite from `@tanstack/ai-sandbox/testkit` against it, using `makeFakeShellSpawn` (also from that testkit) to exercise the journal/claim/driver seam without a real sandbox. |
141​
142## 1. Quick Start
143​
144```bash
145# Install dependencies
146pnpm install
147​
148# Run all E2E tests
149pnpm --filter @tanstack/ai-e2e test:e2e
150​
151# Run with Playwright UI (useful for debugging)
152pnpm --filter @tanstack/ai-e2e test:e2e:ui
153​
154# Run a specific spec
155pnpm --filter @tanstack/ai-e2e test:e2e -- --grep "openai -- chat"
156​
157# Run only the tools-test specs
158pnpm --filter @tanstack/ai-e2e test:e2e -- tests/tools-test/
159```
160​
161## 2. Recording a New Fixture
162​
163```bash
164# 1. Set your API keys
165export OPENAI_API_KEY=sk-...
166export ANTHROPIC_API_KEY=sk-ant-...
167​
168# 2. Start the app in record mode
169pnpm --filter @tanstack/ai-e2e record
170​
171# 3. Navigate to the feature: http://localhost:3010/openai/tool-calling
172​
173# 4. Chat — aimock proxies to the real API and saves the fixture
174​
175# 5. Find it in testing/e2e/fixtures/recorded/
176​
177# 6. Stop the dev server (Ctrl+C)
178```
179​
180## 3. Organizing the Recorded Fixture
181​
182Move from `recorded/` to the appropriate feature directory:
183​
184```bash
185mv fixtures/recorded/openai-*.json fixtures/tool-calling/my-new-scenario.json
186```
187​
188Clean up the fixture:
189​
190- **Simplify the `match` field** — use a unique `[prefix]` userMessage
191- **Verify the `response`** — check content, toolCalls, or reasoning fields
192- **Remove provider-specific artifacts** — fixtures should be provider-agnostic
193​
194**Important:** aimock uses **substring matching** for `userMessage`. Always use a unique `[prefix]` to prevent collisions:
195​
196```json
198 "fixtures": [
199 {
200 "match": { "userMessage": "[myfeature] describe the guitar" },
201 "response": {
202 "content": "The Fender Stratocaster is a versatile electric guitar..."
203 }
204 }
205 ]
207```
208​
209Existing prefixes: `[chat]`, `[oneshot]`, `[reasoning]`, `[multiturn-1]`, `[multiturn-2]`, `[toolcall]`, `[parallel]`, `[approval]`, `[approval-deny]`, `[text-tool-text]`, `[structured]`, `[structured-stream]`, `[structured-stream-abort]`, `[agentic]`, `[mmimage]`, `[mmstruct]`, `[summarize]`, `[imagegen]`, `[tts]`, `[transcription]`, `[abort-test]`, `[error-test]`.
210​
211## 4. Writing a Test
212​
213Tests import from `./fixtures` to get the `testId` and `aimockPort` for parallel isolation:
214​
215```typescript
216import { test, expect } from './fixtures'
217import {
218 sendMessage,
219 waitForResponse,
220 getLastAssistantMessage,
221 featureUrl,
222} from './helpers'
223import { providersFor } from './test-matrix'
224​
225for (const provider of providersFor('my-feature')) {
226 test.describe(`${provider} — my-feature`, () => {
227 test('does the thing', async ({ page, testId, aimockPort }) => {
228 await page.goto(featureUrl(provider, 'my-feature', testId, aimockPort))
229​
230 await sendMessage(page, '[myfeature] describe the guitar')
231 await waitForResponse(page)
232​
233 const response = await getLastAssistantMessage(page)
234 expect(response).toContain('Stratocaster')
235 })
236 })
238```
239​
240For tool tests that use `sequenceIndex`, use `waitForAssistantText` — the agentic loop produces multiple responses:
241​
242```typescript
243await sendMessage(page, '[toolcall] what guitars do you have in stock')
244await waitForResponse(page)
245​
246const toolCalls = await getToolCalls(page)
247expect(toolCalls[0].name).toBe('getGuitars')
248​
249// Wait for text response AFTER tool execution
250await waitForAssistantText(page, 'Fender Stratocaster')
251```
252​
253## 5. Adding a New Feature
254​
2551. **Add to `src/lib/types.ts`** — `Feature` union + `ALL_FEATURES` array
2562. **Add to `src/lib/features.ts`** — define tools, modelOptions
2573. **Add to `src/lib/feature-support.ts`** — mark which providers support it
2584. **Add to `tests/test-matrix.ts`** — mirror the support matrix
2595. **Create fixture** — `fixtures/my-new-feature/basic.json` with `[prefix]` userMessage
2606. **Create test spec** — `tests/my-new-feature.spec.ts` using `providersFor()`
261​
262## 6. Adding a New Provider
263​
2641. **Add adapter factory to `src/lib/providers.ts`** — with `defaultHeaders` for `X-Test-Id`
2652. **Add to `src/lib/feature-support.ts`** — mark which features it supports
2663. **Add to `tests/test-matrix.ts`** — mirror the support matrix
2674. **No fixture changes needed** — aimock translates to correct wire format
268​
269### Vertex (Gemini on Vertex AI)
270​
271`vertex` is the Gemini adapter with Vertex auth and the Vertex request path. It is not a new protocol.
272​
273The factory in `src/lib/providers.ts` calls `vertexText` with `vertexE2eConfig()` from `src/lib/vertex-e2e.ts`:
274​
275- `project` + `location` so `@google/genai` posts to `/v1/projects/{p}/locations/{l}/publishers/google/models/{m}:(generateContent|streamGenerateContent)`. aimock already serves that path.
276- A dummy `googleAuthOptions.authClient` so the SDK does not look for Application Default Credentials in CI.
277- `apiVersion: 'v1'`. The SDK default for Vertex is `v1beta1`, and aimock's Vertex handler only matches `/v1/…`.
278​
279Chat, tools, structured output, multimodal image, and summarize reuse the existing Gemini fixtures. Media, embedding, TTS, video, and Gemini Interactions stay off the Vertex row: those Gemini e2e mounts live under `/v1beta`, and Vertex uses a different path.
280​
281Claude on Vertex (`anthropicVertexText`) is not in this matrix. That SDK talks OAuth and a different Vertex URL that aimock does not mock.
282​
283### Vertex Grok and Vertex Mistral
284​
285`vertex-grok` is the Grok Responses adapter with Vertex auth. The factory in `src/lib/providers.ts` calls `grokVertexText` with:
286​
287- `baseURL` pointed at aimock `/v1`, so the OpenAI client posts `/v1/responses` like the xAI Grok row
288- a dummy `authClient` so the factory does not look for Application Default Credentials
289- the factory still prefixes the wire model with `xai/`
290​
291`vertex-mistral` is the Mistral chat adapter with Vertex auth. The factory calls `mistralVertexText` with `resolveRequestUrl` pointed at aimock `/v1/chat/completions`. That skips the Vertex publisher `:rawPredict` rewrite.
292​
293Both rows reuse the existing Grok and Mistral fixtures. Image, TTS, transcription, and embedding stay off these rows.
294​
295### Bedrock Converse coverage gap
296​
297The `bedrock` and `bedrock-responses` providers in this matrix use `createBedrockText` with a `baseURL` pointing at aimock — they speak Bedrock's **OpenAI-compatible** endpoint, which aimock's OpenAI replay handles fine.
298​
299The default `bedrock-converse` adapter (introduced later) uses `@aws-sdk/client-bedrock-runtime` and speaks AWS's **binary event-stream (`vnd.amazon.eventstream`) Converse protocol**, which `@copilotkit/aimock` does not currently mock. Adding `bedrock-converse` to the live matrix would fail without a Converse-capable aimock provider.
300​
301**Coverage today:** the Converse translation layer (message converter, tool converter, stream processor, structured output, adapter) is covered by unit tests in `packages/ai-bedrock/tests/converse/` (64 tests). The OpenAI-compatible `bedrock` and `bedrock-responses` entries remain in the E2E matrix as-is.
302​
303**Partial coverage:** `bedrock-converse-cache.spec.ts` drives the real Converse adapter through the AWS SDK against a hand-crafted mount (`/bedrock-converse-cache` in `global-setup.ts`) that encodes `vnd.amazon.eventstream` frames with `@smithy/eventstream-codec`. It covers `metadata.cachePoint` placement and the cache usage counters. The mount answers one fixed stream, so it is not a general Converse replay.
304​
305**Follow-up:** a Bedrock/Converse provider will be added to aimock to close this gap and enable full E2E coverage of the Converse path.
306​
307### BytePlus (Ark) path handling and record-mode gap
308​
309BytePlus splits across two products, and the E2E wiring reflects that split:
310​
311- **Ark** (chat, Seedream image, Seedance video) serves everything under `/api/v3`, so the chat, image and video adapters get `baseURL: <mock>/api/v3`.
312- **Seed Speech** (TTS, ASR) is a separate host with a separate key, and its adapters append `/api/v3/...` themselves — so they get the bare `<mock>` base.
313​
314Chat and image need **no mock changes**. aimock's compat-path normalizer rewrites any non-`/v1/`, non-`/v2/` path ending in a known OpenAI suffix to `/v1/<suffix>`, so `/api/v3/chat/completions` and `/api/v3/images/generations` land on the native handlers and the provider-agnostic fixtures apply unchanged. Seedream's request body differs from OpenAI's (`size` as a `1K`/`2K` token, no `n`, `watermark`), but aimock's image handler only reads `model` and `prompt` and answers with the `{ created, data: [...] }` envelope Seedream also returns.
315​
316Three endpoints have no aimock equivalent and are mounted in `global-setup.ts`, all on the `/api/v3` prefix — each returns `false` for paths it doesn't own so chat and image still fall through:
317​
318- `byteplusSeedanceMount()` — `POST`/`GET /contents/generations/tasks[/{id}]`
319- `byteplusTTSMount()` — `POST /tts/create`
320- `byteplusASRMount()` — `POST /auc/bigmodel/recognize/flash`
321​
322**Record-mode gap:** aimock's `RecordProviderKey` union has no `byteplus` entry, so `pnpm record` can't proxy `ark.ap-southeast.bytepluses.com` or the Seed Speech host to capture real fixtures — the same situation as the Bedrock Converse gap above. Chat features reuse the existing provider-agnostic fixtures (aimock matches on message content, not provider); the media endpoints are served by the hand-written mounts listed above. Update those mounts by hand if the wire shapes change, and cross-check against the adapter unit tests in `packages/ai-byteplus/tests/`.
323​
324**SDK baseURL notes:**
325​
326- OpenAI, Grok: `LLMOCK_OPENAI` (with `/v1`) + `defaultHeaders`
327- Groq: `LLMOCK_BASE` (SDK appends `/openai/v1/` internally) + `defaultHeaders`
328- Anthropic: `LLMOCK_BASE` + `defaultHeaders`
329- Gemini: `httpOptions: { baseUrl: LLMOCK_BASE, headers }`
330- Vertex: `vertexE2eConfig(LLMOCK_BASE, headers)` (`project` + `location` + dummy auth + `apiVersion: 'v1'`)
331- Vertex Grok: `grokVertexText` with `baseURL: LLMOCK_OPENAI`, dummy `authClient`, and `defaultHeaders`
332- Vertex Mistral: `mistralVertexText` with `resolveRequestUrl` → `LLMOCK_BASE/v1/chat/completions`, dummy `authClient`, and `defaultHeaders`
333- Ollama: `{ host: LLMOCK_BASE, headers }` (config object)
334- OpenRouter: `serverURL` with `?testId=` query param (SDK doesn't support headers)
335- BytePlus: `LLMOCK_BASE + /api/v3` + `defaultHeaders` for Ark (chat, image, video); bare `LLMOCK_BASE` + `defaultHeaders` for Seed Speech (TTS, ASR)
336​
337## 7. Adding a Tool Test Scenario
338​
3391. **Create fixture** — `fixtures/tools-test/my-scenario.json` with `[my-scenario] run test` userMessage
3402. **Add tool definitions to `src/lib/tools-test-tools.ts`** if new tools needed
3413. **Update `getToolsForScenario`** — map scenario to tools
3424. **Add to `SCENARIO_LIST`** — for the UI dropdown
3435. **Create test** in `tests/tools-test/` — use helpers from `tests/tools-test/helpers.ts`
344​
345## 8. Adding a Middleware Test
346​
3471. **Create fixture** — `fixtures/middleware-test/my-scenario.json`
3482. **Add middleware to `src/routes/api.middleware-test.ts`** — new mode
3493. **Add test to `tests/middleware.spec.ts`**
350​
351## 9. Fixture Matching Tips
352​
353- **`userMessage`** — **substring matching**, always use unique `[prefix]` strings
354- **`sequenceIndex`** — tracks request count per match pattern per `X-Test-Id`. Use for multi-step tool flows.
355- **`tool`** — matches when the model calls a specific tool
356- **`model`** — matches a specific model name (avoid — breaks provider-agnosticism)
357- Fixtures are matched in order — first match wins
358​
359## 10. Troubleshooting
360​
361- **Test times out**: Check `userMessage` in fixture exactly matches `sendMessage()` (including `[prefix]`)
362- **Wrong fixture matched**: Overlapping `userMessage` substrings. Make prefixes more specific.
363- **Tool test wrong response**: `sequenceIndex` counter issue. Each test gets a unique `X-Test-Id` for isolation — make sure you import `test` from `./fixtures`, not `@playwright/test`
364- **Fixture works for OpenAI but not Anthropic**: Remove `model` from match field
365- **Port 4010 already in use**: Kill stale aimock process. aimock starts in `globalSetup` and lives for the entire test run.
366​
367## Architecture
368​
369```
370testing/e2e/
371├── src/
372│ ├── routes/
373│ │ ├── $provider/$feature.tsx # Dynamic chat UI per provider+feature
374│ │ ├── tools-test.tsx # Tools test page with event tracking
375│ │ ├── middleware-test.tsx # Middleware test page
376│ │ ├── api.chat.ts # Chat endpoint → aimock
377│ │ ├── api.tools-test.ts # Tools endpoint → aimock
378│ │ └── api.middleware-test.ts # Middleware endpoint → aimock + middleware
379│ ├── lib/
380│ │ ├── providers.ts # Provider → adapter factory (X-Test-Id headers)
381│ │ ├── features.ts # Feature → config (tools, modelOptions)
382│ │ ├── feature-support.ts # Provider × feature support matrix
383│ │ └── tools-test-tools.ts # Server + client tool definitions
384│ └── components/
385│ └── ChatUI.tsx # Chat interface with stop button + image rendering
386├── fixtures/ # aimock fixture JSON files (organized by feature)
387├── test-assets/ # Images for multimodal tests
388├── global-setup.ts # Starts aimock on port 4010
389├── global-teardown.ts # Stops aimock
390├── tests/
391│ ├── fixtures.ts # Playwright fixture (testId + aimockPort)
392│ ├── helpers.ts # sendMessage, waitForResponse, featureUrl, etc.
393│ ├── test-matrix.ts # providersFor() — which providers support which features
394│ ├── *.spec.ts # Provider-coverage + advanced feature tests
395│ └── tools-test/ # Tool execution flow tests
396│ ├── helpers.ts # selectScenario, runTest, getMetadata, etc.
397│ └── *.spec.ts # Tool scenario tests
398└── playwright.config.ts # fullyParallel: true, retries: 2, globalSetup/Teardown
399```