Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2474-1782406552
Open

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

Conversation

@stooit

@stooit stooit commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and TypeScript errors in the multi-package API repo. Final state: 22 tests pass / 0 fail, npx tsc --noEmit exits clean.

Changes

  • Pagination (shared/src/utils/pagination.ts) — implemented the paginate() stub. Correct page-slice (start = (page-1)*size), totalPages = Math.ceil(total/size), and handling for out-of-range and partial-last-page cases.
  • Auth middleware (api/src/middleware/auth.ts) — fixed a case-sensitivity bug in the public-method allow-list (postPOST); HTTP methods arrive upper-cased, so POST /users was wrongly treated as protected.
  • Shared types (shared/src/types.ts) — renamed User.userNameusername to match what the tests (source of truth) and route handlers expect, restoring cross-package consistency.
  • Users route (api/src/routes/users.ts) — added the missing badRequest import causing a runtime/type failure.
  • tsconfig.json — added already-installed Bun types to types so Bun globals (bun:test, process) type-check without new dependencies.

Verification

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

Assumptions

  • The test files are the source of truth for field naming (username), so the shared type was aligned to them rather than the reverse.
  • The tsconfig types addition uses only type packages already present in node_modules — no new dependencies were added.
  • No test files were modified.

Notes (non-blocking, out of scope)

Review flagged that paginate() does not special-case size = 0 and the auth check could add a defensive .toUpperCase(). Neither is exercised by the test contract, so per the "fix only what tests require" constraint they were left unchanged.

- Implement paginate() stub in shared with correct page-slice and totalPages math
- Fix auth middleware HTTP method case bug (post -> POST) so POST /users is public
- Rename User.userName -> username for cross-package consistency (tests expect username)
- Add missing badRequest import in users route handler
- Add bun-types to tsconfig types so Bun globals type-check cleanly
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