Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into epic/multichain-safes
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Sep 16, 2024
2 parents 09fc8a6 + 6ff1680 commit 80c8649
Show file tree
Hide file tree
Showing 30 changed files with 737 additions and 857 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
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/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
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)
})
})
4 changes: 2 additions & 2 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
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)
},
)
})
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 @@ -69,7 +69,7 @@ describe('Drain Account tests', () => {
getBody().findByLabelText(safeapps.recipientStr).type(safeAppSafes.SEP_SAFEAPP_SAFE_2)
getBody().findAllByText(safeapps.transferEverythingStr).click()
})
navigation.clickOnModalCloseBtn()
navigation.clickOnModalCloseBtn(1)
cy.enter(iframeSelector).then((getBody) => {
getBody().findAllByText(safeapps.transferEverythingStr).should('be.visible')
})
Expand Down
Loading

0 comments on commit 80c8649

Please sign in to comment.