From c4112b759ef0775980aedc6cccb76d1261568348 Mon Sep 17 00:00:00 2001 From: mike10ca Date: Wed, 1 Nov 2023 15:53:10 +0100 Subject: [PATCH 1/4] Fix create safe tests --- cypress/e2e/pages/create_wallet.pages.js | 15 ++++++---- cypress/e2e/pages/owners.pages.js | 7 +++-- cypress/e2e/smoke/create_safe_simple.cy.js | 35 +++++++++++++++------- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/cypress/e2e/pages/create_wallet.pages.js b/cypress/e2e/pages/create_wallet.pages.js index af5ccda2ef..d68d8e1c63 100644 --- a/cypress/e2e/pages/create_wallet.pages.js +++ b/cypress/e2e/pages/create_wallet.pages.js @@ -1,5 +1,8 @@ import * as constants from '../../support/constants' +import * as owner from '../pages/owners.pages' +const welcomeLoginScreen = '[data-testid="welcome-login"]' +const expandMoreIcon = 'svg[data-testid="ExpandMoreIcon"]' const nameInput = 'input[name="name"]' const selectNetworkBtn = '[data-cy="create-safe-select-network"]' const ownerInput = 'input[name^="owners"][name$="name"]' @@ -12,11 +15,11 @@ const connectWalletBtn = 'Connect wallet' const changeNetworkWarningStr = 'Change your wallet network' const safeAccountSetupStr = 'Safe Account setup' -const policy1_2 = '1/2 policy' +const policy1_2 = '1/1 policy' export const walletName = 'test1-sepolia-safe' export const defaltSepoliaPlaceholder = 'sepolia-safe' -export function verifyPolicy1_2() { +export function verifyPolicy1_1() { cy.contains(policy1_2).should('exist') // TOD: Need data-cy for containers } @@ -50,8 +53,8 @@ export function clickOnCreateNewSafeBtn() { cy.get(createNewSafeBtn).click().wait(1000) } -export function clickOnConnectWalletAndCreateBtn() { - cy.contains('[data-testid="welcome-login"]', connectWalletBtn).click().wait(1000) +export function clickOnConnectWalletBtn() { + cy.contains(welcomeLoginScreen, connectWalletBtn).click().wait(1000) } export function typeWalletName(name) { @@ -64,7 +67,7 @@ export function clearWalletName() { export function selectNetwork(network, regex = false) { cy.wait(1000) - cy.get(selectNetworkBtn).should('be.visible').click() + cy.get(expandMoreIcon).eq(1).parents('div').eq(1).click() cy.wait(1000) cy.get('li').contains(network).click() cy.get('body').click() @@ -100,7 +103,7 @@ export function typeOwnerAddress(address, index, clearOnly = false) { } export function clickOnAddNewOwnerBtn() { - cy.contains('button', 'Add new owner').click() + cy.contains('button', 'Add new owner').click().wait(700) } export function addNewOwner(name, address, index) { diff --git a/cypress/e2e/pages/owners.pages.js b/cypress/e2e/pages/owners.pages.js index 51d0c658f6..6e2e30aef3 100644 --- a/cypress/e2e/pages/owners.pages.js +++ b/cypress/e2e/pages/owners.pages.js @@ -19,6 +19,7 @@ const thresholdDropdown = 'div[aria-haspopup="listbox"]' const thresholdOption = 'li[role="option"]' const existingOwnerAddressInput = (index) => `input[name="owners.${index}.address"]` const existingOwnerNameInput = (index) => `input[name="owners.${index}.name"]` +const singleOwnerNameInput = 'input[name="name"]' const disconnectBtnStr = 'Disconnect' const notConnectedStatus = 'Connect' @@ -57,9 +58,9 @@ export function verifyExistingOwnerName(index, name) { cy.get(existingOwnerNameInput(index)).should('have.value', name) } -export function typeExistingOwnerName(index, name) { - cy.get(existingOwnerNameInput(index)).clear().type(name) - main.verifyInputValue(existingOwnerNameInput(index), name) +export function typeExistingOwnerName(name) { + cy.get(singleOwnerNameInput).clear().type(name) + main.verifyInputValue(singleOwnerNameInput, name) } export function verifyOwnerDeletionWindowDisplayed() { diff --git a/cypress/e2e/smoke/create_safe_simple.cy.js b/cypress/e2e/smoke/create_safe_simple.cy.js index a0d1103808..7f5a8690c3 100644 --- a/cypress/e2e/smoke/create_safe_simple.cy.js +++ b/cypress/e2e/smoke/create_safe_simple.cy.js @@ -1,14 +1,11 @@ import * as constants from '../../support/constants' import * as main from '../../e2e/pages/main.page' import * as createwallet from '../pages/create_wallet.pages' - import * as owner from '../pages/owners.pages' describe('Safe creation tests', () => { - before(() => { - cy.visit(constants.welcomeUrl + '?chain=sep') - }) beforeEach(() => { + cy.visit(constants.welcomeUrl + '?chain=sep') cy.clearLocalStorage() main.acceptCookies() }) @@ -17,15 +14,14 @@ describe('Safe creation tests', () => { createwallet.clickOnCreateNewSafeBtn() owner.clickOnWalletExpandMoreIcon() owner.clickOnDisconnectBtn() - cy.url().should('include', constants.welcomeUrl) - createwallet.clickOnConnectWalletAndCreateBtn() + createwallet.clickOnConnectWalletBtn() createwallet.connectWallet() - cy.url().should('include', constants.createNewSafeSepoliaUrl) }) it('Verify Next button is disabled until switching to network is done [C56102]', () => { owner.waitForConnectionStatus() createwallet.selectNetwork(constants.networks.ethereum) + createwallet.clickOnCreateNewSafeBtn() createwallet.checkNetworkChangeWarningMsg() createwallet.verifyNextBtnIsDisabled() createwallet.selectNetwork(constants.networks.sepolia) @@ -34,11 +30,13 @@ describe('Safe creation tests', () => { it('Verify that a new Wallet has default name related to the selected network [C56099]', () => { owner.waitForConnectionStatus() + createwallet.clickOnCreateNewSafeBtn() createwallet.verifyDefaultWalletName(createwallet.defaltSepoliaPlaceholder) }) it('Verify error message is displayed if wallet name input exceeds 50 characters [C56098]', () => { owner.waitForConnectionStatus() + createwallet.clickOnCreateNewSafeBtn() createwallet.typeWalletName(main.generateRandomString(51)) owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.exceedChars) createwallet.clearWalletName() @@ -46,30 +44,36 @@ describe('Safe creation tests', () => { it('Verify there is no error message is displayed if wallet name input contains less than 50 characters [C56100]', () => { owner.waitForConnectionStatus() + createwallet.clickOnCreateNewSafeBtn() createwallet.typeWalletName(main.generateRandomString(50)) owner.verifyValidWalletName(constants.addressBookErrrMsg.exceedChars) }) it('Verify current connected account is shown as default owner [C56091]', () => { owner.waitForConnectionStatus() + createwallet.clickOnCreateNewSafeBtn() owner.clickOnNextBtn() owner.verifyExistingOwnerAddress(0, constants.DEFAULT_OWNER_ADDRESS) }) it('Verify error message is displayed if owner name input exceeds 50 characters [C56092]', () => { owner.waitForConnectionStatus() - owner.typeExistingOwnerName(0, main.generateRandomString(51)) + createwallet.clickOnCreateNewSafeBtn() + owner.typeExistingOwnerName(main.generateRandomString(51)) owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.exceedChars) }) it('Verify there is no error message is displayed if owner name input contains less than 50 characters [C56093]', () => { owner.waitForConnectionStatus() - owner.typeExistingOwnerName(0, main.generateRandomString(50)) + createwallet.clickOnCreateNewSafeBtn() + owner.typeExistingOwnerName(main.generateRandomString(50)) owner.verifyValidWalletName(constants.addressBookErrrMsg.exceedChars) }) it('Verify Add and Remove Owner Row works as expected [C56094]', () => { owner.waitForConnectionStatus() + createwallet.clickOnCreateNewSafeBtn() + owner.clickOnNextBtn() createwallet.clickOnAddNewOwnerBtn() owner.verifyNumberOfOwners(2) owner.verifyExistingOwnerAddress(1, '') @@ -82,6 +86,9 @@ describe('Safe creation tests', () => { it('Verify Threshold Setup [C56096]', () => { owner.waitForConnectionStatus() + createwallet.clickOnCreateNewSafeBtn() + owner.clickOnNextBtn() + createwallet.clickOnAddNewOwnerBtn() createwallet.clickOnAddNewOwnerBtn() owner.verifyNumberOfOwners(3) createwallet.clickOnAddNewOwnerBtn() @@ -98,6 +105,9 @@ describe('Safe creation tests', () => { it('Verify data persistence [C56103]', () => { const ownerName = 'David' owner.waitForConnectionStatus() + createwallet.clickOnCreateNewSafeBtn() + owner.clickOnNextBtn() + createwallet.clickOnAddNewOwnerBtn() createwallet.typeOwnerName(ownerName, 1) createwallet.typeOwnerAddress(constants.SEPOLIA_OWNER_2, 1) owner.clickOnBackBtn() @@ -127,12 +137,15 @@ describe('Safe creation tests', () => { it('Verify tip is displayed on right side for threshold 1/1 [C56097]', () => { owner.waitForConnectionStatus() - owner.clickOnBackBtn() - createwallet.verifyPolicy1_2() + createwallet.clickOnCreateNewSafeBtn() + owner.clickOnNextBtn() + createwallet.verifyPolicy1_1() }) it('Verify address input validation rules [C56095]', () => { owner.waitForConnectionStatus() + createwallet.clickOnCreateNewSafeBtn() + owner.clickOnNextBtn() createwallet.clickOnAddNewOwnerBtn() createwallet.typeOwnerAddress(main.generateRandomString(10), 1) owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.invalidFormat) From f45e120b36a8b5996490abbb1399f88839e8d616 Mon Sep 17 00:00:00 2001 From: mike10ca Date: Thu, 2 Nov 2023 09:14:38 +0100 Subject: [PATCH 2/4] Remove unused import --- cypress/e2e/pages/create_wallet.pages.js | 1 - 1 file changed, 1 deletion(-) diff --git a/cypress/e2e/pages/create_wallet.pages.js b/cypress/e2e/pages/create_wallet.pages.js index d68d8e1c63..82bb018f60 100644 --- a/cypress/e2e/pages/create_wallet.pages.js +++ b/cypress/e2e/pages/create_wallet.pages.js @@ -1,5 +1,4 @@ import * as constants from '../../support/constants' -import * as owner from '../pages/owners.pages' const welcomeLoginScreen = '[data-testid="welcome-login"]' const expandMoreIcon = 'svg[data-testid="ExpandMoreIcon"]' From ae195abff861414ccbd3b0ae1ced8340d8f15a6b Mon Sep 17 00:00:00 2001 From: mike10ca Date: Thu, 2 Nov 2023 10:40:52 +0100 Subject: [PATCH 3/4] Fix waiting issue --- cypress/e2e/pages/create_wallet.pages.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/pages/create_wallet.pages.js b/cypress/e2e/pages/create_wallet.pages.js index 82bb018f60..cc64b05bb8 100644 --- a/cypress/e2e/pages/create_wallet.pages.js +++ b/cypress/e2e/pages/create_wallet.pages.js @@ -53,7 +53,11 @@ export function clickOnCreateNewSafeBtn() { } export function clickOnConnectWalletBtn() { - cy.contains(welcomeLoginScreen, connectWalletBtn).click().wait(1000) + cy.get(welcomeLoginScreen).within(() => { + cy.get('button').contains(connectWalletBtn).should('be.visible').should('be.enabled').click().wait(1000) + }) + + // cy.contains(welcomeLoginScreen, connectWalletBtn).should('be.visible').should('be.enabled').click().wait(1000) } export function typeWalletName(name) { From f39604832729f91f4dc3a52a2bd66bb9d60dcba4 Mon Sep 17 00:00:00 2001 From: mike10ca Date: Thu, 2 Nov 2023 10:49:27 +0100 Subject: [PATCH 4/4] Cleanup --- cypress/e2e/pages/create_wallet.pages.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/cypress/e2e/pages/create_wallet.pages.js b/cypress/e2e/pages/create_wallet.pages.js index cc64b05bb8..f0764b37f2 100644 --- a/cypress/e2e/pages/create_wallet.pages.js +++ b/cypress/e2e/pages/create_wallet.pages.js @@ -56,8 +56,6 @@ export function clickOnConnectWalletBtn() { cy.get(welcomeLoginScreen).within(() => { cy.get('button').contains(connectWalletBtn).should('be.visible').should('be.enabled').click().wait(1000) }) - - // cy.contains(welcomeLoginScreen, connectWalletBtn).should('be.visible').should('be.enabled').click().wait(1000) } export function typeWalletName(name) {