fix: repair failing tests across api and shared packages - #141
Open
stooit wants to merge 1 commit into
Open
Conversation
- Implement paginate utility (was an unimplemented stub) - Rename shared User field userName -> username to match tests - Add missing badRequest import in users route (500 -> 400) - Fix auth middleware method case-sensitivity in public-methods allow-list - Add bun-types to tsconfig so process/bun:test resolve (config only, no new deps)
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.
Summary
Fixes all 9 failing tests and all TypeScript type errors.
bun testnow reports 22 pass / 0 fail andbunx tsc --noEmitexits 0 (was 13 pass / 9 fail, 14 type errors).Changes
packages/shared/src/utils/pagination.tspaginatestub — 1-indexed page slicing,Math.ceiltotalPages, empty data for out-of-range/empty inputs. Fixes 7 pagination tests.packages/shared/src/types.tsUser.userName→usernameto match the field name the tests (source of truth) and all route consumers use. Clears theTS2561errors.packages/api/src/routes/users.tsbadRequestimport — theReferenceErrorwas turning a 400 into a 500.packages/api/src/middleware/auth.ts"post"→"POST", plus.toUpperCase()normalisation) soPOST /usersis correctly public. DELETE-without-token still returns 401.tsconfig.json"types": ["bun-types"]soprocessandbun:testresolve. Config-only —bun-typeswas already a declared devDependency.Constraints honoured
git diff --name-only).Verification
bun test→ 22 pass / 0 failbunx tsc --noEmit→ exit 0Follow-up (out of scope — noted from review)
The
paginateutil does not validate a negative or fractionalsize/page(a negativesizecan over-fetch viaslice's negative-index behaviour). This is not currently reachable —paginatehas no callers insrc/and no route wires it to user-supplied query params — so it's left as-is to respect the "fix only what tests require" constraint. Worth hardening before any route parsespage/pageSizefrom query params.