Skip to content

Commit

Permalink
chore: e2e test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
enesozturk committed Feb 20, 2025
1 parent 819a88a commit 7b3a909
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions apps/laboratory/tests/shared/validators/ModalValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ export class ModalValidator {
await expect(title).toBeVisible()
}

async expectSwitchChainWithNetworkButton(chainName: string) {
const switchNetworkViewLocator = this.page.locator('wui-network-button')
await expect(switchNetworkViewLocator).toHaveText(chainName)
}

async expectSwitchedNetworkWithNetworkView() {
const switchNetworkViewLocator = this.page.locator('w3m-network-switch-view')
await expect(switchNetworkViewLocator).toBeVisible()
Expand Down
23 changes: 23 additions & 0 deletions apps/laboratory/tests/wallet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,29 @@ sampleWalletTest(
}
)

sampleWalletTest(
"it should switch to first available network when wallet doesn't support the active network of the appkit",
async ({ library }) => {
if (library === 'solana') {
return
}

await walletPage.disconnectConnection()
await modalValidator.expectDisconnected()

await modalPage.switchNetworkWithNetworkButton('Aurora')
await modalValidator.expectSwitchChainWithNetworkButton('Aurora')
await modalPage.closeModal()

await modalPage.qrCodeFlow(modalPage, walletPage)
await modalValidator.expectConnected()
await modalPage.openModal()
await modalPage.openNetworks()
await modalValidator.expectSwitchedNetwork('Ethereum')
await modalPage.closeModal()
}
)

sampleWalletTest('it should connect and disconnect using hook', async () => {
await walletPage.disconnectConnection()
await modalValidator.expectDisconnected()
Expand Down
2 changes: 1 addition & 1 deletion packages/appkit/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ export class AppKit {
}: Pick<AdapterBlueprint.ConnectResult, 'address' | 'chainId'> & {
chainNamespace: ChainNamespace
}) {
const caipNetworkId = `${chainNamespace}:${chainId}`
const caipNetworkId = `${chainNamespace}:${chainId}` as CaipNetworkId

Check failure on line 1786 in packages/appkit/src/client.ts

View workflow job for this annotation

GitHub Actions / code_style (lint)

This assertion is unnecessary since it does not change the type of the expression
const activeCaipNetwork = this.caipNetworks?.find(n => n.caipNetworkId === caipNetworkId)

if (chainNamespace !== ConstantsUtil.CHAIN.EVM || activeCaipNetwork?.testnet) {
Expand Down

0 comments on commit 7b3a909

Please sign in to comment.