Skip to content

fix: resolve failing tests and type errors across api and shared packages#40

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2450-1780874892
Open

fix: resolve failing tests and type errors across api and shared packages#40
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2450-1780874892

Conversation

@stooit

@stooit stooit commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the multi-package repo. After this change: 22 tests pass, 0 fail and tsc --noEmit is clean.

Fixes

Area Bug Fix
api/src/routes/users.ts badRequest called but not imported → ReferenceError (500 instead of 400) Added badRequest to the ../lib/errors import
api/src/middleware/auth.ts Public-methods allow-list used lowercase ("post") but c.req.method is uppercase, so POST /users wrongly returned 401 Changed allow-list entries to uppercase ("GET", "POST")
shared/src/types.ts User.userName mismatched the username field used by routes and tests Renamed userNameusername (canonical, per authoritative tests)
shared/src/utils/pagination.ts paginate() was a throwing stub Implemented: 1-indexed pages, real slice, total/totalPages/page/pageSize, handles partial last page, out-of-range, and empty input
tsconfig.json bun:test module and process unresolved Added `"types": ["bun-types"]` (already installed; pulls in node globals)

Also removed two now-stale code comments (the `// BUG:` note and the pagination `TODO`).

Verification

  • `bun test` → 22 pass, 0 fail
  • `npx tsc --noEmit` → exit 0, no errors

Constraints honoured

  • No test files modified
  • No new dependencies added
  • Reviewed by the `review` subagent (verdict: APPROVE)

Assumptions

  • `username` (lowercase n) is the canonical field name, since the test files are authoritative and cannot be changed.
  • Pagination pages are 1-indexed, matching the contract asserted by `shared/test/pagination.test.ts`.

…ages

- routes/users: import missing badRequest helper (was throwing ReferenceError → 500)
- middleware/auth: use uppercase HTTP methods in public allow-list so POST /users is public
- shared/types: rename User.userName → username to match callers and tests
- shared/pagination: implement paginate() (1-indexed, real slice + totalPages)
- tsconfig: add types:[bun-types] so bun:test globals and process resolve
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