Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Automation tests updates #4335

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cypress/e2e/happypath/sendfunds_relay.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import SafeApiKit from '@safe-global/api-kit'
import { 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'
import * as wallet from '../../support/utils/wallet.js'
import * as fundSafes from '../../fixtures/safes/funds.json'

const transferAmount = '1'

Expand Down Expand Up @@ -55,7 +55,7 @@ describe('Send funds with relay happy path tests', { defaultCommandTimeout: 3000
ls.cookies.acceptedTokenListOnboarding,
)
})
safesData = await getSafes(CATEGORIES.funds)
safesData = fundSafes
apiKit = new SafeApiKit({
chainId: BigInt(1),
txServiceUrl: constants.stagingTxServiceUrl,
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/pages/safeapps.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const acceptBtnStr = /accept/i
const clearAllBtnStr = /clear all/i
const allowAllPermissions = /allow all/i
export const enterAddressStr = /enter address or ens name/i
export const addTransactionStr = /add transaction/i
export const addTransactionStr = /add new transaction/i
export const createBatchStr = /create batch/i
export const sendBatchStr = /send batch/i
export const transactionDetailsStr = /transaction details/i
Expand Down
66 changes: 35 additions & 31 deletions cypress/e2e/regression/add_owner.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,40 +65,44 @@ describe('Add Owners tests', () => {
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(1)
owner.clickOnNextBtn()
createTx.clickOnSignTransactionBtn()
createTx.clickViewTransaction()
it(
'Verify creation, confirmation and deletion of Add owner tx. GA tx_confirm',
{ defaultCommandTimeout: 30000 },
() => {
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(1)
owner.clickOnNextBtn()
createTx.clickOnSignTransactionBtn()
createTx.clickViewTransaction()

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

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

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

createTx.deleteTx()
createTx.deleteTx()

getEvents()
checkDataLayerEvents(tx_confirmed)
})
getEvents()
checkDataLayerEvents(tx_confirmed)
},
)
})
182 changes: 182 additions & 0 deletions cypress/e2e/safe-apps/tx-builder.2spec.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
import 'cypress-file-upload'
import * as constants from '../../support/constants.js'
import * as safeapps from '../pages/safeapps.pages.js'
import * as createtx from '../pages/create_tx.pages.js'
import * as navigation from '../pages/navigation.page.js'
import { getSafes, CATEGORIES } from '../../support/safes/safesHandler.js'
import * as ls from '../../support/localstorage_data.js'
import { getEvents, events, checkDataLayerEvents } from '../../support/utils/gtag.js'
import * as wallet from '../../support/utils/wallet.js'
import * as utils from '../../support/utils/checkers.js'

let safeAppSafes = []
let iframeSelector

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

describe('Transaction Builder 2 tests', { defaultCommandTimeout: 20000 }, () => {
before(async () => {
safeAppSafes = await getSafes(CATEGORIES.safeapps)
})

beforeEach(() => {
cy.clearLocalStorage()
cy.clearCookies()
cy.window().then((win) => {
win.localStorage.setItem(constants.localStorageKeys.SAFE_v2_cookies, ls.cookies.acceptedCookies)
win.localStorage.setItem(
constants.localStorageKeys.SAFE_v2__SafeApps__infoModal,
ls.appPermissions(constants.safeTestAppurl).infoModalAccepted,
)
})

const appUrl = constants.TX_Builder_url
iframeSelector = `iframe[id="iframe-${appUrl}"]`
const visitUrl = `/apps/open?safe=${safeAppSafes.SEP_SAFEAPP_SAFE_1}&appUrl=${encodeURIComponent(appUrl)}`
cy.visit(visitUrl)
})

it('Verify a batch cannot be created without method data', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.enterAddressStr).type(constants.SAFE_APP_ADDRESS)
getBody().findByText(safeapps.addTransactionStr).click()
getBody()
.findAllByText(safeapps.requiredStr)
.then(($element) => {
const color = $element.css('color')
expect(utils.isInRedRange(color), 'Element color is ').to.be.true
})
})
})

it('Verify a batch can be uploaded, saved to library, downloaded and removed', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findAllByText('choose a file').attachFile('test-working-batch.json', { subjectType: 'drag-n-drop' })
getBody().findAllByText('uploaded').wait(300)
getBody().find(safeapps.saveToLibraryBtn).click()
getBody().findByLabelText(safeapps.batchNameStr).type(safeapps.e3eTestStr)
getBody().findAllByText(safeapps.createBtnStr).should('not.be.disabled').click()
getBody().findByText(safeapps.transactionLibraryStr).click()
getBody().find(safeapps.downloadBatchBtn).click()
getBody().find(safeapps.deleteBatchBtn).click()
getBody().findAllByText(safeapps.confirmDeleteBtnStr).should('not.be.disabled').click()
getBody().findByText(safeapps.noSavedBatchesStr).should('be.visible')
getBody().findByText(safeapps.backToTransactionStr).should('be.visible')
})
cy.readFile('cypress/downloads/E2E test.json').should('exist')
})

it('Verify there is notification if uploaded batch is from a different chain', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findAllByText('choose a file').attachFile('test-mainnet-batch.json', { subjectType: 'drag-n-drop' })
getBody().findAllByText(safeapps.warningStr).should('be.visible')
getBody().findAllByText(safeapps.anotherChainStr).should('be.visible')
})
})

it('Verify there is error message when a modified batch is uploaded', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findAllByText('choose a file').attachFile('test-modified-batch.json', { subjectType: 'drag-n-drop' })
getBody().findAllByText(safeapps.changedPropertiesStr)
getBody().findAllByText('choose a file').should('be.visible')
})
})

it('Verify an invalid batch cannot be uploaded', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody()
.findAllByText('choose a file')
.attachFile('test-invalid-batch.json', { subjectType: 'drag-n-drop' })
.findAllByText('choose a file')
.should('be.visible')
})
})

it('Verify an empty batch cannot be uploaded', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody()
.findAllByText('choose a file')
.attachFile('test-empty-batch.json', { subjectType: 'drag-n-drop' })
.findAllByText('choose a file')
.should('be.visible')
})
})

it('Verify a valid batch as successful can be simulated', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.enterAddressStr).type(safeAppSafes.SEP_SAFEAPP_SAFE_2)
getBody().findByText(safeapps.keepProxiABIStr).click()
getBody().findByLabelText(safeapps.tokenAmount).type('0')
getBody().findByText(safeapps.addTransactionStr).click()
getBody().findByText(safeapps.createBatchStr).click()
getBody().findByText(safeapps.simulateBtnStr).click()
getBody().findByText(safeapps.transferStr).should('be.visible')
getBody().findByText(safeapps.successStr).should('be.visible')
})
})

it('Verify an invalid batch as failed can be simulated', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.enterAddressStr).type(safeAppSafes.SEP_SAFEAPP_SAFE_2)
getBody().findByText(safeapps.keepProxiABIStr).click()
getBody().findByLabelText(safeapps.tokenAmount).type('100')
getBody().findByText(safeapps.addTransactionStr).click()
getBody().findByText(safeapps.createBatchStr).click()
getBody().findByText(safeapps.simulateBtnStr).click()
getBody().findByText(safeapps.failedStr).should('be.visible')
})
})

// TODO: Fix visibility element
it('Verify a simple batch can be created, signed by second signer and deleted. GA tx_confirm, tx_created', () => {
const tx_created = [
{
eventLabel: events.txCreatedTxBuilder.eventLabel,
eventCategory: events.txCreatedTxBuilder.category,
eventType: events.txCreatedTxBuilder.eventType,
event: events.txCreatedTxBuilder.event,
safeAddress: safeAppSafes.SEP_SAFEAPP_SAFE_1.slice(6),
},
]
const tx_confirmed = [
{
eventLabel: events.txConfirmedTxBuilder.eventLabel,
eventCategory: events.txConfirmedTxBuilder.category,
eventType: events.txConfirmedTxBuilder.eventType,
safeAddress: safeAppSafes.SEP_SAFEAPP_SAFE_1.slice(6),
},
]
// wallet.connectSigner(signer)
// cy.enter(iframeSelector).then((getBody) => {
// getBody().findByLabelText(safeapps.enterAddressStr).type(constants.SAFE_APP_ADDRESS)
// getBody().find(safeapps.contractMethodIndex).parent().click()
// getBody().findByRole('option', { name: safeapps.testAddressValue2 }).click()
// getBody().findByLabelText(safeapps.newAddressValueStr).type(safeAppSafes.SEP_SAFEAPP_SAFE_2)
// getBody().findByText(safeapps.addTransactionStr).click()
// getBody().findAllByText(constants.SEPOLIA_CONTRACT_SHORT).should('have.length', 1)
// getBody().findByText(safeapps.testAddressValueStr).should('exist')
// getBody().findByText(safeapps.createBatchStr).click()
// getBody().findByText(safeapps.sendBatchStr).click()
// })

// createtx.clickOnSignTransactionBtn()
// createtx.clickViewTransaction()
// navigation.clickOnWalletExpandMoreIcon()
// navigation.clickOnDisconnectBtn()
// wallet.connectSigner(signer2)

// createtx.clickOnConfirmTransactionBtn()
// createtx.clickOnNoLaterOption()
// createtx.clickOnSignTransactionBtn()
// navigation.clickOnWalletExpandMoreIcon()
// navigation.clickOnDisconnectBtn()
// wallet.connectSigner(signer)
// createtx.deleteTx()
// createtx.verifyNumberOfTransactions(0)
// getEvents()
// checkDataLayerEvents(tx_created)
// checkDataLayerEvents(tx_confirmed)
})
})
Loading
Loading