Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2424-1783268943
Open

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

Conversation

@stooit

@stooit stooit commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 9 failing tests and all tsc --noEmit type errors in the bun/Hono workspace. bun test now passes 22/22 and npx tsc --noEmit is clean.

Changes

  • shared/types.ts — renamed User.userNameusername to match the route handlers, db seed data, and tests (field name was inconsistent between packages).
  • shared/utils/pagination.ts — implemented the paginate() stub (previously threw "not implemented"). 1-indexed pages: data = items.slice((page-1)*size, ...), total, totalPages = ceil(total/size) (0 when empty), returns empty data for out-of-range pages.
  • api/middleware/auth.ts — fixed a case-sensitivity bug: the public-method allow-list contained lowercase 'post' while Hono's c.req.method is uppercase, so POST /users was wrongly requiring a token.
  • api/routes/users.ts — added the missing badRequest import from ../lib/errors (runtime failure on validation path).
  • tsconfig.json — added bun-types so bun:test and node globals (process) resolve. No new dependencies (bun-types already installed).

Verification

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

Constraints honoured

  • No test files modified
  • No new dependencies added
  • Only the changes the tests required

Assumptions

  • Correct field spelling is username (lowercase n) — tests, db seed, and route logic all use it; only the shared type declared userName.
  • paginate pages are 1-indexed, per the pagination test contract.

- shared: rename User.userName -> username to match route handlers, db, and tests
- shared: implement paginate() stub with 1-indexed page slicing and edge-case handling
- api: fix auth middleware public-method allow-list ('post' -> 'POST')
- api: add missing badRequest import in users route
- tsconfig: add bun-types so bun:test and node globals 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