Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2163-1787869704
Open

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

Conversation

@stooit

@stooit stooit commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 9 failing tests and all 14 tsc --noEmit type errors. Both gates now pass cleanly (bun test → 22 pass / 0 fail; tsc --noEmit → exit 0). Bugs spanned both the api and shared packages.

Changes

  • packages/shared/src/utils/pagination.ts — implemented the paginate stub. Correctly handles the empty-array case (totalPages: 0, not 1) and out-of-range pages (returns empty data rather than clamping), matching the test contract.
  • packages/api/src/middleware/auth.ts — fixed a case-sensitivity bug in the public-methods list ("post""POST"). POST/GET are intentionally public in this API; the lowercase entry never matched the uppercased HTTP method, so public POST was wrongly returning 401.
  • packages/shared/src/types.ts — renamed User.userNameUser.username so the shared type matches the field name the (unmodifiable) tests and the API routes use. Propagates cleanly through Omit<User, ...> consumers; zero orphaned userName references remain.
  • packages/api/src/routes/users.ts — added the missing badRequest import that was causing a ReferenceError (500 instead of 400 on invalid input).
  • tsconfig.json — added "types": ["bun-types"] so the already-installed bun-types package supplies the process and bun:test globals. Resolved 8 type errors.

Verification

  • bun test22 pass / 0 fail (was 13 pass / 9 fail)
  • tsc --noEmitexit 0 (was 14 errors)
  • Independently reviewed: every change is a genuine root-cause fix aligned with what the tests assert, not a compiler workaround.

Constraints honoured / assumptions

  • No test files modified.
  • No dependencies addedbun-types was already in root devDependencies; tsconfig only references it.
  • The rename direction (type → username) was the only legal one, since the tests assert username and must not be edited.
  • Left docs/ (untracked prior-agent scratch) and README.md's stale "known bugs" list untouched — the README appears to be intentional test-corpus scaffolding.

Fixes 9 failing tests and 14 typecheck errors:
- pagination.ts: implement the paginate stub (correct empty-array/boundary handling)
- auth.ts: correct HTTP method case ("post" -> "POST") so public routes match
- types.ts: rename User.userName -> User.username to match test expectations
- users.ts: add missing badRequest import
- tsconfig.json: reference already-installed bun-types for process/bun:test globals

No test files modified; no dependencies added.
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