-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: only show browser tab option for browser wallets (#3491)
Co-authored-by: tomiir <rocchitomas@gmail.com>
- Loading branch information
Showing
4 changed files
with
120 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
'@reown/appkit-scaffold-ui': patch | ||
'@reown/appkit-adapter-ethers': patch | ||
'@reown/appkit-adapter-ethers5': patch | ||
'@reown/appkit-adapter-solana': patch | ||
'@reown/appkit-adapter-wagmi': patch | ||
'@reown/appkit': patch | ||
'@reown/appkit-utils': patch | ||
'@reown/appkit-cdn': patch | ||
'@reown/appkit-cli': patch | ||
'@reown/appkit-common': patch | ||
'@reown/appkit-core': patch | ||
'@reown/appkit-experimental': patch | ||
'@reown/appkit-polyfills': patch | ||
'@reown/appkit-siwe': patch | ||
'@reown/appkit-siwx': patch | ||
'@reown/appkit-ui': patch | ||
'@reown/appkit-wallet': patch | ||
'@reown/appkit-wallet-button': patch | ||
--- | ||
|
||
Fixed an issue where browser tab option was showing for all wallets |
This file contains 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
This file contains 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
93 changes: 93 additions & 0 deletions
93
packages/scaffold-ui/test/views/w3m-connecting-wc-view.test.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { describe, expect, vi, test } from 'vitest' | ||
import { CoreHelperUtil, RouterController } from '@reown/appkit-core' | ||
import type { W3mConnectingWcView } from '../../exports' | ||
import { fixture } from '@open-wc/testing' | ||
import { html } from 'lit' | ||
import type { WcWallet } from '@reown/appkit-core' | ||
import { HelpersUtil } from '../utils/HelpersUtil' | ||
import type { WuiTabs } from '@reown/appkit-ui' | ||
|
||
// --- Constants ---------------------------------------------------- // | ||
|
||
const WALLET = { | ||
id: 'metamask', | ||
name: 'MetaMask' | ||
} as WcWallet | ||
|
||
describe('W3mConnectingWcView - Render', () => { | ||
test('should render walletConnect widget if no wallet is given', async () => { | ||
const element: W3mConnectingWcView = await fixture( | ||
html`<w3m-connecting-wc-view></w3m-connecting-wc-view>` | ||
) | ||
|
||
expect(HelpersUtil.querySelect(element, 'w3m-connecting-wc-qrcode')).not.toBeNull() | ||
}) | ||
|
||
test('should render web and browser platforms', async () => { | ||
vi.spyOn(CoreHelperUtil, 'isMobile').mockReturnValue(false) | ||
|
||
vi.spyOn(RouterController, 'state', 'get').mockReturnValue({ | ||
...RouterController.state, | ||
data: { | ||
wallet: { | ||
...WALLET, | ||
rdns: 'metamask.io', | ||
webapp_link: 'https://metamask.io' | ||
} | ||
} | ||
}) | ||
|
||
const element: W3mConnectingWcView = await fixture( | ||
html`<w3m-connecting-wc-view></w3m-connecting-wc-view>` | ||
) | ||
|
||
const w3mConnectingHeader = HelpersUtil.querySelect(element, 'w3m-connecting-header') | ||
|
||
expect(w3mConnectingHeader).not.toBeNull() | ||
|
||
const wuiTabs = HelpersUtil.querySelect(w3mConnectingHeader, 'wui-tabs') as WuiTabs | ||
|
||
expect(wuiTabs).not.toBeNull() | ||
|
||
const tabsProperty = wuiTabs.tabs | ||
|
||
expect(tabsProperty).toStrictEqual([ | ||
{ label: 'Webapp', icon: 'browser', platform: 'web' }, | ||
{ label: 'Browser', icon: 'extension', platform: 'unsupported' } | ||
]) | ||
}) | ||
|
||
test('should render mobile and browser platforms', async () => { | ||
vi.spyOn(CoreHelperUtil, 'isMobile').mockReturnValue(true) | ||
|
||
vi.spyOn(RouterController, 'state', 'get').mockReturnValue({ | ||
...RouterController.state, | ||
data: { | ||
wallet: { | ||
...WALLET, | ||
webapp_link: 'https://metamask.io', | ||
mobile_link: 'https://metamask.io' | ||
} | ||
} | ||
}) | ||
|
||
const element: W3mConnectingWcView = await fixture( | ||
html`<w3m-connecting-wc-view></w3m-connecting-wc-view>` | ||
) | ||
|
||
const w3mConnectingHeader = HelpersUtil.querySelect(element, 'w3m-connecting-header') | ||
|
||
expect(w3mConnectingHeader).not.toBeNull() | ||
|
||
const wuiTabs = HelpersUtil.querySelect(w3mConnectingHeader, 'wui-tabs') as WuiTabs | ||
|
||
expect(wuiTabs).not.toBeNull() | ||
|
||
const tabsProperty = wuiTabs.tabs | ||
|
||
expect(tabsProperty).toStrictEqual([ | ||
{ label: 'Mobile', icon: 'mobile', platform: 'mobile' }, | ||
{ label: 'Webapp', icon: 'browser', platform: 'web' } | ||
]) | ||
}) | ||
}) |