Skip to content

Commit

Permalink
Merge branch 'dev' into subaccount-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
iamacook committed Nov 29, 2024
2 parents 55cceba + b50340d commit 5b246ad
Show file tree
Hide file tree
Showing 103 changed files with 2,875 additions and 481 deletions.
26 changes: 10 additions & 16 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
NEXT_PUBLIC_INFURA_TOKEN=
NEXT_PUBLIC_SAFE_APPS_INFURA_TOKEN=

# WalletConnect
NEXT_PUBLIC_WC_PROJECT_ID=

## CGW
NEXT_PUBLIC_GATEWAY_URL_PRODUCTION=
NEXT_PUBLIC_GATEWAY_URL_STAGING=

# Blockaid
NEXT_PUBLIC_BLOCKAID_CLIENT_ID=

# Transaction simulation
NEXT_PUBLIC_TENDERLY_SIMULATE_ENDPOINT_URL=
NEXT_PUBLIC_TENDERLY_PROJECT_NAME=
Expand All @@ -17,15 +23,11 @@ NEXT_PUBLIC_IS_PRODUCTION=
# Latest supported safe version, used for upgrade prompts
NEXT_PUBLIC_SAFE_VERSION=

# Access keys
# Sentry
NEXT_PUBLIC_SENTRY_DSN=
NEXT_PUBLIC_BEAMER_ID=

# Wallet-specific variables
NEXT_PUBLIC_WC_PROJECT_ID=

# E2E tests
NEXT_PUBLIC_CYPRESS_MNEMONIC=
# Beamer
NEXT_PUBLIC_BEAMER_ID=

# Safe Gelato relay service
NEXT_PUBLIC_SAFE_GELATO_RELAY_SERVICE_URL_PRODUCTION=
Expand All @@ -34,19 +36,11 @@ NEXT_PUBLIC_SAFE_GELATO_RELAY_SERVICE_URL_STAGING=
# Firebase Cloud Messaging
NEXT_PUBLIC_FIREBASE_OPTIONS_PRODUCTION=
NEXT_PUBLIC_FIREBASE_VAPID_KEY_PRODUCTION=

NEXT_PUBLIC_FIREBASE_OPTIONS_STAGING=
NEXT_PUBLIC_FIREBASE_VAPID_KEY_STAGING=

# Blockaid
NEXT_PUBLIC_BLOCKAID_CLIENT_ID

# Social Login
NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_STAGING=
NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_PRODUCTION=

# Cypress wallet private keys
CYPRESS_WALLET_CREDENTIALS=

# [optional] Beamer keys for e2e tests
BEAMER_DATA_E2E=
BEAMER_DATA_E2E=
2 changes: 1 addition & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default defineConfig({
hideXHR: true,
defaultCommandTimeout: 10000,
pageLoadTimeout: 60000,
numTestsKeptInMemory: 0,
numTestsKeptInMemory: 20,
},

chromeWebSecurity: false,
Expand Down
59 changes: 54 additions & 5 deletions cypress/e2e/pages/sidebar.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ const emptyPinnedList = '[data-testid="empty-pinned-list"]'
const boomarkIcon = '[data-testid="bookmark-icon"]'
const emptyAccountList = '[data-testid="empty-account-list"]'
const searchInput = '[id="search-by-name"]'
const accountsList = '[data-testid="accounts-list"]'
const sortbyBtn = '[data-testid="sortby-button"]'

export const importBtnStr = 'Import'
export const exportBtnStr = 'Export'
export const undeployedSafe = 'Undeployed Sepolia'
Expand All @@ -80,11 +83,13 @@ export const sideBarListItems = ['Home', 'Assets', 'Transactions', 'Address book
export const sideBarSafes = {
safe1: '0xBb26E3717172d5000F87DeFd391994f789D80aEB',
safe2: '0x905934aA8758c06B2422F0C90D97d2fbb6677811',
safe3: '0xC96ee38f5A73C8A70b565CB8EA938D2aF913ee3B',
safe1short: '0xBb26...0aEB',
safe1short_: '0xBb26',
safe2short: '0x9059...7811',
safe3short: '0x86Cb...2C27',
safe4short: '0x9261...7E00',
multichain_short_: '0xC96e',
}

// 0x926186108f74dB20BFeb2b6c888E523C78cb7E00
Expand All @@ -96,10 +101,19 @@ export const testSafeHeaderDetails = ['2/2', safes.SEP_STATIC_SAFE_9_SHORT]
const receiveAssetsStr = 'Receive assets'
const emptyPinnedListStr = 'Watch any Safe Account to keep an eye on its activity'
const emptySafeListStr = "You don't have any safes yet"
const accountsStr = 'Accounts'
const accountsRegex = /(My accounts|Accounts) \((\d+)\)/
const confirmTxStr = (number) => `${number} to confirm`
const pedningTxStr = (n) => `${n} pending`
export const confirmGenStr = 'to confirm'
const searchResults = (number) => `Found ${number} result${number === 1 ? '' : 's'}`

export const sortOptions = {
lastVisited: '[data-testid="last-visited-option"]',
name: '[data-testid="name-option"]',
}
export function checkSearchResults(number) {
cy.contains(searchResults(number)).should('exist')
}

export const multichainSafes = {
polygon: 'Multichain polygon',
Expand All @@ -110,6 +124,18 @@ export function searchSafe(safe) {
cy.get(searchInput).clear().type(safe)
}

export function openSortOptionsMenu() {
cy.get(sortbyBtn).click()
}

export function selectSortOption(option) {
cy.get(option).click()
}

export function clearSearchInput() {
cy.get(searchInput).scrollIntoView().clear({ force: true })
}

export function verifySearchInputPosition() {
cy.get(searchInput).then(($searchInput) => {
cy.get(pinnedAccountsContainer).then(($pinnedList) => {
Expand Down Expand Up @@ -232,6 +258,12 @@ export function verifySafeCount(count) {
main.verifyMinimumElementsCount(sideSafeListItem, count)
}

export function verifyAccountListSafeCount(count) {
cy.get(accountsList).within(() => {
cy.get(sideSafeListItem).should('have.length', count)
})
}

export function clickOnOpenSidebarBtn() {
cy.get(openSafesIcon).click()
}
Expand All @@ -248,9 +280,12 @@ export function verifyAddedSafesExist(safes) {
main.verifyValuesExist(sideSafeListItem, safes)
}

export function verifySafesDoNotExist(safes) {
main.verifyValuesDoNotExist(sidebarSafeContainer, safes)
}

export function verifyAddedSafesExistByIndex(index, safe) {
cy.get(sideSafeListItem).eq(index).should('contain', safe)
cy.get(sideSafeListItem).eq(index).should('contain', 'sep:')
}

export function verifySafesByNetwork(netwrok, safes) {
Expand All @@ -266,7 +301,7 @@ export function verifySafesByNetwork(netwrok, safes) {
}

function getSafeByName(safe) {
return cy.get(sidebarSafeContainer).find(sideSafeListItem).contains(safe).parents('span').parent()
return cy.get(sidebarSafeContainer).find(sideSafeListItem).contains(safe).parents('span').parent().should('exist')
}

function getSafeItemOptions(name) {
Expand Down Expand Up @@ -295,13 +330,16 @@ export function clickOnSafeItemOptionsBtnByIndex(index) {
cy.get(safeItemOptionsBtn).eq(index).click()
}

export function expandGroupSafes(index) {
cy.get(multichainItemSummary).eq(index).click()
}

export function clickOnMultichainItemOptionsBtn(index) {
cy.get(multichainItemSummary).eq(index).find(safeItemOptionsBtn).click()
}

export function checkMultichainTooltipExists(index) {
cy.get(multichainItemSummary).eq(index).find(chainLogo).eq(0).trigger('mouseover', { force: true })

cy.get(multichainTooltip).should('exist')
}

Expand Down Expand Up @@ -340,6 +378,10 @@ export function checkUndeployedSafeExists(index) {
return getSubAccountContainer(index).contains(notActivatedStr).should('exist')
}

export function checkMultichainSubSafeExists(safes) {
main.verifyValuesExist(subAccountContainer, safes)
}

export function checkAddNetworkBtnPosition(index) {
cy.get(multichainItemSummary)
.eq(index)
Expand Down Expand Up @@ -464,7 +506,14 @@ export function verifySafeGiveNameOptionExists(index) {
}

export function checkAccountsCounter(value) {
cy.contains(accountsStr).should('contain', value)
cy.get(sidebarSafeContainer)
.should('exist')
.then(($el) => {
const text = $el.text()
const match = text.match(accountsRegex)
expect(match).not.to.be.null
expect(match[0]).to.exist
})
}

export function checkTxToConfirm(numberOfTx) {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/sidebar_3.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('[PROD] Sidebar tests 3', () => {
})
wallet.connectSigner(signer)
sideBar.openSidebar()
sideBar.checkAccountsCounter(2)
sideBar.checkAccountsCounter('2')
})

it('Verify pending signature is displayed in sidebar for unsigned tx', () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/regression/sidebar_3.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('Sidebar tests 3', () => {
})
wallet.connectSigner(signer)
sideBar.openSidebar()
sideBar.checkAccountsCounter(2)
sideBar.checkAccountsCounter('2')
})

it('Verify that safes the user do not owns show in the watchlist after adding them', () => {
Expand Down
59 changes: 56 additions & 3 deletions cypress/e2e/regression/sidebar_5.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ 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'))
Expand Down Expand Up @@ -36,4 +33,60 @@ describe('Sidebar search tests', () => {
sideBar.verifyAddedSafesExist([sideBar.sideBarSafes.safe1short])
sideBar.verifySafeCount(1)
})

it("Verify searching for a safe name filters out those who don't match", () => {
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.searchSafe(sideBar.sideBarSafes.safe1short_)
sideBar.verifyAddedSafesExist([sideBar.sideBarSafes.safe1short])
sideBar.verifySafesDoNotExist([sideBar.sideBarSafes.safe2short])
})

it('Verify searching for a safe also finds safes in different networks', () => {
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_9)
cy.intercept('GET', constants.safeListEndpoint, {
11155111: [sideBar.sideBarSafes.safe3],
})
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__undeployedSafes, ls.undeployedSafe.safes2)
wallet.connectSigner(signer)
sideBar.clickOnOpenSidebarBtn()
sideBar.searchSafe(sideBar.sideBarSafes.multichain_short_)
sideBar.checkMultichainSubSafeExists([
constants.networks.gnosis,
constants.networks.ethereum,
constants.networks.sepolia,
])
})

it('Verify search shows number of results found', () => {
const safe = main.changeSafeChainName(staticSafes.MATIC_STATIC_SAFE_28, 'eth')
cy.visit(constants.BALANCE_URL + safe)
cy.intercept('GET', constants.safeListEndpoint, {
11155111: [sideBar.sideBarSafes.safe1, sideBar.sideBarSafes.safe2, sideBar.sideBarSafes.safe3],
})
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__undeployedSafes, ls.undeployedSafe.safes2)
wallet.connectSigner(signer)
sideBar.clickOnOpenSidebarBtn()
sideBar.searchSafe('0x')
sideBar.checkSearchResults(3)
})

it('Verify clearing the search input returns back to the previous lists', () => {
const safe = main.changeSafeChainName(staticSafes.MATIC_STATIC_SAFE_28, 'eth')
cy.visit(constants.BALANCE_URL + safe)
cy.intercept('GET', constants.safeListEndpoint, {
11155111: [sideBar.sideBarSafes.safe1, sideBar.sideBarSafes.safe2, sideBar.sideBarSafes.safe3],
})
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__undeployedSafes, ls.undeployedSafe.safes2)
wallet.connectSigner(signer)
sideBar.clickOnOpenSidebarBtn()
sideBar.searchSafe('0xC')
sideBar.checkSearchResults(1)
sideBar.clearSearchInput()
sideBar.verifyAccountListSafeCount(6)
})
})
86 changes: 86 additions & 0 deletions cypress/e2e/regression/sidebar_6.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
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'

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

const aSafe = 'Safe A'
const bSafe = 'Safe B'
const safe14 = 'Safe 14'
const safe15 = 'Safe 15'

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

it('Verify the same safe of the different networks is ordered by most recent', () => {
let safe_eth = main.changeSafeChainName(staticSafes.MATIC_STATIC_SAFE_28, 'eth')
let safe_gno = main.changeSafeChainName(staticSafes.MATIC_STATIC_SAFE_28, 'gno')
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_9)
cy.intercept('GET', constants.safeListEndpoint, { 1: [], 100: [], 137: [], 11155111: [] })
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__undeployedSafes, ls.undeployedSafe.safes2)
wallet.connectSigner(signer)
cy.visit(constants.BALANCE_URL + safe_eth)
cy.visit(constants.BALANCE_URL + safe_gno)

sideBar.clickOnOpenSidebarBtn()
sideBar.searchSafe('96')
sideBar.checkSearchResults(1)
sideBar.verifySafeCount(3)
sideBar.verifyAddedSafesExistByIndex(1, constants.networks.gnosis)
sideBar.verifyAddedSafesExistByIndex(2, constants.networks.ethereum)
})

it('Verify the same safe of the different networks is ordered by name', () => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__addressBook, ls.addressBookData.undeployedSet)
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__undeployedSafes, ls.undeployedSafe.safes2)
cy.visit(constants.BALANCE_URL + staticSafes.SEP_STATIC_SAFE_9)
cy.intercept('GET', constants.safeListEndpoint, { 1: [], 100: [], 137: [], 11155111: [] })
wallet.connectSigner(signer)

sideBar.clickOnOpenSidebarBtn()
sideBar.searchSafe('96')
sideBar.verifySafeCount(3)
sideBar.expandGroupSafes(0)
sideBar.openSortOptionsMenu()
sideBar.selectSortOption(sideBar.sortOptions.name)
sideBar.verifyAddedSafesExistByIndex(1, aSafe)
sideBar.verifyAddedSafesExistByIndex(2, bSafe)
})

it('Verify that a pinned safe can be sorted by name and last visited', () => {
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__addressBook, ls.addressBookData.pagination)
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__visitedSafes, ls.visitedSafes.set1)
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.clickOnOpenSidebarBtn()
sideBar.searchSafe('15')
cy.wait(1000)
sideBar.clickOnBookmarkBtn(sideBar.sideBarSafes.safe2short)
sideBar.clearSearchInput()
sideBar.searchSafe('14')
cy.wait(1000)
sideBar.clickOnBookmarkBtn(sideBar.sideBarSafes.safe1short)
sideBar.clearSearchInput()

sideBar.verifyPinnedSafe(sideBar.sideBarSafes.safe2short)
sideBar.verifyPinnedSafe(sideBar.sideBarSafes.safe1short)

sideBar.openSortOptionsMenu()
sideBar.selectSortOption(sideBar.sortOptions.name)
sideBar.verifyAddedSafesExistByIndex(0, safe14)
sideBar.verifyAddedSafesExistByIndex(1, safe15)
sideBar.selectSortOption(sideBar.sortOptions.lastVisited)
sideBar.verifyAddedSafesExistByIndex(0, safe15)
sideBar.verifyAddedSafesExistByIndex(1, safe14)
})
})
2 changes: 1 addition & 1 deletion cypress/e2e/safe-apps/drain_account.spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let iframeSelector
const walletCredentials = JSON.parse(Cypress.env('CYPRESS_WALLET_CREDENTIALS'))
const signer = walletCredentials.OWNER_4_PRIVATE_KEY

describe('Drain Account tests', () => {
describe('Drain Account tests', { defaultCommandTimeout: 40000 }, () => {
before(async () => {
safeAppSafes = await getSafes(CATEGORIES.safeapps)
})
Expand Down
Loading

0 comments on commit 5b246ad

Please sign in to comment.