Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into wallet-balance
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/pages/_app.tsx
  • Loading branch information
usame-algan committed Nov 3, 2023
2 parents 981a868 + cb5da93 commit 20a59c9
Show file tree
Hide file tree
Showing 192 changed files with 6,410 additions and 1,163 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ concurrency:
jobs:
e2e:
runs-on: ubuntu-20.04
name: Smoke E2E tests
name: Cypress Smoke tests
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3]
steps:
- uses: actions/checkout@v3

Expand All @@ -30,9 +34,12 @@ jobs:

- uses: cypress-io/github-action@v4
with:
parallel: true
spec: cypress/e2e/smoke/*.cy.js
browser: chrome
record: true
config: baseUrl=http://localhost:8080
group: 'Smoke tests'
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 8 additions & 1 deletion .github/workflows/safe-apps-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ concurrency:
jobs:
e2e:
runs-on: ubuntu-latest
name: Safe Apps E2E tests
name: Cypress Safe Apps tests
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3]
steps:
- uses: actions/checkout@v3

Expand All @@ -31,10 +35,13 @@ jobs:

- uses: cypress-io/github-action@v4
with:
parallel: true
spec: cypress/e2e/safe-apps/*.cy.js
browser: chrome
record: true
config: baseUrl=http://localhost:8080
group: 'Safe Apps tests'
env:
CYPRESS_PROJECT_ID: okn21k
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_SAFE_APPS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ COPY . .

# install deps
RUN yarn install --frozen-lockfile
RUN yarn after-install

ENV NODE_ENV production

Expand Down
7 changes: 7 additions & 0 deletions cypress/e2e/pages/address_book.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ export function verifyNewEntryAdded(name, address) {
cy.contains(address).should('exist')
}

export function addEntry(name, address) {
typeInName(name)
typeInAddress(address)
clickOnSaveEntryBtn()
verifyNewEntryAdded(name, address)
}

export function clickOnEditEntryBtn() {
cy.get(editEntryBtn).click({ force: true })
}
Expand Down
15 changes: 4 additions & 11 deletions cypress/e2e/pages/balances.pages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as main from '../pages/main.page'

let etherscanLink = 'a[aria-label="View on goerli.etherscan.io"]'
let etherscanLink = 'a[aria-label="View on sepolia.etherscan.io"]'
let etherscanLinkSepolia = 'a[aria-label="View on sepolia.etherscan.io"]'
export const balanceSingleRow = '[aria-labelledby="tableTitle"] > tbody tr'
const currencyDropdown = '[id="currency"]'
Expand All @@ -20,7 +20,6 @@ const hiddenTokenDeselectAllBtn = 'span[data-track="assets: Deselect all hide di
const hiddenTokenIcon = 'svg[data-testid="VisibilityOffOutlinedIcon"]'

const hideTokenDefaultString = 'Hide tokens'
const gotItStr = 'Got it!'
const assetNameSortBtnStr = 'Asset'
const assetBalanceSortBtnStr = 'Balance'
const sendBtnStr = 'Send'
Expand All @@ -45,6 +44,8 @@ export const tokenListOptions = {
export const currencyEUR = 'EUR'
export const currencyUSD = 'USD'

export const currentcySepoliaFormat = '0.09996 ETH'

export const currencyAave = 'AAVE'
export const currencyAaveAlttext = 'AAVE'
export const currentcyAaveFormat = '27 AAVE'
Expand All @@ -68,7 +69,7 @@ export const currentcyLinkFormat = '35.94 LINK'
export const currencyDai = 'Dai'
export const currencyDaiCap = 'DAI'
export const currencyDaiAlttext = 'DAI'
export const currentcyDaiFormat = '120,496.61 DAI'
export const currentcyDaiFormat = '82 DAI'
export const currencyDaiFormat_2 = '82 DAI'

export const currencyEther = 'Wrapped Ether'
Expand Down Expand Up @@ -182,14 +183,6 @@ export function verifyEachRowHasCheckbox(state) {
})
}

export function acceptSpamWarning() {
cy.get('button').contains(gotItStr).click()
verifySpamWarningNotdisplayed()
}

export function verifySpamWarningNotdisplayed() {
cy.contains(gotItStr).should('not.exist')
}
export function verifyTokensTabIsSelected(option) {
cy.get(`a[aria-selected="${option}"]`).contains('Tokens')
}
Expand Down
15 changes: 10 additions & 5 deletions cypress/e2e/pages/batches.pages.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as constants from '../../support/constants'

const tokenSelectorText = 'G(ö|oe)rli Ether'
const noLaterString = 'No, later'
const yesExecuteString = 'Yes, execute'
Expand Down Expand Up @@ -39,7 +41,7 @@ function fillTransactionData(EOA, amount) {
cy.get(recipientInput).type(EOA, { delay: 1 })
// Click on the Token selector
cy.get(tokenAddressInput).prev().click()
cy.get(listBox).contains(new RegExp(tokenSelectorText)).click()
cy.get(listBox).contains(constants.tokenNames.sepoliaEther).click()
cy.get(amountInput).type(amount)
cy.contains(nextBtn).click()
}
Expand All @@ -59,22 +61,25 @@ function executeTransaction() {
}

function addToBatchButton() {
cy.contains(noLaterString, { timeout: 4000 }).click()
cy.contains(addToBatchBtn).should('be.visible').and('not.be.disabled').click()
}

export function openBatchtransactionsModal() {
cy.get(batchTxTopBar).should('be.visible').click()
cy.contains(batchedTransactionsStr).should('be.visible')
cy.contains(addInitialTransactionStr)
}

export function openNewTransactionModal() {
cy.get(addNewTxBatch).click()
cy.contains('h1', newTransactionTitle).should('be.visible')
cy.contains(sendTokensButn).click()
}

export function addNewTransactionToBatch(EOA, currentNonce, funds_first_tx) {
openBatchtransactionsModal()
openNewTransactionModal()
addToBatch(EOA, currentNonce, funds_first_tx)
}

export function verifyAmountTransactionsInBatch(count) {
cy.contains(batchedTransactionsStr, { timeout: 7000 })
.should('be.visible')
Expand All @@ -84,7 +89,7 @@ export function verifyAmountTransactionsInBatch(count) {
}

export function clickOnConfirmBatchBtn() {
cy.contains(confirmBatchBtn).click()
cy.get('button').contains(confirmBatchBtn).should('be.visible').should('be.enabled').click()
}

export function verifyBatchTransactionsCount(count) {
Expand Down
29 changes: 17 additions & 12 deletions cypress/e2e/pages/create_tx.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ const nonceInput = 'input[name="nonce"]'
const gasLimitInput = '[name="gasLimit"]'
const rotateLeftIcon = '[data-testid="RotateLeftIcon"]'
const transactionItemExpandable = 'div[id^="transfer"]'
const expandItemIcon = '[data-testid="ExpandMoreIcon"]'

const viewTransactionBtn = 'View transaction'
const transactionDetailsTitle = 'Transaction details'
const QueueLabel = 'needs to be executed first'
const TransactionSummary = 'Send'
const TransactionSummary = 'Send '

const maxAmountBtnStr = 'Max'
const nextBtnStr = 'Next'
Expand Down Expand Up @@ -50,9 +51,9 @@ export function clickOnSendTokensBtn() {
cy.contains(sendTokensBtnStr).click()
}

export function clickOnTokenselectorAndSelectGoerli() {
export function clickOnTokenselectorAndSelectSepolia() {
cy.get(tokenAddressInput).prev().click()
cy.get('ul[role="listbox"]').contains(constants.goerliToken).click()
cy.get('ul[role="listbox"]').contains(constants.tokenNames.sepoliaEther).click()
}

export function setMaxAmount() {
Expand All @@ -66,8 +67,11 @@ export function verifyMaxAmount(token, tokenAbbreviation) {
.contains(token)
.next()
.then((element) => {
const maxBalance = element.text().replace(tokenAbbreviation, '').trim()
cy.get(amountInput).should('have.value', maxBalance)
const maxBalance = parseFloat(element.text().replace(tokenAbbreviation, '').trim())
cy.get(amountInput).should(($input) => {
const actualValue = parseFloat($input.val())
expect(actualValue).to.be.closeTo(maxBalance, 0.1)
})
console.log(maxBalance)
})
}
Expand Down Expand Up @@ -99,9 +103,7 @@ export function verifyConfirmTransactionData() {
// Asserting the sponsored info is present
cy.contains(executeStr).scrollIntoView().should('be.visible')

cy.get('span').contains(estimatedFeeStr).next().should('have.css', 'text-decoration-line', 'line-through')
cy.contains(transactionsPerHrStr)
cy.contains(transactionsPerHr5Of5Str)
cy.get('span').contains(estimatedFeeStr)
}

export function openExecutionParamsModal() {
Expand All @@ -112,10 +114,9 @@ export function openExecutionParamsModal() {
export function verifyAndSubmitExecutionParams() {
cy.contains(executionParamsStr).parents('form').as('Paramsform')

// Only gaslimit should be editable when the relayer is selected
const arrayNames = ['Wallet nonce', 'Max priority fee (Gwei)', 'Max fee (Gwei)']
const arrayNames = ['Wallet nonce', 'Max priority fee (Gwei)', 'Max fee (Gwei)', 'Gas limit']
arrayNames.forEach((element) => {
cy.get('@Paramsform').find('label').contains(`${element}`).next().find('input').should('be.disabled')
cy.get('@Paramsform').find('label').contains(`${element}`).next().find('input').should('not.be.disabled')
})

cy.get('@Paramsform').find(gasLimitInput).clear().type('300000').invoke('prop', 'value').should('equal', '300000')
Expand Down Expand Up @@ -150,7 +151,7 @@ export function verifyQueueLabel() {
}

export function verifyTransactionSummary(sendValue) {
cy.contains(TransactionSummary + `${sendValue} ${constants.tokenAbbreviation.gor}`).should('exist')
cy.contains(TransactionSummary + `${sendValue} ${constants.tokenAbbreviation.sep}`).should('exist')
}

export function verifyDateExists(date) {
Expand Down Expand Up @@ -189,3 +190,7 @@ export function clickOnExpandAllBtn() {
export function clickOnCollapseAllBtn() {
cy.contains(collapseAllBtnStr).click()
}

export function clickOnExpandIcon() {
cy.get(expandItemIcon).click()
}
10 changes: 2 additions & 8 deletions cypress/e2e/pages/create_wallet.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,9 @@ export function typeWalletName(name) {

export function selectNetwork(network, regex = false) {
cy.wait(1000)
cy.get(selectNetworkBtn).should('exist').click()
cy.get(selectNetworkBtn).should('be.visible').click()
cy.wait(1000)
cy.get('li').contains(network).click()

if (regex) {
regex = constants.networks.goerli
cy.get(selectNetworkBtn).click().invoke('text').should('match', regex)
} else {
cy.get(selectNetworkBtn).click().should('have.text', network)
}
cy.get('body').click()
}

Expand Down
40 changes: 15 additions & 25 deletions cypress/e2e/pages/dashboard.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ export function verifyOverviewWidgetData() {

cy.get('@overviewSection').within(() => {
// Prefix is separated across elements in EthHashInfo
cy.contains(constants.TEST_SAFE).should('exist')
cy.contains('1/2')
cy.get(`a[href="${constants.BALANCE_URL}${encodeURIComponent(constants.TEST_SAFE)}"]`).contains(viewAssetsStr)
// Text next to Tokens contains a number greater than 0
cy.contains('p', tokensStr).next().contains('1')
cy.contains('p', nftStr).next().contains('0')
cy.contains(constants.SEPOLIA_TEST_SAFE_5).should('exist')
cy.get('h2').contains('Overview')
cy.get(`a[href="${constants.BALANCE_URL}${encodeURIComponent(constants.SEPOLIA_TEST_SAFE_5)}"]`).contains(
viewAssetsStr,
)
})
}

Expand All @@ -45,9 +44,15 @@ export function verifyTxQueueWidget() {
cy.contains(noTransactionStr).should('not.exist')

// Queued txns
cy.contains(`a[href^="/transactions/tx?id=multisig_0x"]`, '13' + 'Send' + '-0.00002 GOR' + '1/1').should('exist')

cy.contains(`a[href="${constants.transactionQueueUrl}${encodeURIComponent(constants.TEST_SAFE)}"]`, viewAllStr)
cy.contains(
`a[href^="/transactions/tx?id=multisig_0x"]`,
'13' + 'Send' + `-0.00002 ${constants.tokenAbbreviation.sep}` + '1/1',
).should('exist')

cy.contains(
`a[href="${constants.transactionQueueUrl}${encodeURIComponent(constants.SEPOLIA_TEST_SAFE_5)}"]`,
viewAllStr,
)
})
}

Expand All @@ -61,27 +66,12 @@ export function verifyFeaturedAppsSection() {
cy.contains(transactionBuilderStr)
cy.get(txBuilder).should('exist')

// WalletConnect app
cy.contains(walletConnectStr)
cy.get(walletConnect).should('exist')

// Featured apps have a Safe-specific link
cy.get(safeSpecificLink).should('have.length', 2)
cy.get(safeSpecificLink).should('have.length', 1)
})
}

export function verifySafeAppsSection() {
// Create an alias for the Safe Apps section
cy.contains('h2', safeAppStr).parents('section').as('safeAppsSection')

cy.get('@safeAppsSection').contains(exploreSafeApps)

// Regular safe apps
cy.get('@safeAppsSection').within(() => {
// Find exactly 5 Safe Apps cards inside the Safe Apps section
cy.get(`a[href^="${constants.openAppsUrl}${encodeURIComponent(constants.TEST_SAFE)}&appUrl=http"]`).should(
'have.length',
5,
)
})
}
11 changes: 5 additions & 6 deletions cypress/e2e/pages/import_export.pages.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as constants from '../../support/constants'
import { format } from 'date-fns'
const path = require('path')

Expand Down Expand Up @@ -33,8 +34,8 @@ export function uploadFile(filePath) {

export function verifyImportModalData() {
//verifies that the modal says the amount of chains/addressbook values it uploaded for file ../fixtures/data_import.json
cy.contains('Added Safe Accounts on 3 chains').should('be.visible')
cy.contains('Address book for 3 chains').should('be.visible')
cy.contains('Added Safe Accounts on 4 chains').should('be.visible')
cy.contains('Address book for 4 chains').should('be.visible')
cy.contains('Settings').should('be.visible')
cy.contains('Bookmarked Safe Apps').should('be.visible')
}
Expand All @@ -55,10 +56,8 @@ export function clickOnAddressBookBtn() {

export function verifyImportedAddressBookData() {
//Verifies imported owners in the Address book for file ../fixtures/data_import.json
cy.get('tbody tr:nth-child(1) td:nth-child(1)').contains('test1')
cy.get('tbody tr:nth-child(1) td:nth-child(2)').contains('0x61a0c717d18232711bC788F19C9Cd56a43cc8872')
cy.get('tbody tr:nth-child(2) td:nth-child(1)').contains('test2')
cy.get('tbody tr:nth-child(2) td:nth-child(2)').contains('0x7724b234c9099C205F03b458944942bcEBA13408')
cy.get('tbody tr:nth-child(1) td:nth-child(1)').contains(constants.SEPOLIA_CSV_ENTRY.name)
cy.get('tbody tr:nth-child(1) td:nth-child(2)').contains(constants.SEPOLIA_CSV_ENTRY.address.substring(4))
}

export function clickOnAppsBtn() {
Expand Down
Loading

0 comments on commit 20a59c9

Please sign in to comment.