From 23fe8751e120a9a36ea427d29860f00067865cab Mon Sep 17 00:00:00 2001 From: Michael <30682308+mike10ca@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:29:35 +0100 Subject: [PATCH] Tests: Make tests independent (#2736) --- cypress/e2e/pages/address_book.page.js | 7 +++++++ cypress/e2e/pages/batches.pages.js | 2 +- cypress/e2e/pages/load_safe.pages.js | 4 ++++ cypress/e2e/safe-apps/info_modal.cy.js | 2 +- cypress/e2e/safe-apps/preview_drawer.cy.js | 2 +- cypress/e2e/safe-apps/tx_modal.cy.js | 4 +--- cypress/e2e/smoke/address_book.cy.js | 15 +++++++++------ cypress/e2e/smoke/balances.cy.js | 3 ++- cypress/e2e/smoke/load_safe.cy.js | 20 +++++++++++++++----- cypress/e2e/smoke/tx_history.cy.js | 4 +--- 10 files changed, 42 insertions(+), 21 deletions(-) diff --git a/cypress/e2e/pages/address_book.page.js b/cypress/e2e/pages/address_book.page.js index 29ea8e69de..2906d58290 100644 --- a/cypress/e2e/pages/address_book.page.js +++ b/cypress/e2e/pages/address_book.page.js @@ -67,6 +67,13 @@ export function verifyNewEntryAdded(name, address) { cy.contains(address).should('exist') } +export function addEntry(name, address) { + typeInName(name) + typeInAddress(address) + clickOnSaveEntryBtn() + verifyNewEntryAdded(name, address) +} + export function clickOnEditEntryBtn() { cy.get(editEntryBtn).click({ force: true }) } diff --git a/cypress/e2e/pages/batches.pages.js b/cypress/e2e/pages/batches.pages.js index d1c5628475..85e98e6350 100644 --- a/cypress/e2e/pages/batches.pages.js +++ b/cypress/e2e/pages/batches.pages.js @@ -89,7 +89,7 @@ export function verifyAmountTransactionsInBatch(count) { } export function clickOnConfirmBatchBtn() { - cy.contains(confirmBatchBtn).click() + cy.get('button').contains(confirmBatchBtn).should('be.visible').should('be.enabled').click() } export function verifyBatchTransactionsCount(count) { diff --git a/cypress/e2e/pages/load_safe.pages.js b/cypress/e2e/pages/load_safe.pages.js index 9ad46717d5..bc0fa83daa 100644 --- a/cypress/e2e/pages/load_safe.pages.js +++ b/cypress/e2e/pages/load_safe.pages.js @@ -39,6 +39,10 @@ export function selectPolygon() { cy.contains('span', constants.networks.polygon) } +export function inputNameAndAddress(name, address) { + inputName(name) + inputAddress(address) +} export function inputName(name) { cy.get(nameInput).type(name).should('have.value', name) } diff --git a/cypress/e2e/safe-apps/info_modal.cy.js b/cypress/e2e/safe-apps/info_modal.cy.js index 63e45f1b0e..650fe1b041 100644 --- a/cypress/e2e/safe-apps/info_modal.cy.js +++ b/cypress/e2e/safe-apps/info_modal.cy.js @@ -3,7 +3,7 @@ import * as main from '../pages/main.page' import * as safeapps from '../pages/safeapps.pages' describe('Safe Apps info modal tests', () => { - before(() => { + beforeEach(() => { cy.clearLocalStorage() cy.visit(constants.SEPOLIA_TEST_SAFE_5 + constants.appsUrl, { failOnStatusCode: false }) main.acceptCookies() diff --git a/cypress/e2e/safe-apps/preview_drawer.cy.js b/cypress/e2e/safe-apps/preview_drawer.cy.js index bae5b9ca94..985a1bcad6 100644 --- a/cypress/e2e/safe-apps/preview_drawer.cy.js +++ b/cypress/e2e/safe-apps/preview_drawer.cy.js @@ -3,7 +3,7 @@ import * as main from '../pages/main.page' import * as safeapps from '../pages/safeapps.pages' describe('Safe Apps info modal tests', () => { - before(() => { + beforeEach(() => { cy.clearLocalStorage() cy.visit(`/${constants.SEPOLIA_TEST_SAFE_5}/apps`, { failOnStatusCode: false }) main.acceptCookies() diff --git a/cypress/e2e/safe-apps/tx_modal.cy.js b/cypress/e2e/safe-apps/tx_modal.cy.js index 44941ef2bd..b2961038a1 100644 --- a/cypress/e2e/safe-apps/tx_modal.cy.js +++ b/cypress/e2e/safe-apps/tx_modal.cy.js @@ -6,10 +6,8 @@ const testAppName = 'Cypress Test App' const testAppDescr = 'Cypress Test App Description' describe('Transaction modal tests', () => { - before(() => { - cy.clearLocalStorage() - }) beforeEach(() => { + cy.clearLocalStorage() cy.fixture('safe-app').then((html) => { cy.intercept('GET', `${constants.testAppUrl}/*`, html) cy.intercept('GET', `*/manifest.json`, { diff --git a/cypress/e2e/smoke/address_book.cy.js b/cypress/e2e/smoke/address_book.cy.js index 21481837e4..3a5af18932 100644 --- a/cypress/e2e/smoke/address_book.cy.js +++ b/cypress/e2e/smoke/address_book.cy.js @@ -9,21 +9,20 @@ const NAME = 'Owner1' const EDITED_NAME = 'Edited Owner1' describe('Address book tests', () => { - before(() => { + beforeEach(() => { cy.clearLocalStorage() cy.visit(constants.addressBookUrl + constants.SEPOLIA_TEST_SAFE_1) - main.acceptCookies() + main.acceptCookies(1) }) it('Verify entry can be added [C56061]', () => { addressBook.clickOnCreateEntryBtn() - addressBook.typeInName(NAME) - addressBook.typeInAddress(constants.RECIPIENT_ADDRESS) - addressBook.clickOnSaveEntryBtn() - addressBook.verifyNewEntryAdded(NAME, constants.RECIPIENT_ADDRESS) + addressBook.addEntry(NAME, constants.RECIPIENT_ADDRESS) }) it('Verify entered entry in Name input can be saved [C56063]', () => { + addressBook.clickOnCreateEntryBtn() + addressBook.addEntry(NAME, constants.RECIPIENT_ADDRESS) addressBook.clickOnEditEntryBtn() addressBook.typeInNameInput(EDITED_NAME) addressBook.clickOnSaveButton() @@ -31,6 +30,8 @@ describe('Address book tests', () => { }) it('Verify entry can be deleted [C56062]', () => { + addressBook.clickOnCreateEntryBtn() + addressBook.addEntry(NAME, constants.RECIPIENT_ADDRESS) // Click the delete button in the first entry addressBook.clickDeleteEntryButton() addressBook.clickDeleteEntryModalDeleteButton() @@ -63,6 +64,8 @@ describe('Address book tests', () => { }) it('Verify the address book file can be downloaded [C56065]', () => { + addressBook.clickOnImportFileBtn() + addressBook.importFile() // Download the export file const date = format(new Date(), 'yyyy-MM-dd', { timeZone: 'UTC' }) const fileName = `safe-address-book-${date}.csv` //name that is given to the file automatically diff --git a/cypress/e2e/smoke/balances.cy.js b/cypress/e2e/smoke/balances.cy.js index 47142aa9f5..df8e1c3681 100644 --- a/cypress/e2e/smoke/balances.cy.js +++ b/cypress/e2e/smoke/balances.cy.js @@ -11,7 +11,7 @@ describe('Balance tests', () => { // Fiat balance regex const fiatRegex = balances.fiatRegex - before(() => { + beforeEach(() => { cy.clearLocalStorage() cy.visit(constants.BALANCE_URL + constants.SEPOLIA_TEST_SAFE_5) main.acceptCookies(2) @@ -114,6 +114,7 @@ describe('Balance tests', () => { }) it('Verify a token can be unhidden [C56081]', () => { + balances.hideAsset(balances.currencyDaiCap) balances.openHideTokenMenu() balances.clickOnTokenCheckbox(balances.currencyDaiCap) balances.saveHiddenTokenSelection() diff --git a/cypress/e2e/smoke/load_safe.cy.js b/cypress/e2e/smoke/load_safe.cy.js index 0ff6a0c0c8..8aaa66bede 100644 --- a/cypress/e2e/smoke/load_safe.cy.js +++ b/cypress/e2e/smoke/load_safe.cy.js @@ -19,7 +19,7 @@ const OWNER_ENS_DEFAULT_NAME = 'test20.eth' const OWNER_ADDRESS = constants.EOA describe('Load Safe tests', () => { - before(() => { + beforeEach(() => { cy.clearLocalStorage() cy.visit(constants.loadNewSafeSepoliaUrl) main.acceptCookies() @@ -39,10 +39,8 @@ describe('Load Safe tests', () => { cy.get('input[name="address"]').parent().prev('label').as('addressLabel') createwallet.verifyDefaultWalletName(createwallet.defaltSepoliaPlaceholder) - - safe.inputName(testSafeName) safe.verifyIncorrectAddressErrorMessage() - safe.inputAddress(constants.SEPOLIA_TEST_SAFE_1) + safe.inputNameAndAddress(testSafeName, constants.SEPOLIA_TEST_SAFE_1) // Type an invalid address // cy.get('input[name="address"]').clear().type(EOA_ADDRESS) @@ -65,17 +63,29 @@ describe('Load Safe tests', () => { }) it('Verify custom name in the first owner an be set [C56120]', () => { + safe.inputNameAndAddress(testSafeName, constants.SEPOLIA_TEST_SAFE_1) + safe.clickOnNextBtn() createwallet.typeOwnerName(testOwnerName, 0) safe.clickOnNextBtn() }) it('Verify Safe and owner names are displayed in the Review step [C56121]', () => { + safe.inputNameAndAddress(testSafeName, constants.SEPOLIA_TEST_SAFE_1) + safe.clickOnNextBtn() + createwallet.typeOwnerName(testOwnerName, 0) + safe.clickOnNextBtn() safe.verifyDataInReviewSection(testSafeName, testOwnerName) safe.clickOnAddBtn() }) it('Verify the custom Safe name is successfully loaded [C56122]', () => { - main.verifyHomeSafeUrl(constants.SEPOLIA_TEST_SAFE_1) + safe.inputNameAndAddress(testSafeName, constants.SEPOLIA_TEST_SAFE_2) + safe.clickOnNextBtn() + createwallet.typeOwnerName(testOwnerName, 0) + safe.clickOnNextBtn() + safe.verifyDataInReviewSection(testSafeName, testOwnerName) + safe.clickOnAddBtn() + main.verifyHomeSafeUrl(constants.SEPOLIA_TEST_SAFE_2) safe.veriySidebarSafeNameIsVisible(testSafeName) safe.verifyOwnerNamePresentInSettings(testOwnerName) }) diff --git a/cypress/e2e/smoke/tx_history.cy.js b/cypress/e2e/smoke/tx_history.cy.js index cbc49612ed..42fdbeeb44 100644 --- a/cypress/e2e/smoke/tx_history.cy.js +++ b/cypress/e2e/smoke/tx_history.cy.js @@ -20,11 +20,10 @@ describe('Transaction history tests', () => { main.acceptCookies(1) }) - it('Verify October 9th transactions are displayed [C56128]', () => { + it('Verify October 29th transactions are displayed [C56128]', () => { const DATE = 'Oct 29, 2023' const NEXT_DATE_LABEL = 'Oct 20, 2023' const amount = '0.00001 ETH' - const time = '10:39 PM' const success = 'Success' createTx.verifyDateExists(DATE) @@ -42,7 +41,6 @@ describe('Transaction history tests', () => { // Info createTx.verifyImageAltTxt(1, constants.tokenAbbreviation.sep) createTx.verifyTransactionStrExists(amount) - createTx.verifyTransactionStrExists(time) createTx.verifyTransactionStrExists(success) }) })