Skip to content

test(provider): assert disconnect error is visible after isDisconnect… - #1033

Open
extolkom wants to merge 1 commit into
Sorokit:mainfrom
extolkom:test/sorokit-disconnect-error-852
Open

extolkom wants to merge 1 commit into
Sorokit:mainfrom
extolkom:test/sorokit-disconnect-error-852

Conversation

@extolkom

Copy link
Copy Markdown
Contributor

Description

closes #852

Adds a focused regression test to SorokitProvider.test.tsx verifying that when a wallet adapter's disconnect() throws an error, the failure message remains visible in context.error and walletError after isDisconnecting resets back to false. Also fixes an unclosed afterEach block in the test file that was introduced in a recent upstream merge.

Problem

In SorokitProvider.tsx's disconnectWallet(), session state is cleared before reportError() is called, and isDisconnecting is flipped to false in finally. Without explicit test coverage, a race condition could occur where a consumer's cleanup triggered by isDisconnecting === false wipes or clears the error before it can be read.

What the Test Covers

  • Simulates a throwing disconnect() wallet adapter rejecting with a known Error.
  • Calls disconnectWallet().
  • Asserts isDisconnecting is false.
  • Asserts context.error is non-null and matches the exception message.
  • Asserts walletError contains the exception message.

Acceptance Criteria Mapping

  • Regression test: throwing disconnect() → isDisconnecting false → context.error is non-null:
    Satisfied by expect(screen.getByTestId("isDisconnecting")).toHaveTextContent("false") and expect(screen.getByTestId("error")).toHaveTextContent(disconnectErrorMessage) / .not.toHaveTextContent("none").
  • Error string from the exception is in walletError:
    Satisfied by expect(screen.getByTestId("walletError")).toHaveTextContent(disconnectErrorMessage).
  • isDisconnecting is false after failure:
    Satisfied by expect(screen.getByTestId("isDisconnecting")).toHaveTextContent("false").

How to Verify

npm test -- SorokitProvider.test.tsx

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SorokitProvider — disconnect error may be cleared before it can be displayed to the user

1 participant