test: add coverage for auth/me, credentials, and user profile endpoints (#202)#251
Merged
3m1n3nc3 merged 3 commits intogeevapp:mainfrom Mar 29, 2026
Merged
Conversation
Covers the three uncovered critical paths identified in issue #202: - GET /api/auth/me: 401 with no/invalid session, 404 user not in DB, 200 happy path, rank fallback, badge flattening - Auth Credentials authorize: register new user, login existing user, invalid signature, missing user on login, malformed key - GET/PATCH /api/users/[id]: 404 unknown user, isFollowing flag, 401/403/409 guards, own-profile update
|
@BigBen-7 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
3m1n3nc3
requested changes
Mar 26, 2026
Contributor
3m1n3nc3
left a comment
There was a problem hiding this comment.
Please fix the failing tests
- Fix parse error in users.test.ts caused by apostrophe in single-quoted string - Fix auth-credentials tests accessing the default stub authorize instead of the real implementation: in NextAuth v5 beta.30, Credentials() stores the user-provided config at .options, so authorize is at .options.authorize
The route was moved from app/api/auth/me/route.ts to (auth)/me/route.ts in upstream main (commit 4ac1a9c). Update the test import accordingly.
Contributor
Author
|
@3m1n3nc3 fixed |
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
Closes #202. Adds unit test coverage for the three critical paths that had zero automated tests:
tests/api/auth.test.ts—GET /api/auth/merankisnullUserBadgejoin tabletests/api/auth-credentials.test.ts— NextAuth Credentialsauthorizecallback (login + register logic)null(→ 401)null(→ 401)nullKeypair.fromPublicKeythrows) → returnsnulltests/api/users.test.ts—GET /PATCH /api/users/[id]isFollowingflag set correctly for authenticated and anonymous requestsApproach
Follows the exact patterns from
tests/api/posts.test.tsandtests/api/interactions.unit.test.ts:vi.mock/vi.hoistedfor all external dependencies (Prisma, auth, Stellar SDK, PrismaAdapter)createMockRequest/parseResponsefromtests/helpers/api.tsTest plan
pnpm --filter app testpasses locally