diff --git a/packages/react/__tests__/modal/modal.test.tsx b/packages/react/__tests__/modal/modal.test.tsx index 9b9d3ed4e..b869e26a8 100644 --- a/packages/react/__tests__/modal/modal.test.tsx +++ b/packages/react/__tests__/modal/modal.test.tsx @@ -81,16 +81,93 @@ describe('WalletModal', () => { expect(screen.getByText('Select your wallet')).toBeInTheDocument(); }); - it('renders QRCodeContent when walletConnectQRCodeUri is provided', () => { + const pairingUri = + 'wc:8a74e2cfb093524dbba0cbdd616909108c6cef30363f560b2853daeadbf345fb@2?relay-protocol=irn&symKey=5ea13e76bd30c736a5c5e33ee58c9f8e314036a0b7390ac18986bc2949d5c340&expiryTimestamp=1743361685'; + const mobileWallet = { + ...mockWalletStore, + info: { + name: 'keplr-mobile', + prettyName: 'Keplr Mobile', + mode: 'wallet-connect' as const, + }, + }; + + it.each(['WalletConnect', 'keplr-mobile', 'leap-mobile'])( + 'renders the pairing QR code for %s', + (name) => { + render( + + ); + expect(screen.getByText('Open App to connect')).toBeInTheDocument(); + expect( + screen.queryByText('Requesting Connection') + ).not.toBeInTheDocument(); + } + ); + + it('keeps the connecting view when no pairing URI is available', () => { + render( + + ); + expect(screen.getByText('Requesting Connection')).toBeInTheDocument(); + expect(screen.queryByText('Open App to connect')).not.toBeInTheDocument(); + }); + + it('does not show a pairing QR code for an extension wallet', () => { render( ); + expect(screen.getByText('Requesting Connection')).toBeInTheDocument(); + expect(screen.queryByText('Open App to connect')).not.toBeInTheDocument(); + }); + + it('prioritizes wallet selection over an available pairing URI', () => { + render( + + ); + expect(screen.getByText('Select your wallet')).toBeInTheDocument(); + expect(screen.queryByText('Open App to connect')).not.toBeInTheDocument(); + }); + + it('updates the pairing view when the wallet mode changes', () => { + const props = { + ...mockProps, + isConnecting: true, + walletConnectQRCodeUri: pairingUri, + }; + const { rerender } = render( + + ); + expect(screen.getByText('Requesting Connection')).toBeInTheDocument(); + rerender(); expect(screen.getByText('Open App to connect')).toBeInTheDocument(); }); diff --git a/packages/react/src/modal/modal.tsx b/packages/react/src/modal/modal.tsx index 85f5fc506..7b3657d0f 100644 --- a/packages/react/src/modal/modal.tsx +++ b/packages/react/src/modal/modal.tsx @@ -224,7 +224,7 @@ export const WalletModalElement = ({ if ( currentWallet && walletConnectQRCodeUri && - currentWallet.info.name === 'WalletConnect' + currentWallet.info.mode === 'wallet-connect' ) { return { header: ( @@ -314,6 +314,7 @@ export const WalletModalElement = ({ }; }, [ currentWallet?.info?.name, + currentWallet?.info?.mode, isConnected, isConnecting, address,