feat(e2e): add test daemon CLI with ANSI dashboard and Agent SDK bridge

- index.ts: CLI entry point (--full, --spec, --watch, --agent flags)
- runner.ts: programmatic WDIO launcher with result streaming
- dashboard.ts: ANSI terminal UI (pass/fail/skip/running icons, summary)
- agent-bridge.ts: NDJSON stdin/stdout for Agent SDK queries
  (status, rerun, failures, reset-cache)
- Standalone package at tests/e2e/daemon/
This commit is contained in:
Hibryda 2026-03-18 05:17:17 +01:00
parent 46f51d7941
commit d7dd7722ab
7 changed files with 796 additions and 0 deletions

122
tests/e2e/daemon/README.md Normal file
View file

@ -0,0 +1,122 @@
# E2E Test Daemon
Terminal dashboard for running and monitoring Agent Orchestrator E2E tests. Supports smart caching, file watching, and agent SDK integration.
## Prerequisites
- Built Tauri debug binary (`npm run tauri build -- --debug --no-bundle`)
- `tauri-driver` installed (`cargo install tauri-driver`)
- Node.js 20+
## Install
```bash
cd tests/e2e/daemon
npm install
```
The daemon reuses WDIO deps from the root `node_modules`. Its own `package.json` lists `@wdio/cli` and `@wdio/local-runner` for clarity, but they resolve from the workspace root.
## Usage
```bash
# Run all specs (with smart cache — skips recently-passed specs)
npm start
# Full run — reset cache, run everything
npm run start:full
# Filter by spec name pattern
npx tsx index.ts --spec phase-a
# Watch mode — re-run on spec file changes
npm run start:watch
# Agent mode — accept NDJSON queries on stdin, respond on stderr
npm run start:agent
# Combine flags
npx tsx index.ts --full --watch --agent
```
## Dashboard
The terminal UI shows:
```
Agent Orchestrator — E2E Test Daemon RUNNING 12.3s
────────────────────────────────────────────
✓ smoke 1.2s
✓ workspace 0.8s
⟳ settings
· phase-a-structure
· phase-a-agent
⏭ phase-b-grid
────────────────────────────────────────────
2 passed │ 0 failed │ 1 skipped │ 1 running │ 2 pending │ 2.0s
```
Status icons:
- `✓` green — passed
- `✗` red — failed (error message shown below)
- `⏭` gray — skipped (cached)
- `⟳` yellow — running
- `·` white — pending
## Smart Cache
The daemon reads from the shared `test-results/results.json` (managed by `results-db.ts`). Specs that passed in any of the last 5 runs are skipped unless `--full` is used.
## Agent Bridge Protocol
When started with `--agent`, the daemon accepts NDJSON queries on **stdin** and responds on **stderr** (stdout is used by the dashboard).
### Queries
**Status** — get current test state:
```json
{"type": "status"}
```
Response:
```json
{"type": "status", "running": false, "passed": 15, "failed": 2, "skipped": 1, "pending": 0, "total": 18, "failures": [{"name": "phase-b-grid", "error": "WDIO exited with code 1"}]}
```
**Rerun** — trigger a new test run:
```json
{"type": "rerun", "pattern": "phase-a"}
```
Response:
```json
{"type": "rerun", "specsQueued": 1}
```
**Failures** — get detailed failure list:
```json
{"type": "failures"}
```
Response:
```json
{"type": "failures", "failures": [{"name": "phase-b-grid", "specFile": "phase-b-grid.test.ts", "error": "WDIO exited with code 1"}]}
```
**Reset cache** — clear smart cache:
```json
{"type": "reset-cache"}
```
Response:
```json
{"type": "reset-cache", "ok": true}
```
## Architecture
```
index.ts CLI entry point, arg parsing, main loop
runner.ts WDIO Launcher wrapper, spec discovery, smart cache
dashboard.ts ANSI terminal UI (no external deps)
agent-bridge.ts NDJSON stdio interface for agent integration
```
The daemon reuses the project's existing `wdio.conf.js` and `infra/results-db.ts`.