fix: repair failing tests and type errors across api and shared packages - #108
Open
stooit wants to merge 1 commit into
Open
fix: repair failing tests and type errors across api and shared packages#108stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all 9 failing tests and all 6 type errors in the monorepo. Result: 22 pass / 0 fail,
npx tsc --noEmitclean.Changes
packages/shared/src/utils/pagination.ts— implementedpaginate()per the test contract (was athrow "not implemented"stub): computes page slice,total,totalPages, and echoespage/pageSize.packages/api/src/routes/users.ts— added the missingbadRequestimport (was a runtimeReferenceError, breaking thePOST /users400-on-missing-fields test).packages/shared/src/types.ts— renamedUser.userName→usernameto 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 soPOST /usersis correctly treated as a public route (no token required).tsconfig.json— added"types": ["bun-types"]soprocessandbun:testresolve during typecheck. No new dependency (bun-typeswas already a devDependency).Verification
bun test→ 22 pass, 0 failnpx tsc --noEmit→ 0 errorsConstraints honoured
Assumptions
username(lowercase) is canonical — chosen because the (unmodifiable) tests use it.paginateedge 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