mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix SRP paste duplication (#14625)
* Fix SRP paste duplication * Remove else-case for paste event * Add E2E test that would catch this issue in the future * Fix linting
This commit is contained in:
parent
07da8ce589
commit
fa9d703aa0
@ -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 = {
|
module.exports = {
|
||||||
getWindowHandles,
|
getWindowHandles,
|
||||||
convertToHexValue,
|
convertToHexValue,
|
||||||
@ -270,4 +311,5 @@ module.exports = {
|
|||||||
withFixtures,
|
withFixtures,
|
||||||
connectDappWithExtensionPopup,
|
connectDappWithExtensionPopup,
|
||||||
completeImportSRPOnboardingFlow,
|
completeImportSRPOnboardingFlow,
|
||||||
|
completeImportSRPOnboardingFlowWordByWord,
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@ const {
|
|||||||
regularDelayMs,
|
regularDelayMs,
|
||||||
largeDelayMs,
|
largeDelayMs,
|
||||||
completeImportSRPOnboardingFlow,
|
completeImportSRPOnboardingFlow,
|
||||||
|
completeImportSRPOnboardingFlowWordByWord,
|
||||||
} = require('../helpers');
|
} = require('../helpers');
|
||||||
|
|
||||||
describe('Metamask Import UI', function () {
|
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 () {
|
it('Import Account using private key', async function () {
|
||||||
const ganacheOptions = {
|
const ganacheOptions = {
|
||||||
accounts: [
|
accounts: [
|
||||||
|
@ -179,8 +179,6 @@ export default function SrpInput({ onChange, srpText }) {
|
|||||||
if (newSrp.trim().match(/\s/u)) {
|
if (newSrp.trim().match(/\s/u)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
onSrpPaste(newSrp);
|
onSrpPaste(newSrp);
|
||||||
} else {
|
|
||||||
onSrpWordChange(index, newSrp);
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user