Skip to content

Commit

Permalink
Tests: organise test safes (#3641)
Browse files Browse the repository at this point in the history
  • Loading branch information
mike10ca authored May 2, 2024
1 parent 388b6ee commit a93145c
Show file tree
Hide file tree
Showing 55 changed files with 584 additions and 260 deletions.
9 changes: 8 additions & 1 deletion cypress/e2e/happypath/recovery_hp_1.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ import * as main from '../pages/main.page'
import * as owner from '../pages/owners.pages'
import * as recovery from '../pages/recovery.pages'
import * as tx from '../pages/transactions.page'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'

let recoverySafes = []
//
describe('Recovery happy path tests 1', () => {
before(async () => {
recoverySafes = await getSafes(CATEGORIES.recovery)
})

beforeEach(() => {
cy.visit(constants.securityUrl + constants.SEPOLIA_TEST_SAFE_23_RECOVERY_1)
cy.visit(constants.securityUrl + recoverySafes.SEP_RECOVERY_SAFE_1)
cy.clearLocalStorage()
main.acceptCookies()
})
Expand Down
13 changes: 10 additions & 3 deletions cypress/e2e/happypath/recovery_hp_2.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ import * as constants from '../../support/constants'
import * as main from '../pages/main.page'
import * as ownerP from '../pages/owners.pages'
import * as recovery from '../pages/recovery.pages'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'

let recoverySafes = []

describe('Recovery happy path tests 2', () => {
before(async () => {
recoverySafes = await getSafes(CATEGORIES.recovery)
})

beforeEach(() => {
cy.visit(constants.homeUrl + constants.SEPOLIA_TEST_SAFE_24_RECOVERY_2)
cy.visit(constants.homeUrl + recoverySafes.SEP_RECOVERY_SAFE_2)
cy.clearLocalStorage()
main.acceptCookies()
})
Expand All @@ -16,7 +23,7 @@ describe('Recovery happy path tests 2', () => {
recovery.clickOnRecoveryExecuteBtn()
return false
})
main.fetchSafeData(constants.SEPOLIA_TEST_SAFE_24_RECOVERY_2.substring(4)).then((response) => {
main.fetchSafeData(recoverySafes.SEP_RECOVERY_SAFE_2.substring(4)).then((response) => {
expect(response.status).to.eq(200)
console.log(response.body)
expect(response.body).to.have.property('owners')
Expand All @@ -42,7 +49,7 @@ describe('Recovery happy path tests 2', () => {
recovery.verifyTxNotInQueue()
cy.wait(2000)

main.fetchSafeData(constants.SEPOLIA_TEST_SAFE_24_RECOVERY_2.substring(4)).then((response) => {
main.fetchSafeData(recoverySafes.SEP_RECOVERY_SAFE_2.substring(4)).then((response) => {
const owners = response.body.owners
expect(owners).to.include(owner)
})
Expand Down
13 changes: 10 additions & 3 deletions cypress/e2e/happypath/recovery_hp_3.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@ import * as main from '../pages/main.page'
import * as ownerP from '../pages/owners.pages'
import * as recovery from '../pages/recovery.pages'
import * as tx from '../pages/transactions.page'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'

let recoverySafes = []

describe('Recovery happy path tests 3', () => {
before(async () => {
recoverySafes = await getSafes(CATEGORIES.recovery)
})

beforeEach(() => {
cy.visit(constants.homeUrl + constants.SEPOLIA_TEST_SAFE_25_RECOVERY_3)
cy.visit(constants.homeUrl + recoverySafes.SEP_RECOVERY_SAFE_3)
cy.clearLocalStorage()
main.acceptCookies()
})

// Check that an owner can cancel account recovery tx
it.skip('Recovery setup happy path 3', { defaultCommandTimeout: 300000 }, () => {
main.fetchSafeData(constants.SEPOLIA_TEST_SAFE_25_RECOVERY_3.substring(4)).then((response) => {
main.fetchSafeData(recoverySafes.SEP_RECOVERY_SAFE_3.substring(4)).then((response) => {
expect(response.status).to.eq(200)
console.log(response.body)
expect(response.body).to.have.property('owners')
Expand Down Expand Up @@ -45,7 +52,7 @@ describe('Recovery happy path tests 3', () => {
tx.clickOnFinishBtn()
cy.wait(1000)

main.fetchSafeData(constants.SEPOLIA_TEST_SAFE_25_RECOVERY_3.substring(4)).then((response) => {
main.fetchSafeData(recoverySafes.SEP_RECOVERY_SAFE_3.substring(4)).then((response) => {
const owners = response.body.owners
expect(owners).to.include(constants.SPENDING_LIMIT_ADDRESS_2)
})
Expand Down
11 changes: 7 additions & 4 deletions cypress/e2e/happypath/sendfunds_connected_wallet.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SafeApiKit from '@safe-global/api-kit'
import { createEthersAdapter, createSigners } from '../../support/api/utils_ether'
import { createSafes } from '../../support/api/utils_protocolkit'
import { contracts, abi_qtrust, abi_nft_pc2 } from '../../support/api/contracts'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'

const safeBalanceEth = 305220000000000000n
const qtrustBanance = 93000000000000000025n
Expand All @@ -26,6 +27,7 @@ const unit_eth = 'ether'
let apiKit, protocolKitOwner1_S3, protocolKitOwner2_S3, outgoingSafeAddress

let safes = []
let safesData = []

const provider = new ethers.InfuraProvider(netwrok, Cypress.env('INFURA_API_KEY'))
const privateKeys = [walletCredentials.OWNER_1_PRIVATE_KEY, walletCredentials.OWNER_2_PRIVATE_KEY]
Expand All @@ -49,6 +51,7 @@ function visit(url) {

describe('Send funds with connected signer happy path tests', { defaultCommandTimeout: 60000 }, () => {
before(async () => {
safesData = await getSafes(CATEGORIES.funds)
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__cookies, ls.cookies.acceptedCookies)
main.addToLocalStorage(
constants.localStorageKeys.SAFE_v2__tokenlist_onboarding,
Expand All @@ -59,7 +62,7 @@ describe('Send funds with connected signer happy path tests', { defaultCommandTi
txServiceUrl: constants.stagingTxServiceUrl,
})

outgoingSafeAddress = constants.SEPOLIA_TEST_SAFE_43_SEND_FUNDS_HP13.substring(4)
outgoingSafeAddress = safesData.SEP_FUNDS_SAFE_6.substring(4)

const safeConfigurations = [
{ ethAdapter: ethAdapterOwner1, safeAddress: outgoingSafeAddress },
Expand All @@ -74,7 +77,7 @@ describe('Send funds with connected signer happy path tests', { defaultCommandTi

it('Verify tx creation and execution of NFT with connected signer', () => {
cy.wait(2000)
const originatingSafe = constants.SEPOLIA_TEST_SAFE_44_SEND_FUNDS_HP14.substring(4)
const originatingSafe = safesData.SEP_FUNDS_SAFE_7.substring(4)

function executeTransactionFlow(fromSafe, toSafe) {
return cy.visit(constants.balanceNftsUrl + fromSafe).then(() => {
Expand Down Expand Up @@ -106,7 +109,7 @@ describe('Send funds with connected signer happy path tests', { defaultCommandTi

it('Verify tx creation and execution of native token with connected signer', () => {
cy.wait(2000)
const targetSafe = constants.SEPOLIA_TEST_SAFE_32_SEND_NATIVE_HP1.substring(4)
const targetSafe = safesData.SEP_FUNDS_SAFE_12.substring(4)
function executeTransactionFlow(fromSafe, toSafe, tokenAmount) {
visit(constants.BALANCE_URL + fromSafe)
assets.clickOnSendBtn(0)
Expand Down Expand Up @@ -158,7 +161,7 @@ describe('Send funds with connected signer happy path tests', { defaultCommandTi

it('Verify tx creation and execution of non-native token with connected signer', () => {
cy.wait(2000)
const originatingSafe = constants.SEPOLIA_TEST_SAFE_28_SEND_FUNDS_HP1.substring(4)
const originatingSafe = safesData.SEP_FUNDS_SAFE_11.substring(4)
const amount = ethers.parseUnits(transferAmount, unit_eth).toString()

function executeTransactionFlow(fromSafe, toSafe) {
Expand Down
11 changes: 7 additions & 4 deletions cypress/e2e/happypath/sendfunds_queue_1.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ethers } from 'ethers'
import SafeApiKit from '@safe-global/api-kit'
import { createEthersAdapter, createSigners } from '../../support/api/utils_ether'
import { createSafes } from '../../support/api/utils_protocolkit'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'

const walletCredentials = JSON.parse(Cypress.env('CYPRESS_WALLET_CREDENTIALS'))
const receiver = walletCredentials.OWNER_2_WALLET_ADDRESS
Expand All @@ -24,6 +25,7 @@ let apiKit,
existingSafeAddress3

let safes = []
let safesData = []

const provider = new ethers.InfuraProvider(netwrok, Cypress.env('INFURA_API_KEY'))
const privateKeys = [walletCredentials.OWNER_1_PRIVATE_KEY, walletCredentials.OWNER_2_PRIVATE_KEY]
Expand Down Expand Up @@ -51,14 +53,15 @@ function executeTransactionFlow(fromSafe) {

describe('Send funds from queue happy path tests 1', () => {
before(async () => {
safesData = await getSafes(CATEGORIES.funds)
apiKit = new SafeApiKit({
chainId: BigInt(1),
txServiceUrl: constants.stagingTxServiceUrl,
})

existingSafeAddress1 = constants.SEPOLIA_TEST_SAFE_40_SEND_FUNDS_HP9.substring(4)
existingSafeAddress2 = constants.SEPOLIA_TEST_SAFE_41_SEND_FUNDS_HP10.substring(4)
existingSafeAddress3 = constants.SEPOLIA_TEST_SAFE_41_SEND_FUNDS_HP11.substring(4)
existingSafeAddress1 = safesData.SEP_FUNDS_SAFE_3.substring(4)
existingSafeAddress2 = safesData.SEP_FUNDS_SAFE_4.substring(4)
existingSafeAddress3 = safesData.SEP_FUNDS_SAFE_5.substring(4)

const safeConfigurations = [
{ ethAdapter: ethAdapterOwner1, safeAddress: existingSafeAddress1 },
Expand Down Expand Up @@ -107,7 +110,7 @@ describe('Send funds from queue happy path tests 1', () => {
})
})

it('Verify confirmation and execution of native token queued tx by second signer with relayer', () => {
it.skip('Verify confirmation and execution of native token queued tx by second signer with relayer', () => {
function executeTransactionFlow(fromSafe) {
visit(constants.transactionQueueUrl + fromSafe)
assets.clickOnConfirmBtn(0)
Expand Down
18 changes: 10 additions & 8 deletions cypress/e2e/happypath/sendfunds_relay.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SafeApiKit from '@safe-global/api-kit'
import { createEthersAdapter, createSigners } from '../../support/api/utils_ether'
import { createSafes } from '../../support/api/utils_protocolkit'
import { contracts, abi_qtrust, abi_nft_pc2 } from '../../support/api/contracts'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'

const safeBalanceEth = 405210000000000000n
const qtrustBanance = 59000000000000000000n
Expand All @@ -25,6 +26,7 @@ const unit_eth = 'ether'
let apiKit, protocolKitOwner1_S3, protocolKitOwner2_S3, outgoingSafeAddress

let safes = []
let safesData = []

const provider = new ethers.InfuraProvider(netwrok, Cypress.env('INFURA_API_KEY'))
const privateKeys = [walletCredentials.OWNER_1_PRIVATE_KEY, walletCredentials.OWNER_2_PRIVATE_KEY]
Expand All @@ -48,6 +50,7 @@ function visit(url) {

describe('Send funds with relay happy path tests', { defaultCommandTimeout: 60000 }, () => {
before(async () => {
safesData = await getSafes(CATEGORIES.funds)
main.addToLocalStorage(constants.localStorageKeys.SAFE_v2__cookies, ls.cookies.acceptedCookies)
main.addToLocalStorage(
constants.localStorageKeys.SAFE_v2__tokenlist_onboarding,
Expand All @@ -58,7 +61,7 @@ describe('Send funds with relay happy path tests', { defaultCommandTimeout: 6000
txServiceUrl: constants.stagingTxServiceUrl,
})

outgoingSafeAddress = constants.SEPOLIA_TEST_SAFE_45_SEND_FUNDS_HP15.substring(4)
outgoingSafeAddress = safesData.SEP_FUNDS_SAFE_8.substring(4)

const safeConfigurations = [
{ ethAdapter: ethAdapterOwner1, safeAddress: outgoingSafeAddress },
Expand All @@ -71,10 +74,9 @@ describe('Send funds with relay happy path tests', { defaultCommandTimeout: 6000
protocolKitOwner2_S3 = safes[1]
})

it('Verify tx creation and execution of NFT with relay', () => {
it.skip('Verify tx creation and execution of NFT with relay', () => {
cy.wait(2000)
const originatingSafe = constants.SEPOLIA_TEST_SAFE_46_SEND_FUNDS_HP16.substring(4)

const originatingSafe = safesData.SEP_FUNDS_SAFE_9.substring(4)
function executeTransactionFlow(fromSafe, toSafe) {
return cy.visit(constants.balanceNftsUrl + fromSafe).then(() => {
nfts.selectNFTs(1)
Expand Down Expand Up @@ -104,9 +106,9 @@ describe('Send funds with relay happy path tests', { defaultCommandTimeout: 6000
})
})

it('Verify tx creation and execution of native token with relay', () => {
it.skip('Verify tx creation and execution of native token with relay', () => {
cy.wait(2000)
const targetSafe = constants.SEPOLIA_TEST_SAFE_34_SEND_FUNDS_HP3.substring(4)
const targetSafe = safesData.SEP_FUNDS_SAFE_1.substring(4)
function executeTransactionFlow(fromSafe, toSafe, tokenAmount) {
visit(constants.BALANCE_URL + fromSafe)
assets.clickOnSendBtn(0)
Expand Down Expand Up @@ -156,9 +158,9 @@ describe('Send funds with relay happy path tests', { defaultCommandTimeout: 6000
})
})

it('Verify tx creation and execution of non-native token with with relay', () => {
it.skip('Verify tx creation and execution of non-native token with with relay', () => {
cy.wait(2000)
const originatingSafe = constants.SEPOLIA_TEST_SAFE_36_SEND_FUNDS_HP5.substring(4)
const originatingSafe = safesData.SEP_FUNDS_SAFE_2.substring(4)
const amount = ethers.parseUnits(transferAmount, unit_eth).toString()

function executeTransactionFlow(fromSafe, toSafe) {
Expand Down
7 changes: 4 additions & 3 deletions cypress/e2e/pages/address_book.page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as constants from '../../support/constants'
import * as main from '../pages/main.page'
import * as constants from '../../support/constants.js'
import * as main from './main.page.js'
import staticSafes from '../../fixtures/safes/static.json'

export const addressBookRecipient = '[data-testid="address-book-recipient"]'
const beameriFrameContainer = '#beamerOverlay .iframeCointaner'
Expand Down Expand Up @@ -119,7 +120,7 @@ export function addEntryByENS(name, ens) {
typeInName(name)
typeInAddress(ens)
clickOnSaveEntryBtn()
verifyNewEntryAdded(name, constants.SEPOLIA_TEST_SAFE_7)
verifyNewEntryAdded(name, staticSafes.SEP_STATIC_SAFE_6)
}

export function verifyModalSummaryMessage(entryCount, chainCount) {
Expand Down
11 changes: 6 additions & 5 deletions cypress/e2e/pages/dashboard.pages.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as constants from '../../support/constants'
import * as safeapps from '../pages/safeapps.pages'
import * as main from '../pages/main.page'
import * as createtx from '../../e2e/pages/create_tx.pages'
import * as constants from '../../support/constants.js'
import * as safeapps from './safeapps.pages.js'
import * as main from './main.page.js'
import * as createtx from './create_tx.pages.js'
import staticSafes from '../../fixtures/safes/static.json'

const connectAndTransactStr = 'Connect & transact'
const transactionQueueStr = 'Pending transactions'
Expand Down Expand Up @@ -137,7 +138,7 @@ export function verifyTxQueueWidget() {
).should('exist')

cy.contains(
`a[href="${constants.transactionQueueUrl}${encodeURIComponent(constants.SEPOLIA_TEST_SAFE_5)}"]`,
`a[href="${constants.transactionQueueUrl}${encodeURIComponent(staticSafes.SEP_STATIC_SAFE_2)}"]`,
viewAllStr,
)
})
Expand Down
15 changes: 8 additions & 7 deletions cypress/e2e/pages/sidebar.pages.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as constants from '../../support/constants'
import * as main from './main.page'
import * as modal from '../pages/modals.page'
import * as navigation from './navigation.page'
import { safeHeaderInfo } from './import_export.pages'
import * as file from '../pages/import_export.pages'
import * as constants from '../../support/constants.js'
import * as main from './main.page.js'
import * as modal from './modals.page.js'
import * as navigation from './navigation.page.js'
import { safeHeaderInfo } from './import_export.pages.js'
import * as file from './import_export.pages.js'
import safes from '../../fixtures/safes/static.json'

export const chainLogo = '[data-testid="chain-logo"]'
const safeIcon = '[data-testid="safe-icon"]'
Expand Down Expand Up @@ -36,7 +37,7 @@ export const pendingActivationIcon = '[data-testid="pending-activation-icon"]'
export const addedSafesEth = ['0x8675...a19b']
export const addedSafesSepolia = ['0x6d0b...6dC1', '0x5912...fFdb', '0x0637...708e', '0xD157...DE9a']
export const sideBarListItems = ['Home', 'Assets', 'Transactions', 'Address book', 'Apps', 'Settings']
export const testSafeHeaderDetails = ['2/2', constants.SEPOLIA_TEST_SAFE_13_SHORT]
export const testSafeHeaderDetails = ['2/2', safes.SEP_STATIC_SAFE_9_SHORT]
const receiveAssetsStr = 'Receive assets'

export function getImportBtn() {
Expand Down
13 changes: 10 additions & 3 deletions cypress/e2e/regression/add_owner.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ import * as constants from '../../support/constants'
import * as main from '../../e2e/pages/main.page'
import * as owner from '../pages/owners.pages'
import * as addressBook from '../pages/address_book.page'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'

let staticSafes = []

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

beforeEach(() => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_1)
cy.visit(constants.setupUrl + staticSafes.SEP_STATIC_SAFE_4)
cy.clearLocalStorage()
main.acceptCookies()
cy.contains(owner.safeAccountNonceStr, { timeout: 10000 })
Expand All @@ -31,13 +38,13 @@ describe('Add Owners tests', () => {
})

it('Verify that the "Name" field is auto-filled with the relevant name from Address Book', () => {
cy.visit(constants.addressBookUrl + constants.SEPOLIA_TEST_SAFE_1)
cy.visit(constants.addressBookUrl + staticSafes.SEP_STATIC_SAFE_4)
addressBook.clickOnCreateEntryBtn()
addressBook.typeInName(constants.addresBookContacts.user1.name)
addressBook.typeInAddress(constants.addresBookContacts.user1.address)
addressBook.clickOnSaveEntryBtn()
addressBook.verifyNewEntryAdded(constants.addresBookContacts.user1.name, constants.addresBookContacts.user1.address)
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_1)
cy.visit(constants.setupUrl + staticSafes.SEP_STATIC_SAFE_4)
owner.waitForConnectionStatus()
owner.openAddOwnerWindow()
owner.typeOwnerAddress(constants.addresBookContacts.user1.address)
Expand Down
9 changes: 8 additions & 1 deletion cypress/e2e/regression/address_book.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ import * as addressBook from '../../e2e/pages/address_book.page'
import * as main from '../../e2e/pages/main.page'
import * as ls from '../../support/localstorage_data.js'
import * as sidebar from '../pages/sidebar.pages.js'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'

let staticSafes = []

const NAME = 'Owner1'
const EDITED_NAME = 'Edited Owner1'
const importedSafe = 'imported-safe'

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

beforeEach(() => {
cy.visit(constants.addressBookUrl + constants.SEPOLIA_TEST_SAFE_1)
cy.visit(constants.addressBookUrl + staticSafes.SEP_STATIC_SAFE_4)
cy.clearLocalStorage()
main.acceptCookies()
})
Expand Down
Loading

0 comments on commit a93145c

Please sign in to comment.