Skip to content

Commit

Permalink
Create Sepolia wallets and add more "Add owner" tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mike10ca committed Sep 27, 2023
1 parent 1848b43 commit aa700ec
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/pages/address_book.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function clickOnCreateEntryBtn() {
cy.contains(createEntryBtn).click()
}

export function tyeInName(name) {
export function typeInName(name) {
cy.get(nameInput).type(name)
}

Expand Down
19 changes: 19 additions & 0 deletions cypress/e2e/pages/main.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,22 @@ export function checkTextsExistWithinElement(element, texts) {
export function verifyCheckboxeState(element, index, state) {
cy.get(element).eq(index).should(state)
}

export function verifyInputValue(selector, value) {
cy.get(selector)
.invoke('val')
.should(($value) => {
console.log($value)
})
}

export function generateRandomString(length) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZz0123456789'
let result = ''

for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * characters.length))
}

return result
}
65 changes: 62 additions & 3 deletions cypress/e2e/pages/owners.pages.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import * as main from '../../support/constants'
import * as constants from '../../support/constants'
import * as main from '../pages/main.page'

const addOwnerBtn = 'span[data-track="settings: Add owner"]'
const tooltip = 'div[role="tooltip"]'
const expandMoreIcon = 'svg[data-testid="ExpandMoreIcon"]'
const sentinelStart = 'div[data-testid="sentinelStart"]'
const newOwnerName = 'input[name="newOwner.name"]'
const newOwnerAddress = 'input[name="newOwner.address"]'
const newOwnerNonceInput = 'input[name="nonce"]'
const thresholdInput = 'input[name="threshold"]'
const thresHoldDropDownIcon = 'svg[data-testid="ArrowDropDownIcon"]'
const thresholdList = 'ul[role="listbox"]'

const disconnectBtnStr = 'Disconnect'
const notConnectedStatus = 'Not connected'
const e2eWalletStr = 'E2E Wallet'
const max50charsLimitStr = 'Maximum 50 symbols'
const nextBtnStr = 'Next'

export const safeAccountNonceStr = 'Safe Account nonce'
export const nonOwnerErrorMsg = 'Your connected wallet is not an owner of this Safe Account'
Expand All @@ -16,8 +26,8 @@ export function verifyAddOwnerBtnIsEnabled() {
cy.get(addOwnerBtn).should('exist').and('not.be.disabled')
}

export function hoverOverAddOwnerbtn() {
return cy.get(addOwnerBtn).trigger('mouseover')
export function hoverOverAddOwnerBtn() {
cy.get(addOwnerBtn).trigger('mouseover')
}

export function verifyTooltiptext(text) {
Expand All @@ -37,3 +47,52 @@ export function clickOnDisconnectBtn() {
export function waitForConnectionStatus() {
cy.get('div').contains(e2eWalletStr)
}

export function openAddOwnerWindow() {
cy.get(addOwnerBtn).click()
cy.get(newOwnerName).should('be.visible')
cy.get(newOwnerAddress).should('be.visible')
}

export function verifyNonceInputValue(value) {
cy.get(newOwnerNonceInput).should('not.be.disabled')
main.verifyInputValue(newOwnerNonceInput, value)
}

export function verifyErrorMsgInvalidAddress(errorMsg) {
cy.get('label').contains(errorMsg).should('be.visible')
}

export function typeOwnerAddress(address) {
cy.get(newOwnerAddress).clear().type(address)
main.verifyInputValue(newOwnerAddress, address)
cy.wait(1000)
}

export function typeOwnerName(name) {
cy.get(newOwnerName).clear().type(name)
main.verifyInputValue(newOwnerName, name)
}

export function selectNewOwner(name) {
cy.contains(name).click()
}

export function verifyNewOwnerName(name) {
cy.get(newOwnerName).should('have.attr', 'placeholder', name)
}

export function clickOnNextBtn() {
cy.get('button').contains(nextBtnStr).click()
}

export function verifyConfirmTransactionWindowDisplayed() {
cy.get('div').contains(constants.transactionStatus.confirm).should('exist')
}

export function verifyThreshold(startValue, endValue) {
main.verifyInputValue(thresholdInput, startValue)
cy.get('p').contains(`out of ${endValue} owner(s)`).should('be.visible')
cy.get(thresholdInput).parent().click()
cy.get(thresholdList).contains(endValue).should('be.visible')
}
69 changes: 65 additions & 4 deletions cypress/e2e/smoke/add_owner.cy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as constants from '../../support/constants'
import * as main from '../../e2e/pages/main.page'
import * as owner from '../pages/owners.pages'
import * as addressBook from '../pages/address_book.page'

describe('Adding an owner', () => {
beforeEach(() => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_1)
cy.clearLocalStorage()
cy.visit(constants.setupUrl + constants.GOERLI_TEST_SAFE)
main.acceptCookies()
cy.contains(owner.safeAccountNonceStr, { timeout: 10000 })
})
Expand All @@ -16,17 +17,77 @@ describe('Adding an owner', () => {
})

it('Verify “Add new owner” button tooltip displays correct message for Non-Owner', () => {
cy.visit(constants.setupUrl + constants.TEST_SAFE_2)
owner.hoverOverAddOwnerbtn()
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_2)
owner.hoverOverAddOwnerBtn()
owner.verifyTooltiptext(owner.nonOwnerErrorMsg)
})

it('Verify Tooltip displays correct message for disconnected user', () => {
owner.waitForConnectionStatus()
owner.clickOnWalletExpandMoreIcon()
owner.clickOnDisconnectBtn()
owner.hoverOverAddOwnerbtn()
owner.hoverOverAddOwnerBtn()
owner.verifyTooltiptext(owner.disconnectedUserErrorMsg)
})
it('Verify the Add New Owner Form can be opened', () => {
owner.waitForConnectionStatus()
owner.openAddOwnerWindow()
})

it('Verify error message displayed if character limit is exceeded in Name input', () => {
owner.waitForConnectionStatus()
owner.openAddOwnerWindow()
owner.typeOwnerName(main.generateRandomString(51))
owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.exceedChars)
})

it('Verify that the "Name" field is auto-filled with the relevant name from Address Book', () => {
cy.visit(constants.addressBookUrl + constants.SEPOLIA_TEST_SAFE_1)
addressBook.clickOnCreateEntryBtn()
addressBook.typeInName(constants.addresBookContacts.user1.name)
addressBook.typeInAddress(constants.addresBookContacts.user1.address)
addressBook.clickOnSaveEntryBtn()
addressBook.verifyNewEntryAdded(
constants.addresBookContacts.user1.name,
constants.addresBookContacts.user1.address,
)
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_1)
owner.waitForConnectionStatus()
owner.openAddOwnerWindow()
owner.typeOwnerAddress(constants.addresBookContacts.user1.address)
owner.selectNewOwner(constants.addresBookContacts.user1.name)
owner.verifyNewOwnerName(constants.addresBookContacts.user1.name)
})

it('Verify that Name field not mandatory', () => {
owner.waitForConnectionStatus()
owner.openAddOwnerWindow()
owner.typeOwnerAddress(constants.addresBookContacts.user2.address)
owner.clickOnNextBtn()
owner.verifyConfirmTransactionWindowDisplayed()
})

it('Verify relevant error messages are displayed in Address input ', () => {
owner.waitForConnectionStatus()
owner.openAddOwnerWindow()
owner.typeOwnerAddress(main.generateRandomString(10))
owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.invalidFormat)

owner.typeOwnerAddress(constants.addresBookContacts.user1.address.toUpperCase())
owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.invalidChecksum)

owner.typeOwnerAddress(constants.SEPOLIA_TEST_SAFE_1)
owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.ownSafe)

owner.typeOwnerAddress(constants.DEFAULT_OWNER_ADDRESS)
owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.alreadyAdded)
})

it('Verify default threshold value. Verify correct threshold calculation', () => {
owner.waitForConnectionStatus()
owner.openAddOwnerWindow()
owner.typeOwnerAddress(constants.DEFAULT_OWNER_ADDRESS)
owner.verifyThreshold(1, 2)
})
})
})
2 changes: 1 addition & 1 deletion cypress/e2e/smoke/address_book.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Address book tests', () => {
describe('should add remove and edit entries in the address book', () => {
it('should add an entry', () => {
addressBook.clickOnCreateEntryBtn()
addressBook.tyeInName(NAME)
addressBook.typeInName(NAME)
addressBook.typeInAddress(constants.RECIPIENT_ADDRESS)
addressBook.clickOnSaveEntryBtn()
addressBook.verifyNewEntryAdded(NAME, constants.RECIPIENT_ADDRESS)
Expand Down
27 changes: 27 additions & 0 deletions cypress/support/constants.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { LS_NAMESPACE } from '../../src/config/constants'
export const RECIPIENT_ADDRESS = '0x6a5602335a878ADDCa4BF63a050E34946B56B5bC'
export const GOERLI_TEST_SAFE = 'gor:0x97d314157727D517A706B5D08507A1f9B44AaaE9'
export const SEPOLIA_TEST_SAFE_1 = 'sep:0xBb26E3717172d5000F87DeFd391994f789D80aEB'
// SEPOLIA_TEST_SAFE_2 Has no transactions, 1 owner, using for verificatons only
export const SEPOLIA_TEST_SAFE_2 = 'sep:0x33C4AA5729D91FfB3B87AEf8a324bb6304Fb905c'
export const GNO_TEST_SAFE = 'gno:0xB8d760a90a5ed54D3c2b3EFC231277e99188642A'
export const PAGINATION_TEST_SAFE = 'gor:0x850493a15914aAC05a821A3FAb973b4598889A7b'
export const TEST_SAFE = 'gor:0x04f8b1EA3cBB315b87ced0E32deb5a43cC151a91'
export const EOA = '0xE297437d6b53890cbf004e401F3acc67c8b39665'
export const DEFAULT_OWNER_ADDRESS = '0xC16Db0251654C0a72E91B190d81eAD367d2C6fED'
export const SEPOLIA_OWNER_2 = '0x96D4c6fFC338912322813a77655fCC926b9A5aC5'
export const TEST_SAFE_2 = 'gor:0xE96C43C54B08eC528e9e815fC3D02Ea94A320505'
export const SIDEBAR_ADDRESS = '0x04f8...1a91'

Expand Down Expand Up @@ -82,8 +86,31 @@ export const transactionStatus = {
approve: 'Approve',
success: 'Success',
interaction: 'Contract interaction',
confirm: 'Confirm transaction',
}

export const tokenNames = {
wrappedEther: 'Wrapped Ether',
}

export const addressBookErrrMsg = {
invalidFormat: 'Invalid address format',
invalidChecksum: 'Invalid address checksum',
exceedChars: 'Maximum 50 symbols',
ownSafe: 'Cannot use Safe Account itself as owner',
alreadyAdded: 'Address already added',
}
export const addresBookContacts = {
user1: {
address: '0x01A9F68e339da12565cfBc47fe7D6EdEcB11C46f',
name: 'David',
},
user2: {
address: 'francotest.eth',
name: 'Franco ESN',
},
}

export const localStorageKeys = {
SAFE_v2__addressBook: 'SAFE_v2__addressBook',
}

0 comments on commit aa700ec

Please sign in to comment.