From 5e674f80be977f65a4c43b19193f25474d7d4db5 Mon Sep 17 00:00:00 2001 From: Daniel Izdebski Date: Thu, 14 Dec 2023 21:34:28 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(metamask):=20Check=20if=20onbo?= =?UTF-8?q?arding=20process=20is=20completed=20(#1041)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OnboardingPage/actions/importWallet.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) 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') + ) + ) }