From 803d05bcf3e34c7b773c05b467e968e7396f46d5 Mon Sep 17 00:00:00 2001 From: Harsh R <53080940+fullstackninja864@users.noreply.github.com> Date: Tue, 14 Sep 2021 11:32:49 +0530 Subject: [PATCH] Updated themebased text color test for restore mnemonic (#843) * 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 --- cypress/.eslintrc | 1 + .../onboarding/createMnemonicWallet.spec.ts | 26 ++++++++++++------- cypress/support/onboardingCommands.ts | 20 +++++++------- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/cypress/.eslintrc b/cypress/.eslintrc index cf2381bc22..688e06b359 100644 --- a/cypress/.eslintrc +++ b/cypress/.eslintrc @@ -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", diff --git a/cypress/integration/functional/onboarding/createMnemonicWallet.spec.ts b/cypress/integration/functional/onboarding/createMnemonicWallet.spec.ts index 8679ac5cb3..d24c88f45d 100644 --- a/cypress/integration/functional/onboarding/createMnemonicWallet.spec.ts +++ b/cypress/integration/functional/onboarding/createMnemonicWallet.spec.ts @@ -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) }) @@ -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() }) @@ -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) @@ -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) + }) }) }) diff --git a/cypress/support/onboardingCommands.ts b/cypress/support/onboardingCommands.ts index c84a4a7b53..3ecb83d21c 100644 --- a/cypress/support/onboardingCommands.ts +++ b/cypress/support/onboardingCommands.ts @@ -7,19 +7,19 @@ declare global { * @description Start onboarding mnemonic wallet process * @param {string[]} recoveryWords - pass an empty array to be filled later */ - startCreateMnemonicWallet (recoveryWords: string[]): Chainable + startCreateMnemonicWallet: (recoveryWords: string[]) => Chainable /** * @description Select mnemonic words from Verify Step * @param {string[]} recoveryWords - list of recoveryWords * @example cy.selectMnemonicWords(recoveryWords) */ - selectMnemonicWords (recoveryWords: string[]): Chainable + selectMnemonicWords: (recoveryWords: string[]) => Chainable /** * @description Setup pin code from Onboarding */ - setupPinCode (): Chainable + setupPinCode: () => Chainable /** * @description Verify created mnemonic words in Settings Page @@ -27,14 +27,14 @@ declare global { * @param {string[]} recoveryWords - recovery words from create page * @example cy.verifyMnemonicOnSettingsPage(settingsRecoveryWords, recoveryWords) */ - verifyMnemonicOnSettingsPage (settingsRecoveryWords: string[], recoveryWords: string[]): Chainable + verifyMnemonicOnSettingsPage: (settingsRecoveryWords: string[], recoveryWords: string[]) => Chainable /** * @description Restore wallet using mnemonic words * @param {string[]} recoveryWords - recovery words to restore * @example cy.restoreMnemonicWords(recoveryWords) */ - restoreMnemonicWords (recoveryWords: string[]): Chainable + restoreMnemonicWords: (recoveryWords: string[]) => Chainable } } } @@ -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) => { @@ -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') @@ -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) => { @@ -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') })