Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2449-1785094251
Open

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

Conversation

@stooit

@stooit stooit commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 9 failing tests and all 6 type errors in the monorepo. Result: 22 pass / 0 fail, npx tsc --noEmit clean.

Changes

  • packages/shared/src/utils/pagination.ts — implemented paginate() per the test contract (was a throw "not implemented" stub): computes page slice, total, totalPages, and echoes page/pageSize.
  • packages/api/src/routes/users.ts — added the missing badRequest import (was a runtime ReferenceError, breaking the POST /users 400-on-missing-fields test).
  • packages/shared/src/types.ts — renamed User.userNameusername to match the field the tests (authoritative) and route handlers expect, resolving the cross-package mismatch.
  • packages/api/src/middleware/auth.ts — fixed the HTTP-method case-sensitivity bug so POST /users is correctly treated as a public route (no token required).
  • tsconfig.json — added "types": ["bun-types"] so process and bun:test resolve during typecheck. No new dependency (bun-types was already a devDependency).

Verification

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

Constraints honoured

  • No test files modified.
  • No new dependencies added.
  • Scope limited to what the tests require.

Assumptions

  • username (lowercase) is canonical — chosen because the (unmodifiable) tests use it.
  • Reviewer noted optional, non-blocking hardening for paginate edge inputs (negative/zero page/size) and general auth robustness. These are out of scope for "fix only what the tests require" and were intentionally not changed.

🤖 Generated with autonomous agent

- Implement paginate() utility per test contract (was a stub)
- Import badRequest in users route (was ReferenceError)
- Rename User.userName -> username to match tests and consumers
- Fix auth middleware method allow-list to normalise case (POST public)
- Add bun-types to tsconfig types for process/bun:test resolution
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