Skip to content

Add unit tests for OAuth.refreshAccessToken()#13857

Merged
rickyrombo merged 3 commits into
mjp-oauth-standalonefrom
copilot/sub-pr-13805
Mar 9, 2026
Merged

Add unit tests for OAuth.refreshAccessToken()#13857
rickyrombo merged 3 commits into
mjp-oauth-standalonefrom
copilot/sub-pr-13805

Conversation

Copilot AI commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

The refresh-token exchange logic was moved into OAuth.refreshAccessToken() without corresponding unit tests. This adds focused coverage for that method.

Tests added (OAuth.test.ts)

  • Success path — token store is updated with new access + refresh tokens; new access token is returned
  • Request shape — verifies grant_type, refresh_token, and client_id are sent correctly
  • Failure paths:
    • Non-OK HTTP response → null, token store unchanged
    • Invalid JSON body → null
    • Missing access_token or refresh_token in response → null
    • Missing tokenStore or basePath config → null
    • No refresh token in store → null
    • fetch throws (network error) → null

jsdom is not installed in this package, so the browser-only constructor guard is satisfied by stubbing window via vi.stubGlobal.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@changeset-bot

changeset-bot Bot commented Mar 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: fdc433a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI and others added 2 commits March 9, 2026 17:59
Co-authored-by: rickyrombo <3690498+rickyrombo@users.noreply.github.com>
Co-authored-by: rickyrombo <3690498+rickyrombo@users.noreply.github.com>
@pull-request-size pull-request-size Bot added size/L and removed size/XS labels Mar 9, 2026
Copilot AI changed the title [WIP] WIP address feedback on simplifying OAuth refreshToken middleware Add unit tests for OAuth.refreshAccessToken() Mar 9, 2026
@rickyrombo rickyrombo marked this pull request as ready for review March 9, 2026 18:38
@rickyrombo rickyrombo merged commit e800370 into mjp-oauth-standalone Mar 9, 2026
3 checks passed
@rickyrombo rickyrombo deleted the copilot/sub-pr-13805 branch March 9, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants