From e0135fa76e4d1fc496fa16dffb13ce0c1b405c7a Mon Sep 17 00:00:00 2001 From: ThatXliner Date: Sun, 26 Jul 2026 15:30:24 -0700 Subject: [PATCH] Fix broken db seed and silent test discovery in the scraper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two independent bugs, both on main today. `pnpm db:seed` fails outright. Every one of the five fixture bill descriptions runs 119–135 characters, and `bill.description` is capped at 100 by the `bill_description_max_100_chars` check constraint. The first insert aborts, so nothing is seeded at all — not bills, not government content, not court cases, not the video feed rows. `pnpm onboard` offers "Seed sample feed content for local development?", so every contributor who says yes hits a hard failure and ends up with an empty database. Fixed by clamping with `clampBillDescription`, the same helper the scraper and API already use, rather than hand-trimming the five strings. The fixtures stay readable as prose, what lands in the table matches what a real scraped row looks like, and the invariant now holds by construction — you cannot reintroduce the bug without deleting the clamp. `pnpm test` in the scraper silently skips half the suite. The glob in `tsx --test src/**/*.test.ts` is unquoted, so the shell expands it before tsx sees it, and sh's `**` behaves like `*` — matching exactly one directory level. `src/utils/*.test.ts` was collected; `src/env.test.ts`, `src/*.test.ts`, and anything nested deeper was not. 2 of 4 files ran, and the suite reported green the whole time. Quoting the pattern hands globbing to Node's test runner, which walks recursively: 17 tests discovered instead of 7. Verified by reproducing both on a clean checkout of main, then re-running: the seed inserts 5 bills / 4 gov content / 3 court cases / 12 videos against a throwaway local Postgres, and the clamped descriptions truncate on word boundaries as intended. Co-Authored-By: Claude --- apps/scraper/package.json | 2 +- packages/db/seed.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/scraper/package.json b/apps/scraper/package.json index c8a909f7..9cce7e87 100644 --- a/apps/scraper/package.json +++ b/apps/scraper/package.json @@ -41,7 +41,7 @@ "start:dev": "tsx src/entry.ts", "build": "pnpm run typecheck && vite build", "typecheck": "tsc --noEmit", - "test": "tsx --test src/**/*.test.ts", + "test": "tsx --test \"src/**/*.test.ts\"", "retroactive-lenses": "tsx src/retroactive-lenses-entry.ts", "reprocess-content": "tsx src/reprocess-content-entry.ts", "retroactive-videos": "tsx src/retroactive-videos-entry.ts", diff --git a/packages/db/seed.ts b/packages/db/seed.ts index 52068647..fe0fec78 100644 --- a/packages/db/seed.ts +++ b/packages/db/seed.ts @@ -1,5 +1,6 @@ import { createHash } from "node:crypto"; +import { clampBillDescription } from "./src/bill-description"; import { db } from "./src/client"; import { Bill, CourtCase, GovernmentContent, Video } from "./src/schema"; @@ -202,6 +203,12 @@ Housing advocates strongly support the bill but want even more aggressive zoning }, ].map((b) => ({ ...b, + // `bill.description` is capped at 100 characters by a check constraint, and + // every fixture above was written longer, so the very first insert aborted + // the whole seed. Clamp with the same helper the scraper and API use rather + // than hand-trimming the prose: the fixtures stay readable here, and what + // lands in the table matches what a real scraped row looks like. + description: clampBillDescription(b.description), contentHash: hash(b.title + b.fullText), versions: [], }));