refactor(04): move rank.test.ts into tests/ mirror dir (convention + dist hygiene)

src/lib/rank.test.ts was the last co-located API test. The API tsconfig excludes
tests/ from the build, so all test files belong there; a test in src/ gets compiled
into dist/ and vitest then runs the stale compiled copy (the source of phantom
'22 todo' and dist sourcemap warnings). Moving it to tests/lib/ matches convention
and leaves zero test files in src/, so the production build no longer emits test
artifacts. Updated rank.test.ts path refs in phase-04 plan docs.
This commit is contained in:
Lucas Berger
2026-06-09 13:40:11 -04:00
parent ca9e97879f
commit 690f0b95c0
5 changed files with 20 additions and 20 deletions
@@ -8,7 +8,7 @@ files_modified:
- apps/pwa/src/routes/ListDetail.tsx
- apps/pwa/src/components/ItemRow.tsx
- apps/pwa/src/api/listsClient.ts
- apps/api/src/lib/rank.test.ts
- apps/api/tests/lib/rank.test.ts
- apps/api/tests/routes/lists.test.ts
autonomous: true
requirements: [LIST-03]
@@ -97,9 +97,9 @@ Output: dnd-kit DndContext/SortableContext in ListDetail; sortable ItemRow with
<task type="auto">
<name>Task 2: Strengthen server-side reorder ordering tests (LIST-03, D-13)</name>
<files>apps/api/src/lib/rank.test.ts, apps/api/tests/routes/lists.test.ts</files>
<files>apps/api/tests/lib/rank.test.ts, apps/api/tests/routes/lists.test.ts</files>
<read_first>
- apps/api/src/lib/rank.test.ts (from Plan 04)
- apps/api/tests/lib/rank.test.ts (from Plan 04)
- apps/api/tests/routes/lists.test.ts (PATCH position coverage)
- .planning/phases/04-shared-lists-live-sync/04-VALIDATION.md (LIST-03 row: "PATCH new rank produces correct fractional order")
- .planning/phases/04-shared-lists-live-sync/04-RESEARCH.md §"Common Pitfalls" Pitfall 2 (precision)
@@ -108,7 +108,7 @@ Output: dnd-kit DndContext/SortableContext in ListDetail; sortable ItemRow with
Add server-side tests proving reorder correctness: (a) repeated mid-point inserts via rankBetween produce strictly increasing distinct strings over many iterations (precision does not collapse — Pitfall 2); (b) PATCH /api/list-items/:id { position } updates only rank and a subsequent GET returns items in the new ASC order; (c) moving an item between two neighbors yields a rank strictly between theirs. These align the LIST-03 row in 04-VALIDATION.md to a green automated check. No production behavior change — Plan 04 already implements the PATCH position path.
</action>
<verify>
<automated>pnpm --filter @familysync/api exec vitest run src/lib/rank.test.ts tests/routes/lists.test.ts</automated>
<automated>pnpm --filter @familysync/api exec vitest run tests/lib/rank.test.ts tests/routes/lists.test.ts</automated>
</verify>
<acceptance_criteria>
- LIST-03 ordering test ("PATCH new rank produces correct fractional order") is present and green.
@@ -136,7 +136,7 @@ Output: dnd-kit DndContext/SortableContext in ListDetail; sortable ItemRow with
</threat_model>
<verification>
<automated>pnpm --filter @familysync/api exec vitest run src/lib/rank.test.ts tests/routes/lists.test.ts && pnpm --filter @familysync/pwa exec tsc --noEmit</automated>
<automated>pnpm --filter @familysync/api exec vitest run tests/lib/rank.test.ts tests/routes/lists.test.ts && pnpm --filter @familysync/pwa exec tsc --noEmit</automated>
- `playwright-cli`: drag-reorder persists across reload.
</verification>