Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Seedless cypress tests(normal flow) #2726

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions cypress/e2e/pages/create_wallet.pages.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as constants from '../../support/constants'

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"]'
Expand All @@ -12,11 +14,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
}
Expand Down Expand Up @@ -50,8 +52,10 @@ 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.get(welcomeLoginScreen).within(() => {
cy.get('button').contains(connectWalletBtn).should('be.visible').should('be.enabled').click().wait(1000)
})
}

export function typeWalletName(name) {
Expand All @@ -64,7 +68,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()
Expand Down Expand Up @@ -100,7 +104,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) {
Expand Down
7 changes: 4 additions & 3 deletions cypress/e2e/pages/owners.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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() {
Expand Down
35 changes: 24 additions & 11 deletions cypress/e2e/smoke/create_safe_simple.cy.js
Original file line number Diff line number Diff line change
@@ -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()
})
Expand All @@ -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)
Expand All @@ -34,42 +30,50 @@ 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()
})

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, '')
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
Loading