Skip to content

Commit

Permalink
Tests: Fix sidebar and staking tests (#4566)
Browse files Browse the repository at this point in the history
  • Loading branch information
mike10ca authored Nov 26, 2024
1 parent 0eb9dc2 commit 7642d4a
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 8 deletions.
9 changes: 6 additions & 3 deletions cypress/e2e/pages/sidebar.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const addedNetworkOption = 'li[role="option"]'
const modalAddNetworkName = '[data-testid="added-network"]'
const networkSeperator = 'div[role="separator"]'
export const addNetworkTooltip = '[data-testid="add-network-tooltip"]'
const pinnedAccountsContainer = '[data-testid="pinned-accounts"]'
export const importBtnStr = 'Import'
export const exportBtnStr = 'Export'
export const undeployedSafe = 'Undeployed Sepolia'
Expand Down Expand Up @@ -87,7 +88,7 @@ const emptyWatchListStr = 'Watch any Safe Account to keep an eye on its activity
const emptySafeListStr = "You don't have any Safe Accounts yet"
const myAccountsStr = 'My accounts'
const confirmTxStr = (number) => `${number} to confirm`
const pedningTxStr = (n) => `${n} pending transaction`
const pedningTxStr = (n) => `${n} pending`
export const confirmGenStr = 'to confirm'

export const multichainSafes = {
Expand All @@ -96,7 +97,9 @@ export const multichainSafes = {
}

export function verifyNumberOfPendingTxTag(tx) {
cy.contains(pedningTxStr(tx))
cy.get(pinnedAccountsContainer).within(() => {
cy.get('span').contains(pedningTxStr(tx))
})
}

export function getImportBtn() {
Expand Down Expand Up @@ -464,7 +467,7 @@ export function checkNetworksInRange(expectedString, expectedCount, direction =

return cy
.get(startSelector)
[traversalMethod](endSelector, 'li')
[traversalMethod](endSelector, 'li')
.then((liElements) => {
expect(liElements.length).to.equal(expectedCount)
const optionTexts = [...liElements].map((li) => li.innerText)
Expand Down
4 changes: 4 additions & 0 deletions cypress/e2e/pages/staking.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export function getRewardRegex() {
return new RegExp('^\\d+(\\.\\d+)? ETH \\(\\$\\s?\\d{1,3}(,\\d{3})*\\)$')
}

export function getActivationTimeRegex() {
return new RegExp('^\\d+\\s+hour(s)?\\s+\\d+\\s+minute(s)?$')
}

export function checkTxHeaderData(data) {
main.verifyValuesExist(create_tx.transactionItem, data)
}
Expand Down
7 changes: 6 additions & 1 deletion cypress/e2e/regression/sidebar_2.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import * as sideBar from '../pages/sidebar.pages'
import * as ls from '../../support/localstorage_data.js'
import * as assets from '../pages/assets.pages.js'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'
import * as wallet from '../../support/utils/wallet.js'

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

const newSafeName = 'Added safe 3'
const addedSafe900 = 'Added safe 900'
Expand Down Expand Up @@ -35,7 +38,8 @@ describe('Sidebar added sidebar tests', () => {
sideBar.verifySafeNameExists(newSafeName)
})

it('Verify a safe can be removed', () => {
// TODO: Waiting for new tests due to changed functionality
it.skip('Verify a safe can be removed', () => {
sideBar.openSidebar()
sideBar.removeSafeItem(addedSafe900)
sideBar.verifySafeRemoved([addedSafe900])
Expand All @@ -47,6 +51,7 @@ describe('Sidebar added sidebar tests', () => {
})

it('Verify "wallet" tag counter if the safe has tx ready for execution', () => {
wallet.connectSigner(signer)
sideBar.openSidebar()
sideBar.verifyNumberOfPendingTxTag(1)
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/regression/staking_history.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Staking history tests', { defaultCommandTimeout: 30000 }, () => {
staking.checkDataFields(staking.dataFields.netMonthlyRewards, staking.getRewardRegex())
staking.checkDataFields(staking.dataFields.fee, staking.getPercentageRegex())
staking.checkDataFields(staking.dataFields.validators, '1')
staking.checkDataFields(staking.dataFields.activationTime, historyData.activationTimeValue)
staking.checkDataFields(staking.dataFields.activationTime, staking.getActivationTimeRegex())
staking.checkDataFields(staking.dataFields.rewards, historyData.rewardsValue)
})
})
1 change: 0 additions & 1 deletion cypress/fixtures/staking_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"stake": "Stake",
"withdrawal": "Withdraw request",
"validator_1": "1 Validator",
"activationTimeValue": "10 hours 14 minutes",
"rewardsValue": "Approx. every 5 days after activation"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ const MultiAccountItem = ({ onLinkClick, multiSafeAccountItem }: MultiAccountIte
</Typography>
</Box>
<IconButton
data-testid="bookmark-icon"
edge="end"
size="medium"
sx={{ mx: 1 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,13 @@ const AccountItem = ({ onLinkClick, safeItem }: AccountItemProps) => {
</Typography>
</Link>
</Track>
<IconButton edge="end" size="medium" sx={{ mx: 1 }} onClick={isPinned ? removeFromPinnedList : addToPinnedList}>
<IconButton
data-testid="bookmark-icon"
edge="end"
size="medium"
sx={{ mx: 1 }}
onClick={isPinned ? removeFromPinnedList : addToPinnedList}
>
<SvgIcon
component={isPinned ? BookmarkedIcon : BookmarkIcon}
inheritViewBox
Expand Down
2 changes: 1 addition & 1 deletion src/features/myAccounts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const AccountsList = ({ safes, onLinkClick, isSidebar = false }: AccountsListPro
) : (
<>
{/* Pinned Accounts */}
<Box mb={2} minHeight="170px">
<Box data-testid="pinned-accounts" mb={2} minHeight="170px">
<div className={css.listHeader}>
<SvgIcon
component={BookmarkIcon}
Expand Down

0 comments on commit 7642d4a

Please sign in to comment.