diff --git a/wallets/metamask/src/pages/OnboardingPage/actions/importWallet.ts b/wallets/metamask/src/pages/OnboardingPage/actions/importWallet.ts index 0894dd86d..7dda51b9f 100644 --- a/wallets/metamask/src/pages/OnboardingPage/actions/importWallet.ts +++ b/wallets/metamask/src/pages/OnboardingPage/actions/importWallet.ts @@ -1,5 +1,7 @@ +import assert from 'node:assert' import type { Page } from '@playwright/test' import { closePopover } from '../../HomePage/actions' +import HomePageSelectors from '../../HomePage/selectors' import Selectors from '../selectors' import { confirmSecretRecoveryPhrase, createPassword } from './helpers' @@ -19,4 +21,23 @@ export async function importWallet(page: Page, seedPhrase: string, password: str await page.locator(Selectors.PinExtensionPageSelectors.confirmButton).click() await closePopover(page) + + await verifyImportedWallet(page) +} + +// Checks if the wallet was imported successfully. +// On rare occasions, the MetaMask hangs during the onboarding process. +async function verifyImportedWallet(page: Page) { + const accountAddress = await page.locator(HomePageSelectors.copyAccountAddressButton).textContent() + + assert.strictEqual( + accountAddress?.startsWith('0x'), + true, + new Error( + [ + `Incorrect state after importing the seed phrase. Account address is expected to start with "0x", but got "${accountAddress}" instead.`, + 'Note: Try to re-run the cache creation. This is a known but rare error where MetaMask hangs during the onboarding process. If it persists, please file an issue on GitHub.' + ].join('\n') + ) + ) }