Skip to content

fix: repair failing tests and type errors across api and shared packages - #109

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2393-1785107000
Open

fix: repair failing tests and type errors across api and shared packages#109
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2393-1785107000

Conversation

@stooit

@stooit stooit commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and eliminates all tsc --noEmit type errors across the api and shared packages. bun test && tsc --noEmit is now fully green: 22 pass / 0 fail, tsc exit 0.

Root causes & fixes

  • Auth middleware (packages/api/src/middleware/auth.ts) — HTTP method comparison for public routes was case-sensitive, so POST /users was not recognised as public and required a token. Normalised the method comparison and removed dead code around the branch.
  • Shared types (packages/shared/src/types.ts) — field-name inconsistency on the User type between packages caused a tsc error at the users route. Made the field name consistent with what the route/tests expect.
  • Users route (packages/api/src/routes/users.ts) — missing import(s) (e.g. badRequest) caused a Cannot find name type error / runtime failure. Added the missing import(s).
  • Pagination utility (packages/shared/src/utils/pagination.ts) — was a stub throwing not implemented. Implemented paginate() to the test contract: correct page slice, second/partial-last pages, total/totalPages, page/pageSize, and empty data for out-of-range pages.
  • tsconfig.jsonbun-types was installed but never wired into the compiler types, so process (and bun:test) had no global declarations. Added it so these resolve without adding any dependency.

Verification

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

Constraints honoured

  • No test files modified.
  • No new dependencies added (bun-types was already installed).
  • Changes limited to the five source/config files required by the failing tests.

- auth: normalise HTTP method comparison so POST /users is public (was case-sensitive)
- shared types: rename User.userName -> username for cross-package consistency
- users route: add missing badRequest/notFound imports
- pagination: implement paginate() per test contract
- tsconfig: add bun-types so process and bun:test 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