Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2356-1785515968
Open

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

Conversation

@stooit

@stooit stooit commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 9 failing tests and all tsc --noEmit type errors in the Bun/Hono monorepo. Final state: 22 pass / 0 fail, npx tsc --noEmit clean (exit 0).

Changes

  • shared/src/utils/pagination.ts — implemented paginate<T>() (was a throw new Error("not implemented") stub), satisfying the full PaginatedResponse contract: page slicing, partial last page, total/totalPages, page/pageSize echo, and empty/out-of-range pages returning empty data.
  • shared/src/types.ts — renamed User.userNameusername to reconcile the inconsistency between the shared type, the users route, and the tests.
  • api/src/routes/users.ts — imported badRequest (previously used but unimported → ReferenceError on POST /users); aligned field to username.
  • api/src/middleware/auth.ts — fixed the public-route allow-list: HTTP method is now normalised (case-insensitive) so POST /users is correctly treated as public. Resolved the process type error via tsconfig.
  • tsconfig.json — added bun-types to compilerOptions.types (resolves bun:test module + process type errors). No new dependencies added.

Verification

  • bun test → 22 pass / 0 fail
  • npx tsc --noEmit → 0 errors

Constraints honoured

  • No test files modified.
  • No new dependencies added.
  • Fixed only what the tests/type-checker required.

Notes / assumptions

  • Canonical field name resolved to username (lowercase) because that is what the read-only tests and route body expect.
  • A review flagged optional hardening for paginate() on non-finite / zero size inputs. Those paths are not exercised by any test and paginate() is not yet wired to a route, so they were left out of scope per "fix only what the tests require." Worth a follow-up if paginate is later bound to request query params.

🤖 Generated with autonomous agent

- shared: implement paginate() utility (was a throwing stub)
- shared: rename User.userName -> username to match route and tests
- api: import badRequest in users route (fixes ReferenceError on POST /users)
- api: normalise HTTP method + add POST to auth public-route allow-list
- tsconfig: add bun-types to compilerOptions.types (fixes bun:test/process)
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