Skip to content

fix: repair failing tests across api and shared packages - #141

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2215-1787155851
Open

fix: repair failing tests across api and shared packages#141
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2215-1787155851

Conversation

@stooit

@stooit stooit commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 9 failing tests and all TypeScript type errors. bun test now reports 22 pass / 0 fail and bunx tsc --noEmit exits 0 (was 13 pass / 9 fail, 14 type errors).

Changes

File Fix
packages/shared/src/utils/pagination.ts Implemented the paginate stub — 1-indexed page slicing, Math.ceil totalPages, empty data for out-of-range/empty inputs. Fixes 7 pagination tests.
packages/shared/src/types.ts Renamed User.userNameusername to match the field name the tests (source of truth) and all route consumers use. Clears the TS2561 errors.
packages/api/src/routes/users.ts Added the missing badRequest import — the ReferenceError was turning a 400 into a 500.
packages/api/src/middleware/auth.ts Fixed a case-sensitivity bug in the public-methods allow-list ("post""POST", plus .toUpperCase() normalisation) so POST /users is correctly public. DELETE-without-token still returns 401.
tsconfig.json Added "types": ["bun-types"] so process and bun:test resolve. Config-only — bun-types was already a declared devDependency.

Constraints honoured

  • No test files modified (verified via git diff --name-only).
  • No new dependencies added.
  • Changes scoped to only what the tests require.

Verification

  • bun test → 22 pass / 0 fail
  • bunx tsc --noEmit → exit 0

Follow-up (out of scope — noted from review)

The paginate util does not validate a negative or fractional size/page (a negative size can over-fetch via slice's negative-index behaviour). This is not currently reachablepaginate has no callers in src/ 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 parses page/pageSize from query params.

- 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant