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

Add Replace owner tests #2580

Closed
wants to merge 6 commits into from
Closed
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
26 changes: 25 additions & 1 deletion cypress/e2e/pages/owners.pages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as constants from '../../support/constants'
import * as main from '../pages/main.page'

const copyToClipboardBtn = 'button[aria-label="Copy to clipboard"]'
const tooltipLabel = (label) => `span[aria-label="${label}"]`
const replaceOwnerBtn = 'button[aria-label="Replace owner"]'
const addOwnerBtn = 'span[data-track="settings: Add owner"]'
const tooltip = 'div[role="tooltip"]'
const expandMoreIcon = 'svg[data-testid="ExpandMoreIcon"]'
Expand All @@ -13,15 +16,34 @@ const thresHoldDropDownIcon = 'svg[data-testid="ArrowDropDownIcon"]'
const thresholdList = 'ul[role="listbox"]'

const disconnectBtnStr = 'Disconnect'
const notConnectedStatus = 'Connect'
const e2eWalletStr = 'E2E Wallet'
const max50charsLimitStr = 'Maximum 50 symbols'
const nextBtnStr = 'Next'
const executeBtnStr = 'Execute'
const backbtnStr = 'Back'
const notConnectedStatus = 'Connect'

export const safeAccountNonceStr = 'Safe Account nonce'
export const nonOwnerErrorMsg = 'Your connected wallet is not an owner of this Safe Account'
export const disconnectedUserErrorMsg = 'Please connect your wallet'

export function openReplaceOwnerWindow() {
cy.get(replaceOwnerBtn).click({ force: true })
cy.get(newOwnerName).should('be.visible')
cy.get(newOwnerAddress).should('be.visible')
cy.get(copyToClipboardBtn).parent().eq(2).find('span').contains('0x').should('be.visible')
}
export function verifyTooltipLabel(label) {
cy.get(tooltipLabel(label)).should('be.visible')
}
export function verifyReplaceBtnIsEnabled() {
cy.get(replaceOwnerBtn).should('exist').and('not.be.disabled')
}

export function hoverOverReplaceOwnerBtn() {
cy.get(replaceOwnerBtn).trigger('mouseover', { force: true })
}

export function verifyAddOwnerBtnIsEnabled() {
cy.get(addOwnerBtn).should('exist').and('not.be.disabled')
}
Expand Down Expand Up @@ -88,6 +110,8 @@ export function clickOnNextBtn() {

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

export function verifyThreshold(startValue, endValue) {
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/smoke/add_owner.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as owner from '../pages/owners.pages'
import * as addressBook from '../pages/address_book.page'


Check failure on line 6 in cypress/e2e/smoke/add_owner.cy.js

View workflow job for this annotation

GitHub Actions / ESLint Results

prettier/prettier

Delete `⏎`
// TODO: Need to add tests to testRail
describe('Adding an owner', () => {
beforeEach(() => {
Expand Down
86 changes: 86 additions & 0 deletions cypress/e2e/smoke/replace_owner.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
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('Replace an owner tests', () => {
beforeEach(() => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_1)
cy.clearLocalStorage()
main.acceptCookies()
cy.contains(owner.safeAccountNonceStr, { timeout: 10000 })
})

it('Verify that "Replace" icon is visible', () => {
owner.verifyReplaceBtnIsEnabled()
})

it('Verify Tooltip displays correct message for Non-Owner', () => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_2)
owner.waitForConnectionStatus()
owner.hoverOverReplaceOwnerBtn()
owner.verifyTooltipLabel(owner.nonOwnerErrorMsg)
})

it('Verify Tooltip displays correct message for disconnected user', () => {
owner.waitForConnectionStatus()
owner.clickOnWalletExpandMoreIcon()
owner.clickOnDisconnectBtn()
owner.hoverOverReplaceOwnerBtn()
owner.verifyTooltipLabel(owner.disconnectedUserErrorMsg)
})

it('Verify that the owner replacement form is opened', () => {
owner.waitForConnectionStatus()
owner.openReplaceOwnerWindow()
})

it('Verify max characters in name field', () => {
owner.waitForConnectionStatus()
owner.openReplaceOwnerWindow()
owner.typeOwnerName(main.generateRandomString(51))
owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.exceedChars)
})

it('Verify that Address input auto-fills with related value', () => {
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.openReplaceOwnerWindow()
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. Verify confirmation for owner replacement is displayed', () => {
owner.waitForConnectionStatus()
owner.openReplaceOwnerWindow()
owner.typeOwnerAddress(constants.SEPOLIA_OWNER_2)
owner.clickOnNextBtn()
owner.verifyConfirmTransactionWindowDisplayed()
})

it('Verify relevant error messages are displayed in Address input', () => {
owner.waitForConnectionStatus()
owner.openReplaceOwnerWindow()
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.addresBookContacts.user1.address.replace('F', 'f'))
owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.invalidChecksum)

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