beadboard/docs/plans/2026-03-07-phase-7-tests.md
zenchantlive d335e5bf71 fix: orchestrator button + Pi SDK session error
- Move leftSidebarMode from URL state to local useState in unified-shell,
    avoiding force-dynamic router round-trip that made the button appear broken                                           - Replace fileURLToPath(new URL(..., import.meta.url)) with process.cwd()
    in bb-pi-bootstrap.ts — import.meta.url is a webpack:// URL in Next.js,
    causing cross-realm TypeError when passed to Node.js fileURLToPath()
2026-03-24 19:02:04 -05:00

1.7 KiB

Phase 7 - Tests and Verification

Status: Planning Created: 2026-03-07 Goal: Add comprehensive tests for embedded Pi runtime and agent system


Test Categories

1. Unit Tests

Runtime Path Resolution:

  • pi-runtime-detection.test.ts - SDK detection, path resolution
  • bb-pi-bootstrap.test.ts - bootstrap process

Event Projection:

  • embedded-daemon.test.ts - event emission, deduplication
  • orchestrator-chat.test.ts - message projection

Worker Session:

  • worker-session-manager.test.ts - spawn, status, lifecycle

2. Contract Tests

Adapter Schemas:

  • Pi SDK adapter input/output contracts
  • Runtime event schema validation

3. Integration Tests

Orchestrator Flow:

  • Session creation
  • Prompt submission
  • Tool execution
  • Response handling

Worker Flow:

  • Worker spawn
  • Bead claim/update/close
  • Result retrieval

4. UI Tests

Left Panel:

  • Chat rendering
  • Message projection
  • Error display

Implementation Plan

Step 1: Unit Test Setup

  • Configure test runner (Jest or Vitest)
  • Create test utilities for mocking Pi SDK

Files:

  • tests/setup.ts
  • tests/mocks/pi-sdk.ts

Step 2: Runtime Unit Tests

  • Test path detection
  • Test bootstrap process
  • Test event deduplication

Step 3: Worker Unit Tests

  • Test spawn flow
  • Test status tracking
  • Test result collection

Step 4: Integration Tests

  • Test full orchestrator flow
  • Test worker-to-bead workflow

Blocked Items

None identified.


Success Criteria

  • Unit tests for runtime components pass
  • Unit tests for worker session manager pass
  • Integration tests for orchestrator flow pass
  • Integration tests for worker flow pass

Estimated Effort

4-5 hours