From 4adca3cee34febd4204c37d02af755b4293d8149 Mon Sep 17 00:00:00 2001 From: ibrahimtaveras00 Date: Wed, 4 Sep 2019 13:49:31 -0400 Subject: [PATCH] Detox: Import seed phrase and validate via settings (#1056) * imported seed phrase and validated in settings * renamed other tests back to what it was prior * updated snaps --- app/components/UI/DrawerView/index.js | 6 +- .../__snapshots__/index.test.js.snap | 2 + app/components/Views/ImportFromSeed/index.js | 8 +- app/components/Views/ImportWallet/index.js | 8 +- app/components/Views/Login/index.js | 9 +- .../__snapshots__/index.test.js.snap | 2 + .../Views/RevealPrivateCredential/index.js | 7 +- .../__snapshots__/index.test.js.snap | 3 + .../Views/Settings/SecuritySettings/index.js | 9 +- e2e/helpers.js | 12 +- e2e/import-seed-phrase.spec.js | 107 ++++++++++++++++++ 11 files changed, 157 insertions(+), 16 deletions(-) create mode 100644 e2e/import-seed-phrase.spec.js diff --git a/app/components/UI/DrawerView/index.js b/app/components/UI/DrawerView/index.js index 313e532a12c..a89febcc191 100644 --- a/app/components/UI/DrawerView/index.js +++ b/app/components/UI/DrawerView/index.js @@ -831,7 +831,11 @@ class DrawerView extends PureComponent { - + diff --git a/app/components/Views/ImportFromSeed/__snapshots__/index.test.js.snap b/app/components/Views/ImportFromSeed/__snapshots__/index.test.js.snap index 3e1266aa5e6..df213b4d7fb 100644 --- a/app/components/Views/ImportFromSeed/__snapshots__/index.test.js.snap +++ b/app/components/Views/ImportFromSeed/__snapshots__/index.test.js.snap @@ -174,6 +174,7 @@ exports[`ImportFromSeed should render correctly 1`] = ` "paddingVertical": 10, } } + testID="input-password-field" underlineColorAndroid="#d6d9dc" value="" /> @@ -283,6 +284,7 @@ exports[`ImportFromSeed should render correctly 1`] = ` "paddingVertical": 10, } } + testID="input-password-field-confirm" underlineColorAndroid="#d6d9dc" value="" /> diff --git a/app/components/Views/ImportFromSeed/index.js b/app/components/Views/ImportFromSeed/index.js index 91299e17fdb..d6f3170cb6b 100644 --- a/app/components/Views/ImportFromSeed/index.js +++ b/app/components/Views/ImportFromSeed/index.js @@ -519,6 +519,7 @@ class ImportFromSeed extends PureComponent { {this.state.error}} + {!!this.state.error && ( + + {this.state.error} + + )} + - + {!this.state.loading && ( diff --git a/app/components/Views/Login/index.js b/app/components/Views/Login/index.js index ee295389b56..9f63db84588 100644 --- a/app/components/Views/Login/index.js +++ b/app/components/Views/Login/index.js @@ -301,6 +301,7 @@ class Login extends PureComponent { {strings('login.password')} {this.state.error}} + {!!this.state.error && ( + + {this.state.error} + + )} - + {this.state.loading ? ( diff --git a/app/components/Views/RevealPrivateCredential/__snapshots__/index.test.js.snap b/app/components/Views/RevealPrivateCredential/__snapshots__/index.test.js.snap index 7f9780e931b..a7cd207614e 100644 --- a/app/components/Views/RevealPrivateCredential/__snapshots__/index.test.js.snap +++ b/app/components/Views/RevealPrivateCredential/__snapshots__/index.test.js.snap @@ -21,6 +21,7 @@ exports[`RevealPrivateCredential should render correctly 1`] = ` onConfirmPress={[Function]} showCancelButton={true} showConfirmButton={true} + testID="next-button" > diff --git a/app/components/Views/RevealPrivateCredential/index.js b/app/components/Views/RevealPrivateCredential/index.js index af992e35056..fae3536e705 100644 --- a/app/components/Views/RevealPrivateCredential/index.js +++ b/app/components/Views/RevealPrivateCredential/index.js @@ -267,6 +267,7 @@ class RevealPrivateCredential extends PureComponent { cancelText={strings('reveal_credential.cancel')} confirmText={strings('reveal_credential.confirm')} onCancelPress={this.cancel} + testID={`next-button`} onConfirmPress={this.tryUnlock} showConfirmButton={!unlocked} > @@ -326,13 +327,15 @@ class RevealPrivateCredential extends PureComponent { - {this.state.warningIncorrectPassword} + + {this.state.warningIncorrectPassword} + )} diff --git a/app/components/Views/Settings/SecuritySettings/__snapshots__/index.test.js.snap b/app/components/Views/Settings/SecuritySettings/__snapshots__/index.test.js.snap index feb99bfc3b8..5e739ad42e8 100644 --- a/app/components/Views/Settings/SecuritySettings/__snapshots__/index.test.js.snap +++ b/app/components/Views/Settings/SecuritySettings/__snapshots__/index.test.js.snap @@ -137,6 +137,7 @@ exports[`SecuritySettings should render correctly 1`] = ` "marginTop": 50, } } + testID="clear-privacy" > Reveal Seed Phrase @@ -457,6 +459,7 @@ exports[`SecuritySettings should render correctly 1`] = ` "opacity": 0.6, } } + testID="reveal-seedphrase-button" type="danger" > REVEAL SEED PHRASE diff --git a/app/components/Views/Settings/SecuritySettings/index.js b/app/components/Views/Settings/SecuritySettings/index.js index 8d6d5913c33..bdea7bdbb25 100644 --- a/app/components/Views/Settings/SecuritySettings/index.js +++ b/app/components/Views/Settings/SecuritySettings/index.js @@ -466,7 +466,7 @@ class Settings extends PureComponent { /> - + {strings('app_settings.clear_privacy_title')} {strings('app_settings.clear_privacy_desc')} {biometryType && ( - + {strings(`biometrics.enable_${this.state.biometryType.toLowerCase()}`)} @@ -560,10 +560,13 @@ class Settings extends PureComponent { - {strings('reveal_credential.seed_phrase_title')} + + {strings('reveal_credential.seed_phrase_title')} + {strings('reveal_credential.seed_warning')} diff --git a/e2e/helpers.js b/e2e/helpers.js index 385ef7cbc88..a091162c629 100644 --- a/e2e/helpers.js +++ b/e2e/helpers.js @@ -2,7 +2,7 @@ export default class TestHelpers { static async waitAndTap(elementId) { await waitFor(element(by.id(elementId))) .toBeVisible() - .withTimeout(5000); + .withTimeout(8000); return element(by.id(elementId)).tap(); } @@ -48,6 +48,16 @@ export default class TestHelpers { } } + static async selectAllAndClear(elementId) { + await TestHelpers.tapByText('Select All'); + return element(by.id(elementId)).tapBackspaceKey(); + } + + static async tapAndLongPress(elementId) { + await TestHelpers.tap(elementId); + return element(by.id(elementId)).longPress(); + } + static tapAlertWithButton(text) { if (device.getPlatform() === 'android') { return element(by.text(text)) diff --git a/e2e/import-seed-phrase.spec.js b/e2e/import-seed-phrase.spec.js new file mode 100644 index 00000000000..7cf1c15e051 --- /dev/null +++ b/e2e/import-seed-phrase.spec.js @@ -0,0 +1,107 @@ +'use strict'; +import TestHelpers from './helpers'; + +const Incorrect_Seed_Words = 'fold media south add since false relax immense pause cloth just falcon'; +const Correct_Seed_Words = 'fold media south add since false relax immense pause cloth just raven'; +const Incorrect_Password_Length = 'The password needs to be at least 8 characters long'; +const Invalid_Seed_Error = `Error: Seed phrase is invalid.`; +const Correct_Password = `12345678`; +const Incorrect_Password = `1234567`; +const Password_Warning = "Couldn't unlock your account. Please try again."; + +describe('Import seedphrase flow', () => { + beforeEach(() => { + jest.setTimeout(90000); + }); + + it('should import via seed phrase and validate in settings', async () => { + // Check that we are on the home screen + await TestHelpers.checkIfVisible('home-screen'); + // Check that Sync or import your wallet CTA is visible & tap it + await TestHelpers.waitAndTap('onboarding-import-button'); + // Check that we are on the import wallet screen + await TestHelpers.checkIfVisible('import-wallet-screen'); + // Check that Import using seed phrase CTA is visible & tap it + await TestHelpers.waitAndTap('import-wallet-import-from-seed-button'); + // Check that we are on the import from seed screen + await TestHelpers.checkIfVisible('import-from-seed-screen'); + // Input incorrect seed phrase + await TestHelpers.typeTextAndHideKeyboard(`input-seed-phrase`, Incorrect_Seed_Words); + // Input short password + await TestHelpers.typeTextAndHideKeyboard(`input-password-field`, Incorrect_Password); + // Input short password confirm + await TestHelpers.typeTextAndHideKeyboard(`input-password-field-confirm`, Incorrect_Password); + // ensure alert box is displayed with correct text + await TestHelpers.checkIfElementByTextIsVisible(Incorrect_Password_Length); + // dismiss alert by tapping ok + await element(by.label('OK')) + .atIndex(0) + .tap(); + // Input password + await TestHelpers.typeTextAndHideKeyboard(`input-password-field`, Correct_Password); + // Input password confirm + await TestHelpers.typeTextAndHideKeyboard(`input-password-field-confirm`, Correct_Password); + // Ensure error is displayed + await TestHelpers.checkIfHasText('invalid-seed-phrase', Invalid_Seed_Error); + // Tap back into seed phrase text input and long press + await TestHelpers.tapAndLongPress('input-seed-phrase'); + // Select all and delete + await TestHelpers.selectAllAndClear('input-seed-phrase'); + // Input correct seed phrase + await TestHelpers.typeTextAndHideKeyboard(`input-seed-phrase`, Correct_Seed_Words); + // Tap outside of box + await TestHelpers.tapAtPoint('import-from-seed-screen', { x: 40, y: 20 }); + // Tap import to continue + await TestHelpers.waitAndTap('submit'); + // Check that we are on the metametrics optIn screen + await TestHelpers.checkIfVisible('metaMetrics-OptIn'); + // Check that I Agree CTA is visible and tap it + await TestHelpers.waitAndTap('agree-button'); + // Check that we are on the wallet screen + await TestHelpers.checkIfExists('wallet-screen'); + // Check that No thanks CTA is visible and tap it + await TestHelpers.waitAndTap('onboarding-wizard-back-button'); + // Check that the onboarding wizard is gone + await TestHelpers.checkIfNotVisible('onboarding-wizard-step1-view'); + // Open Drawer + await TestHelpers.tapAtPoint('wallet-screen', { x: 30, y: -5 }); + // Check that the drawer is visbile + await TestHelpers.checkIfVisible('drawer-screen'); + // Tap on settings + await TestHelpers.tap('settings-button'); + // Tap on the "Security & Privacy" option + await TestHelpers.tapByText('Security & Privacy'); + // Swipe up the screen + await TestHelpers.swipe('clear-privacy', 'up'); + // Check that you are on bottom of screen + await TestHelpers.checkIfVisible('reveal-seed-title'); + // Tap on Reveal Seed Phrase Button + await TestHelpers.waitAndTap('reveal-seedphrase-button'); + // Check that we are on the reveal seed phrase screen + await TestHelpers.checkIfVisible('reveal-private-credential-screen'); + // Input incorrect password + await TestHelpers.typeTextAndHideKeyboard('private-credential-password-text-input', Incorrect_Password); + // Ensure error is displayed + await TestHelpers.checkIfHasText('password-warning', Password_Warning); + // Input correct password + await TestHelpers.typeTextAndHideKeyboard('private-credential-password-text-input', Correct_Password); + // Ensure password field no longer is shown + await TestHelpers.checkIfNotVisible('private-credential-password-text-input'); + // Seed phrase should now be revealed + await TestHelpers.checkIfVisible('private-credential-touchable'); + // Check that the seed phrase displayed matches what we inputted in the beginning + await TestHelpers.checkIfHasText('private-credential-text', Correct_Seed_Words); + // Relaunch app + await TestHelpers.relaunchApp(); + // Check that we are on login screen + await TestHelpers.checkIfVisible('login'); + // Tap on log in button + await TestHelpers.tap('log-in-button'); + // Check that the invalid error is displayed + await TestHelpers.checkIfVisible('invalid-password-error'); + // Log in + await TestHelpers.typeTextAndHideKeyboard('login-password-input', Correct_Password); + // Check that we are on the Browser page + await TestHelpers.checkIfVisible('browser-screen'); + }); +});