Fix broken db seed and silent test discovery in the scraper - #199
Merged
Conversation
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 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two independent bugs, both live on
maintoday. Split out of #198 so they can land on their own.1.
pnpm db:seedfails outrightEvery one of the five fixture bill descriptions runs 119–135 characters, and
bill.descriptionis capped at 100 by thebill_description_max_100_charscheck constraint:The bills insert is the first statement in
seed(), so it aborts the whole run — nothing gets seeded. Not bills, not government content, not court cases, not the video feed rows.This is on the contributor onboarding path.
pnpm onboardasks "Seed sample feed content for local development?", and everyone who says yes getsSample-data seed failed.and an empty database.Fix: clamp with
clampBillDescription— the same helper the scraper and API already use — rather than hand-trimming the five strings. The fixtures stay readable as prose in the file, what lands in the table matches what a real scraped row looks like, and the invariant now holds by construction: you can't reintroduce the bug without deleting the clamp.Result (truncates on word boundaries, as intended):
2.
pnpm testin the scraper silently skips half the suiteThe glob in
tsx --test src/**/*.test.tsis unquoted, so the shell expands it beforetsxever sees it — and sh's**behaves like*, matching exactly one directory level:src/env.test.tsandsrc/scraper-contracts.test.tswere never collected, and anything nested deeper thansrc/utils/never would be. 2 of 4 files ran, and the suite reported green the whole time — which is the dangerous part: a broken test in an uncollected file looks identical to a passing one.Fix: quote the pattern so globbing is handled by Node's test runner, which walks recursively.
Verification
Both reproduced on a clean checkout of
mainfirst, then re-run after the fix:Note on #198
#198 currently carries both of these fixes too — it needed the seed working to verify its own changes. Once this merges, I can rebase #198 to drop them, or leave it and resolve the (identical-content) conflict at merge time. Happy to do whichever you prefer.
🤖 Generated with Claude Code