Skip to content

Commit

Permalink
Tests: add extra tests to address bug fix and restore a deleted test (#…
Browse files Browse the repository at this point in the history
…3173)

* tests: add extra tests to address bug fix and restore a deleted test

* tests: skip drain account tests - wip
  • Loading branch information
mike10ca authored Jan 30, 2024
1 parent d12c70c commit 7d8574d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/pages/create_tx.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export function verifyNativeTokenTransfer() {
}

export function changeNonce(value) {
cy.get(nonceInput).clear().type(value, { force: true }).blur()
cy.get(nonceInput).clear().type(value, { force: true })
}

export function verifyConfirmTransactionData() {
Expand Down
13 changes: 11 additions & 2 deletions cypress/e2e/pages/spending_limits.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 './main.page'
import * as addressBook from '../pages/address_book.page'
import { invalidAddressFormatErrorMsg } from '../pages/load_safe.pages'
import * as ls from '../../support/localstorage_data.js'
import 'cypress-file-upload'

export const spendingLimitsSection = '[data-testid="spending-limit-section"]'
Expand Down Expand Up @@ -31,7 +32,10 @@ const oldTokenAmount = '[data-testid="old-token-amount"]'
const oldResetTime = '[data-testid="old-reset-time"]'
const slimitReplacementWarning = '[data-testid="limit-replacement-warning"]'
const addressItem = '[data-testid="address-item"]'
import * as ls from '../../support/localstorage_data.js'

const actionSectionItem = () => {
return cy.get('[data-testid="CodeIcon"]').parent()
}

export const timePeriodOptions = {
oneTime: 'One time',
Expand All @@ -43,7 +47,7 @@ export const timePeriodOptions = {
const getBeneficiaryInput = () => cy.get(beneficiarySection).find('input').should('be.enabled')
const automationOwner = ls.addressBookData.sepoliaAddress2[11155111]['0xC16Db0251654C0a72E91B190d81eAD367d2C6fED']

const expectedSpendOptions = ['0 of 0.17 ETH', '0 of 0.05 ETH', '0 of 0.01 ETH']
const expectedSpendOptions = ['0 of 0.17 ETH', '0.00001 of 0.05 ETH', '0 of 0.01 ETH']
const expectedResetOptions = new Array(3).fill('One-time')

const newTransactionStr = 'New transaction'
Expand All @@ -59,6 +63,11 @@ export function selectRecipient(recipient) {
export function verifyOldValuesAreDisplayed() {
main.verifyElementsIsVisible([oldTokenAmount, oldResetTime, slimitReplacementWarning])
}

export function verifyActionNamesAreDisplayed(names) {
main.verifyValuesExist(actionSectionItem, names)
}

export function verifySpendingLimitBtnIsDisabled() {
cy.get(newSpendingLimitBtn).should('be.disabled')
}
Expand Down
13 changes: 13 additions & 0 deletions cypress/e2e/regression/spending_limits.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ describe('Spending limits tests', () => {
spendinglimit.verifyOldValuesAreDisplayed()
})

it('Verify that when editing spending limit for owner who used some of it, relevant actions are displayed', () => {
spendinglimit.clickOnNewSpendingLimitBtn()
spendinglimit.enterBeneficiaryAddress(constants.SPENDING_LIMIT_ADDRESS_2)
spendinglimit.enterSpendingLimitAmount(newTokenAmount)
spendinglimit.clickOnTimePeriodDropdown()
spendinglimit.selectTimePeriod(spendinglimit.timePeriodOptions.oneTime)
tx.clickOnNextBtn()
spendinglimit.verifyActionNamesAreDisplayed([
constants.TXActionNames.resetAllowance,
constants.TXActionNames.setAllowance,
])
})

it('Verify that when multiple assets are available, they are displayed in token dropdown', () => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__settings, ls.safeSettings.slimitSettings).then(() => {
main
Expand Down
18 changes: 9 additions & 9 deletions cypress/e2e/safe-apps/drain_account.spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import * as safeapps from '../pages/safeapps.pages'
describe('Drain Account tests', { defaultCommandTimeout: 12000 }, () => {
const appUrl = constants.drainAccount_url
const iframeSelector = `iframe[id="iframe-${appUrl}"]`
const visitUrl = `/apps/open?safe=${constants.GOERLI_SAFE_APPS_SAFE}&appUrl=${encodeURIComponent(appUrl)}`
const visitUrl = `/apps/open?safe=${constants.SEPOLIA_TEST_SAFE_5}&appUrl=${encodeURIComponent(appUrl)}`

beforeEach(() => {
cy.intercept(`**//v1/chains/5/safes/${constants.GOERLI_SAFE_APPS_SAFE.substring(4)}/balances/**`, {
cy.intercept(`**//v1/chains/5/safes/${constants.SEPOLIA_TEST_SAFE_5.substring(4)}/balances/**`, {
fixture: 'balances.json',
})

Expand All @@ -19,7 +19,7 @@ describe('Drain Account tests', { defaultCommandTimeout: 12000 }, () => {
safeapps.clickOnContinueBtn()
})

it('Verify drain can be created', () => {
it.skip('Verify drain can be created', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.recipientStr).type(constants.SAFE_APP_ADDRESS_2)
getBody().findAllByText(safeapps.transferEverythingStr).click()
Expand All @@ -28,7 +28,7 @@ describe('Drain Account tests', { defaultCommandTimeout: 12000 }, () => {
cy.findByRole('button', { name: safeapps.testNativeTransfer2 })
})

it('Verify partial drain can be created', () => {
it.skip('Verify partial drain can be created', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.selectAllRowsChbxStr).click()
getBody().findAllByLabelText(safeapps.selectRowChbxStr).eq(1).click()
Expand All @@ -40,7 +40,7 @@ describe('Drain Account tests', { defaultCommandTimeout: 12000 }, () => {
cy.findByRole('button', { name: safeapps.testNativeTransfer1 })
})

it('Verify a drain can be created when a ENS is specified', () => {
it.skip('Verify a drain can be created when a ENS is specified', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.recipientStr).type('goerli-test-safe.eth').wait(2000)
getBody().findAllByText(safeapps.transferEverythingStr).click()
Expand All @@ -61,30 +61,30 @@ describe('Drain Account tests', { defaultCommandTimeout: 12000 }, () => {
})
})

it('Verify a drain cannot be created with no recipient selected', () => {
it.skip('Verify a drain cannot be created with no recipient selected', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findAllByText(safeapps.transferEverythingStr).click()
getBody().findByText(safeapps.validRecipientAddressStr)
})
})

it('Verify a drain cannot be created with invalid recipient selected', () => {
it.skip('Verify a drain cannot be created with invalid recipient selected', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.recipientStr).type(constants.SAFE_APP_ADDRESS_2.substring(1))
getBody().findAllByText(safeapps.transferEverythingStr).click()
getBody().findByText(safeapps.validRecipientAddressStr)
})
})

it('Verify a drain cannot be created when no assets are selected', () => {
it.skip('Verify a drain cannot be created when no assets are selected', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.selectAllRowsChbxStr).click()
getBody().findByLabelText(safeapps.recipientStr).type(constants.SAFE_APP_ADDRESS_2)
getBody().findAllByText(safeapps.noTokensSelectedStr).should('be.visible')
})
})

it('Verify a drain cannot be created when no assets and recipient are selected', () => {
it.skip('Verify a drain cannot be created when no assets and recipient are selected', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.selectAllRowsChbxStr).click()
getBody().findAllByText(safeapps.noTokensSelectedStr).should('be.visible')
Expand Down
4 changes: 3 additions & 1 deletion cypress/e2e/smoke/create_tx.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as main from '../../e2e/pages/main.page'
import * as createtx from '../../e2e/pages/create_tx.pages'

const sendValue = 0.00002
const currentNonce = 0
const currentNonce = 1

function happyPathToStepTwo() {
createtx.typeRecipientAddress(constants.EOA)
Expand Down Expand Up @@ -42,6 +42,8 @@ describe('[SMOKE] Create transactions tests', () => {
})

it('[SMOKE] Verify nonce tooltip warning messages', () => {
createtx.changeNonce(0)
createtx.verifyTooltipMessage(constants.nonceTooltipMsg.lowerThanCurrent + currentNonce.toString())
createtx.changeNonce(currentNonce + 50)
createtx.verifyTooltipMessage(constants.nonceTooltipMsg.higherThanRecommended)
createtx.changeNonce(currentNonce + 150)
Expand Down
6 changes: 6 additions & 0 deletions cypress/support/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const SAFE_APP_ADDRESS = '0x11AB70A4564C62F567B92868Cb5e69b50c5434aF'
export const SAFE_APP_ADDRESS_2 = '0x49d4450977E2c95362C13D3a31a09311E0Ea26A6'
export const SAFE_APP_ADDRESS_3 = '0xc6b82bA149CFA113f8f48d5E3b1F78e933e16DfD'
export const DEFAULT_OWNER_ADDRESS = '0xC16Db0251654C0a72E91B190d81eAD367d2C6fED'
export const SPENDING_LIMIT_ADDRESS_2 = '0x52835f11E348605E9D791Ec09380a3224526d538'
export const SEPOLIA_OWNER_2 = '0x96D4c6fFC338912322813a77655fCC926b9A5aC5'
export const TEST_SAFE_2 = 'gor:0xE96C43C54B08eC528e9e815fC3D02Ea94A320505'
export const SIDEBAR_ADDRESS = '0x04f8...1a91'
Expand Down Expand Up @@ -85,6 +86,11 @@ export const safeListEndpoint = '**/safes'
export const VALID_QR_CODE_PATH = '../fixtures/sepolia_test_safe_QR.png'
export const INVALID_QR_CODE_PATH = '../fixtures/invalid_image_QR_test.png'

export const TXActionNames = {
resetAllowance: 'resetAllowance',
setAllowance: 'setAllowance',
}

export const networkKeys = {
sepolia: '11155111',
}
Expand Down

0 comments on commit 7d8574d

Please sign in to comment.