Skip to content

Commit

Permalink
Tests: Add incoming tx history tests (#4615)
Browse files Browse the repository at this point in the history
  • Loading branch information
mike10ca authored Dec 5, 2024
1 parent 74fe854 commit fa245b7
Show file tree
Hide file tree
Showing 17 changed files with 503 additions and 140 deletions.
79 changes: 49 additions & 30 deletions cypress/e2e/pages/create_tx.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,17 @@ export function verifyNumberOfCopyIcons(number) {
}

export function verifyNumberOfExternalLinks(number) {
for (let i = 0; i <= number; i++) {
cy.get(copyIcon).parent().parent().next().should('be.visible')
cy.get(copyIcon)
.parent()
.parent()
.next()
.children()
.should('have.attr', 'href')
.and('include', constants.sepoliaEtherscanlLink)
}
cy.get(copyIcon)
.parent()
.parent()
.next()
.children('a')
.then(($links) => {
expect($links.length).to.be.at.least(number)
for (let i = 0; i < number; i++) {
cy.wrap($links[i]).should('have.attr', 'href').and('include', constants.etherscanlLink)
}
})
}

export function clickOnTransactionItemByName(name, token) {
Expand Down Expand Up @@ -346,29 +347,47 @@ export function verifySpamIconIsDisplayed(name, token) {
}

export function verifySummaryByName(name, token, data, alt, altToken) {
cy.get(transactionItem)
.filter(':contains("' + name + '")')
.then(($elements) => {
if (token) {
$elements = $elements.filter(':contains("' + token + '")')
}
if (!name) {
throw new Error('Name parameter is required for verification')
}

if ($elements.length > 0) {
cy.wrap($elements.first()).then(($element) => {
if (Array.isArray(data)) {
data.forEach((text) => {
cy.wrap($element).contains(text).should('be.visible')
})
} else {
cy.wrap($element).contains(data).should('be.visible')
}
if (alt) cy.wrap($element).find('img').eq(0).should('have.attr', 'alt', alt).should('be.visible')
if (altToken) cy.wrap($element).find('img').eq(1).should('have.attr', 'alt', alt).should('be.visible')
})
let selector = `${transactionItem}:contains("${name}")`
if (token) {
selector += `:contains("${token}")`
}

cy.get(selector).then(($elements) => {
expect($elements.length, `Transaction items found for name: ${name}`).to.be.greaterThan(0)

const $element = $elements.first()

if (Array.isArray(data)) {
data.forEach((text) => {
expect($element.text()).to.include(text)
})
} else if (data) {
expect($element.text()).to.include(data)
}

if (alt) {
const firstImg = $element.find('img')
const firstSvg = $element.find('svg')

if (firstImg.length > 0) {
const targetImg = firstImg.first()
expect(targetImg.attr('alt')).to.equal(alt)
} else if (firstSvg.length > 0) {
const targetSvg = firstSvg.first()
expect(targetSvg.attr('alt')).to.equal(alt)
}
})
}
}

if (altToken) {
const secondImg = $element.find('img').eq(1)
expect(secondImg.attr('alt')).to.equal(altToken)
}
})
}
export function verifySummaryByIndex(index, data, alt) {
cy.get(messageItem)
.eq(index)
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/pages/sidebar.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export function verifyEtherscanLinkExists() {
cy.get(sidebarContainer)
.should('be.visible')
.within(() => {
cy.get(explorerBtn).should('have.attr', 'href').and('include', constants.sepoliaEtherscanlLink)
cy.get(explorerBtn).should('have.attr', 'href').and('include', constants.etherscanlLink)
})
}

Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/prodhealthcheck/messages_onchain.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ describe('[PROD] Onchain Messages tests', () => {
it('Verify summary for signed on-chain message', () => {
createTx.verifySummaryByName(
typeMessagesOnchain.contractName,
null,
[typeMessagesOnchain.success, typeMessagesOnchain.signMessage],
typeMessagesOnchain.altTmage,
typeMessagesOnchain.altImage,
)
})
})
5 changes: 3 additions & 2 deletions cypress/e2e/prodhealthcheck/tx_history.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ describe('[PROD] Tx history tests 1', () => {
it('Verify summary for account creation', () => {
createTx.verifySummaryByName(
typeCreateAccount.title,
null,
[typeCreateAccount.actionsSummary, typeGeneral.statusOk],
typeCreateAccount.altTmage,
typeCreateAccount.altImage,
)
})

Expand Down Expand Up @@ -78,7 +79,7 @@ describe('[PROD] Tx history tests 1', () => {
typeSpendingLimits.title,
typeSpendingLimits.summaryTxInfo,
[typeGeneral.statusOk],
typeSpendingLimits.altTmage,
typeSpendingLimits.altImage,
)
})

Expand Down
14 changes: 5 additions & 9 deletions cypress/e2e/prodhealthcheck/tx_history_2.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ describe('[PROD] Tx history tests 2', () => {

// Add owner
it('Verify summary for adding owner', () => {
createTx.verifySummaryByName(typeAddOwner.title, [typeGeneral.statusOk], typeAddOwner.altImage)
createTx.verifySummaryByName(typeAddOwner.title, null, [typeGeneral.statusOk], typeAddOwner.altImage)
})

// Change owner
it('Verify summary for changing owner', () => {
createTx.verifySummaryByName(typeChangeOwner.title, [typeGeneral.statusOk], typeChangeOwner.altImage)
createTx.verifySummaryByName(typeChangeOwner.title, null, [typeGeneral.statusOk], typeChangeOwner.altImage)
})

it('Verify exapanded details for changing owner', () => {
Expand All @@ -93,21 +93,17 @@ describe('[PROD] Tx history tests 2', () => {

// Remove owner
it('Verify summary for removing owner', () => {
createTx.verifySummaryByName(typeRemoveOwner.title, [typeGeneral.statusOk], typeRemoveOwner.altImage)
createTx.verifySummaryByName(typeRemoveOwner.title, null, [typeGeneral.statusOk], typeRemoveOwner.altImage)
})

// Disbale module
it('Verify summary for disable module', () => {
createTx.verifySummaryByName(typeDisableOwner.title, [typeGeneral.statusOk], typeDisableOwner.altImage)
createTx.verifySummaryByName(typeDisableOwner.title, null, [typeGeneral.statusOk], typeDisableOwner.altImage)
})

// Change threshold
it('Verify summary for changing threshold', () => {
createTx.verifySummaryByName(
typeChangeThreshold.title,
[typeChangeThreshold.summaryTxInfo, typeGeneral.statusOk],
typeChangeThreshold.altImage,
)
createTx.verifySummaryByName(typeChangeThreshold.title, null, [typeGeneral.statusOk], typeChangeThreshold.altImage)
})

it('Verify exapanded details for changing threshold', () => {
Expand Down
8 changes: 5 additions & 3 deletions cypress/e2e/regression/messages_onchain.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,19 @@ describe('Onchain Messages tests', () => {
cy.visit(constants.transactionQueueUrl + staticSafes.SEP_STATIC_SAFE_10)
createTx.verifySummaryByName(
typeMessagesOnchain.contractName,
null,
[typeMessagesOnchain.oneOftwo, typeMessagesOnchain.signMessage],
typeMessagesOnchain.altTmage,
typeMessagesOnchain.altImage,
)
})

// Added to prod
it('Verify summary for signed on-chain message', () => {
createTx.verifySummaryByName(
typeMessagesOnchain.contractName,
[typeMessagesOnchain.success, typeMessagesOnchain.signMessage],
typeMessagesOnchain.altTmage,
null,
[(typeMessagesOnchain.success, typeMessagesOnchain.signMessage)],
typeMessagesOnchain.altImage,
)
})
})
79 changes: 0 additions & 79 deletions cypress/e2e/regression/sidebar_3.cy.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import * as constants from '../../support/constants.js'
import * as main from '../pages/main.page.js'
import * as sideBar from '../pages/sidebar.pages.js'
import * as ls from '../../support/localstorage_data.js'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'
import * as wallet from '../../support/utils/wallet.js'
import * as create_wallet from '../pages/create_wallet.pages.js'
import * as navigation from '../pages/navigation.page.js'
import * as owner from '../pages/owners.pages.js'

let staticSafes = []
const walletCredentials = JSON.parse(Cypress.env('CYPRESS_WALLET_CREDENTIALS'))
const signer = walletCredentials.OWNER_4_PRIVATE_KEY
const signer1 = walletCredentials.OWNER_1_PRIVATE_KEY
const signer2 = walletCredentials.OWNER_3_PRIVATE_KEY

describe('Sidebar tests 3', () => {
before(async () => {
Expand Down Expand Up @@ -64,77 +58,4 @@ describe('Sidebar tests 3', () => {
sideBar.openSidebar()
sideBar.verifySafeGiveNameOptionExists(0)
})

it('Verify Import/export buttons are present', () => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__addressBook, ls.addressBookData.addedSafes)
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_9)
cy.intercept('GET', constants.safeListEndpoint, {
11155111: [sideBar.sideBarSafes.safe1, sideBar.sideBarSafes.safe2],
})
wallet.connectSigner(signer)
sideBar.openSidebar()
main.checkButtonByTextExists(sideBar.importBtnStr)
main.checkButtonByTextExists(sideBar.exportBtnStr)
})

// Added to prod
it('Verify the "Accounts" counter at the top is counting all safes the user owns', () => {
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_9)
cy.intercept('GET', constants.safeListEndpoint, {
11155111: [sideBar.sideBarSafes.safe1, sideBar.sideBarSafes.safe2],
})
wallet.connectSigner(signer)
sideBar.openSidebar()
sideBar.checkAccountsCounter('2')
})

it('Verify that safes the user do not owns show in the watchlist after adding them', () => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__addedSafes, ls.addedSafes.set4)
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_9)
wallet.connectSigner(signer1)
sideBar.openSidebar()
sideBar.verifyAddedSafesExist([sideBar.sideBarSafes.safe3short])
})

it('Verify that safes that the user owns do show in the watchlist after adding them', () => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__addedSafes, ls.addedSafes.set4)
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_9)
wallet.connectSigner(signer1)
sideBar.openSidebar()
sideBar.verifyAddedSafesExist([sideBar.sideBarSafes.safe3short])
})

// Added to prod
it('Verify pending signature is displayed in sidebar for unsigned tx', () => {
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_7)
wallet.connectSigner(signer)
cy.intercept('GET', constants.safeListEndpoint, {
11155111: [sideBar.sideBarSafesPendingActions.safe1],
})
sideBar.openSidebar()
sideBar.verifyTxToConfirmDoesNotExist()
owner.clickOnWalletExpandMoreIcon()
navigation.clickOnDisconnectBtn()
cy.intercept('GET', constants.safeListEndpoint, {
11155111: [sideBar.sideBarSafesPendingActions.safe1],
})
wallet.connectSigner(signer2)
sideBar.verifyAddedSafesExist([sideBar.sideBarSafesPendingActions.safe1short])
sideBar.checkTxToConfirm(1)
})

// Added to prod
it('Verify balance exists in a tx in sidebar', () => {
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_7)
wallet.connectSigner(signer)
owner.clickOnWalletExpandMoreIcon()
navigation.clickOnDisconnectBtn()
wallet.connectSigner(signer)
cy.intercept('GET', constants.safeListEndpoint, {
11155111: [sideBar.sideBarSafesPendingActions.safe1],
})
sideBar.openSidebar()
sideBar.verifyTxToConfirmDoesNotExist()
sideBar.checkBalanceExists()
})
})
93 changes: 93 additions & 0 deletions cypress/e2e/regression/sidebar_7.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import * as constants from '../../support/constants.js'
import * as main from '../pages/main.page.js'
import * as sideBar from '../pages/sidebar.pages.js'
import * as ls from '../../support/localstorage_data.js'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'
import * as wallet from '../../support/utils/wallet.js'
import * as navigation from '../pages/navigation.page.js'
import * as owner from '../pages/owners.pages.js'

let staticSafes = []
const walletCredentials = JSON.parse(Cypress.env('CYPRESS_WALLET_CREDENTIALS'))
const signer = walletCredentials.OWNER_4_PRIVATE_KEY
const signer1 = walletCredentials.OWNER_1_PRIVATE_KEY
const signer2 = walletCredentials.OWNER_3_PRIVATE_KEY

describe('Sidebar tests 7', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
})

it('Verify Import/export buttons are present', () => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__addressBook, ls.addressBookData.addedSafes)
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_9)
cy.intercept('GET', constants.safeListEndpoint, {
11155111: [sideBar.sideBarSafes.safe1, sideBar.sideBarSafes.safe2],
})
wallet.connectSigner(signer)
sideBar.openSidebar()
main.checkButtonByTextExists(sideBar.importBtnStr)
main.checkButtonByTextExists(sideBar.exportBtnStr)
})

// Added to prod
it('Verify the "Accounts" counter at the top is counting all safes the user owns', () => {
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_9)
cy.intercept('GET', constants.safeListEndpoint, {
11155111: [sideBar.sideBarSafes.safe1, sideBar.sideBarSafes.safe2],
})
wallet.connectSigner(signer)
sideBar.openSidebar()
sideBar.checkAccountsCounter('2')
})

it('Verify that safes the user do not owns show in the watchlist after adding them', () => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__addedSafes, ls.addedSafes.set4)
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_9)
wallet.connectSigner(signer1)
sideBar.openSidebar()
sideBar.verifyAddedSafesExist([sideBar.sideBarSafes.safe3short])
})

it('Verify that safes that the user owns do show in the watchlist after adding them', () => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__addedSafes, ls.addedSafes.set4)
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_9)
wallet.connectSigner(signer1)
sideBar.openSidebar()
sideBar.verifyAddedSafesExist([sideBar.sideBarSafes.safe3short])
})

// Added to prod
it('Verify pending signature is displayed in sidebar for unsigned tx', () => {
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_7)
wallet.connectSigner(signer)
cy.intercept('GET', constants.safeListEndpoint, {
11155111: [sideBar.sideBarSafesPendingActions.safe1],
})
sideBar.openSidebar()
sideBar.verifyTxToConfirmDoesNotExist()
owner.clickOnWalletExpandMoreIcon()
navigation.clickOnDisconnectBtn()
cy.intercept('GET', constants.safeListEndpoint, {
11155111: [sideBar.sideBarSafesPendingActions.safe1],
})
wallet.connectSigner(signer2)
sideBar.verifyAddedSafesExist([sideBar.sideBarSafesPendingActions.safe1short])
sideBar.checkTxToConfirm(1)
})

// Added to prod
it('Verify balance exists in a tx in sidebar', () => {
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_7)
wallet.connectSigner(signer)
owner.clickOnWalletExpandMoreIcon()
navigation.clickOnDisconnectBtn()
wallet.connectSigner(signer)
cy.intercept('GET', constants.safeListEndpoint, {
11155111: [sideBar.sideBarSafesPendingActions.safe1],
})
sideBar.openSidebar()
sideBar.verifyTxToConfirmDoesNotExist()
sideBar.checkBalanceExists()
})
})
Loading

0 comments on commit fa245b7

Please sign in to comment.