You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add comprehensive test coverage (unit + E2E) with mock SDK client (#834)
## Summary
Adds comprehensive test coverage for the frontend and runner, going from
**0% → 74% unit test coverage** with a mock SDK client for E2E tests
that doesn't require a real Anthropic API key.
## What's included
### Mock SDK Client
- `MockClaudeSDKClient` in the runner — activated by
`ANTHROPIC_API_KEY=mock-replay-key`
- Replays pre-recorded SDK messages from JSONL fixtures through the real
`ClaudeAgentAdapter`
- Tests the full AG-UI translation pipeline without calling the
Anthropic API
- Capture script (`scripts/capture-fixtures.py`) to record new fixtures
from real sessions
### Frontend Unit Tests (466 tests, ~74% coverage)
- **26 test files** using Vitest + React Testing Library
- Covers: event-handlers, export-chat, tool-message, ChatInputBox,
FeedbackModal, stream-message, normalize-snapshot, status-colors,
file-tree, input-with-history, theme-toggle, use-session-queue,
use-agui-stream, use-autocomplete, use-workspace, use-projects,
use-sessions, and more
### E2E Tests (58 tests)
- **One comprehensive test file** (`sessions.cy.ts`) covering the full
user journey
- Workspace CRUD, session lifecycle, agent interaction, chat features,
workspace admin, modals, feedback
- Always uses `mock-replay-key` — no real API key needed
- Runs in Chrome (Electron has SSE issues)
### CI Updates
- `unit-tests.yml`: Added frontend vitest job alongside
backend/runner/CLI tests
- `e2e.yml`: Removed `ANTHROPIC_API_KEY` dependency, uses mock SDK mode
- `run-tests.sh`: Uses Chrome instead of Electron
### Documentation
- `CLAUDE.md`: Testing section with quick reference
- `e2e/README.md`: Full E2E guide (mock SDK, test structure, writing
tests)
- `components/frontend/README.md`: Unit test guide (vitest patterns,
mocking)
### Cleanup
- Removed outdated test files: `chatbox-demo.cy.ts`,
`jira-integration-demo.cy.ts`, `public-api.cy.ts`, `vteam.cy.ts`
- Removed deleted admin/runtimes page
- Added `data-testid` attributes to key frontend components
- Added `.gitignore` for coverage output
## How to run
```bash
# Unit tests (fast, ~2s)
cd components/frontend && npx vitest run --coverage
# E2E tests (~3min, needs running cluster)
cd e2e
TEST_TOKEN=$(kubectl get secret test-user-token -n ambient-code -o jsonpath='{.data.token}' | base64 -d) \
CYPRESS_BASE_URL=http://localhost:3000 \
npx cypress run --browser chrome --spec cypress/e2e/sessions.cy.ts
```
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
-**Error Handling**: Comprehensive error states with recovery actions
192
192
193
193
The frontend provides a complete user interface for the RFE (Request For Enhancement) workflow system, integrating GitHub repositories, AI runners, and real-time collaboration features.
194
+
195
+
## Testing
196
+
197
+
### Unit Tests (Vitest)
198
+
199
+
466 tests across 26 files. Primary coverage metric (~74%).
200
+
201
+
```bash
202
+
# Run all tests
203
+
npx vitest run
204
+
205
+
# With coverage report
206
+
npx vitest run --coverage
207
+
open coverage/index.html
208
+
209
+
# Watch mode
210
+
npx vitest
211
+
212
+
# Single file
213
+
npx vitest run src/utils/__tests__/export-chat.test.ts
214
+
```
215
+
216
+
**Config**: `vitest.config.ts` — uses jsdom, Istanbul coverage, `@/` path alias.
0 commit comments