test(WalletConnectButton): add tests for all three render states and click handlers (#600) - #634
Merged
k-deejah merged 2 commits intoAug 29, 2026
Conversation
|
@jotel-dev 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! 🚀 |
…ton-all-three-render-states
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.
Description
Overview
This pull request adds complete, end-to-end unit test coverage for the
WalletConnectButtoncomponent (src/components/WalletConnectButton.tsx) using React Testing Library and Vitest.Previously,
WalletConnectButtonhad gaps in test coverage across its three distinct lifecycle render states:isConnected: false, isConnecting: false)isConnecting: true)isConnected: true, address: "...")Motivation & Problem Solved
SorokitProviderstate transitions.truncateAddress()fromsrc/lib/utils.ts.onOpenModalProp Handler & Fallback Behavior: Provide test verification for the click handler on the connected address pill. WhenonOpenModalis provided (e.g., wired viaTopBarto trigger theAccountSidebar), the callback fires as expected. WhenonOpenModalis omitted (undefined), the component gracefully toggles the internal disconnect dropdown without throwing runtime errors or crashing.isConnectingis active, the button renders the "Connecting…" label, setsaria-busy="true", disables interaction, and displays the.animate-spinloading spinner alongside the screen-reader accessible"Loading"text.clearError(), handleisDisconnectingloading spinners, and ensure stale error banners reset upon successful reconnection.Key Changes Implemented
src/components/WalletConnectButton.test.tsx:Disconnected StateSuite:renders 'Connect Wallet' text when not connected: Confirms both role query and text rendering.opens the wallet connect modal on click: Tests interaction with the button to ensureWalletConnectModalopens.triggers connectWallet from context when a wallet is selected in the modal: End-to-end verification that choosing a wallet option (e.g. Freighter) triggersconnectWallet()from context.Connecting StateSuite:renders button text showing 'Connecting…' when connecting: Confirms button label changes whenisConnecting: true.renders loading indicator and spinner while isConnecting is true: Checksaria-busy="true",disabledstate, screen-reader"Loading"text, and.animate-spinspinner element.Connected StateSuite:renders truncated wallet address in the pill using truncateAddress(): Validates that the rendered text matchestruncateAddress(fullAddress)("GABC12...WXYZ") within the[data-address]container.renders connected state with correct aria-label and green indicator dot: Confirms the.bg-greenindicator dot and accessiblearia-label="Wallet connected: <address>. Click to manage.".calls onOpenModal when address pill is clicked and the prop is provided: Validates theonOpenModalcallback execution upon pill click.does not crash and toggles dropdown when address pill is clicked without onOpenModal: Confirms safe fallback behavior and dropdown toggle with the Disconnect action.Error & Disconnect HandlingSuite:renders inline error message and handles clearError: Tests inline error display and dismiss button.renders disconnect loading state when isDisconnecting is true: Validates "Disconnecting…" copy and button disabled state.clears the error banner after a successful connect clears the error: Validates re-render behavior when state transitions from error to connected.Related Issues
Closes #600
Type of Change
Testing
Automated Test Execution
src/components/WalletConnectButton.test.tsx: