Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2243-1789748243
Open

stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2243-1789748243

Conversation

@stooit

@stooit stooit commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 9 failing tests and all 14 tsc --noEmit type errors. Final state: 22 tests pass, 0 fail; tsc --noEmit exits clean. No test files modified, no dependencies added.

Changes

File Fix
packages/shared/src/utils/pagination.ts Implemented the paginate() stub per the test contract (page slice, page/pageSize, total/totalPages, empty data for out-of-range page, empty array).
packages/api/src/middleware/auth.ts Fixed case-sensitivity bug in public-route method matching — methods are now normalised (.toUpperCase()) so POST /users is correctly treated as public regardless of casing.
packages/api/src/routes/users.ts Added missing badRequest import from ../lib/errors (was causing a runtime ReferenceError → the "returns 400 for missing fields" test failed).
packages/shared/src/types.ts Renamed User.userName → username to match the field name asserted by the tests across both packages.
tsconfig.json Added typeRoots + types: ["bun-types"] so bun:test and process resolve from the already-installed bun-types (no new deps).

Assumptions / decisions documented

  • Field-name direction: the task hinted at aligning the route to userName, but the tests (which must not change) all assert lowercase username, and 4 of the TS2561 errors originated inside test files. The tests are the source of truth, so the shared User type was changed to username instead — the only change that satisfies the un-editable tests.
  • @types/node not installed: only bun-types and typescript are present in node_modules. bun-types bundles its own node type references, so pointing typeRoots at ./node_modules resolves both bun:test and process without adding @types/node.
  • Pagination input clamping: page/pageSize are clamped with Math.max(1, ...) to avoid negative slice windows on zero/negative input. Not covered by tests; chosen as safe default behaviour.

Follow-up (not done — out of scope, not required by tests)

  • README.md "Known issues" still documents the old (incorrect) rename direction and references a docstring that was removed from shared/src/types.ts.

…ername field

- Implement paginate() in shared/utils per the pagination test contract
- Fix auth middleware public-route method matching to be case-insensitive
- Add missing badRequest import in users route (was causing runtime ReferenceError)
- Align User.username field name across packages (source of truth: tests)
- Configure tsconfig typeRoots so bun:test and process resolve from bun-types (no 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