Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-4217-1783182486
Open

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

Conversation

@stooit

@stooit stooit commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and eliminates all tsc --noEmit errors in this multi-package Hono API repo. Bugs spanned both the api and shared packages.

Result: bun test → 22 pass / 0 fail (4 files); bunx tsc --noEmit → 0 errors.

Fixes

  • Pagination (packages/shared/src/utils/pagination.ts) — implemented the paginate() stub (was throw new Error("not implemented")) to satisfy the full test contract: page slicing, total, totalPages (0 when empty), page/pageSize fields, and clamping for out-of-range pages.
  • Auth middleware (packages/api/src/middleware/auth.ts) — case-sensitivity bug: public-methods list used "post" but HTTP methods compare as uppercase, so POST /users was not treated as public. Changed to "POST".
  • Shared types (packages/shared/src/types.ts) — renamed User.userNameusername to match the route handlers, DB usage, and test expectations.
  • Route handler (packages/api/src/routes/users.ts) — added the missing badRequest import from ../lib/errors that caused a runtime failure on the 400/missing-fields path.
  • tsconfig.json — added "types": ["bun-types"] (already a devDependency) so the process global and bun:test module resolve for tsc.

Constraints honoured

  • No test files modified.
  • No new dependencies added (bun-types was already present).
  • Only source/config files required by the tests were changed.

Assumptions

  • The username (lowercase) field name is canonical, since the route handlers, DB layer, and tests all use it — only the shared type diverged.
  • The tsc errors for bun:test/process were resolved via tsconfig types rather than editing tests, per the "do not modify tests" constraint.

Verification

Reviewed by the review subagent (approved, no issues) and independently confirmed both bun test and bunx tsc --noEmit pass locally.

- implement paginate() stub in shared with full contract (slicing, totals, clamping)
- fix auth middleware public-method check to use uppercase HTTP method (POST)
- rename User.userName to username in shared types to match routes and tests
- add missing badRequest import in users route handler
- add bun-types to tsconfig types so process and bun:test 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