UI Testing
The UI has three testing layers: unit tests, component tests, and end-to-end (E2E) tests.
Unit and Component Tests
Unit and component tests use Vitest with React Testing Library and run entirely in jsdom (no browser or cluster required).
Running
# From the repo root
make test-ui
# Or from the ui/ directory
cd ui
npm test # Single run
npm run test:watch # Watch mode (re-runs on file changes)
npm run test:coverage # With coverage reportWriting Tests
- Place test files next to the code they test with a
.test.tsor.test.tsxsuffix. - Use
@testing-library/reactfor rendering components and querying the DOM. - Use
@testing-library/user-eventfor simulating user interactions. - Vitest globals (
describe,it,expect) are available without imports, but explicit imports also work.
Example component test:
import { render, screen } from '@testing-library/react'
import { StatusBadge } from './StatusBadge'
it('renders the phase label', () => {
render(<StatusBadge phase="Succeeded" />)
expect(screen.getByText('✓ Succeeded')).toBeInTheDocument()
})Example unit test:
import { PHASE_COLOR } from './phaseColors'
it('maps Running to a hex color', () => {
expect(PHASE_COLOR['Running']).toMatch(/^#[0-9a-f]{6}$/i)
})Scheduled runs flows
ui/src/components/SchedulesView.test.tsx drives the schedule flows against a stubbed API: the list with next run, last result and spend; creating a schedule from a preset with the live "next runs" preview; refusing a schedule that runs too often or has no spend limit; editing with the resourceVersion it read and showing a 409 in words; pause, resume and Run now (including a quota refusal); the history with skipped times; deleting after a confirmation; and a Git-owned schedule opening read-only with Copy YAML and Duplicate. RunsView.test.tsx covers the "Started by" filter, FleetView.test.tsx the clock badge and the Scheduled filter. /operate/schedules is also in the live-tenant smoke test.
End-to-End Tests
E2E tests use Playwright and run against a deployed instance of the application. They exercise the full stack: UI served by Caddy, API proxied to the operator, and Kubernetes resources.
Prerequisites
Install Playwright browsers (one-time):
cd ui
npx playwright install --with-deps chromiumRunning Locally Against a Kind Cluster
Start the dev cluster and deploy (if not already running):
bashkind create cluster --name agent-orca-dev skaffold devskaffold devbuilds all images, deploys via Helm, and port-forwards the UI to http://localhost:8080 automatically. Leave it running in a dedicated terminal.Run the tests:
bash# From the repo root make test-ui-e2e # Or from the ui/ directory with a custom base URL cd ui BASE_URL=http://localhost:8080 npm run test:e2eFor interactive debugging:
bashcd ui BASE_URL=http://localhost:8080 npm run test:e2e:uiThis opens the Playwright UI, which lets you step through tests, view screenshots, and inspect the DOM.
Writing E2E Tests
- Place test files in
ui/e2e/with a.spec.tssuffix. - Tests receive a
pagefixture — a real Chromium browser page. - Use
page.goto('/')to navigate (thebaseURLfromplaywright.config.tsis prepended automatically). - Prefer accessible locators (
getByRole,getByText,getByPlaceholder) over CSS selectors.
Example:
import { test, expect } from '@playwright/test'
test('sidebar shows resource tabs', async ({ page }) => {
await page.goto('/')
await expect(page.getByRole('button', { name: /runs/i })).toBeVisible()
})Configuration
Playwright configuration is in ui/playwright.config.ts. Key settings:
| Setting | Default | Override |
|---|---|---|
| Base URL | http://localhost:8080 | BASE_URL env var |
| Browser | Chromium | Add projects in config |
| Timeout | 30s | timeout in config |
| Retries | 1 | retries in config |
CI
Two GitHub Actions workflows run UI tests automatically:
- test-ui.yml — Runs
npm run buildandnpm test(Vitest) on pushes and PRs that touchui/. - test-ui-e2e.yml — Creates a Kind cluster, deploys the app with Helm, and runs Playwright tests on all pushes and PRs.
Failed E2E runs upload Playwright traces as artifacts for debugging.
