Open History to see the last commit
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
93### Durable / detachable run tests
94
95| Spec file | What it covers |
96| -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
97| `tests/delivery-durability.spec.ts` | Transport layer: offset-tagged log, `Last-Event-ID` reconnect, second-tab join, SSE + NDJSON |
98| `tests/persistence-durability.spec.ts` | Client layer: a browser refresh restores the conversation and any pending interrupt |
99| `tests/join-run-client-tool.spec.ts` | Mid-run reload: `joinRun` replay that ends on a client tool drains the continuation (issue #1058) |
100| `tests/sandbox-durability.spec.ts` | Sandbox instances: a second run resumes the persisted sandbox |
101| `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 |
102
103`durable-takeover.spec.ts` drives `/api/durable-takeover`, a provider-free harness
104whose fake agent journal advances only on an explicit `?action=tick`, so every
105disconnect happens at a known point in the stream. Two things to know before
106extending it:
107
108- **The disconnect is injected server-side** (`?action=drop`, a plain abort with
109 no reason) — a genuine precondition, not a workaround. A client `fetch` abort
110 does not propagate to the server through this app's dev server, so a test
111 cannot otherwise produce a mid-stream socket close the run observes; the spec
112 documents this in the `SseStream` comments (around lines 141-146).
113- **`?action=seed` is also used, and is still legitimate**: it lets a test reach
114 the cross-host takeover case — attaching from a process that never held the
115 original connection — which a single test process cannot otherwise produce.
116 A detached run's log now stays open for takeover: `RunDetachedCapability` and
117 `packages/ai/src/delivery-detach.ts` carry the run's detach verdict to the
118 sink, which skips both the synthetic `RUN_ERROR` and `durability.close()` for
119 an unrequested disconnect on a detachable run. That path is pinned by
120 `'a real disconnect, then an attach, continues the stream'` — a normal
121 passing test, not a `test.fail()` case.
122
123## What to add for your change
124
125E2E coverage is mandatory for every feature, bug fix, or behavior change (see the root `CLAUDE.md`). Mirror of that table, kept in sync here:
126
127| Change type | What E2E test to add |
128| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
129| New provider adapter | Add provider to `feature-support.ts` + `test-matrix.ts`. Existing feature tests auto-run. |
130| New feature (e.g., new generation type) | Add feature to types, feature config, support matrix. Create fixture + spec file. |
131| Bug fix in chat/streaming | Add a test case to `chat.spec.ts` or `tools-test/` that reproduces the bug. |
132| Tool system change | Add scenario to `tools-test-scenarios.ts` + test in `tools-test/` specs. |
133| Middleware change | Add test to `middleware.spec.ts` with appropriate scenario. |
134| Client-side change (useChat, etc.) | Add test covering the observable behavior change. |
135| 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`). |
136| 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. |
137| 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). |
138| 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`. |
139| 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. |
140
141## 1. Quick Start
142
143```bash
144# Install dependencies
145pnpm install
146
147# Run all E2E tests
148pnpm --filter @tanstack/ai-e2e test:e2e
149
150# Run with Playwright UI (useful for debugging)
151pnpm --filter @tanstack/ai-e2e test:e2e:ui
152
153# Run a specific spec
154pnpm --filter @tanstack/ai-e2e test:e2e -- --grep "openai -- chat"
155
156# Run only the tools-test specs
157pnpm --filter @tanstack/ai-e2e test:e2e -- tests/tools-test/
158```
159
160## 2. Recording a New Fixture
161
162```bash
163# 1. Set your API keys
164export OPENAI_API_KEY=sk-...
165export ANTHROPIC_API_KEY=sk-ant-...
166
167# 2. Start the app in record mode
168pnpm --filter @tanstack/ai-e2e record
169
170# 3. Navigate to the feature: http://localhost:3010/openai/tool-calling
171
172# 4. Chat — aimock proxies to the real API and saves the fixture
173
174# 5. Find it in testing/e2e/fixtures/recorded/
175
176# 6. Stop the dev server (Ctrl+C)
177```
178
179## 3. Organizing the Recorded Fixture
180
181Move from `recorded/` to the appropriate feature directory:
182
183```bash
184mv fixtures/recorded/openai-*.json fixtures/tool-calling/my-new-scenario.json
185```
186
187Clean up the fixture:
188
189- **Simplify the `match` field** — use a unique `[prefix]` userMessage
190- **Verify the `response`** — check content, toolCalls, or reasoning fields
191- **Remove provider-specific artifacts** — fixtures should be provider-agnostic
192
193**Important:** aimock uses **substring matching** for `userMessage`. Always use a unique `[prefix]` to prevent collisions:
194
195```json
196{
197 "fixtures": [
198 {
199 "match": { "userMessage": "[myfeature] describe the guitar" },
200 "response": {
201 "content": "The Fender Stratocaster is a versatile electric guitar..."
202 }
203 }
204 ]
205}
206```
207
208Existing 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]`.
209
210## 4. Writing a Test
211
212Tests import from `./fixtures` to get the `testId` and `aimockPort` for parallel isolation:
213
214```typescript
215import { test, expect } from './fixtures'
216import {
217 sendMessage,
218 waitForResponse,
219 getLastAssistantMessage,
220 featureUrl,
221} from './helpers'
222import { providersFor } from './test-matrix'
223
224for (const provider of providersFor('my-feature')) {
225 test.describe(`${provider} — my-feature`, () => {
226 test('does the thing', async ({ page, testId, aimockPort }) => {
227 await page.goto(featureUrl(provider, 'my-feature', testId, aimockPort))
228
229 await sendMessage(page, '[myfeature] describe the guitar')
230 await waitForResponse(page)
231
232 const response = await getLastAssistantMessage(page)
233 expect(response).toContain('Stratocaster')
234 })
235 })
236}
237```
238
239For tool tests that use `sequenceIndex`, use `waitForAssistantText` — the agentic loop produces multiple responses:
240
241```typescript
242await sendMessage(page, '[toolcall] what guitars do you have in stock')
243await waitForResponse(page)
244
245const toolCalls = await getToolCalls(page)
246expect(toolCalls[0].name).toBe('getGuitars')
247
248// Wait for text response AFTER tool execution
249await waitForAssistantText(page, 'Fender Stratocaster')
250```
251
252## 5. Adding a New Feature
253
2541. **Add to `src/lib/types.ts`** — `Feature` union + `ALL_FEATURES` array
2552. **Add to `src/lib/features.ts`** — define tools, modelOptions
2563. **Add to `src/lib/feature-support.ts`** — mark which providers support it
2574. **Add to `tests/test-matrix.ts`** — mirror the support matrix
2585. **Create fixture** — `fixtures/my-new-feature/basic.json` with `[prefix]` userMessage
2596. **Create test spec** — `tests/my-new-feature.spec.ts` using `providersFor()`
260
261## 6. Adding a New Provider
262
2631. **Add adapter factory to `src/lib/providers.ts`** — with `defaultHeaders` for `X-Test-Id`
2642. **Add to `src/lib/feature-support.ts`** — mark which features it supports
2653. **Add to `tests/test-matrix.ts`** — mirror the support matrix
2664. **No fixture changes needed** — aimock translates to correct wire format
267
268### Vertex (Gemini on Vertex AI)
269
270`vertex` is the Gemini adapter with Vertex auth and the Vertex request path. It is not a new protocol.
271
272The factory in `src/lib/providers.ts` calls `vertexText` with `vertexE2eConfig()` from `src/lib/vertex-e2e.ts`:
273
274- `project` + `location` so `@google/genai` posts to `/v1/projects/{p}/locations/{l}/publishers/google/models/{m}:(generateContent|streamGenerateContent)`. aimock already serves that path.
275- A dummy `googleAuthOptions.authClient` so the SDK does not look for Application Default Credentials in CI.
276- `apiVersion: 'v1'`. The SDK default for Vertex is `v1beta1`, and aimock's Vertex handler only matches `/v1/…`.
277
278Chat, 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.
279
280Claude on Vertex (`anthropicVertexText`) is not in this matrix. That SDK talks OAuth and a different Vertex URL that aimock does not mock.
281
282### Vertex Grok and Vertex Mistral
283
284`vertex-grok` is the Grok Responses adapter with Vertex auth. The factory in `src/lib/providers.ts` calls `grokVertexText` with:
285
286- `baseURL` pointed at aimock `/v1`, so the OpenAI client posts `/v1/responses` like the xAI Grok row
287- a dummy `authClient` so the factory does not look for Application Default Credentials
288- the factory still prefixes the wire model with `xai/`
289
290`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.
291
292Both rows reuse the existing Grok and Mistral fixtures. Image, TTS, transcription, and embedding stay off these rows.
293
294### Bedrock Converse coverage gap
295
296The `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.
297
298The 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.
299
300**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.
301
302**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.
303
304**Follow-up:** a Bedrock/Converse provider will be added to aimock to close this gap and enable full E2E coverage of the Converse path.
305
306### BytePlus (Ark) path handling and record-mode gap
307
308BytePlus splits across two products, and the E2E wiring reflects that split:
309
310- **Ark** (chat, Seedream image, Seedance video) serves everything under `/api/v3`, so the chat, image and video adapters get `baseURL: <mock>/api/v3`.
311- **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.
312
313Chat 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.
314
315Three 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:
316
317- `byteplusSeedanceMount()` — `POST`/`GET /contents/generations/tasks[/{id}]`
318- `byteplusTTSMount()` — `POST /tts/create`
319- `byteplusASRMount()` — `POST /auc/bigmodel/recognize/flash`
320
321**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/`.
322
323**SDK baseURL notes:**
324
325- OpenAI, Grok: `LLMOCK_OPENAI` (with `/v1`) + `defaultHeaders`
326- Groq: `LLMOCK_BASE` (SDK appends `/openai/v1/` internally) + `defaultHeaders`
327- Anthropic: `LLMOCK_BASE` + `defaultHeaders`
328- Gemini: `httpOptions: { baseUrl: LLMOCK_BASE, headers }`
329- Vertex: `vertexE2eConfig(LLMOCK_BASE, headers)` (`project` + `location` + dummy auth + `apiVersion: 'v1'`)
330- Vertex Grok: `grokVertexText` with `baseURL: LLMOCK_OPENAI`, dummy `authClient`, and `defaultHeaders`
331- Vertex Mistral: `mistralVertexText` with `resolveRequestUrl` → `LLMOCK_BASE/v1/chat/completions`, dummy `authClient`, and `defaultHeaders`
332- Ollama: `{ host: LLMOCK_BASE, headers }` (config object)
333- OpenRouter: `serverURL` with `?testId=` query param (SDK doesn't support headers)
334- BytePlus: `LLMOCK_BASE + /api/v3` + `defaultHeaders` for Ark (chat, image, video); bare `LLMOCK_BASE` + `defaultHeaders` for Seed Speech (TTS, ASR)
335
336## 7. Adding a Tool Test Scenario
337
3381. **Create fixture** — `fixtures/tools-test/my-scenario.json` with `[my-scenario] run test` userMessage
3392. **Add tool definitions to `src/lib/tools-test-tools.ts`** if new tools needed
3403. **Update `getToolsForScenario`** — map scenario to tools
3414. **Add to `SCENARIO_LIST`** — for the UI dropdown
3425. **Create test** in `tests/tools-test/` — use helpers from `tests/tools-test/helpers.ts`
343
344## 8. Adding a Middleware Test
345
3461. **Create fixture** — `fixtures/middleware-test/my-scenario.json`
3472. **Add middleware to `src/routes/api.middleware-test.ts`** — new mode
3483. **Add test to `tests/middleware.spec.ts`**
349
350## 9. Fixture Matching Tips
351
352- **`userMessage`** — **substring matching**, always use unique `[prefix]` strings
353- **`sequenceIndex`** — tracks request count per match pattern per `X-Test-Id`. Use for multi-step tool flows.
354- **`tool`** — matches when the model calls a specific tool
355- **`model`** — matches a specific model name (avoid — breaks provider-agnosticism)
356- Fixtures are matched in order — first match wins
357
358## 10. Troubleshooting
359
360- **Test times out**: Check `userMessage` in fixture exactly matches `sendMessage()` (including `[prefix]`)
361- **Wrong fixture matched**: Overlapping `userMessage` substrings. Make prefixes more specific.
362- **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`
363- **Fixture works for OpenAI but not Anthropic**: Remove `model` from match field
364- **Port 4010 already in use**: Kill stale aimock process. aimock starts in `globalSetup` and lives for the entire test run.
365
366## Architecture
367
368```
369testing/e2e/
370├── src/
371│ ├── routes/
372│ │ ├── $provider/$feature.tsx # Dynamic chat UI per provider+feature
373│ │ ├── tools-test.tsx # Tools test page with event tracking
374│ │ ├── middleware-test.tsx # Middleware test page
375│ │ ├── api.chat.ts # Chat endpoint → aimock
376│ │ ├── api.tools-test.ts # Tools endpoint → aimock
377│ │ └── api.middleware-test.ts # Middleware endpoint → aimock + middleware
378│ ├── lib/
379│ │ ├── providers.ts # Provider → adapter factory (X-Test-Id headers)
380│ │ ├── features.ts # Feature → config (tools, modelOptions)
381│ │ ├── feature-support.ts # Provider × feature support matrix
382│ │ └── tools-test-tools.ts # Server + client tool definitions
383│ └── components/
384│ └── ChatUI.tsx # Chat interface with stop button + image rendering
385├── fixtures/ # aimock fixture JSON files (organized by feature)
386├── test-assets/ # Images for multimodal tests
387├── global-setup.ts # Starts aimock on port 4010
388├── global-teardown.ts # Stops aimock
389├── tests/
390│ ├── fixtures.ts # Playwright fixture (testId + aimockPort)
391│ ├── helpers.ts # sendMessage, waitForResponse, featureUrl, etc.
392│ ├── test-matrix.ts # providersFor() — which providers support which features
393│ ├── *.spec.ts # Provider-coverage + advanced feature tests
394│ └── tools-test/ # Tool execution flow tests
395│ ├── helpers.ts # selectScenario, runTest, getMetadata, etc.
396│ └── *.spec.ts # Tool scenario tests
397└── playwright.config.ts # fullyParallel: true, retries: 2, globalSetup/Teardown
398```