refactor(04-01): move API list test stubs into tests/ mirror dir to match convention

The two Wave-0 RED stubs (lists.test.ts, listEmitter.test.ts) were co-located in
src/ but all existing API tests live in apps/api/tests/. Move them to tests/routes/
and tests/lib/, add explicit vitest imports to match the tests/ convention, and
update path references in downstream plans 04-02..04-06. PWA tests keep co-location
(that IS the PWA convention).
This commit is contained in:
Lucas Berger
2026-06-09 12:10:31 -04:00
parent 0fd4d66ee7
commit 60745b3281
11 changed files with 43 additions and 39 deletions
@@ -7,7 +7,7 @@ depends_on: ["04-02", "04-04", "04-05"]
files_modified:
- apps/api/src/routes/sse.ts
- apps/api/src/routes/lists.ts
- apps/api/src/routes/lists.test.ts
- apps/api/tests/routes/lists.test.ts
- apps/pwa/src/hooks/useListSSE.ts
- apps/pwa/src/hooks/useListSSE.test.ts
- apps/pwa/src/components/LiveSyncIndicator.tsx
@@ -76,13 +76,13 @@ Output: /api/sse/lists endpoint; publishListEvent triggers in lists.ts; useListS
<task type="auto" tdd="true">
<name>Task 1: Scoped /api/sse/lists endpoint + fan-out triggers on every write (LIST-04, D-04/D-10)</name>
<files>apps/api/src/routes/sse.ts, apps/api/src/routes/lists.ts, apps/api/src/routes/lists.test.ts</files>
<files>apps/api/src/routes/sse.ts, apps/api/src/routes/lists.ts, apps/api/tests/routes/lists.test.ts</files>
<read_first>
- apps/api/src/routes/sse.ts (existing /heartbeat streamSSE pattern — extend)
- apps/api/src/routes/lists.ts (item/list write handlers from Plans 0304 — add emit seams)
- apps/api/src/lib/listEmitter.ts (publishListEvent, subscribeListEvents — Plan 02)
- apps/api/src/lib/listAccess.ts (getAccessibleListIds — Plan 02)
- apps/api/src/routes/lists.test.ts (LIST-04 stub incl. private-list no-leak)
- apps/api/tests/routes/lists.test.ts (LIST-04 stub incl. private-list no-leak)
- .planning/phases/04-shared-lists-live-sync/04-PATTERNS.md §"apps/api/src/routes/sse.ts" (the /lists endpoint pattern verbatim)
- .planning/phases/04-shared-lists-live-sync/04-RESEARCH.md Finding 1 + Finding 3
</read_first>
@@ -100,7 +100,7 @@ Output: /api/sse/lists endpoint; publishListEvent triggers in lists.ts; useListS
Mount: /api/sse/lists is already under /api/sse (sseRouter mounted in index.ts) — no index.ts change needed beyond what exists. Confirm it sits behind the OIDC/dev-bypass guard.
</action>
<verify>
<automated>pnpm --filter @familysync/api exec vitest run src/routes/lists.test.ts && grep -q "publishListEvent" apps/api/src/routes/lists.ts && grep -q "/lists" apps/api/src/routes/sse.ts && pnpm --filter @familysync/api typecheck</automated>
<automated>pnpm --filter @familysync/api exec vitest run tests/routes/lists.test.ts && grep -q "publishListEvent" apps/api/src/routes/lists.ts && grep -q "/lists" apps/api/src/routes/sse.ts && pnpm --filter @familysync/api typecheck</automated>
</verify>
<acceptance_criteria>
- GET /api/sse/lists subscribes only to getAccessibleListIds channels; 401 when unauthenticated.
@@ -169,7 +169,7 @@ Output: /api/sse/lists endpoint; publishListEvent triggers in lists.ts; useListS
</threat_model>
<verification>
<automated>pnpm --filter @familysync/api exec vitest run src/routes/lists.test.ts && pnpm --filter @familysync/pwa exec vitest run src/hooks/useListSSE.test.ts && pnpm --filter @familysync/pwa exec tsc --noEmit</automated>
<automated>pnpm --filter @familysync/api exec vitest run tests/routes/lists.test.ts && pnpm --filter @familysync/pwa exec vitest run src/hooks/useListSSE.test.ts && pnpm --filter @familysync/pwa exec tsc --noEmit</automated>
- `playwright-cli` two-context live-update check.
- D-04 route-layer no-leak test green.
</verification>