-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(e2e): add new account creation test for new tab and cloud backup #5142
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dad9aa8
test(e2e): add new account creation test for new tab and cloud backup
satish-ravi 3a21624
add missing helper
satish-ravi 6ec8961
add expect as a dev dependency
satish-ravi dadbc20
Merge branch 'main' into satish/act-1113-4
satish-ravi 078f201
fix test name
satish-ravi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import NewAccountOnboarding from './usecases/NewAccountOnboarding' | ||
import NewAccountOnboardingDrawer from './usecases/NewAccountOnboardingDrawer' | ||
import RestoreAccountOnboarding from './usecases/RestoreAccountOnboarding' | ||
|
||
describe('Account Setup', () => { | ||
describe('New Account', NewAccountOnboarding) | ||
describe('New Account Drawer', NewAccountOnboardingDrawer) | ||
describe('Restore', RestoreAccountOnboarding) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
import { getAddressChunks } from '@celo/utils/lib/address' | ||
import { EXAMPLE_NAME } from '../utils/consts' | ||
import { launchApp } from '../utils/retries' | ||
import { | ||
completeProtectWalletScreen, | ||
enterPinUi, | ||
quickOnboarding, | ||
scrollIntoView, | ||
sleep, | ||
waitForElementId, | ||
} from '../utils/utils' | ||
|
||
import jestExpect from 'expect' | ||
|
||
const quickEducation = async () => { | ||
await element(by.id('DrawerItem/Recovery Phrase')).tap() | ||
await enterPinUi() | ||
await element(by.id('SetUpAccountKey')).tap() | ||
|
||
// Go through education | ||
for (let i = 0; i < 4; i++) { | ||
await element(by.id('Education/progressButton')).tap() | ||
} | ||
|
||
await expect(element(by.id('AccountKeyWordsContainer'))).toBeVisible() | ||
} | ||
|
||
const arriveAtHomeScreen = async () => { | ||
// Arrived to Home screen | ||
await expect(element(by.id('HomeAction-Send'))).toBeVisible() | ||
} | ||
|
||
const openHamburger = async () => { | ||
// Able to open the drawer - testing https://github.com/valora-inc/wallet/issues/3043 | ||
await waitForElementId('Hamburger') | ||
await element(by.id('Hamburger')).tap() | ||
await waitForElementId('Drawer/Header') | ||
} | ||
|
||
export default NewAccountOnboarding = () => { | ||
let testRecoveryPhrase, testAccountAddress | ||
beforeAll(async () => { | ||
await device.terminateApp() | ||
await sleep(5000) | ||
await launchApp({ | ||
delete: true, | ||
permissions: { notifications: 'YES', contacts: 'YES' }, | ||
}) | ||
await sleep(5000) | ||
}) | ||
|
||
it('Create a new account', async () => { | ||
await element(by.id('CreateAccountButton')).tap() | ||
|
||
// Accept Terms | ||
await element(by.id('scrollView')).scrollTo('bottom') | ||
await expect(element(by.id('AcceptTermsButton'))).toBeVisible() | ||
await element(by.id('AcceptTermsButton')).tap() | ||
|
||
// Set name and number | ||
await element(by.id('NameEntry')).replaceText(EXAMPLE_NAME) | ||
await element(by.id('NameAndPictureContinueButton')).tap() | ||
|
||
// Set & Verify pin | ||
await enterPinUi() | ||
await enterPinUi() | ||
|
||
// Protect Wallet screen | ||
await completeProtectWalletScreen() | ||
|
||
// Skip Phone Number verification | ||
await element(by.id('PhoneVerificationSkipHeader')).tap() | ||
|
||
// Arrived to Home screen | ||
await arriveAtHomeScreen() | ||
|
||
// Able to open the drawer | ||
await openHamburger() | ||
}) | ||
|
||
it('Should be able to exit recovery phrase flow', async () => { | ||
await quickEducation() | ||
await waitFor(element(by.text('Cancel'))) | ||
.toBeVisible() | ||
.withTimeout(10 * 1000) | ||
await element(by.text('Cancel')).tap() | ||
|
||
// Cancel modal is shown | ||
await waitFor(element(by.text('Set Up Later'))) | ||
.toBeVisible() | ||
.withTimeout(10 * 1000) | ||
await element(by.text('Set Up Later')).tap() | ||
|
||
// App doesn't crash and we arrive at the home screen | ||
await arriveAtHomeScreen() | ||
}) | ||
|
||
it('Setup Recovery Phrase', async () => { | ||
await openHamburger() | ||
await quickEducation() | ||
|
||
const attributes = await element(by.id('AccountKeyWordsContainer')).getAttributes() | ||
testRecoveryPhrase = attributes.label | ||
|
||
await element(by.id('backupKeySavedSwitch')).longPress() | ||
await element(by.id('backupKeyContinue')).tap() | ||
for (const word of testRecoveryPhrase.split(' ')) { | ||
await element(by.id(`backupQuiz/${word}`)).tap() | ||
} | ||
await element(by.id('QuizSubmit')).tap() | ||
|
||
// Backup complete screen is served | ||
await waitFor(element(by.id('BackupComplete'))) | ||
.toBeVisible() | ||
.withTimeout(10 * 1000) | ||
|
||
// Navigated to Home screen | ||
await waitFor(element(by.id('HomeAction-Send'))) | ||
.toBeVisible() | ||
.withTimeout(10 * 1000) | ||
}) | ||
|
||
it('Account Address shown in drawer menu', async () => { | ||
await waitForElementId('Hamburger') | ||
await element(by.id('Hamburger')).tap() | ||
await scrollIntoView('Account Address', 'SettingsScrollView') | ||
const accountAddressElement = await element(by.id('AccountNumber')).getAttributes() | ||
const accountAddressText = accountAddressElement.text.replace(/\s/g, '') | ||
testAccountAddress = accountAddressText | ||
jestExpect(testAccountAddress).toMatch(/0x[0-9a-fA-F]{40}/) | ||
}) | ||
|
||
// After quiz completion recovery phrase should only be shown in settings | ||
it('Recovery phrase only shown in settings', async () => { | ||
await expect(element(by.id('DrawerItem/Recovery Phrase'))).not.toExist() | ||
await waitForElementId('DrawerItem/Settings') | ||
await element(by.id('DrawerItem/Settings')).tap() | ||
await waitForElementId('RecoveryPhrase') | ||
await element(by.id('RecoveryPhrase')).tap() | ||
await enterPinUi() | ||
await waitForElementId('AccountKeyWordsContainer') | ||
}) | ||
|
||
// Based off the flag set in src/firebase/remoteConfigValuesDefaults.e2e.ts | ||
// We can only test one path 12 or 24 words as we cannot flip the flag after the build step | ||
it('Recovery phrase has 12 words', async () => { | ||
const recoveryPhraseContainer = await element(by.id('AccountKeyWordsContainer')).getAttributes() | ||
const recoveryPhraseText = recoveryPhraseContainer.label | ||
jestExpect(recoveryPhraseText.split(' ').length).toBe(12) | ||
jestExpect(recoveryPhraseText).toBe(testRecoveryPhrase) | ||
}) | ||
|
||
it('Should be able to restore newly created account', async () => { | ||
await device.uninstallApp() | ||
await device.installApp() | ||
await launchApp() | ||
await quickOnboarding(testRecoveryPhrase) | ||
await waitForElementId('Hamburger') | ||
await element(by.id('Hamburger')).tap() | ||
await scrollIntoView('Account Address', 'SettingsScrollView') | ||
const addressString = '0x ' + getAddressChunks(testAccountAddress).join(' ') | ||
await expect(element(by.text(addressString))).toBeVisible() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixes a knip error. We use expect directly in e2e tests. It was previously a transitive dependency from jest which knip doesn't allow https://knip.dev/guides/handling-issues#unlisted-dependencies