E2E Testing Suite

May 28, 2026 · View on GitHub

Cypress E2E tests for the Ambient Code Platform. Tests run against a live cluster using a mock SDK client — no real Anthropic API key needed.

Tests: 58 | Runtime: ~3 min (Chrome) | Coverage: Integration confidence

Quick Start

# Prerequisites: Kind cluster running (make kind-up), port-forwarded (make kind-port-forward)
cd e2e && npm install

# Extract test token (uses Keycloak client_credentials when available, falls back to K8s SA)
bash scripts/extract-token.sh

# Run headless
source .env.test
npx cypress run --browser chrome --spec "cypress/e2e/sessions.cy.ts"

# Interactive mode (for debugging)
source .env.test
npx cypress open

Mock SDK Client

Tests always use ANTHROPIC_API_KEY=mock-replay-key. When the runner pod sees this key, MockClaudeSDKClient replays pre-recorded SDK messages from JSONL fixtures through the real ClaudeAgentAdapter. This tests the full AG-UI translation pipeline without calling the Anthropic API.

Fixtures: components/runners/ambient-runner/ambient_runner/bridges/claude/fixtures/

Capturing new fixtures (requires real API key):

cd components/runners/ambient-runner
ANTHROPIC_API_KEY=sk-ant-... uv run --extra claude python scripts/capture-fixtures.py 'your prompt'

Prompt matching: hellohello.jsonl, comprehensivecomprehensive.jsonl, default → default.jsonl

Test Structure

One file: cypress/e2e/sessions.cy.ts — 58 tests across 15 describe blocks:

BlockTestsWhat it covers
Workspace & Session Creation1Create workspace, wait for namespace, create session
Session Page UI4Phase badge, accordions, breadcrumbs, chat area
Workspace Page3Sessions list, admin tabs, create session dialog
Projects List2Workspace list, status badges
Agent Interaction1Send message, verify response, workflow selection
Session Header Actions1Three-dot menu interactions
Workspace Admin Tabs3Settings, sharing, keys tab rendering
Session Header Menu Deep4View details, edit name, clone, export chat
Chat Input Features3Toolbar buttons, autocomplete, history
Feedback Buttons1Thumbs up/down on agent messages
Theme & Navigation2Dark/light/system toggle, nav component
Session Page Modals6Add context, upload, workflow, clone, details, edit name
Workspace Admin Form Submissions7Save settings, create keys, grant permissions, feature flags
Chat Input Deep3Slash commands, Ctrl+Space, agents/commands buttons
Welcome Experience3Workflow cards, view all, search

Writing Tests

All tests go in sessions.cy.ts. They share one workspace created in before().

// Add new tests inside an existing describe block, or create a new one:
describe('My Feature', () => {
  it('should do the thing', () => {
    cy.visit(`/projects/${workspaceSlug}/sessions/${pendingSessionId}`)

    // Use data-testid for reliable selectors
    cy.get('[data-testid="my-button"]').click({ force: true })

    // Conditional checks for optional elements
    cy.get('body').then(($body) => {
      if ($body.find('.optional-element').length) {
        cy.get('.optional-element').click({ force: true })
      }
    })

    // Close modals with Escape
    cy.get('body').type('{esc}')
  })
})

Rules:

  • Use { force: true } on all clicks (elements may be in overflow containers)
  • Wrap optional elements in .then($body => { if ($body.find(...).length) { ... } })
  • Use data-testid attributes — add them to frontend components as needed
  • Never use real API keys — tests always use mock-replay-key
  • Use Chrome, not Electron (Electron drops SSE events)

Environment Variables

VariableRequiredDescription
TEST_TOKENYesK8s service account token for API auth
CYPRESS_BASE_URLYesFrontend URL (e.g., http://localhost:3000)
CYPRESS_OC_TOKENNoOpenShift OAuth token (only for OCP clusters)
KEEP_WORKSPACESNoSet to true to skip cleanup after tests

Debugging

# Screenshots (on failure)
open cypress/screenshots/

# Videos (always captured)
open cypress/videos/sessions.cy.ts.mp4

# Interactive mode — best for debugging
npx cypress open