Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2218-1786896490
Open

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

Conversation

@stooit

@stooit stooit commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and TypeScript errors in the multi-package repo. bun test now reports 22 pass / 0 fail and bunx tsc --noEmit exits clean. No test files were modified and no dependencies were added.

Fixes

  • Auth middleware (packages/api/src/middleware/auth.ts): fixed an HTTP-method case-sensitivity bug in the public allow-list (["GET", "post"]["GET", "POST"] with .toUpperCase() normalisation) so unauthenticated public GET/POST routes are matched correctly. DELETE/PUT/PATCH still correctly require a token.
  • Shared types (packages/shared/src/types.ts): aligned the User field to username (was userName) so the shared type, both API route handlers, and the tests agree. Renaming the type — rather than the routes — was the correct direction, since the tests (which must not change) use username.
  • Users route (packages/api/src/routes/users.ts): restored the missing badRequest import from lib/errors.ts (already exported and already imported in the sibling posts.ts), so invalid payloads return 400 instead of a 500 ReferenceError.
  • Pagination (packages/shared/src/utils/pagination.ts): implemented the previously-stubbed paginate() to satisfy the shared test contract — correct page slicing, page/pageSize/total/totalPages, out-of-range → empty data, and empty-input handling. Verified no off-by-one.
  • tsconfig (tsconfig.json): added "types": ["bun-types"] (already present in devDependencies + node_modules) so process and bun:test resolve. Wires up an existing dependency; the alternative (@types/node) would have been a new dependency, which was disallowed.

Verification

  • bun test -> 22 pass / 0 fail
  • bunx tsc --noEmit -> clean (exit 0)
  • No test files modified; no dependencies added.

Assumptions

  • The username/userName inconsistency was resolved toward username because the (unmodifiable) tests assert on username.
  • bun-types was preferred over @types/node to honour the no-new-dependencies constraint.

Generated with autonomous agent

- auth middleware: fix HTTP method case-sensitivity so public GET/POST routes match correctly
- shared types: align User field to 'username' (was 'userName') to match consumers and tests
- users route: restore missing badRequest import so invalid payloads return 400 not 500
- pagination: implement paginate() to satisfy shared package test contract
- tsconfig: wire up existing bun-types so 'process' and 'bun:test' 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