diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index a6f7b3c7b..8e13c4c6c 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -260,6 +260,47 @@ const completeImportSRPOnboardingFlow = async ( } }; +const completeImportSRPOnboardingFlowWordByWord = async ( + driver, + seedPhrase, + password, +) => { + // clicks the continue button on the welcome screen + await driver.findElement('.welcome-page__header'); + await driver.clickElement({ + text: enLocaleMessages.getStarted.message, + tag: 'button', + }); + + // clicks the "Import Wallet" option + await driver.clickElement({ text: 'Import wallet', tag: 'button' }); + + // clicks the "No thanks" option on the metametrics opt-in screen + await driver.clickElement('.btn-secondary'); + + const words = seedPhrase.split(' '); + for (const word of words) { + await driver.pasteIntoField( + `[data-testid="import-srp__srp-word-${words.indexOf(word)}"]`, + word, + ); + } + + await driver.fill('#password', password); + await driver.fill('#confirm-password', password); + + await driver.clickElement('[data-testid="create-new-vault__terms-checkbox"]'); + + await driver.clickElement({ text: 'Import', tag: 'button' }); + + // clicks through the success screen + await driver.findElement({ text: 'Congratulations', tag: 'div' }); + await driver.clickElement({ + text: enLocaleMessages.endOfFlowMessage10.message, + tag: 'button', + }); +}; + module.exports = { getWindowHandles, convertToHexValue, @@ -270,4 +311,5 @@ module.exports = { withFixtures, connectDappWithExtensionPopup, completeImportSRPOnboardingFlow, + completeImportSRPOnboardingFlowWordByWord, }; diff --git a/test/e2e/tests/from-import-ui.spec.js b/test/e2e/tests/from-import-ui.spec.js index dc31d1551..6bc41b1fa 100644 --- a/test/e2e/tests/from-import-ui.spec.js +++ b/test/e2e/tests/from-import-ui.spec.js @@ -6,6 +6,7 @@ const { regularDelayMs, largeDelayMs, completeImportSRPOnboardingFlow, + completeImportSRPOnboardingFlowWordByWord, } = require('../helpers'); describe('Metamask Import UI', function () { @@ -126,6 +127,53 @@ describe('Metamask Import UI', function () { ); }); + it('Importing wallet using Secret Recovery Phrase with pasting word by word', async function () { + const ganacheOptions = { + accounts: [ + { + secretKey: + '0x53CB0AB5226EEBF4D872113D98332C1555DC304443BEE1CF759D15798D3C55A9', + balance: convertToHexValue(25000000000000000000), + }, + ], + }; + const testSeedPhrase = + 'forum vessel pink push lonely enact gentle tail admit parrot grunt dress'; + const testPassword = 'correct horse battery staple'; + const testAddress = '0x0Cc5261AB8cE458dc977078A3623E2BaDD27afD3'; + + await withFixtures( + { + fixtures: 'onboarding', + ganacheOptions, + title: this.test.title, + failOnConsoleError: false, + }, + async ({ driver }) => { + await driver.navigate(); + + await completeImportSRPOnboardingFlowWordByWord( + driver, + testSeedPhrase, + testPassword, + ); + + // Show account information + await driver.clickElement( + '[data-testid="account-options-menu-button"]', + ); + await driver.clickElement( + '[data-testid="account-options-menu__account-details"]', + ); + await driver.findVisibleElement('.qr-code__wrapper'); + // shows the correct account address + const address = await driver.findElement('.qr-code__address'); + + assert.equal(await address.getText(), testAddress); + }, + ); + }); + it('Import Account using private key', async function () { const ganacheOptions = { accounts: [ diff --git a/ui/components/app/srp-input/srp-input.js b/ui/components/app/srp-input/srp-input.js index 0b114d63c..c2f3b1bd0 100644 --- a/ui/components/app/srp-input/srp-input.js +++ b/ui/components/app/srp-input/srp-input.js @@ -179,8 +179,6 @@ export default function SrpInput({ onChange, srpText }) { if (newSrp.trim().match(/\s/u)) { event.preventDefault(); onSrpPaste(newSrp); - } else { - onSrpWordChange(index, newSrp); } }} />