Skip to content

test : add tests for getSessionWithToken utility #3100

Closed as not planned
Closed as not planned

Description

@tmdeveloper007

Summary of What Needs to be Done: Add unit tests for the session-with-token utility in src/lib/get-session-token.ts, covering getSessionWithToken return shape and null cases.

Changes that Need to be Made: Create test/get-session-token.test.ts with vitest mocking next-auth and @/lib/resolve-user. Cover: getSessionWithToken returns null when no session, returns null when session lacks githubId or githubLogin, returns null when session lacks accessToken, returns null when resolveAppUser returns null, returns SessionWithToken with correct shape when all conditions met, accessToken field is populated from session.

Impact that it would Provide: getSessionWithToken is used across authenticated API routes to get GitHub access tokens. Tests ensure the null-safety logic is correct and no null access errors occur when user data is incomplete.

Hello @Priyanshu-byte-coder, please assign this issue to me (@tmdeveloper007) so I can open a focused PR.

Activity

  1. saksham242007 commented on Jul 3, 2026

    @saksham242007

    Hi @Priyanshu-byte-coder, I'd like to work on this issue. I can add the unit tests for getSessionWithToken, covering the null cases and the valid session flow using mocks where needed. Please assign this issue to me. Thanks!

  2. github-actions commented on Jul 3, 2026

    @github-actions

    Assigned to @saksham242007! You have 7 days to open a PR. No PR after 7 days = auto-unassigned so others can pick it up. Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions