Skip to content

Commit

Permalink
Updated themebased text color test for restore mnemonic (#843)
Browse files Browse the repository at this point in the history
* Updated themebased text color test for restore mnemonic

* Update restore.spec.ts

* Update onboardingCommands.ts

* create mnemonic flaky test fix

* Removed themebased color check for recovery word
  • Loading branch information
fullstackninja864 authored Sep 14, 2021
1 parent b74eb1a commit 803d05b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
1 change: 1 addition & 0 deletions cypress/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"standard-with-typescript"
],
"rules": {
"@typescript-eslint/no-namespace": "off",
"cypress/no-assigning-return-values": "error",
"cypress/no-unnecessary-waiting": "off",
"cypress/assertion-before-screenshot": "warn",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ context('Onboarding - Create Mnemonic Wallet', () => {
cy.exitWallet()
cy.restoreMnemonicWords(settingsRecoveryWords)
})
})

context('Settings - On Restore - Mnemonic Verification', () => {
it('should be able to verify mnemonic from settings page', function () {
cy.verifyMnemonicOnSettingsPage([], recoveryWords)
})
Expand All @@ -75,12 +73,15 @@ context('Onboarding - Create Mnemonic Wallet with refresh recovery word', () =>
const settingsRecoveryWords: string[] = []

before(() => {
cy.restoreLocalStorage()
cy.visit('/')
cy.exitWallet()
cy.visit('/')
})

after(() => {
beforeEach(() => {
cy.restoreLocalStorage()
})

afterEach(() => {
cy.saveLocalStorage()
})

Expand All @@ -102,9 +103,9 @@ context('Onboarding - Create Mnemonic Wallet with refresh recovery word', () =>
cy.getByTestID(`word_${i + 1}_number`).should('exist').contains(`${i + 1}.`)
cy.getByTestID(`word_${i + 1}`).then(($txt: any) => {
recoveryWords.push($txt[0].textContent)
expect(oldRecoveryWords[i]).not.eq($txt[0].textContent)
})
}).then(() => {
expect(oldRecoveryWords).not.deep.equal(recoveryWords)
cy.getByTestID('verify_button').should('not.have.attr', 'disabled')
cy.getByTestID('verify_button').click()
cy.selectMnemonicWords(recoveryWords)
Expand All @@ -117,9 +118,14 @@ context('Onboarding - Create Mnemonic Wallet with refresh recovery word', () =>
cy.verifyMnemonicOnSettingsPage(settingsRecoveryWords, recoveryWords)
})

it('should be able to restore refreshed mnemonic words', function () {
cy.exitWallet()
cy.visit('/')
cy.restoreMnemonicWords(recoveryWords)
context('Restore - Refreshed Mnemonic Verification', () => {
it('should be able to restore refreshed mnemonic words', function () {
cy.exitWallet()
cy.restoreMnemonicWords(settingsRecoveryWords)
})

it('should be able to verify refreshed mnemonic from settings page', function () {
cy.verifyMnemonicOnSettingsPage([], recoveryWords)
})
})
})
20 changes: 10 additions & 10 deletions cypress/support/onboardingCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@ declare global {
* @description Start onboarding mnemonic wallet process
* @param {string[]} recoveryWords - pass an empty array to be filled later
*/
startCreateMnemonicWallet (recoveryWords: string[]): Chainable<Element>
startCreateMnemonicWallet: (recoveryWords: string[]) => Chainable<Element>

/**
* @description Select mnemonic words from Verify Step
* @param {string[]} recoveryWords - list of recoveryWords
* @example cy.selectMnemonicWords(recoveryWords)
*/
selectMnemonicWords (recoveryWords: string[]): Chainable<Element>
selectMnemonicWords: (recoveryWords: string[]) => Chainable<Element>

/**
* @description Setup pin code from Onboarding
*/
setupPinCode (): Chainable<Element>
setupPinCode: () => Chainable<Element>

/**
* @description Verify created mnemonic words in Settings Page
* @param {string[]} settingsRecoveryWords - need to pass reference to be used on other steps
* @param {string[]} recoveryWords - recovery words from create page
* @example cy.verifyMnemonicOnSettingsPage(settingsRecoveryWords, recoveryWords)
*/
verifyMnemonicOnSettingsPage (settingsRecoveryWords: string[], recoveryWords: string[]): Chainable<Element>
verifyMnemonicOnSettingsPage: (settingsRecoveryWords: string[], recoveryWords: string[]) => Chainable<Element>

/**
* @description Restore wallet using mnemonic words
* @param {string[]} recoveryWords - recovery words to restore
* @example cy.restoreMnemonicWords(recoveryWords)
*/
restoreMnemonicWords (recoveryWords: string[]): Chainable<Element>
restoreMnemonicWords: (recoveryWords: string[]) => Chainable<Element>
}
}
}
Expand All @@ -44,7 +44,7 @@ Cypress.Commands.add('startCreateMnemonicWallet', (recoveryWords: string[]) => {
cy.getByTestID('guidelines_switch').click()
cy.getByTestID('create_recovery_words_button').click()
cy.url().should('include', 'wallet/mnemonic/create')
cy.wrap(Array.from(Array(24), (v, i) => i)).each((el, i) => {
cy.wrap(Array.from(Array(24), (v, i) => i)).each((el, i: number) => {
cy.getByTestID(`word_${i + 1}`).should('exist')
cy.getByTestID(`word_${i + 1}_number`).should('exist').contains(`${i + 1}.`)
cy.getByTestID(`word_${i + 1}`).then(($txt: any) => {
Expand All @@ -68,7 +68,7 @@ Cypress.Commands.add('selectMnemonicWords', (recoveryWords: string[]) => {
})

Cypress.Commands.add('setupPinCode', () => {
cy.getByTestID('pin_input').type('000000')
cy.getByTestID('pin_input').type('000000')
cy.getByTestID('pin_confirm_input').type('777777').wait(1000)
cy.getByTestID('wrong_passcode_text').should('exist')
cy.getByTestID('pin_confirm_input').type('000000')
Expand All @@ -79,7 +79,7 @@ Cypress.Commands.add('verifyMnemonicOnSettingsPage', function (settingsRecoveryW
cy.getByTestID('bottom_tab_settings').click()
cy.getByTestID('view_recovery_words').click().wait(3000)
cy.getByTestID('pin_authorize').type('000000')
cy.wrap(Array.from(Array(24), (v, i) => i)).each((el, i) => {
cy.wrap(Array.from(Array(24), (v, i) => i)).each((el, i: number) => {
cy.getByTestID(`word_${i + 1}`).should('exist')
cy.getByTestID(`word_${i + 1}_number`).should('exist').contains(`${i + 1}.`)
cy.getByTestID(`word_${i + 1}`).then(($txt: any) => {
Expand All @@ -92,13 +92,13 @@ Cypress.Commands.add('verifyMnemonicOnSettingsPage', function (settingsRecoveryW

Cypress.Commands.add('restoreMnemonicWords', (recoveryWords: string[]) => {
cy.getByTestID('restore_wallet_button').click()
recoveryWords.forEach((word, index) => {
recoveryWords.forEach((word, index: number) => {
cy.getByTestID(`recover_word_${index + 1}`).clear().type(word).blur()
cy.getByTestID(`recover_word_${index + 1}`).should('have.css', 'color', 'rgb(64, 64, 64)')
})
cy.getByTestID('recover_wallet_button').should('not.have.attr', 'disabled')
cy.getByTestID('recover_wallet_button').click()
cy.getByTestID('pin_input').type('000000')
cy.getByTestID('pin_input').type('000000')
cy.getByTestID('pin_confirm_input').type('000000')
cy.getByTestID('balances_list').should('exist')
})

0 comments on commit 803d05b

Please sign in to comment.