Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/epic/multichain-safes' into feat…
Browse files Browse the repository at this point in the history
…/multi-account-context
  • Loading branch information
schmanu committed Sep 17, 2024
2 parents 5e3bb59 + 4f5e9bf commit de3c784
Show file tree
Hide file tree
Showing 144 changed files with 2,713 additions and 1,747 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
![GitHub package.json version (branch)](https://img.shields.io/github/package-json/v/safe-global/safe-wallet-web)
[![GitPOAP Badge](https://public-api.gitpoap.io/v1/repo/safe-global/safe-wallet-web/badge)](https://www.gitpoap.io/gh/safe-global/safe-wallet-web)

The default Safe web interface.
Safe{Wallet} is a smart contract wallet for Ethereum and other EVM chains. Based on Gnosis Safe multisig contracts.

This repository is the frontend of the Safe{Wallet} app.

## Contributing

Expand Down
5 changes: 5 additions & 0 deletions cypress/e2e/pages/create_tx.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const editBtnStr = 'Edit'
const executionParamsStr = 'Execution parameters'
const noLaterStr = 'No, later'
const signBtnStr = 'Sign'
const confirmBtnStr = 'Confirm'
const expandAllBtnStr = 'Expand all'
const collapseAllBtnStr = 'Collapse all'
export const messageNestedStr = `"nestedString": "Test message 3 off-chain"`
Expand Down Expand Up @@ -504,6 +505,10 @@ export function clickOnSignTransactionBtn() {
cy.get('button').contains(signBtnStr).click()
}

export function clickOnConfirmTransactionBtn() {
cy.get('button').contains(confirmBtnStr).click()
}

export function waitForProposeRequest() {
cy.intercept('POST', constants.proposeEndpoint).as('ProposeTx')
cy.wait('@ProposeTx')
Expand Down
10 changes: 9 additions & 1 deletion cypress/e2e/pages/create_wallet.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const googleSignedinBtn = '[data-testid="signed-in-account-btn"]'
export const accountInfoHeader = '[data-testid="open-account-center"]'
export const reviewStepOwnerInfo = '[data-testid="review-step-owner-info"]'
const reviewStepNextBtn = '[data-testid="review-step-next-btn"]'
const creationModalLetsGoBtn = '[data-testid="cf-creation-lets-go-btn"]'
const safeCreationStatusInfo = '[data-testid="safe-status-info"]'
const startUsingSafeBtn = '[data-testid="start-using-safe-btn"]'
const sponsorIcon = '[data-testid="sponsor-icon"]'
Expand All @@ -32,7 +33,7 @@ export const choiceBtn = '[data-testid="choice-btn"]'
const addFundsBtn = '[data-testid="add-funds-btn"]'
const createTxBtn = '[data-testid="create-tx-btn"]'
const qrCodeSwitch = '[data-testid="qr-code-switch"]'
export const activateAccountBtn = '[data-testid="activate-account-btn"]'
export const activateAccountBtn = '[data-testid="activate-account-btn-cf"]'
const notificationsSwitch = '[data-testid="notifications-switch"]'
export const addFundsSection = '[data-testid="add-funds-section"]'
export const noTokensAlert = '[data-testid="no-tokens-alert"]'
Expand All @@ -50,6 +51,7 @@ export const addSignerStr = 'Add signer'
export const accountRecoveryStr = 'Account recovery'
export const sendTokensStr = 'Send tokens'
const noWalletConnectedMsg = 'No wallet connected'
export const deployWalletStr = 'about to deploy this Safe Account'

const connectWalletBtn = '[data-testid="connect-wallet-btn"]'

Expand Down Expand Up @@ -122,6 +124,12 @@ export function clickOnReviewStepNextBtn() {
cy.get(reviewStepNextBtn).click()
cy.get(reviewStepNextBtn, { timeout: 60000 }).should('not.exist')
}

export function clickOnLetsGoBtn() {
cy.get(creationModalLetsGoBtn).click()
cy.get(creationModalLetsGoBtn, { timeout: 60000 }).should('not.exist')
}

export function verifyOwnerInfoIsPresent() {
return cy.get(reviewStepOwnerInfo).shoul('exist')
}
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/pages/load_safe.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export function verifyDataInReviewSection(safeName, ownerName, threshold = null,
cy.findByText(ownerName).should('be.visible')
if (ownerAddress !== null) cy.get(safeDataForm).contains(ownerAddress).should('be.visible')
if (threshold !== null) cy.get(safeDataForm).contains(threshold).should('be.visible')
if (network !== null) cy.get(sidebar.chainLogo).eq(1).contains(network).should('be.visible')
if (network !== null) cy.get(sidebar.chainLogo).eq(0).contains(network).should('be.visible')
}

export function clickOnAddBtn() {
Expand Down
9 changes: 9 additions & 0 deletions cypress/e2e/pages/main.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,12 @@ export function getIframeBody(iframe) {
export const checkButtonByTextExists = (buttonText) => {
cy.get('button').contains(buttonText).should('exist')
}

export function getAddedSafeAddressFromLocalStorage(chainId, index) {
return cy.window().then((win) => {
const addedSafes = win.localStorage.getItem(constants.localStorageKeys.SAFE_v2__addedSafes)
const addedSafesObj = JSON.parse(addedSafes)
const safeAddress = Object.keys(addedSafesObj[chainId])[index]
return safeAddress
})
}
4 changes: 2 additions & 2 deletions cypress/e2e/pages/navigation.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export function clickOnSideNavigation(option) {
cy.get(option).should('exist').click()
}

export function clickOnModalCloseBtn() {
cy.get(modalCloseIcon).eq(0).trigger('click')
export function clickOnModalCloseBtn(index) {
cy.get(modalCloseIcon).eq(index).trigger('click')
}

export function clickOnNewTxBtn() {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/pages/owners.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function verifyOwnerDeletionWindowDisplayed() {
}

function clickOnThresholdDropdown() {
cy.get(thresholdDropdown).eq(1).click()
cy.get(thresholdDropdown).eq(0).click()
}

export function getThresholdOptions() {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/load_safe.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const INVALID_ADDRESS_ERROR_MSG = 'Address given is not a valid Safe address'
const OWNER_ENS_DEFAULT_NAME = 'test20.eth'
const OWNER_ADDRESS = constants.EOA

describe('Load Safe tests', () => {
describe('[PROD] Load Safe tests', () => {
before(async () => {
staticSafes = await getSafes(CATEGORIES.static)
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/tx_history.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Tx history tests 1', () => {
constants.stagingCGWSafes
}${staticSafes.SEP_STATIC_SAFE_7.substring(4)}/transactions/history**`,
(req) => {
req.url = `https://safe-client.safe.global/v1/chains/11155111/safes/0x5912f6616c84024cD1aff0D5b55bb36F5180fFdb/transactions/history?timezone_offset=7200000&trusted=false&cursor=limit=100&offset=1`
req.url = `https://safe-client.safe.global/v1/chains/11155111/safes/0x5912f6616c84024cD1aff0D5b55bb36F5180fFdb/transactions/history?timezone=Europe/Berlin&trusted=false&cursor=limit=100&offset=1`
req.continue()
},
).as('allTransactions')
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/prodhealthcheck/tx_history_2.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Tx history tests 2', () => {
constants.stagingCGWSafes
}${staticSafes.SEP_STATIC_SAFE_7.substring(4)}/transactions/history**`,
(req) => {
req.url = `https://safe-client.safe.global/v1/chains/11155111/safes/0x5912f6616c84024cD1aff0D5b55bb36F5180fFdb/transactions/history?timezone_offset=7200000&trusted=false&cursor=limit=100&offset=1`
req.url = `https://safe-client.safe.global/v1/chains/11155111/safes/0x5912f6616c84024cD1aff0D5b55bb36F5180fFdb/transactions/history?timezone=Europe/Berlin&trusted=false&cursor=limit=100&offset=1`
req.continue()
},
).as('allTransactions')
Expand Down
41 changes: 41 additions & 0 deletions cypress/e2e/regression/add_owner.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import * as owner from '../pages/owners.pages'
import * as addressBook from '../pages/address_book.page'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'
import * as wallet from '../../support/utils/wallet.js'
import * as createTx from '../pages/create_tx.pages.js'
import * as navigation from '../pages/navigation.page'
import { getEvents, events, checkDataLayerEvents } from '../../support/utils/gtag.js'

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

describe('Add Owners tests', () => {
before(async () => {
Expand Down Expand Up @@ -60,4 +64,41 @@ describe('Add Owners tests', () => {
owner.clickOnNextBtn()
owner.verifyConfirmTransactionWindowDisplayed()
})

it('Verify creation, confirmation and deletion of Add owner tx. GA tx_confirm', () => {
const tx_confirmed = [
{
eventLabel: events.txConfirmedAddOwner.eventLabel,
eventCategory: events.txConfirmedAddOwner.category,
eventType: events.txConfirmedAddOwner.eventType,
safeAddress: staticSafes.SEP_STATIC_SAFE_24.slice(6),
},
]
cy.visit(constants.setupUrl + staticSafes.SEP_STATIC_SAFE_24)
wallet.connectSigner(signer2)
owner.waitForConnectionStatus()
owner.openAddOwnerWindow()
owner.typeOwnerAddress(constants.SEPOLIA_OWNER_2)
createTx.changeNonce(2)
owner.clickOnNextBtn()
createTx.clickOnSignTransactionBtn()
createTx.clickViewTransaction()

navigation.clickOnWalletExpandMoreIcon()
navigation.clickOnDisconnectBtn()
wallet.connectSigner(signer)

createTx.clickOnConfirmTransactionBtn()
createTx.clickOnNoLaterOption()
createTx.clickOnSignTransactionBtn()

navigation.clickOnWalletExpandMoreIcon()
navigation.clickOnDisconnectBtn()
wallet.connectSigner(signer2)

createTx.deleteTx()

getEvents()
checkDataLayerEvents(tx_confirmed)
})
})
6 changes: 3 additions & 3 deletions cypress/e2e/regression/create_safe_cf.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ describe('CF Safe regression tests', () => {
owner.waitForConnectionStatus()
createwallet.clickOnAddFundsBtn()
main.verifyElementsIsVisible([createwallet.qrCode])
navigation.clickOnModalCloseBtn()
navigation.clickOnModalCloseBtn(0)

createwallet.clickOnCreateTxBtn()
navigation.clickOnModalCloseBtn()
navigation.clickOnModalCloseBtn(0)
})

it('Verify "0 out of 2 step completed" is shown in the dashboard', () => {
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('CF Safe regression tests', () => {
owner.waitForConnectionStatus()
createwallet.clickOnCreateTxBtn()
createwallet.clickOnTxType(txOrder[0])
main.verifyElementsExist([createwallet.activateAccountBtn])
cy.contains(createwallet.deployWalletStr)
})

it('Verify "Add another Owner" takes to a tx Add owner', () => {
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/regression/create_tx.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('Create transactions tests', () => {
createtx.changeNonce(14)
cy.wait(1000)
createtx.clickOnSignTransactionBtn()
createtx.waitForProposeRequest()
createtx.clickViewTransaction()
createtx.verifySingleTxPage()
createtx.verifyQueueLabel()
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/regression/recovery.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe('Recovery regression tests', { defaultCommandTimeout: 50000 }, () => {
recovery.enterRecovererAddress(constants.SEPOLIA_OWNER_2)
recovery.agreeToTerms()
recovery.clickOnNextBtn()
navigation.clickOnModalCloseBtn()
navigation.clickOnModalCloseBtn(0)
recovery.getSetupRecoveryBtn()
navigation.clickOnWalletExpandMoreIcon()
navigation.clickOnDisconnectBtn()
Expand Down
17 changes: 14 additions & 3 deletions cypress/e2e/regression/replace_owner.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import * as createTx from '../pages/create_tx.pages.js'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'
import * as wallet from '../../support/utils/wallet.js'
import * as ls from '../../support/localstorage_data.js'
import { getEvents, events, checkDataLayerEvents } from '../../support/utils/gtag.js'

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

const ownerName = 'Replacement Signer Name'

Expand Down Expand Up @@ -76,8 +78,16 @@ describe('Replace Owners tests', () => {
owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.alreadyAdded)
})

// TODO: Flaky. Fix ProposeTx request
it.skip("Verify 'Replace' tx is created", () => {
it("Verify 'Replace' tx is created. GA tx_created", () => {
const tx_created = [
{
eventLabel: events.txCreatedSwapOwner.eventLabel,
eventCategory: events.txCreatedSwapOwner.category,
eventAction: events.txCreatedSwapOwner.action,
event: events.txCreatedSwapOwner.eventName,
safeAddress: staticSafes.SEP_STATIC_SAFE_4.slice(6),
},
]
cy.visit(constants.setupUrl + staticSafes.SEP_STATIC_SAFE_4)
wallet.connectSigner(signer)
owner.waitForConnectionStatus()
Expand All @@ -88,8 +98,9 @@ describe('Replace Owners tests', () => {
createTx.changeNonce(2)
owner.clickOnNextBtn()
createTx.clickOnSignTransactionBtn()
createTx.waitForProposeRequest()
createTx.clickViewTransaction()
createTx.verifyReplacedSigner(ownerName)
getEvents()
checkDataLayerEvents(tx_created)
})
})
59 changes: 59 additions & 0 deletions cypress/e2e/regression/swaps.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'
import * as owner from '../pages/owners.pages'
import * as wallet from '../../support/utils/wallet.js'
import * as swaps_data from '../../fixtures/swaps_data.json'
import * as navigation from '../pages/navigation.page'
import { getEvents, events, checkDataLayerEvents } from '../../support/utils/gtag.js'

const walletCredentials = JSON.parse(Cypress.env('CYPRESS_WALLET_CREDENTIALS'))
const signer = walletCredentials.OWNER_4_PRIVATE_KEY
const signer2 = walletCredentials.OWNER_3_WALLET_ADDRESS
const signer3 = walletCredentials.OWNER_1_PRIVATE_KEY

let staticSafes = []

let iframeSelector
Expand Down Expand Up @@ -197,4 +201,59 @@ describe('Swaps tests', () => {
})
},
)

it(
'Verify an order can be created, signed by second signer and deleted. GA tx_confirm, tx_created',
{ defaultCommandTimeout: 30000 },
() => {
const tx_created = [
{
eventLabel: events.txCreatedSwap.eventLabel,
eventCategory: events.txCreatedSwap.category,
eventType: events.txCreatedSwap.eventType,
safeAddress: staticSafes.SEP_STATIC_SAFE_1.slice(6),
},
]
const tx_confirmed = [
{
eventLabel: events.txConfirmedSwap.eventLabel,
eventCategory: events.txConfirmedSwap.category,
eventType: events.txConfirmedSwap.eventType,
safeAddress: staticSafes.SEP_STATIC_SAFE_1.slice(6),
},
]
swaps.acceptLegalDisclaimer()
cy.wait(4000)
main.getIframeBody(iframeSelector).within(() => {
swaps.clickOnSettingsBtn()
swaps.setSlippage('0.30')
swaps.setExpiry('2')
swaps.clickOnSettingsBtn()
swaps.selectInputCurrency(swaps.swapTokens.cow)
swaps.checkTokenBalance(staticSafes.SEP_STATIC_SAFE_1.substring(4), swaps.swapTokens.cow)
swaps.setInputValue(100)
swaps.selectOutputCurrency(swaps.swapTokens.dai)
swaps.clickOnExceeFeeChkbox()
swaps.clickOnSwapBtn()
swaps.clickOnSwapBtn()
})
create_tx.changeNonce(22)
create_tx.clickOnSignTransactionBtn()
create_tx.clickViewTransaction()
navigation.clickOnWalletExpandMoreIcon()
navigation.clickOnDisconnectBtn()
wallet.connectSigner(signer3)
create_tx.clickOnConfirmTransactionBtn()
create_tx.clickOnNoLaterOption()
create_tx.clickOnSignTransactionBtn()
navigation.clickOnWalletExpandMoreIcon()
navigation.clickOnDisconnectBtn()
wallet.connectSigner(signer)
create_tx.deleteTx()

getEvents()
checkDataLayerEvents(tx_created)
checkDataLayerEvents(tx_confirmed)
},
)
})
12 changes: 2 additions & 10 deletions cypress/e2e/regression/swaps_history_2.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@ describe('Swaps history tests 2', () => {
const dai = swaps.createRegex(swapsHistory.forAtLeastFullDai, 'DAI')
const eq = swaps.createRegex(swapsHistory.DAIeqCOW, 'COW')

create_tx.verifyExpandedDetails([
swapsHistory.sellFull,
dai,
eq,
swapsHistory.dai,
swapsHistory.filled,
swapsHistory.gGpV2,
])
create_tx.verifyExpandedDetails([swapsHistory.sellFull, dai, eq, swapsHistory.dai, swapsHistory.filled])
})

// TODO: Added to prod
Expand Down Expand Up @@ -70,7 +63,6 @@ describe('Swaps history tests 2', () => {
eq,
swapsHistory.cow,
swapsHistory.cancelled,
swapsHistory.gGpV2,
])
})

Expand Down Expand Up @@ -133,7 +125,7 @@ describe('Swaps history tests 2', () => {
swapsHistory.forAtMost,
])
main.verifyValuesDoNotExist(create_tx.transactionItem, [swapsHistory.title, swapsHistory.cow, swapsHistory.dai])
main.verifyValuesExist(create_tx.transactionItem, [swapsHistory.actionPreSignatureG, swapsHistory.safeAppTitile])
main.verifyValuesExist(create_tx.transactionItem, [swapsHistory.actionPreSignatureG, swapsHistory.gGpV2])
},
)

Expand Down
Loading

0 comments on commit de3c784

Please sign in to comment.