Skip to content

fix: make all tests pass and eliminate type errors#51

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2594-1781368742
Open

fix: make all tests pass and eliminate type errors#51
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2594-1781368742

Conversation

@stooit

@stooit stooit commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and TypeScript type errors across the api (Hono) and shared packages. Final state: bun test → 22 pass / 0 fail, npx tsc --noEmit → clean (exit 0).

Bugs fixed

  1. Pagination not implemented (packages/shared/src/utils/pagination.ts) — replaced the throw new Error("not implemented") stub with a real paginate<T>(): 1-indexed page, totalPages = ceil(total/size) (0 when empty), out-of-range pages return empty data, correct partial-last-page slicing.
  2. Auth case-sensitivity (packages/api/src/middleware/auth.ts) — the public-method check compared a lowercase literal against Hono's uppercase c.req.method, so POST /users was wrongly treated as protected. Normalised the comparison to be case-insensitive.
  3. Inconsistent shared field name (packages/shared/src/types.ts) — User.userName renamed to username to match the tests and usage across both packages.
  4. Missing import (packages/api/src/routes/users.ts) — badRequest is now imported from the existing ../lib/errors helper (no new dependency).
  5. Type errors for process / bun:test (tsconfig.json) — set compilerOptions.types to ["bun-types"] so the already-present ambient Bun/Node types resolve. No dependencies added.

Constraints honoured

  • No test files modified.
  • No dependencies added (package.json untouched).
  • Minimal, scoped changes (5 files, +10/-9 lines).

Assumptions

  • Pagination is 1-indexed and returns empty data for out-of-range pages (from the pagination test contract).
  • username (lowercase) is canonical, since test files (uneditable) use it.
  • page<=0 / size=0 are not guarded — not exercised by tests, not wired to a live route.

Verification

bun test  → 22 pass, 0 fail
npx tsc --noEmit → exit 0 (clean)

…d name, repair imports

- Implement paginate() in shared (1-indexed, totalPages, out-of-range -> empty)
- Fix auth middleware public-method check to be case-insensitive (POST /users now public)
- Rename User.userName -> username for cross-package consistency
- Import badRequest from ../lib/errors in users route
- Set tsconfig types to bun-types so process/bun:test resolve without new deps
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