1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Onboarding v2 e2e test (#12628)

* add data-testid's

* import wallet test

* create wallet test

* fix lint issues
This commit is contained in:
PeterYinusa 2021-11-10 17:27:10 +00:00 committed by GitHub
parent ab2aca2c08
commit dc19e1d5f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 245 additions and 94 deletions

View File

@ -27,38 +27,72 @@ describe('Metamask Import UI', function () {
async ({ driver }) => { async ({ driver }) => {
await driver.navigate(); await driver.navigate();
// clicks the continue button on the welcome screen if (process.env.ONBOARDING_V2 === '1') {
await driver.findElement('.welcome-page__header'); // welcome
await driver.clickElement({ await driver.clickElement('[data-testid="onboarding-import-wallet"]');
text: enLocaleMessages.getStarted.message,
tag: 'button',
});
// clicks the "Import Wallet" option // metrics
await driver.clickElement({ text: 'Import wallet', tag: 'button' }); await driver.clickElement('[data-testid="metametrics-no-thanks"]');
// clicks the "No thanks" option on the metametrics opt-in screen // import with recovery phrase
await driver.clickElement('.btn-secondary'); await driver.fill('[data-testid="import-srp-text"]', testSeedPhrase);
await driver.clickElement('[data-testid="import-srp-confirm"]');
// Import Secret Recovery Phrase // create password
await driver.fill( await driver.fill(
'input[placeholder="Paste Secret Recovery Phrase from clipboard"]', '[data-testid="create-password-new"]',
testSeedPhrase, 'correct horse battery staple',
); );
await driver.fill(
'[data-testid="create-password-confirm"]',
'correct horse battery staple',
);
await driver.clickElement('[data-testid="create-password-terms"]');
await driver.clickElement('[data-testid="create-password-import"]');
await driver.fill('#password', 'correct horse battery staple'); // complete
await driver.fill('#confirm-password', 'correct horse battery staple'); await driver.clickElement('[data-testid="onboarding-complete-done"]');
await driver.clickElement('.first-time-flow__terms'); // pin extension
await driver.clickElement('[data-testid="pin-extension-next"]');
await driver.clickElement('[data-testid="pin-extension-done"]');
} else {
// clicks the continue button on the welcome screen
await driver.findElement('.welcome-page__header');
await driver.clickElement({
text: enLocaleMessages.getStarted.message,
tag: 'button',
});
await driver.clickElement({ text: 'Import', tag: 'button' }); // clicks the "Import Wallet" option
await driver.clickElement({ text: 'Import wallet', tag: 'button' });
// clicks through the success screen // clicks the "No thanks" option on the metametrics opt-in screen
await driver.findElement({ text: 'Congratulations', tag: 'div' }); await driver.clickElement('.btn-secondary');
await driver.clickElement({
text: enLocaleMessages.endOfFlowMessage10.message, // Import Secret Recovery Phrase
tag: 'button', await driver.fill(
}); 'input[placeholder="Paste Secret Recovery Phrase from clipboard"]',
testSeedPhrase,
);
await driver.fill('#password', 'correct horse battery staple');
await driver.fill(
'#confirm-password',
'correct horse battery staple',
);
await driver.clickElement('.first-time-flow__terms');
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',
});
}
// Show account information // Show account information
await driver.clickElement( await driver.clickElement(

View File

@ -16,50 +16,6 @@ describe('Metamask Responsive UI', function () {
async ({ driver }) => { async ({ driver }) => {
await driver.navigate(); await driver.navigate();
// clicks the continue button on the welcome screen
await driver.findElement('.welcome-page__header');
await driver.clickElement({
text: enLocaleMessages.getStarted.message,
tag: 'button',
});
await driver.delay(tinyDelayMs);
// clicks the "Create New Wallet" option
await driver.clickElement({ text: 'Create a Wallet', tag: 'button' });
// clicks the "I Agree" option on the metametrics opt-in screen
await driver.clickElement('.btn-primary');
// accepts a secure password
await driver.fill(
'.first-time-flow__form #create-password',
'correct horse battery staple',
);
await driver.fill(
'.first-time-flow__form #confirm-password',
'correct horse battery staple',
);
await driver.clickElement('.first-time-flow__checkbox');
await driver.clickElement('.first-time-flow__form button');
// renders the Secret Recovery Phrase intro screen
await driver.clickElement('.seed-phrase-intro__left button');
// reveals the Secret Recovery Phrase
await driver.clickElement(
'.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button',
);
const revealedSeedPhrase = await driver.findElement(
'.reveal-seed-phrase__secret-words',
);
const seedPhrase = await revealedSeedPhrase.getText();
assert.equal(seedPhrase.split(' ').length, 12);
await driver.clickElement({
text: enLocaleMessages.next.message,
tag: 'button',
});
async function clickWordAndWait(word) { async function clickWordAndWait(word) {
await driver.clickElement( await driver.clickElement(
`[data-testid="seed-phrase-sorted"] [data-testid="draggable-seed-${word}"]`, `[data-testid="seed-phrase-sorted"] [data-testid="draggable-seed-${word}"]`,
@ -67,26 +23,126 @@ describe('Metamask Responsive UI', function () {
await driver.delay(tinyDelayMs); await driver.delay(tinyDelayMs);
} }
// can retype the Secret Recovery Phrase if (process.env.ONBOARDING_V2 === '1') {
const words = seedPhrase.split(' '); // welcome
for (const word of words) { await driver.clickElement('[data-testid="onboarding-create-wallet"]');
await clickWordAndWait(word);
// metrics
await driver.clickElement('[data-testid="metametrics-no-thanks"]');
// create password
await driver.fill(
'[data-testid="create-password-new"]',
'correct horse battery staple',
);
await driver.fill(
'[data-testid="create-password-confirm"]',
'correct horse battery staple',
);
await driver.clickElement('[data-testid="create-password-terms"]');
await driver.clickElement('[data-testid="create-password-wallet"]');
// secure wallet
await driver.clickElement(
'[data-testid="secure-wallet-recommended"]',
);
// review
await driver.clickElement('[data-testid="recovery-phrase-reveal"]');
const chipTwo = await (
await driver.findElement('[data-testid="recovery-phrase-chip-2"]')
).getText();
const chipThree = await (
await driver.findElement('[data-testid="recovery-phrase-chip-3"]')
).getText();
const chipSeven = await (
await driver.findElement('[data-testid="recovery-phrase-chip-7"]')
).getText();
await driver.clickElement('[data-testid="recovery-phrase-next"]');
// confirm
await driver.fill('[data-testid="recovery-phrase-input-2"]', chipTwo);
await driver.fill(
'[data-testid="recovery-phrase-input-3"]',
chipThree,
);
await driver.fill(
'[data-testid="recovery-phrase-input-7"]',
chipSeven,
);
await driver.clickElement('[data-testid="recovery-phrase-confirm"]');
// complete
await driver.clickElement('[data-testid="onboarding-complete-done"]');
// pin extension
await driver.clickElement('[data-testid="pin-extension-next"]');
await driver.clickElement('[data-testid="pin-extension-done"]');
} else {
// clicks the continue button on the welcome screen
await driver.findElement('.welcome-page__header');
await driver.clickElement({
text: enLocaleMessages.getStarted.message,
tag: 'button',
});
await driver.delay(tinyDelayMs);
// clicks the "Create New Wallet" option
await driver.clickElement({ text: 'Create a Wallet', tag: 'button' });
// clicks the "I Agree" option on the metametrics opt-in screen
await driver.clickElement('.btn-primary');
// accepts a secure password
await driver.fill(
'.first-time-flow__form #create-password',
'correct horse battery staple',
);
await driver.fill(
'.first-time-flow__form #confirm-password',
'correct horse battery staple',
);
await driver.clickElement('.first-time-flow__checkbox');
await driver.clickElement('.first-time-flow__form button');
// renders the Secret Recovery Phrase intro screen
await driver.clickElement('.seed-phrase-intro__left button');
// reveals the Secret Recovery Phrase
await driver.clickElement(
'.reveal-seed-phrase__secret-blocker .reveal-seed-phrase__reveal-button',
);
const revealedSeedPhrase = await driver.findElement(
'.reveal-seed-phrase__secret-words',
);
const seedPhrase = await revealedSeedPhrase.getText();
assert.equal(seedPhrase.split(' ').length, 12);
await driver.clickElement({
text: enLocaleMessages.next.message,
tag: 'button',
});
// can retype the Secret Recovery Phrase
const words = seedPhrase.split(' ');
for (const word of words) {
await clickWordAndWait(word);
}
await driver.clickElement({ text: 'Confirm', tag: 'button' });
// clicks through the success screen
await driver.findElement({ text: 'Congratulations', tag: 'div' });
await driver.clickElement({
text: enLocaleMessages.endOfFlowMessage10.message,
tag: 'button',
});
} }
await driver.clickElement({ text: 'Confirm', tag: 'button' });
// clicks through the success screen // assert balance
await driver.findElement({ text: 'Congratulations', tag: 'div' }); const balance = await driver.findElement(
await driver.clickElement({ '[data-testid="wallet-balance"]',
text: enLocaleMessages.endOfFlowMessage10.message, );
tag: 'button', assert.ok(/^0\sETH$/u.test(await balance.getText()));
});
// Show account information
// balance renders
await driver.waitForSelector({
css: '[data-testid="eth-overview__primary-currency"]',
text: '0 ETH',
});
}, },
); );
}); });

View File

@ -5,6 +5,7 @@ import { COLORS } from '../../../helpers/constants/design-system';
import Chip from '.'; import Chip from '.';
export function ChipWithInput({ export function ChipWithInput({
dataTestId,
className, className,
borderColor = COLORS.UI1, borderColor = COLORS.UI1,
inputValue, inputValue,
@ -17,6 +18,7 @@ export function ChipWithInput({
> >
{setInputValue && ( {setInputValue && (
<input <input
data-testid={dataTestId}
type="text" type="text"
className="chip__input" className="chip__input"
onChange={(e) => { onChange={(e) => {
@ -30,6 +32,7 @@ export function ChipWithInput({
} }
ChipWithInput.propTypes = { ChipWithInput.propTypes = {
dataTestId: PropTypes.string,
borderColor: PropTypes.oneOf(Object.values(COLORS)), borderColor: PropTypes.oneOf(Object.values(COLORS)),
className: PropTypes.string, className: PropTypes.string,
inputValue: PropTypes.string, inputValue: PropTypes.string,

View File

@ -6,6 +6,7 @@ import Typography from '../typography';
import { COLORS, TYPOGRAPHY } from '../../../helpers/constants/design-system'; import { COLORS, TYPOGRAPHY } from '../../../helpers/constants/design-system';
export default function Chip({ export default function Chip({
dataTestId,
className, className,
children, children,
borderColor = COLORS.UI1, borderColor = COLORS.UI1,
@ -25,6 +26,7 @@ export default function Chip({
return ( return (
<div <div
data-testid={dataTestId}
onClick={onClick} onClick={onClick}
onKeyPress={onKeyPress} onKeyPress={onKeyPress}
className={classnames(className, 'chip', { className={classnames(className, 'chip', {
@ -53,6 +55,7 @@ export default function Chip({
} }
Chip.propTypes = { Chip.propTypes = {
dataTestId: PropTypes.string,
borderColor: PropTypes.oneOf(Object.values(COLORS)), borderColor: PropTypes.oneOf(Object.values(COLORS)),
label: PropTypes.string, label: PropTypes.string,
children: PropTypes.node, children: PropTypes.node,

View File

@ -16,6 +16,7 @@ import NumericInput from '../numeric-input/numeric-input.component';
import InfoTooltip from '../info-tooltip/info-tooltip'; import InfoTooltip from '../info-tooltip/info-tooltip';
export default function FormField({ export default function FormField({
dataTestId,
titleText, titleText,
titleUnit, titleUnit,
tooltipText, tooltipText,
@ -94,6 +95,7 @@ export default function FormField({
type={password ? 'password' : 'text'} type={password ? 'password' : 'text'}
autoFocus={autoFocus} autoFocus={autoFocus}
disabled={disabled} disabled={disabled}
data-testid={dataTestId}
/> />
)} )}
{error && ( {error && (
@ -111,6 +113,7 @@ export default function FormField({
} }
FormField.propTypes = { FormField.propTypes = {
dataTestId: PropTypes.string,
titleText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), titleText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
titleUnit: PropTypes.string, titleUnit: PropTypes.string,
tooltipText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), tooltipText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),

View File

@ -131,6 +131,7 @@ export default function CreatePassword({
> >
<form className="create-password__form" onSubmit={handleCreate}> <form className="create-password__form" onSubmit={handleCreate}>
<FormField <FormField
dataTestId="create-password-new"
autoFocus autoFocus
error={passwordError} error={passwordError}
onChange={handlePasswordChange} onChange={handlePasswordChange}
@ -151,6 +152,7 @@ export default function CreatePassword({
} }
/> />
<FormField <FormField
dataTestId="create-password-confirm"
onChange={handleConfirmPasswordChange} onChange={handleConfirmPasswordChange}
password={!showPassword} password={!showPassword}
error={confirmPasswordError} error={confirmPasswordError}
@ -170,6 +172,7 @@ export default function CreatePassword({
marginBottom={4} marginBottom={4}
> >
<CheckBox <CheckBox
dataTestId="create-password-terms"
onClick={() => setTermsChecked(!termsChecked)} onClick={() => setTermsChecked(!termsChecked)}
checked={termsChecked} checked={termsChecked}
/> />
@ -190,6 +193,11 @@ export default function CreatePassword({
</Typography> </Typography>
</Box> </Box>
<Button <Button
data-testid={
secretRecoveryPhrase
? 'create-password-import'
: 'create-password-wallet'
}
type="primary" type="primary"
className="create-password__form--submit-button" className="create-password__form--submit-button"
disabled={!isValid || !termsChecked} disabled={!isValid || !termsChecked}

View File

@ -96,7 +96,13 @@ export default function CreationSuccessful() {
> >
{t('setAdvancedPrivacySettings')} {t('setAdvancedPrivacySettings')}
</Button> </Button>
<Button type="primary" large rounded onClick={onComplete}> <Button
data-testid="onboarding-complete-done"
type="primary"
large
rounded
onClick={onComplete}
>
{t('done')} {t('done')}
</Button> </Button>
</Box> </Box>

View File

@ -78,6 +78,7 @@ export default function ImportSRP({ submitSecretRecoveryPhrase }) {
/> />
</button> </button>
<textarea <textarea
data-testid="import-srp-text"
className={classnames('srp-text-area__textarea', { className={classnames('srp-text-area__textarea', {
'srp-text-area__textarea--blur': !revealSRP, 'srp-text-area__textarea--blur': !revealSRP,
'srp-text-area__textarea--error': error, 'srp-text-area__textarea--error': error,
@ -96,6 +97,7 @@ export default function ImportSRP({ submitSecretRecoveryPhrase }) {
</div> </div>
<Button <Button
type="primary" type="primary"
data-testid="import-srp-confirm"
large large
onClick={() => { onClick={() => {
submitSecretRecoveryPhrase(secretRecoveryPhrase); submitSecretRecoveryPhrase(secretRecoveryPhrase);

View File

@ -140,10 +140,18 @@ export default function OnboardingMetametrics() {
])} ])}
</Typography> </Typography>
<div className="onboarding-metametrics__buttons"> <div className="onboarding-metametrics__buttons">
<Button type="secondary" onClick={onCancel}> <Button
data-testid="metametrics-no-thanks"
type="secondary"
onClick={onCancel}
>
{t('noThanks')} {t('noThanks')}
</Button> </Button>
<Button type="primary" onClick={onConfirm}> <Button
data-testid="metametrics-i-agree"
type="primary"
onClick={onConfirm}
>
{t('affirmAgree')} {t('affirmAgree')}
</Button> </Button>
</div> </div>

View File

@ -58,6 +58,9 @@ export default function OnboardingPinExtension() {
</Carousel> </Carousel>
<div className="onboarding-pin-extension__buttons"> <div className="onboarding-pin-extension__buttons">
<Button <Button
data-testid={
selectedIndex === 0 ? 'pin-extension-next' : 'pin-extension-done'
}
type="primary" type="primary"
onClick={() => { onClick={() => {
if (selectedIndex === 0) { if (selectedIndex === 0) {

View File

@ -83,6 +83,7 @@ export default function ConfirmRecoveryPhrase({ secretRecoveryPhrase = '' }) {
/> />
<div className="recovery-phrase__footer"> <div className="recovery-phrase__footer">
<Button <Button
data-testid="recovery-phrase-confirm"
type="primary" type="primary"
className="recovery-phrase__footer--button" className="recovery-phrase__footer--button"
onClick={() => { onClick={() => {

View File

@ -36,6 +36,7 @@ export default function RecoveryPhraseChips({
className="recovery-phrase__secret" className="recovery-phrase__secret"
> >
<div <div
data-testid="recovery-phrase-chips"
className={classnames('recovery-phrase__chips', { className={classnames('recovery-phrase__chips', {
'recovery-phrase__chips--hidden': hideSeedPhrase, 'recovery-phrase__chips--hidden': hideSeedPhrase,
})} })}
@ -52,6 +53,7 @@ export default function RecoveryPhraseChips({
{`${index + 1}.`} {`${index + 1}.`}
</div> </div>
<ChipWithInput <ChipWithInput
dataTestId={`recovery-phrase-input-${index}`}
borderColor={COLORS.PRIMARY1} borderColor={COLORS.PRIMARY1}
className="recovery-phrase__chip--with-input" className="recovery-phrase__chip--with-input"
inputValue={inputValue[index]} inputValue={inputValue[index]}
@ -67,7 +69,11 @@ export default function RecoveryPhraseChips({
<div className="recovery-phrase__chip-item__number"> <div className="recovery-phrase__chip-item__number">
{`${index + 1}.`} {`${index + 1}.`}
</div> </div>
<Chip className="recovery-phrase__chip" borderColor={COLORS.UI3}> <Chip
dataTestId={`recovery-phrase-chip-${index}`}
className="recovery-phrase__chip"
borderColor={COLORS.UI3}
>
{word} {word}
</Chip> </Chip>
</div> </div>

View File

@ -96,6 +96,7 @@ export default function RecoveryPhrase({ secretRecoveryPhrase }) {
{copied ? t('copiedExclamation') : t('copyToClipboard')} {copied ? t('copiedExclamation') : t('copyToClipboard')}
</Button> </Button>
<Button <Button
data-testid="recovery-phrase-next"
type="primary" type="primary"
className="recovery-phrase__footer--button" className="recovery-phrase__footer--button"
onClick={() => { onClick={() => {
@ -107,6 +108,7 @@ export default function RecoveryPhrase({ secretRecoveryPhrase }) {
</div> </div>
) : ( ) : (
<Button <Button
data-testid="recovery-phrase-reveal"
type="primary" type="primary"
className="recovery-phrase__footer--button" className="recovery-phrase__footer--button"
onClick={() => { onClick={() => {

View File

@ -103,6 +103,7 @@ export default function SecureYourWallet() {
className="secure-your-wallet__actions" className="secure-your-wallet__actions"
> >
<Button <Button
data-testid="secure-wallet-later"
type="secondary" type="secondary"
rounded rounded
large large
@ -110,7 +111,13 @@ export default function SecureYourWallet() {
> >
{t('seedPhraseIntroNotRecommendedButtonCopy')} {t('seedPhraseIntroNotRecommendedButtonCopy')}
</Button> </Button>
<Button type="primary" rounded large onClick={handleClickRecommended}> <Button
data-testid="secure-wallet-recommended"
type="primary"
rounded
large
onClick={handleClickRecommended}
>
{t('seedPhraseIntroRecommendedButtonCopy')} {t('seedPhraseIntroRecommendedButtonCopy')}
</Button> </Button>
</Box> </Box>

View File

@ -33,6 +33,7 @@ export default function SkipSRPBackup({ handleClose }) {
{t('goBack')} {t('goBack')}
</Button> </Button>
<Button <Button
data-testid="skip-srp-backup"
disabled={!checked} disabled={!checked}
type="primary" type="primary"
rounded rounded

View File

@ -96,12 +96,20 @@ export default function OnboardingWelcome() {
</Carousel> </Carousel>
<ul className="onboarding-welcome__buttons"> <ul className="onboarding-welcome__buttons">
<li> <li>
<Button type="primary" onClick={onCreateClick}> <Button
data-testid="onboarding-create-wallet"
type="primary"
onClick={onCreateClick}
>
{t('onboardingCreateWallet')} {t('onboardingCreateWallet')}
</Button> </Button>
</li> </li>
<li> <li>
<Button type="secondary" onClick={onImportClick}> <Button
data-testid="onboarding-import-wallet"
type="secondary"
onClick={onImportClick}
>
{t('onboardingImportWallet')} {t('onboardingImportWallet')}
</Button> </Button>
</li> </li>