|
| 1 | +# Phase 22B — Production-Path Test Suite |
| 2 | + |
| 3 | +**Status:** In Progress |
| 4 | + |
| 5 | +**Goal:** Prove the real production path — seeded database, live API endpoints, and Playwright smoke — is testable, deterministic, and CI-safe. |
| 6 | + |
| 7 | +**Depends on:** Phase 22A (Fixture & Test Infrastructure), Phase 17, Phase 18, Phase 19, Phase 20 |
| 8 | + |
| 9 | +## What Was Not Done in Phase 22A |
| 10 | + |
| 11 | +Phase 22A established deterministic fixture infrastructure (`FIXTURE_IDS` contract, 18-point DB harness, meta-harness, CI wiring). Phase 22B builds on that foundation to prove the live API surface against seeded fixtures. |
| 12 | + |
| 13 | +## Deliverables |
| 14 | + |
| 15 | +### P0: Phase 22B API Production-Path Harness |
| 16 | + |
| 17 | +**File:** `scripts/harness/phase22b-production-path-api-check.ts` |
| 18 | + |
| 19 | +Uses `FIXTURE_IDS` from `scripts/fixtures/visionflow-fixtures.ts` as the single source of truth. Makes HTTP requests to live API endpoints, validates response shapes, and checks fixture ID consistency. |
| 20 | + |
| 21 | +**Endpoints checked:** |
| 22 | + |
| 23 | +| # | Endpoint | Fixture Reference | Validation | |
| 24 | +|---|----------|-------------------|------------| |
| 25 | +| 1 | `GET /api/health` | — | `ok: true`, `service: 'visionflow-api'` | |
| 26 | +| 2 | `GET /api/health/runtime/status` | — | `api.ok: true`, `database.status: 'ready'` | |
| 27 | +| 3 | `GET /api/projects/:projectId/datasets` | `FIXTURE_IDS.project.id` | `datasets[0].id === FIXTURE_IDS.dataset.id` | |
| 28 | +| 4 | `GET /api/projects/:projectId/dataset-versions/:versionId/annotation-workspace?assetId=asset_frame_1482` | `FIXTURE_IDS.datasetVersion.id`, `FIXTURE_IDS.annotationWorkspace.assetId` | `annotations` contains MANUAL source | |
| 29 | +| 5 | `GET /api/projects/:projectId/dataset-versions/:versionId/export/coco` | `FIXTURE_IDS.datasetVersion.id` | `metadata.status === 'LOCKED'`, deterministic hash present, COCO schema valid | |
| 30 | +| 6 | `GET /api/projects/:projectId/inference-jobs` | `FIXTURE_IDS.inferenceJob.id` | canonical job visible | |
| 31 | +| 7 | `GET /api/projects/:projectId/inference-jobs/:jobId/predictions` | `FIXTURE_IDS.inferenceJob.id` | at least 3 predictions | |
| 32 | +| 8 | `GET /api/projects/:projectId/inference-jobs/:jobId/evaluation` | `FIXTURE_IDS.inferenceJob.id` | `report.inputHash === FIXTURE_IDS.evaluation.inputHash` | |
| 33 | + |
| 34 | +**Behavior:** |
| 35 | +- `--strict` mode: exit 1 if `API_BASE_URL` is unreachable or any check fails |
| 36 | +- Non-strict: skip with instructions if API not running |
| 37 | +- No DB mutations |
| 38 | +- Validate Zod schemas where contracts are available |
| 39 | +- COCO determinism: call export twice, hash must match |
| 40 | + |
| 41 | +### P0: Phase 22B Meta-Harness |
| 42 | + |
| 43 | +**File:** `scripts/harness/phase22b-meta-harness.ts` |
| 44 | + |
| 45 | +Orchestrates Phase 22A meta-harness + Phase 22B API harness. DB-only checks always run. Live API checks run only when `--with-api` is passed or `API_BASE_URL` is reachable. |
| 46 | + |
| 47 | +**Behavior:** |
| 48 | +- `pnpm meta:harness:phase22b --strict`: runs Phase 22A meta-harness (DB-only), reports API skipped unless `--with-api` |
| 49 | +- `pnpm meta:harness:phase22b --strict --with-api`: runs Phase 22A meta-harness + Phase 22B API harness; fails if API unreachable |
| 50 | +- In CI: runs DB-only checks only |
| 51 | + |
| 52 | +### P1: Playwright Production-Path Smoke |
| 53 | + |
| 54 | +**File:** `apps/web/e2e/production-path.spec.ts` |
| 55 | + |
| 56 | +Focused smoke test proving seeded fixture surfaces are navigable in the browser. |
| 57 | + |
| 58 | +- Confirms ReadinessStrip appears (Phase 21B requirement) |
| 59 | +- Navigates to Jobs section and verifies non-empty job state |
| 60 | +- Navigates to Annotate section |
| 61 | +- No console errors on any navigation |
| 62 | +- No screenshot-only assertions |
| 63 | +- No flaky sleeps |
| 64 | + |
| 65 | +### P1: CI Wiring (DB-only) |
| 66 | + |
| 67 | +**`.github/workflows/ci.yml`:** |
| 68 | +- Add `pnpm meta:harness:phase22b` to `db-harness` and `migration-chain` jobs after `harness:phase22a` |
| 69 | +- Live API harness NOT added to CI (requires booted stack) |
| 70 | +- `build` continues to depend on `db-harness` and `migration-chain` |
| 71 | + |
| 72 | +### P2: Deterministic Binary Fixtures |
| 73 | + |
| 74 | +Not implemented. Rationale: no Phase 22B harness or test actually requires a binary fixture file — all checks use seeded DB state or HTTP responses. If future tests need binary fixtures, implement in Phase 23. |
| 75 | + |
| 76 | +### P2: Docker Test Stack |
| 77 | + |
| 78 | +Not implemented. GitHub Actions PostgreSQL service is sufficient for Phase 22B CI needs. Docker test stack deferred to Phase 23 or future enhancement. |
| 79 | + |
| 80 | +## Architecture Decisions |
| 81 | + |
| 82 | +### API harness: HTTP client over Prisma |
| 83 | +Phase 22A verifies DB integrity. Phase 22B verifies API surface integrity. HTTP is the correct boundary — the harness exercises the full NestJS request pipeline including routing, guards, services, contracts, and Prisma queries. |
| 84 | + |
| 85 | +### Strict mode skip vs fail |
| 86 | +- DB harnesses: strict mode requires DATABASE_URL |
| 87 | +- API harness: strict mode requires API_BASE_URL reachable |
| 88 | +- Meta-harness: strict mode always runs DB checks; API checks gated by `--with-api` |
| 89 | +- CI runs DB-only (no strict API requirement) |
| 90 | + |
| 91 | +### No fixture factory helpers |
| 92 | +Phase 22A established that FIXTURE_IDS is the single source of truth. Phase 22B uses those IDs directly. No new fixture factory pattern is needed at this stage. |
| 93 | + |
| 94 | +### COCO determinism check |
| 95 | +Calling the COCO endpoint twice and comparing deterministic hashes is sufficient proof of stability. Full content comparison is covered by Phase 20C's hash computation harness. |
| 96 | + |
| 97 | +## Out of Scope |
| 98 | + |
| 99 | +- Demo video/GIF work (Phase 23) |
| 100 | +- UI redesign |
| 101 | +- Product feature changes |
| 102 | +- Docker test-stack.yml |
| 103 | +- Binary fixture files |
| 104 | +- CV worker integration tests (covered by pytest suite) |
| 105 | +- Replacing Phase 22A harness |
| 106 | + |
| 107 | +## Success Criteria |
| 108 | + |
| 109 | +1. `pnpm harness:phase22b:api` passes all 8 endpoint checks (when API is running) |
| 110 | +2. `pnpm meta:harness:phase22b` runs Phase 22A meta-harness + Phase 22B checks |
| 111 | +3. Phase 22A harness still passes (no regression) |
| 112 | +4. Phase 20C/D/E/F harnesses still pass |
| 113 | +5. Playwright `production-path.spec.ts` passes with zero console errors |
| 114 | +6. CI wiring: `db-harness` and `migration-chain` jobs run Phase 22B meta-harness |
| 115 | +7. No existing harness removed or weakened |
| 116 | +8. All FIXTURE_IDS imported from canonical source |
| 117 | + |
| 118 | +## Files to Create |
| 119 | + |
| 120 | +- `scripts/harness/phase22b-production-path-api-check.ts` |
| 121 | +- `scripts/harness/phase22b-meta-harness.ts` |
| 122 | +- `apps/web/e2e/production-path.spec.ts` |
| 123 | +- `.planning/phases/phase-22b-production-path-test-suite/22B-PLAN.md` |
| 124 | +- `.planning/phases/phase-22b-production-path-test-suite/22B-SUMMARY.md` |
| 125 | +- `.planning/phases/phase-22b-production-path-test-suite/22B-REVIEW.md` |
| 126 | + |
| 127 | +## Files to Change |
| 128 | + |
| 129 | +- `package.json` — add `harness:phase22b:api` and `meta:harness:phase22b` |
| 130 | +- `.github/workflows/ci.yml` — add Phase 22B to db-harness and migration-chain |
| 131 | +- `.planning/STATE.md` — mark Phase 22B done |
| 132 | +- `.planning/ROADMAP.md` — Phase 22B entry with commit SHA |
| 133 | +- `.planning/MILESTONES.md` — Phase 22B entry |
0 commit comments