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
@@ -11,8 +11,8 @@ files_modified:
- apps/api/src/db/migrations/0002_lists_schema.sql
- apps/api/test/setup.ts
- apps/api/vitest.config.ts
- apps/api/src/routes/lists.test.ts
- apps/api/src/lib/listEmitter.test.ts
- apps/api/tests/routes/lists.test.ts
- apps/api/tests/lib/listEmitter.test.ts
- apps/pwa/src/hooks/useListSSE.test.ts
- apps/pwa/src/routes/ListDetail.test.tsx
- apps/pwa/src/App.tsx
@@ -42,7 +42,7 @@ must_haves:
- path: "apps/pwa/src/routes/ListsIndex.tsx"
provides: "Lists surface with empty state"
min_lines: 20
- path: "apps/api/src/routes/lists.test.ts"
- path: "apps/api/tests/routes/lists.test.ts"
provides: "RED test stubs for LIST-01/02/03/04 API behavior"
contains: "describe"
key_links:
@@ -109,7 +109,7 @@ Output: New deps installed; three tables migrated; API vitest harness + 4 RED st
<task type="auto">
<name>Task 2: Install new dependencies + scaffold API test harness with Wave-0 RED stubs</name>
<files>apps/pwa/package.json, apps/api/package.json, apps/api/test/setup.ts, apps/api/vitest.config.ts, apps/api/src/routes/lists.test.ts, apps/api/src/lib/listEmitter.test.ts, apps/pwa/src/hooks/useListSSE.test.ts, apps/pwa/src/routes/ListDetail.test.tsx</files>
<files>apps/pwa/package.json, apps/api/package.json, apps/api/test/setup.ts, apps/api/vitest.config.ts, apps/api/tests/routes/lists.test.ts, apps/api/tests/lib/listEmitter.test.ts, apps/pwa/src/hooks/useListSSE.test.ts, apps/pwa/src/routes/ListDetail.test.tsx</files>
<read_first>
- apps/api/vitest.config.ts
- apps/api/src/db/client.ts
@@ -123,8 +123,8 @@ Output: New deps installed; three tables migrated; API vitest harness + 4 RED st
Scaffold the API test harness: the API currently has zero test files. Create `apps/api/test/setup.ts` and reference it from `apps/api/vitest.config.ts` (`test.setupFiles`). The setup file must establish how DB-backed route tests connect — point at the local MariaDB via the existing `apps/api/src/db/client.ts` pool (DB_HOST/DB_NAME from env), and provide a per-test cleanup (truncate lists/list_items/list_shares between tests). Pure-logic tests (listEmitter, fractional rank) do NOT need the DB.
Create the four Wave-0 RED stub test files listed in 04-VALIDATION.md, each with `describe`/`it.todo` or `it(... )` blocks that compile and FAIL (red) rather than error on import — they import the not-yet-existing modules behind a guard or use `it.todo` placeholders that downstream plans convert to real assertions:
- apps/api/src/routes/lists.test.ts — LIST-01/02/03/04 API behavior stubs
- apps/api/src/lib/listEmitter.test.ts — scoped fan-out correctness (D-04) stubs
- apps/api/tests/routes/lists.test.ts — LIST-01/02/03/04 API behavior stubs
- apps/api/tests/lib/listEmitter.test.ts — scoped fan-out correctness (D-04) stubs
- apps/pwa/src/hooks/useListSSE.test.ts — D-11 bounded backoff (mock EventSource) stubs
- apps/pwa/src/routes/ListDetail.test.tsx — D-07 optimistic update + rollback stubs
</action>
@@ -248,7 +248,7 @@ Output: New deps installed; three tables migrated; API vitest harness + 4 RED st
- Tables: `lists`, `list_shares`, `list_items` (apps/api/src/db/schema.ts)
- Migration: `apps/api/src/db/migrations/0002_lists_schema.sql` (+ journal/snapshot)
- API test harness: `apps/api/test/setup.ts`; setupFiles wiring in `apps/api/vitest.config.ts`
- RED stub tests: `apps/api/src/routes/lists.test.ts`, `apps/api/src/lib/listEmitter.test.ts`, `apps/pwa/src/hooks/useListSSE.test.ts`, `apps/pwa/src/routes/ListDetail.test.tsx`
- RED stub tests: `apps/api/tests/routes/lists.test.ts`, `apps/api/tests/lib/listEmitter.test.ts`, `apps/pwa/src/hooks/useListSSE.test.ts`, `apps/pwa/src/routes/ListDetail.test.tsx`
- Components: `BottomTabBar` (apps/pwa/src/components/BottomTabBar.tsx), `ListsIndex` (apps/pwa/src/routes/ListsIndex.tsx), temporary ListDetail placeholder route element
- Store: `useListsStore` (apps/pwa/src/store/listsStore.ts) with activeTab/createListSheetOpen
- App.tsx now exports a BrowserRouter-wrapped App + AppShell