Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2192-1788625022
Open

stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2192-1788625022

Conversation

@stooit

@stooit stooit commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the repo. bun test now reports 22 pass / 0 fail (was 13 pass / 9 fail) and bunx tsc --noEmit is clean (was 14 errors).

Changes

File Fix
packages/shared/src/types.ts Renamed User.userNameusername to match the field name the API routes and tests actually use (tests are the source of truth).
packages/api/src/middleware/auth.ts Case-sensitivity bug: the public-methods list had "post" (lowercase) but c.req.method is uppercase per RFC 9110, so POST /users was never treated as public. Changed to ["GET", "POST"].
packages/api/src/routes/users.ts Added the missing badRequest import from ../lib/errors (was a ReferenceError surfacing as a 500 instead of the expected 400 on missing fields).
packages/shared/src/utils/pagination.ts Implemented the paginate() stub per the contract exercised by pagination.test.ts: 1-indexed pages, echoes page/pageSize, empty data for out-of-range pages, totalPages === 0 for empty input, partial last page handled.
tsconfig.json Added "types": ["bun-types"] to load the already-installed bun-types (supplies bun:test and, transitively, the process global). No new dependencies.

Assumptions

  • The canonical User field name is username (not userName) — derived from the test files, which cannot be modified.
  • POST /users is intentionally public (pinned by auth.test.ts). Left as-is. Note: an unauthenticated write endpoint would warrant authentication + rate limiting before reaching a real/government workload; acceptable here as an e2e fixture.

Constraints honoured

  • No test files modified.
  • No dependencies added (package.json untouched).
  • Only the five source/config files above changed.

Verification

```
bun test → 22 pass / 0 fail
bunx tsc --noEmit → 0 errors
```

Rename User.userName to username to match API and test usage, add the
missing badRequest import, fix the uppercase POST method check in auth
middleware, implement paginate(), and load bun-types in tsconfig.
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