Skip to content

Commit

Permalink
History tests - part 2 (#2980)
Browse files Browse the repository at this point in the history
Add more tx history tests
  • Loading branch information
mike10ca authored Dec 7, 2023
1 parent 28fcf00 commit 2a408ae
Show file tree
Hide file tree
Showing 8 changed files with 285 additions and 79 deletions.
15 changes: 13 additions & 2 deletions cypress/e2e/pages/create_tx.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as constants from '../../support/constants'
import * as main from '../pages/main.page'

export const delegateCallWarning = '[data-testid="delegate-call-warning"]'
export const policyChangeWarning = '[data-testid="threshold-warning"]'
const newTransactionBtnStr = 'New transaction'
const recepientInput = 'input[name="recipient"]'
const sendTokensBtnStr = 'Send tokens'
Expand All @@ -10,7 +11,6 @@ const amountInput = 'input[name="amount"]'
const nonceInput = 'input[name="nonce"]'
const gasLimitInput = '[name="gasLimit"]'
const rotateLeftIcon = '[data-testid="RotateLeftIcon"]'
const transactionActionsList = '[data-testid="transaction-actions-list"]'
const transactionItem = '[data-testid="transaction-item"]'
const connectedWalletExecMethod = '[data-testid="connected-wallet-execution-method"]'
const addToBatchBtn = '[data-track="batching: Add to batch"]'
Expand All @@ -25,6 +25,8 @@ const collapseAllBtn = '[data-testid="collapse-all-btn"]'
const txRowTitle = '[data-testid="tx-row-title"]'
const advancedDetails = '[data-testid="tx-advanced-details"]'
const baseGas = '[data-testid="tx-bas-gas"]'
const requiredConfirmation = '[data-testid="required-confirmations"]'
const txDate = '[data-testid="tx-date"]'

const viewTransactionBtn = 'View transaction'
const transactionDetailsTitle = 'Transaction details'
Expand All @@ -46,6 +48,15 @@ const signBtnStr = 'Sign'
const expandAllBtnStr = 'Expand all'
const collapseAllBtnStr = 'Collapse all'

export function verifyNumberOfTransactions(count) {
cy.get(txDate).should('have.length.at.least', count)
cy.get(transactionItem).should('have.length.at.least', count)
}

export function checkRequiredThreshold(count) {
cy.get(requiredConfirmation).should('be.visible').and('include.text', count)
}

export function verifyCopyIconWorks(index, data) {
cy.get(copyIcon)
.parent()
Expand Down Expand Up @@ -168,7 +179,7 @@ export function clickOnTransactionItem(item) {
}

export function verifyTransactionActionsVisibility(option) {
cy.get(transactionActionsList).should(option)
cy.get(transactionSideList).should(option)
}

export function clickOnNewtransactionBtn() {
Expand Down
10 changes: 6 additions & 4 deletions cypress/e2e/pages/main.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function clickOnSideMenuItem(item) {
cy.get('p').contains(item).click()
}

export function waitForTrnsactionHistoryToComplete() {
export function waitForHistoryCallToComplete() {
cy.intercept('GET', constants.transactionHistoryEndpoint).as('History')
cy.wait('@History')
}
Expand Down Expand Up @@ -51,9 +51,11 @@ export function verifyHomeSafeUrl(safe) {

export function checkTextsExistWithinElement(element, texts) {
texts.forEach((text) => {
cy.get(element).within(() => {
cy.get('div').contains(text).should('be.visible')
})
cy.get(element)
.should('be.visible')
.within(() => {
cy.get('div').contains(text).should('be.visible')
})
})
}

Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/regression/remove_owner.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as owner from '../pages/owners.pages'
describe('Remove Owners tests', () => {
beforeEach(() => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_3)
main.waitForTrnsactionHistoryToComplete()
main.waitForHistoryCallToComplete()
cy.clearLocalStorage()
main.acceptCookies()
owner.waitForConnectionStatus()
Expand All @@ -18,7 +18,7 @@ describe('Remove Owners tests', () => {

it('Verify Tooltip displays correct message for Non-Owner', () => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_4)
main.waitForTrnsactionHistoryToComplete()
main.waitForHistoryCallToComplete()
owner.waitForConnectionStatus()
owner.verifyRemoveBtnIsDisabled()
})
Expand Down
35 changes: 15 additions & 20 deletions cypress/e2e/regression/tx_history.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ const typeDeleteAllowance = data.type.deleteSpendingLimit
const typeSideActions = data.type.sideActions
const typeGeneral = data.type.general

describe('Transaction history tests', () => {
describe('Tx history tests 1', () => {
beforeEach(() => {
cy.clearLocalStorage()
cy.visit(constants.transactionsHistoryUrl + constants.SEPOLIA_TEST_SAFE_8)
main.acceptCookies()
})

// Contract creation
// Account creation
it('Verify summary for account creation', () => {
createTx.verifySummaryByName(
typeCreateAccount.title,
[typeCreateAccount.actionsSummary, typeCreateAccount.summaryTime, typeGeneral.statusOk],
[typeCreateAccount.actionsSummary, typeGeneral.statusOk],
typeCreateAccount.altTmage,
)
})

it('Verify exapnded details for account creation', () => {
it('Verify exapanded details for account creation', () => {
createTx.clickOnTransactionItemByName(typeCreateAccount.title)
createTx.verifyExpandedDetails([
typeCreateAccount.creator.actionTitle,
Expand Down Expand Up @@ -61,13 +61,13 @@ describe('Transaction history tests', () => {
it('Verify summary for token receipt', () => {
createTx.verifySummaryByIndex(
txItemIndex,
[typeReceive.title, typeReceive.summaryTxInfo, typeReceive.summaryTime, typeGeneral.statusOk],
[typeReceive.title, typeReceive.summaryTxInfo, typeGeneral.statusOk],
typeReceive.altImage,
typeReceive.altToken,
)
})

it('Verify exapnded details for token receipt', () => {
it('Verify exapanded details for token receipt', () => {
createTx.clickOnTransactionItemByIndex(txItemIndex)
createTx.verifyExpandedDetails([
typeReceive.title,
Expand All @@ -87,13 +87,13 @@ describe('Transaction history tests', () => {
it('Verify summary for token send', () => {
createTx.verifySummaryByName(
typeSend.title,
[typeSend.summaryTxInfo, typeSend.summaryTime, typeGeneral.statusOk],
[typeSend.summaryTxInfo, typeGeneral.statusOk],
typeSend.altImage,
typeSend.altToken,
)
})

it('Verify exapnded details for token send', () => {
it('Verify exapanded details for token send', () => {
createTx.clickOnTransactionItemByName(typeSend.title)
createTx.verifyExpandedDetails([typeSend.sentTo, typeSend.recipientAddress, typeSend.transactionHash])
createTx.verifyActionListExists([
Expand All @@ -103,21 +103,16 @@ describe('Transaction history tests', () => {
])
})

// Contract interaction
// Spending limits
it('Verify summary for setting spend limits', () => {
createTx.verifySummaryByIndex(
initialSpendingLimitsTx,
[
typeSpendingLimits.title,
typeSpendingLimits.summaryTxInfo,
typeSpendingLimits.summaryTime,
typeGeneral.statusOk,
],
[typeSpendingLimits.title, typeSpendingLimits.summaryTxInfo, typeGeneral.statusOk],
typeSpendingLimits.altImage,
)
})

it('Verify exapnded details for initial spending limits setup', () => {
it('Verify exapanded details for initial spending limits setup', () => {
createTx.clickOnTransactionItemByIndex(initialSpendingLimitsTx)
createTx.verifyExpandedDetails(
[
Expand Down Expand Up @@ -160,16 +155,16 @@ describe('Transaction history tests', () => {
createTx.collapseAllActions([typeSpendingLimits.addDelegate.delegateAddressTitle])
})

// Contract interaction
// Spending limit deletion
it('Verify summary for allowance deletion', () => {
createTx.verifySummaryByName(
typeDeleteAllowance.title,
[typeDeleteAllowance.summaryTxInfo, typeDeleteAllowance.summaryTime, typeGeneral.statusOk],
[typeDeleteAllowance.summaryTxInfo, typeGeneral.statusOk],
typeDeleteAllowance.altImage,
)
})

it('Verify exapnded details for allowance deletion', () => {
it('Verify exapanded details for allowance deletion', () => {
createTx.clickOnTransactionItemByName(typeDeleteAllowance.title)
createTx.verifyExpandedDetails([
typeDeleteAllowance.description,
Expand All @@ -182,7 +177,7 @@ describe('Transaction history tests', () => {
])
})

it('Verify advanced details displayed in exapnded details for allowance deletion', () => {
it('Verify advanced details displayed in exapanded details for allowance deletion', () => {
createTx.clickOnTransactionItemByName(typeDeleteAllowance.title)
createTx.expandAdvancedDetails([typeDeleteAllowance.baseGas])
createTx.collapseAdvancedDetails([typeDeleteAllowance.baseGas])
Expand Down
168 changes: 168 additions & 0 deletions cypress/e2e/regression/tx_history_2.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
import * as constants from '../../support/constants'
import * as main from '../pages/main.page'
import * as createTx from '../pages/create_tx.pages'
import * as data from '../../fixtures/txhistory_data_data.json'

const batchTx = 13
const thresholdTx = 0

const typeOnchainRejection = data.type.onchainRejection
const typeBatch = data.type.batchNativeTransfer
const typeAddOwner = data.type.addOwner
const typeChangeOwner = data.type.swapOwner
const typeRemoveOwner = data.type.removeOwner
const typeDisableOwner = data.type.disableModule
const typeChangeThreshold = data.type.changeThreshold
const typeSideActions = data.type.sideActions
const typeGeneral = data.type.general

describe('Tx history tests 2', () => {
beforeEach(() => {
cy.clearLocalStorage()
cy.visit(constants.transactionsHistoryUrl + constants.SEPOLIA_TEST_SAFE_8)
main.acceptCookies()
})

it('Verify number of transactions is correct', () => {
createTx.verifyNumberOfTransactions(20)
})

// On-chain rejection
it('Verify summary for on-chain rejection', () => {
createTx.verifySummaryByName(typeOnchainRejection.title, [typeGeneral.statusOk], typeOnchainRejection.altImage)
})

it('Verify exapanded details for on-chain rejection', () => {
createTx.clickOnTransactionItemByName(typeOnchainRejection.title)
createTx.verifyExpandedDetails([
typeOnchainRejection.description,
typeOnchainRejection.transactionHash,
typeOnchainRejection.safeTxHash,
])
createTx.verifyActionListExists([
typeSideActions.rejectionCreated,
typeSideActions.confirmations,
typeSideActions.executedBy,
])
})

// Batch transaction
it('Verify summary for batch', () => {
createTx.verifySummaryByIndex(
batchTx,
[typeBatch.title, typeBatch.summaryTxInfo, typeGeneral.statusOk],
typeBatch.altImage,
typeBatch.altToken,
)
})

it('Verify exapanded details for batch', () => {
createTx.clickOnTransactionItemByIndex(batchTx)
createTx.verifyExpandedDetails(
[
typeBatch.description,
typeBatch.contractTitle,
typeBatch.contractAddress,
typeBatch.transactionHash,
typeBatch.safeTxHash,
],
createTx.delegateCallWarning,
)
createTx.verifyActions([typeBatch.nativeTransfer.title])
})

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

it('Verify exapanded details for adding owner', () => {
createTx.clickOnTransactionItemByName(typeAddOwner.title)
createTx.verifyExpandedDetails(
[
typeAddOwner.description,
typeAddOwner.requiredConfirmationsTitle,
typeAddOwner.ownerAddress,
typeAddOwner.transactionHash,
typeAddOwner.safeTxHash,
],
createTx.policyChangeWarning,
)
})

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

it('Verify exapanded details for changing owner', () => {
createTx.clickOnTransactionItemByName(typeChangeOwner.title)
createTx.verifyExpandedDetails([
typeChangeOwner.description,
typeChangeOwner.newOwner.actionTitile,
typeChangeOwner.newOwner.ownerAddress,
typeChangeOwner.oldOwner.actionTitile,
typeChangeOwner.oldOwner.ownerAddress,

typeChangeOwner.transactionHash,
typeChangeOwner.safeTxHash,
])
})

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

it('Verify exapanded details for removing owner', () => {
createTx.clickOnTransactionItemByName(typeRemoveOwner.title)
createTx.verifyExpandedDetails(
[
typeRemoveOwner.description,
typeRemoveOwner.requiredConfirmationsTitle,
typeRemoveOwner.ownerAddress,
typeRemoveOwner.transactionHash,
typeRemoveOwner.safeTxHash,
],
createTx.policyChangeWarning,
)
createTx.checkRequiredThreshold(1)
})

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

it('Verify exapanded details for disable module', () => {
createTx.clickOnTransactionItemByName(typeDisableOwner.title)
createTx.verifyExpandedDetails([
typeDisableOwner.description,
typeDisableOwner.address,
typeDisableOwner.transactionHash,
typeDisableOwner.safeTxHash,
])
})

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

it('Verify exapanded details for changing threshold', () => {
createTx.clickOnTransactionItemByIndex(thresholdTx)
createTx.verifyExpandedDetails(
[
typeChangeThreshold.requiredConfirmationsTitle,
typeChangeThreshold.transactionHash,
typeChangeThreshold.safeTxHash,
],
createTx.policyChangeWarning,
)
createTx.checkRequiredThreshold(2)
})
})
4 changes: 2 additions & 2 deletions cypress/e2e/smoke/add_owner.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('[SMOKE] Add Owners tests', () => {
beforeEach(() => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_1)
cy.clearLocalStorage()
main.waitForTrnsactionHistoryToComplete()
main.waitForHistoryCallToComplete()
main.acceptCookies()
main.verifyElementsExist([navigation.setupSection])
})
Expand All @@ -18,7 +18,7 @@ describe('[SMOKE] Add Owners tests', () => {

it('[SMOKE] Verify “Add new owner” button tooltip displays correct message for Non-Owner', () => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_2)
main.waitForTrnsactionHistoryToComplete()
main.waitForHistoryCallToComplete()
owner.verifyAddOwnerBtnIsDisabled()
})

Expand Down
Loading

0 comments on commit 2a408ae

Please sign in to comment.