Skip to content

[P2.23] Implement the API and web lifecycle tests (mock provider so CI can run them) #1068

Description

@frankbria

Spun off from #948, which removed the two stub files because they were green theatre: @pytest.mark.skip classes whose methods raise NotImplementedError, so scripts/lifecycle --mode api|web collected only skips and exited 0 while CLAUDE.md advertised it as the pre-PR gate.

#948 makes those modes fail loudly (exit 3, "not implemented — see this issue") instead of passing silently. This issue is the actual work.

Both plans below are preserved verbatim from the deleted stubs so nothing is lost.

Why the mock provider matters

test_cli_lifecycle.py costs real money and runs 10–30 minutes, which is why it is opt-in. An API/web lifecycle test driven by CODEFRAME_LLM_PROVIDER=mock costs nothing and can run in CI on every PR — it verifies the server layer, SSE streaming, auth and task execution wire together, which is precisely the seam no unit test covers. That is worth more than a paid duplicate of the CLI test.

API lifecycle plan (from tests/lifecycle/test_api_lifecycle.py)

test_agent_builds_project_via_api — agent builds csv-stats via REST API calls:

  1. POST /api/v2/workspace/init
  2. POST /api/v2/prd (upload PRD.md)
  3. POST /api/v2/tasks/generate
  4. GET /api/v2/tasks to find READY tasks
  5. POST /api/v2/batches/run with all ready task IDs
  6. GET /api/v2/tasks/{id}/stream (SSE) to monitor
  7. Poll until all tasks complete
  8. Run acceptance checks

Note the stub's docstring names endpoints that do not all exist as written — verify each against docs/PHASE_2_CLI_API_MAPPING.md and the live OpenAPI schema before implementing, rather than trusting the plan.

test_sse_streaming_delivers_events — task execution via API emits real-time SSE events.

Web lifecycle plan (from tests/lifecycle/test_web_lifecycle.py)

test_user_can_build_project_via_web_ui — a user drives the full pipeline through the web UI (Playwright):

  1. Navigate to /
  2. Create workspace or use existing
  3. Go to /prd → upload PRD.md
  4. Go to /tasks → click "Generate Tasks"
  5. Verify tasks appear in the kanban board
  6. Launch execution and watch the live stream
  7. Verify the final state

Requires codeframe serve + the web-ui dev server. There is already a Playwright harness (#684/#703) with CI jobs — build on that rather than starting a second one.

Acceptance criteria

  • tests/lifecycle/test_api_lifecycle.py exists with real assertions and passes under CODEFRAME_LLM_PROVIDER=mock
  • It runs in CI (free, no ANTHROPIC_API_KEY), not only under scripts/lifecycle
  • tests/lifecycle/test_web_lifecycle.py likewise, reusing the existing Playwright harness
  • scripts/lifecycle accepts --mode api|web|all again: the exit 3 guards and the "not implemented" list are removed
  • tests/test_lifecycle_gates_948.py is updated — its tests assert that the unimplemented modes are rejected, so they must flip when the modes become real

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions