From 3efd0f2d9892ae66ab4ebb9c41a663904828d917 Mon Sep 17 00:00:00 2001 From: mike10ca Date: Mon, 30 Oct 2023 18:05:31 +0100 Subject: [PATCH] Fix Cypress tests --- cypress/e2e/pages/balances.pages.js | 2 +- cypress/e2e/pages/batches.pages.js | 8 +++++-- cypress/e2e/pages/create_wallet.pages.js | 10 ++------ cypress/e2e/pages/main.page.js | 4 ++-- cypress/e2e/smoke/assets.cy.js | 2 +- cypress/e2e/smoke/balances.cy.js | 2 +- cypress/e2e/smoke/balances_pagination.cy.js | 5 ++-- cypress/e2e/smoke/batch_tx.cy.js | 26 +++++++++++++++------ cypress/e2e/smoke/create_tx.cy.js | 2 +- 9 files changed, 35 insertions(+), 26 deletions(-) diff --git a/cypress/e2e/pages/balances.pages.js b/cypress/e2e/pages/balances.pages.js index 1dcaf46e5c..0cb82caeb1 100644 --- a/cypress/e2e/pages/balances.pages.js +++ b/cypress/e2e/pages/balances.pages.js @@ -44,7 +44,7 @@ export const tokenListOptions = { export const currencyEUR = 'EUR' export const currencyUSD = 'USD' -export const currentcySepoliaFormat = '0.1 ETH' +export const currentcySepoliaFormat = '0.09996 ETH' export const currencyAave = 'AAVE' export const currencyAaveAlttext = 'AAVE' diff --git a/cypress/e2e/pages/batches.pages.js b/cypress/e2e/pages/batches.pages.js index dfbb34d7ef..d1c5628475 100644 --- a/cypress/e2e/pages/batches.pages.js +++ b/cypress/e2e/pages/batches.pages.js @@ -67,15 +67,19 @@ function addToBatchButton() { export function openBatchtransactionsModal() { cy.get(batchTxTopBar).should('be.visible').click() cy.contains(batchedTransactionsStr).should('be.visible') - cy.contains(addInitialTransactionStr) } export function openNewTransactionModal() { cy.get(addNewTxBatch).click() - cy.contains('h1', newTransactionTitle).should('be.visible') cy.contains(sendTokensButn).click() } +export function addNewTransactionToBatch(EOA, currentNonce, funds_first_tx) { + openBatchtransactionsModal() + openNewTransactionModal() + addToBatch(EOA, currentNonce, funds_first_tx) +} + export function verifyAmountTransactionsInBatch(count) { cy.contains(batchedTransactionsStr, { timeout: 7000 }) .should('be.visible') diff --git a/cypress/e2e/pages/create_wallet.pages.js b/cypress/e2e/pages/create_wallet.pages.js index 65ca64c824..706f7e4da1 100644 --- a/cypress/e2e/pages/create_wallet.pages.js +++ b/cypress/e2e/pages/create_wallet.pages.js @@ -55,15 +55,9 @@ export function typeWalletName(name) { export function selectNetwork(network, regex = false) { cy.wait(1000) - cy.get(selectNetworkBtn).should('exist').click() + cy.get(selectNetworkBtn).should('be.visible').click() + cy.wait(1000) cy.get('li').contains(network).click() - - if (regex) { - regex = constants.networks.goerli - cy.get(selectNetworkBtn).click().invoke('text').should('match', regex) - } else { - cy.get(selectNetworkBtn).click().should('have.text', network) - } cy.get('body').click() } diff --git a/cypress/e2e/pages/main.page.js b/cypress/e2e/pages/main.page.js index 1f38e0ded6..438797b93c 100644 --- a/cypress/e2e/pages/main.page.js +++ b/cypress/e2e/pages/main.page.js @@ -6,11 +6,11 @@ export function clickOnSideMenuItem(item) { cy.get('p').contains(item).click() } -export function acceptCookies() { +export function acceptCookies(index = 0) { cy.wait(1000) cy.findAllByText('Got it!') - .should('have.length.at.least', 0) + .should('have.length.at.least', index) .each(($el) => $el.click()) cy.get('button') diff --git a/cypress/e2e/smoke/assets.cy.js b/cypress/e2e/smoke/assets.cy.js index e8067221a9..578fc639ee 100644 --- a/cypress/e2e/smoke/assets.cy.js +++ b/cypress/e2e/smoke/assets.cy.js @@ -13,7 +13,7 @@ describe('Assets tests', () => { beforeEach(() => { cy.visit(constants.BALANCE_URL + constants.SEPOLIA_TEST_SAFE_5) cy.clearLocalStorage() - main.acceptCookies() + main.acceptCookies(2) }) it('Verify that the token tab is selected by default and the table is visible [C56039]', () => { diff --git a/cypress/e2e/smoke/balances.cy.js b/cypress/e2e/smoke/balances.cy.js index 98f32cad67..47142aa9f5 100644 --- a/cypress/e2e/smoke/balances.cy.js +++ b/cypress/e2e/smoke/balances.cy.js @@ -14,7 +14,7 @@ describe('Balance tests', () => { before(() => { cy.clearLocalStorage() cy.visit(constants.BALANCE_URL + constants.SEPOLIA_TEST_SAFE_5) - main.acceptCookies() + main.acceptCookies(2) cy.contains('Assets') cy.get(balances.balanceSingleRow).should('have.length.lessThan', ASSETS_LENGTH) balances.selectTokenList(balances.tokenListOptions.allTokens) diff --git a/cypress/e2e/smoke/balances_pagination.cy.js b/cypress/e2e/smoke/balances_pagination.cy.js index 695dfda308..92539761cd 100644 --- a/cypress/e2e/smoke/balances_pagination.cy.js +++ b/cypress/e2e/smoke/balances_pagination.cy.js @@ -1,5 +1,6 @@ import * as constants from '../../support/constants' import * as balances from '../pages/balances.pages' +import * as main from '../../e2e/pages/main.page' const ASSETS_LENGTH = 8 @@ -8,9 +9,7 @@ describe('Balance tests', () => { cy.clearLocalStorage() // Open the Safe used for testing cy.visit(constants.BALANCE_URL + constants.PAGINATION_TEST_SAFE) - cy.contains('button', 'Accept selection').click() - // Table is loaded - cy.contains('Görli Ether') + main.acceptCookies(2) cy.contains('div', 'Default tokens').click() cy.wait(100) diff --git a/cypress/e2e/smoke/batch_tx.cy.js b/cypress/e2e/smoke/batch_tx.cy.js index 777621dc43..507b2b3ecd 100644 --- a/cypress/e2e/smoke/batch_tx.cy.js +++ b/cypress/e2e/smoke/batch_tx.cy.js @@ -7,10 +7,10 @@ const funds_first_tx = '0.001' const funds_second_tx = '0.002' describe('Batch transaction tests', () => { - before(() => { + beforeEach(() => { cy.clearLocalStorage() cy.visit(constants.BALANCE_URL + constants.SEPOLIA_TEST_SAFE_5) - main.acceptCookies() + main.acceptCookies(2) }) it('Verify empty batch list can be opened [C56082]', () => { @@ -20,10 +20,11 @@ describe('Batch transaction tests', () => { it('Verify the Add batch button is present in a transaction form [C56084]', () => { //The "true" is to validate that the add to batch button is not visible if "Yes, execute" is selected - batch.addToBatch(constants.EOA, currentNonce, funds_first_tx) + batch.addNewTransactionToBatch(constants.EOA, currentNonce, funds_first_tx) }) it('Verify a transaction can be added to the batch [C56085]', () => { + batch.addNewTransactionToBatch(constants.EOA, currentNonce, funds_first_tx) cy.contains(batch.transactionAddedToBatchStr).should('be.visible') //The batch button in the header shows the transaction count batch.verifyBatchIconCount(1) @@ -32,26 +33,37 @@ describe('Batch transaction tests', () => { }) it('Verify a second transaction can be added to the batch [C56086]', () => { - batch.openNewTransactionModal() - batch.addToBatch(constants.EOA, currentNonce, funds_second_tx) + batch.addNewTransactionToBatch(constants.EOA, currentNonce, funds_first_tx) + cy.wait(1000) + batch.addNewTransactionToBatch(constants.EOA, currentNonce, funds_first_tx) batch.verifyBatchIconCount(2) batch.clickOnBatchCounter() batch.verifyAmountTransactionsInBatch(2) }) it('Verify the batch can be confirmed and related transactions exist in the form [C56088]', () => { + batch.addNewTransactionToBatch(constants.EOA, currentNonce, funds_first_tx) + cy.wait(1000) + batch.addNewTransactionToBatch(constants.EOA, currentNonce, funds_first_tx) + batch.clickOnBatchCounter() + batch.clickOnConfirmBatchBtn() + batch.clickOnBatchCounter() batch.clickOnConfirmBatchBtn() batch.verifyBatchTransactionsCount(2) + batch.clickOnBatchCounter() cy.contains(funds_first_tx).parents('ul').as('TransactionList') cy.get('@TransactionList').find('li').eq(0).find('span').eq(0).contains(funds_first_tx) - cy.get('@TransactionList').find('li').eq(1).find('span').eq(0).contains(funds_second_tx) + cy.get('@TransactionList').find('li').eq(1).find('span').eq(0).contains(funds_first_tx) }) it('Verify a transaction can be removed from the batch [C56089]', () => { + batch.addNewTransactionToBatch(constants.EOA, currentNonce, funds_first_tx) + cy.wait(1000) + batch.addNewTransactionToBatch(constants.EOA, currentNonce, funds_first_tx) batch.clickOnBatchCounter() cy.contains(batch.batchedTransactionsStr).should('be.visible').parents('aside').find('ul > li').as('BatchList') cy.get('@BatchList').find(batch.deleteTransactionbtn).eq(0).click() cy.get('@BatchList').should('have.length', 1) - cy.get('@BatchList').contains(funds_first_tx).should('not.exist') + cy.get('@BatchList').contains(funds_second_tx).should('not.exist') }) }) diff --git a/cypress/e2e/smoke/create_tx.cy.js b/cypress/e2e/smoke/create_tx.cy.js index 055adac173..a96db26acc 100644 --- a/cypress/e2e/smoke/create_tx.cy.js +++ b/cypress/e2e/smoke/create_tx.cy.js @@ -3,7 +3,7 @@ import * as main from '../../e2e/pages/main.page' import * as createtx from '../../e2e/pages/create_tx.pages' const sendValue = 0.00002 -const currentNonce = 1 +const currentNonce = 11 describe('Create transactions tests', () => { before(() => {