Skip to content

Commit

Permalink
restore flow
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulnr7 committed May 29, 2024
1 parent 89d731f commit 110f6af
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export const CardAboutPhrase = ({

{title !== undefined && (
<>
<Text style={styles.title} testID={testId}>{title}</Text>
<Text style={styles.title} testID={testId}>
{title}
</Text>

<Space height="sm" />
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const ChooseMnemonicTypeScreen = () => {
title={strings.choose15WordsMnemonicTitle}
icon={<Mnemonic15Words style={styles.icon} />}
onPress={handle15Words}
testId="mnemonic-15-word"
/>

<Space height="lg" />
Expand All @@ -59,6 +60,7 @@ export const ChooseMnemonicTypeScreen = () => {
title={strings.choose24WordsMnemonicTitle}
icon={<Mnemonic24Words style={styles.icon} />}
onPress={handle24Words}
testId="mnemonic-24-word"
/>

<Space height="lg" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const VerifyRecoveryPhraseScreen = () => {
publicKeyHexChanged(accountPubKeyHex)
navigation.navigate('setup-wallet-details-form')
}}
testId="setup-step3-next-button"
testId="setup-next-button"
/>

<Space height="sm" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export const WalletDetailsScreen = () => {
closeModal()
showRestoreWalletInfoModalChanged(false)
}}
testId="setup-step4-modal-continue-button"
testId="setup-modal-continue-button"
/>

<Space height="lg" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const MnemonicInput = ({
mnenonicRefs.forEach((ref) => ref.current?.selectWord(''))
mnenonicRefs[0].current?.focus()
}}
testId="clearAll-button"
/>
)}

Expand All @@ -97,11 +98,11 @@ export const MnemonicInput = ({
)
}

const ClearAllButton = ({onPress}: {onPress: () => void}) => {
const ClearAllButton = ({onPress, testId}: {onPress: () => void; testId?: string}) => {
const {styles} = useStyles()
const strings = useStrings()
return (
<View style={styles.textView}>
<View style={styles.textView} testID={testId}>
<TouchableOpacity activeOpacity={0.5} onPress={onPress}>
<Text style={styles.clearAll}>{strings.clearAll}</Text>
</TouchableOpacity>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ export const RestoreWalletDetailsScreen = () => {

<Space width="sm" />

<Text style={styles.plateNumber}>{plate.accountPlate.TextPart}</Text>
<Text style={styles.plateNumber} testID="wallet-plate-number">
{plate.accountPlate.TextPart}
</Text>

<Space width="sm" />

Expand All @@ -307,6 +309,7 @@ export const RestoreWalletDetailsScreen = () => {
addressMode,
})
}
testId="setup-restore-step2-next-button"
disabled={isLoading || Object.keys(passwordErrors).length > 0 || Object.keys(nameErrors).length > 0}
/>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const NextButton = ({onPress}: {onPress: () => void}) => {

return (
<View style={styles.padding}>
<Button title={strings.next} style={styles.button} onPress={onPress} />
<Button title={strings.next} style={styles.button} onPress={onPress} testID="setup-restore-step1-next-button" />
</View>
)
}
Expand Down
4 changes: 4 additions & 0 deletions e2e/wallet-mobile/screens/chooseMnemonicType.screen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {by, element} from 'detox'

export const mnemonic15WordTypeCard = () => element(by.id('mnemonic-15-word'))
export const mnemonic24wordTypeCard = () => element(by.id('mnemonic-24-word'))
4 changes: 2 additions & 2 deletions e2e/wallet-mobile/screens/createWalletSteps.screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const getSeedPhrase = async (): Promise<Array<string>> => {
return allWords
}

export const step3NextButton = () => element(by.id('setup-step3-next-button'))
export const step3NextButton = () => element(by.id('setup-next-button'))

export const repeatSeedPhrase = async (phraseArray: string[]): Promise<void> => {
for (const phraseArrayWord of phraseArray) {
Expand All @@ -38,7 +38,7 @@ export const step3RecoveryPhraseValidatedText = () => element(by.text('The recov

export const step4Title1OnModal = () => element(by.text('What is wallet name'))
export const step4Title2OnModal = () => element(by.text('What is password'))
export const step4ModalContinueButton = () => element(by.id('setup-step4-modal-continue-button'))
export const step4ModalContinueButton = () => element(by.id('setup-modal-continue-button'))

export const step4WalletNameInput = () => element(by.id('walletNameInput'))
export const step4SpendingPasswordInput = () => element(by.id('walletPasswordInput'))
Expand Down
34 changes: 23 additions & 11 deletions e2e/wallet-mobile/screens/restoreWalletFlow.screen.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
import {by, element} from 'detox'

export const restoreNormalWalletButton = () => element(by.id('restoreNormalWalletButton'))
export const restore24WordWalletButton = () => element(by.id('restore24WordWalletButton'))
export const restoreReadOnlyWalletButton = () => element(by.id('importReadOnlyWalletButton'))
export const step1Title = () => element(by.text('Enter recovery phrase'))

export const mnemonicInputsView = () => element(by.id('mnemonicInputsView'))
export const mnemonicByIndexInput = (wordIndex: number, platform: string) =>
platform === 'android'
? element(by.type(`android.widget.EditText`)).atIndex(wordIndex)
: element(by.id(`mnemonicInput${wordIndex}`))
export const mnemonicRestoreWalletButton = () => element(by.id('restoreButton'))

export const walletChecksumText = () => element(by.id('walletChecksum'))
export const verifyWalletContinueButton = () => element(by.id('verifyWalletContinueButton'))
export const step1RecoveryPhraseSuccessMessage = () => element(by.text('The recovery phrase is verified'))
export const step1Clear_AllButton = () => element(by.id('clearAll-button'))
export const step1NextButton = () => element(by.id('setup-restore-step1-next-button'))

export const credentialsView = () => element(by.id('credentialsView'))
export const walletNameInput = () => element(by.id('walletNameInput'))
export const spendingPasswordInput = () => element(by.id('walletPasswordInput'))
export const repeatSpendingPasswordInput = () => element(by.id('walletRepeatPasswordInput'))
export const credentialsContinueButton = () => element(by.id('walletFormContinueButton'))
export const step2Title1OnModal = () => element(by.text('What is wallet name'))
export const step2Title2OnModal = () => element(by.text('What is password'))
export const step2ModalContinueButton = () => element(by.id('setup-modal-continue-button'))

export const walletPlateNumber = () => element(by.id('wallet-plate-number'))

export const step2WalletNameInput = () => element(by.id('walletNameInput'))
export const step2SpendingPasswordInput = () => element(by.id('walletPasswordInput'))
export const step2RepeatSpendingPasswordInput = () => element(by.id('walletRepeatPasswordInput'))
export const step2NextButton = () => element(by.id('setup-restore-step2-next-button'))

export const praparingYourWalletMessage = () => element(by.text('Preparing your wallet...'))

export const enterRecoveryPhrase = async (phraseArray: string[], platform: string): Promise<void> => {
for (let wordIndex = 0; wordIndex < phraseArray.length; wordIndex++) {
const wordElementInput = mnemonicByIndexInput(wordIndex, platform)
await wordElementInput.typeText(`${phraseArray[wordIndex]}\n`)
}
}
54 changes: 32 additions & 22 deletions e2e/wallet-mobile/tests/_android/restore-wallet.test.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,54 @@
import {device, expect} from 'detox'

import * as constants from '../../general/constants'
import * as myWalletsScreen from '../../screens/myWallets.screen'
import * as restoreWalletFlow from '../../screens/restoreWalletFlow.screen'
import * as utils from '../../general/utils'
import * as chooseSetupTypeScreen from '../../screens/chooseSetupType.screen'
import * as chooseNetworkTypeScreen from '../../screens/chooseNetworkType.screen'
import * as chooseMnemonicTypeScreen from '../../screens/chooseMnemonicType.screen'

describe('Restore a wallet', () => {
let platform: string

beforeAll(async () => {
const vars: any = await utils.initialize()
platform = vars.platform
await device.launchApp({newInstance: true})
await utils.prepareApp(constants.valid_Pin)
})

it('should be able to initiate the "restore wallet" process from home screen', async () => {
await myWalletsScreen.addWalletTestnetButton().tap()
await myWalletsScreen.restoreWalletButton().tap()
await restoreWalletFlow.restoreNormalWalletButton().tap()
it('should be able to select "restore wallet"', async () => {
await chooseSetupTypeScreen.restoreWalletButton().tap()
await expect(chooseNetworkTypeScreen.pageTitleCreateFlow()).toBeVisible()
})

it('should be able to select "preprod" network', async () => {
await chooseNetworkTypeScreen.networkTestnetButton().tap()
await expect(chooseMnemonicTypeScreen.mnemonic15WordTypeCard()).toBeVisible()
})

it('should be able to enter the 15-word recovery phrase', async () => {
await utils.enterRecoveryPhrase(constants.normal_15_Word_Wallet.phrase, platform)
await restoreWalletFlow.mnemonicRestoreWalletButton().tap()
it('should be able to select "15 word" mnemonic type wallet', async () => {
await chooseMnemonicTypeScreen.mnemonic15WordTypeCard().tap()
await expect(restoreWalletFlow.step1Title()).toBeVisible()
})

await expect(restoreWalletFlow.walletChecksumText()).toBeVisible()
await expect(restoreWalletFlow.walletChecksumText()).toHaveText(constants.normal_15_Word_Wallet.checksum)
await restoreWalletFlow.verifyWalletContinueButton().tap()
await expect(restoreWalletFlow.credentialsView()).toBeVisible()
it('should be able to complete "step1: 15-word recovery phrase"', async () => {
await restoreWalletFlow.enterRecoveryPhrase(constants.normal_15_Word_Wallet.phrase, platform)
await utils.takeScreenshot('Recovery Phrase entered')
await expect(restoreWalletFlow.step1RecoveryPhraseSuccessMessage()).toBeVisible()
await restoreWalletFlow.step1NextButton().tap()
await expect(restoreWalletFlow.walletPlateNumber()).toBeVisible()
})

it('should be able to set the spending password', async () => {
await restoreWalletFlow.walletNameInput().typeText(constants.normal_15_Word_Wallet.name)
await device.disableSynchronization()
await restoreWalletFlow.spendingPasswordInput().typeText(constants.spending_Password)
await restoreWalletFlow.repeatSpendingPasswordInput().typeText(`${constants.spending_Password}\n`)
await device.enableSynchronization()
await restoreWalletFlow.credentialsContinueButton().tap()
await expect(myWalletsScreen.pageTitle()).toBeVisible()
await expect(myWalletsScreen.walletByNameButton(constants.normal_15_Word_Wallet.name)).toBeVisible()
it('should be able to complete "step2 : set credentials"', async () => {
await expect(restoreWalletFlow.walletPlateNumber()).toHaveText(constants.normal_15_Word_Wallet.checksum)
await restoreWalletFlow.step2WalletNameInput().tap()
await restoreWalletFlow.step2WalletNameInput().typeText(constants.wallet_Name)
await restoreWalletFlow.step2SpendingPasswordInput().tap()
await restoreWalletFlow.step2SpendingPasswordInput().typeText(`${constants.spending_Password}\n`)
await restoreWalletFlow.step2RepeatSpendingPasswordInput().tap()
await restoreWalletFlow.step2RepeatSpendingPasswordInput().typeText(constants.spending_Password)
await utils.takeScreenshot('Set the spending password')
await restoreWalletFlow.step2NextButton().tap()
await expect(restoreWalletFlow.praparingYourWalletMessage()).toBeVisible()
})
})
2 changes: 1 addition & 1 deletion e2e/wallet-mobile/tests/_ios/create-wallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Create a wallet', () => {
await expect(chooseNetworkTypeScreen.pageTitleCreateFlow()).toBeVisible()
})

it('should be able to select "testnet" network', async () => {
it('should be able to select "preprod" network', async () => {
await chooseNetworkTypeScreen.networkTestnetButton().tap()
await expect(createWalletStepsScreen.step1Title()).toBeVisible()
})
Expand Down
56 changes: 31 additions & 25 deletions e2e/wallet-mobile/tests/_ios/restore-wallet.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {device, expect} from 'detox'

import * as constants from '../../general/constants'
import * as myWalletsScreen from '../../screens/myWallets.screen'
import * as restoreWalletFlow from '../../screens/restoreWalletFlow.screen'
import * as utils from '../../general/utils'
import * as chooseSetupTypeScreen from '../../screens/chooseSetupType.screen'
import * as chooseNetworkTypeScreen from '../../screens/chooseNetworkType.screen'
import * as chooseMnemonicTypeScreen from '../../screens/chooseMnemonicType.screen'

describe('Restore a wallet', () => {
let platform: string
Expand All @@ -14,35 +16,39 @@ describe('Restore a wallet', () => {
await utils.prepareApp(constants.valid_Pin)
})

it('should be able to initiate the "restore wallet" process from home screen', async () => {
await utils.takeScreenshot('Home Screen')
await myWalletsScreen.addWalletTestnetButton().tap()
await myWalletsScreen.restoreWalletButton().tap()
await restoreWalletFlow.restoreNormalWalletButton().tap()
it('should be able to select "restore wallet"', async () => {
await chooseSetupTypeScreen.restoreWalletButton().tap()
await expect(chooseNetworkTypeScreen.pageTitleRestoreFlow()).toBeVisible()
})

it('should be able to enter the 15-word recovery phrase', async () => {
await utils.enterRecoveryPhrase(constants.normal_15_Word_Wallet.phrase, platform)
await utils.takeScreenshot('Recovery Phrase entered')
await restoreWalletFlow.mnemonicRestoreWalletButton().tap()
it('should be able to select "preprod" network', async () => {
await chooseNetworkTypeScreen.networkTestnetButton().tap()
await expect(chooseMnemonicTypeScreen.mnemonic15WordTypeCard()).toBeVisible()
})

await expect(restoreWalletFlow.walletChecksumText()).toBeVisible()
await expect(restoreWalletFlow.walletChecksumText()).toHaveText(constants.normal_15_Word_Wallet.checksum)
await restoreWalletFlow.verifyWalletContinueButton().tap()
await expect(restoreWalletFlow.credentialsView()).toBeVisible()
it('should be able to select "15 word" mnemonic type wallet', async () => {
await chooseMnemonicTypeScreen.mnemonic15WordTypeCard().tap()
await expect(restoreWalletFlow.step1Title()).toBeVisible()
})

it('should be able to set the spending password', async () => {
await restoreWalletFlow.walletNameInput().typeText(constants.normal_15_Word_Wallet.name)
await restoreWalletFlow.spendingPasswordInput().tap()
await restoreWalletFlow.spendingPasswordInput().typeText(`${constants.spending_Password}\n`)
await waitFor(restoreWalletFlow.repeatSpendingPasswordInput()).toBeVisible(50).withTimeout(10000)
await restoreWalletFlow.repeatSpendingPasswordInput().tap()
await restoreWalletFlow.repeatSpendingPasswordInput().typeText(constants.spending_Password)
await restoreWalletFlow.credentialsContinueButton().tap()
it('should be able to complete "step1: 15-word recovery phrase"', async () => {
await restoreWalletFlow.enterRecoveryPhrase(constants.normal_15_Word_Wallet.phrase, platform)
await utils.takeScreenshot('Recovery Phrase entered')
await expect(restoreWalletFlow.step1RecoveryPhraseSuccessMessage()).toBeVisible()
await restoreWalletFlow.step1NextButton().tap()
await expect(restoreWalletFlow.walletPlateNumber()).toBeVisible()
})

await expect(myWalletsScreen.pageTitle()).toBeVisible()
await expect(myWalletsScreen.walletByNameButton(constants.normal_15_Word_Wallet.name)).toBeVisible()
await utils.takeScreenshot(`Wallet "${constants.wallet_Name} is added.`)
it('should be able to complete "step2 : set credentials"', async () => {
await expect(restoreWalletFlow.walletPlateNumber()).toHaveText(constants.normal_15_Word_Wallet.checksum)
await restoreWalletFlow.step2WalletNameInput().tap()
await restoreWalletFlow.step2WalletNameInput().typeText(constants.wallet_Name)
await restoreWalletFlow.step2SpendingPasswordInput().tap()
await restoreWalletFlow.step2SpendingPasswordInput().typeText(`${constants.spending_Password}\n`)
await restoreWalletFlow.step2RepeatSpendingPasswordInput().tap()
await restoreWalletFlow.step2RepeatSpendingPasswordInput().typeText(constants.spending_Password)
await utils.takeScreenshot('Set the spending password')
await restoreWalletFlow.step2NextButton().tap()
await expect(restoreWalletFlow.praparingYourWalletMessage()).toBeVisible()
})
})

0 comments on commit 110f6af

Please sign in to comment.