Skip to content

test: correct onRefresh signature in MockAuthClient test-utils#262

Merged
panz3r merged 2 commits intomainfrom
copilot/fix-onrefresh-signature
Apr 4, 2026
Merged

test: correct onRefresh signature in MockAuthClient test-utils#262
panz3r merged 2 commits intomainfrom
copilot/fix-onrefresh-signature

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

Affected Package(s)

  • @forward-software/react-auth (lib)
  • @forward-software/react-auth-google (packages/google-signin)
  • Examples
  • CI/CD / Repository configuration

Related Issue(s)

Motivation

MockAuthClient and MockAuthClientWithHooks in lib/test/test-utils.tsx declared onRefresh without the required currentTokens first parameter, diverging silently from the AuthClient interface. Anyone using these mocks as a reference would learn the wrong contract.

Description of Changes

  • Fixed onRefresh signature in MockAuthClient to match the AuthClient interface:
// Before (wrong — missing currentTokens)
onRefresh(_minValidity?: number): Promise<MockTokens>

// After (correct)
onRefresh(_currentTokens: MockTokens, _minValidity?: number): Promise<MockTokens>
  • Applied the same fix to MockAuthClientWithHooks, which extended MockAuthClient but overrode onRefresh with the same incorrect signature.

Breaking Changes

None

How to Test

  1. CI Checks: Verify that all automated tests (Vitest) and build steps pass successfully on this PR.
  2. Local Verification (Optional):
    • Run pnpm install to install dependencies.
    • Run pnpm --filter @forward-software/react-auth test to run tests for the affected package.
    • Run pnpm --filter @forward-software/react-auth build to verify the build succeeds.
    • Run pnpm --filter @forward-software/react-auth lint to check for linting errors.

Checklist

  • My code follows the project's style guidelines
  • I have added or updated tests to cover the changes
  • I have updated relevant documentation
  • All tests are passing locally
  • CI checks are passing
  • I have reviewed my own code and lock file changes
  • I have checked for any potential security implications
  • I have verified the changes work as expected
  • My commit messages follow Conventional Commits format

Notes for Reviewers

No behavioural change — this is a pure signature correction in test utilities. The actual onRefresh call in AuthClientEnhancements already passes this.tokens as the first argument (auth.tsx:385); the mocks were just misrepresenting the contract.

…ude currentTokens parameter

Agent-Logs-Url: https://github.com/forwardsoftware/react-auth/sessions/b6f55c79-068c-4a40-8450-f5518adede3f

Co-authored-by: panz3r <1754457+panz3r@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix onRefresh signature in lib test-utils to include currentTokens parameter fix: correct onRefresh signature in MockAuthClient test-utils Apr 4, 2026
Copilot AI requested a review from panz3r April 4, 2026 15:43
@panz3r panz3r requested a review from Copilot April 4, 2026 17:08
@panz3r panz3r changed the title fix: correct onRefresh signature in MockAuthClient test-utils test(react-auth): correct onRefresh signature in MockAuthClient test-utils Apr 4, 2026
@panz3r panz3r changed the title test(react-auth): correct onRefresh signature in MockAuthClient test-utils test: correct onRefresh signature in MockAuthClient test-utils Apr 4, 2026
@panz3r panz3r added the bug Something isn't working label Apr 4, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Aligns the MockAuthClient / MockAuthClientWithHooks test utilities with the real AuthClient contract so the mocks accurately reflect how wrapAuthClient invokes onRefresh.

Changes:

  • Corrected MockAuthClient.onRefresh to accept (currentTokens, minValidity?).
  • Applied the same onRefresh signature correction to MockAuthClientWithHooks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@panz3r panz3r marked this pull request as ready for review April 4, 2026 17:12
@panz3r panz3r merged commit 22e35bf into main Apr 4, 2026
20 checks passed
@panz3r panz3r deleted the copilot/fix-onrefresh-signature branch April 4, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: onRefresh signature in lib test-utils omits required currentTokens parameter

3 participants