Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2465-1784738194
Open

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

Conversation

@stooit

@stooit stooit commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 9 failing tests and eliminates all TypeScript errors in the repo. bun test now reports 22 pass / 0 fail and npx tsc --noEmit exits clean.

Changes

  • packages/api/src/middleware/auth.ts — Fixed an HTTP-method case-sensitivity bug in the public-route check. c.req.method is always upper-case (POST), so the comparison now matches correctly and public POST requests are no longer wrongly rejected. Auth is still enforced for non-public methods.
  • packages/shared/src/types.ts — Reconciled the User field name from userName to username to match what the API routes and tests expect (cross-package inconsistency).
  • packages/api/src/routes/users.ts — Added the missing badRequest import that caused a runtime/type failure, and updated the field usage to username.
  • packages/shared/src/utils/pagination.ts — Implemented paginate<T>() (previously a throw new Error("not implemented") stub): correct page slicing, total, totalPages (ceil), page/pageSize, out-of-range pages return empty data, and empty-array handling.
  • tsconfig.json — Added bun-types to the types array so tsc resolves Bun test globals and process (no new dependency installed — bun-types was already present).

Verification

bun test         -> 22 pass, 0 fail
npx tsc --noEmit -> exit 0 (zero errors)

Assumptions

  • Where the test suite expected username but source used userName, the source was changed to match the tests (tests are the contract and must not be modified per the task constraints).
  • No test files were modified and no new dependencies were added, per constraints.

Review

An independent review pass confirmed all changes are genuine fixes (not test-silencing hacks), the auth fix introduces no bypass, and the pagination math is correct with no off-by-one.

- Fix auth middleware HTTP-method case-sensitivity bug that blocked public POST requests
- Reconcile User field name (userName -> username) between shared types and api routes
- Implement paginate() utility (was a throwing stub) with correct total/totalPages and edge-case handling
- Add missing badRequest import in users route handler
- Add bun-types to tsconfig 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