Skip to content

fix: resolve all failing tests and type errors#66

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2470-1781973702
Open

fix: resolve all failing tests and type errors#66
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2470-1781973702

Conversation

@stooit

@stooit stooit commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors across the api and shared packages. After these changes bun test reports 22 pass / 0 fail and bunx tsc --noEmit is clean.

Bugs fixed

  • Auth middleware case-sensitivity (packages/api/src/middleware/auth.ts) — the public-methods list used lowercase 'post', but Hono's c.req.method returns the uppercase RFC 7231 string. POST /users was therefore never treated as public and wrongly required a Bearer token. Changed 'post' to 'POST'.
  • Missing import (packages/api/src/routes/users.ts) — the invalid-body path called badRequest() which was never imported, a guaranteed runtime ReferenceError. Added it to the existing ../lib/errors import.
  • Inconsistent shared field name (packages/shared/src/types.ts) — renamed userName to username to match how the API route references the field. No dangling references remain.
  • Unimplemented pagination utility (packages/shared/src/utils/pagination.ts) — replaced the throwing stub with a real implementation (page slice, total/totalPages via Math.ceil, correct empty/out-of-range handling) matching the PaginatedResponse<T> contract exercised by the tests.
  • Type resolution (tsconfig.json) — added "types": ["bun-types"] so tsc resolves the bun:test globals used in test files.

Verification

  • bun test -> 22 pass, 0 fail
  • bunx tsc --noEmit -> clean

Constraints honoured

  • No test files modified
  • No new dependencies added
  • Changes minimal and targeted

Assumptions

  • bun-types was added to tsconfig.json types as the intended fix for the bun:test global type errors, since it is already a declared devDependency.

…ages

- auth middleware: fix case-sensitivity bug (lowercase 'post' never matched
  Hono's uppercase RFC 7231 method string, so POST /users wrongly required auth)
- users route: import missing badRequest helper (ReferenceError on invalid body)
- shared types: align field name userName -> username with API usage
- pagination: implement the stubbed paginate() to satisfy the test contract
- tsconfig: add bun-types so tsc resolves bun:test globals
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