Skip to content

Commit

Permalink
Update test definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
mike10ca committed Nov 7, 2023
1 parent f7d170d commit ef39efb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 38 deletions.
2 changes: 1 addition & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
trashAssetsBeforeRuns: true,

retries: {
runMode: 3,
runMode: 1,
openMode: 0,
},

Expand Down
3 changes: 3 additions & 0 deletions cypress/e2e/pages/safeapps.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const anotherChainStr = 'This batch is from another Chain (1)!'
export const useImplementationABI = 'Use Implementation ABI'
export const addressNotValidStr = 'The address is not valid'
export const transferEverythingStr = 'Transfer everything'
export const noTokensSelectedStr = 'No tokens selected'
export const requiredStr = 'Required'
export const e3eTestStr = 'E2E test'
export const createBtnStr = 'Create'
Expand All @@ -98,6 +99,8 @@ export const gridItem = 'main .MuiPaper-root > .MuiGrid-item'
export const linkNames = {
logo: /logo/i,
}
export const abi =
'[{{}"inputs":[{{}"internalType":"address","name":"_singleton","type":"address"{}}],"stateMutability":"nonpayable","type":"constructor"{}},{{}"stateMutability":"payable","type":"fallback"{}}]'

export const permissionCheckboxes = {
camera: 'input[name="camera"]',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Drain Account Safe App tests', { defaultCommandTimeout: 12000 }, () =>
safeapps.clickOnContinueBtn()
})

it('should allow to perform a drain', () => {
it('Verify drain can be created [C56627]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.recipientStr).type(constants.SAFE_APP_ADDRESS_2)
getBody().findAllByText(safeapps.transferEverythingStr).click()
Expand All @@ -28,7 +28,7 @@ describe('Drain Account Safe App tests', { defaultCommandTimeout: 12000 }, () =>
cy.findByRole('button', { name: safeapps.testNativeTransfer2 })
})

it('should allow to perform a partial drain', () => {
it('Verify partial drain can be created [C56628]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.selectAllRowsChbxStr).click()
getBody().findAllByLabelText(safeapps.selectRowChbxStr).eq(1).click()
Expand All @@ -40,7 +40,7 @@ describe('Drain Account Safe App tests', { defaultCommandTimeout: 12000 }, () =>
cy.findByRole('button', { name: safeapps.testNativeTransfer1 })
})

it('should allow to perform a drain when a ENS is specified', () => {
it('Verify a drain can be created when a ENS is specified [C56629]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.recipientStr).type('goerli-test-safe.eth').wait(2000)
getBody().findAllByText(safeapps.transferEverythingStr).click()
Expand All @@ -49,45 +49,45 @@ describe('Drain Account Safe App tests', { defaultCommandTimeout: 12000 }, () =>
cy.findByRole('button', { name: safeapps.testNativeTransfer2 })
})

// Adjust safe - owner
it.skip('should keep previous data when drain is cancelled', () => {
// TODO: Adjust safe - owner
it.skip('Verify when cancelling a drain, previous data is preserved [C56630]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.recipientStr).type(constants.SAFE_APP_ADDRESS_2)
getBody().findAllByText(safeapps.transferEverythingStr).click()
})
cy.findByRole('button', { name: 'Cancel' }).click()
cy.findByRole('button', { name: safeapps.cancelBtnStr }).click()
cy.enter(iframeSelector).then((getBody) => {
getBody().findAllByText(safeapps.transferEverythingStr).should('be.visible')
})
})

it('should not allow to perform a drain when no recipient is selected', () => {
it('Verify a drain cannot be created with no recipient selected [C56631]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findAllByText(safeapps.transferEverythingStr).click()
getBody().findByText(safeapps.validRecipientAddressStr)
})
})

it('should not allow to perform a drain when an invalid recipient is selected', () => {
it('Verify a drain cannot be created with invalid recipient selected [C56632]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.recipientStr).type('0x49d4450977E2c95362C13D3a31a09311E0Ea26A')
getBody().findByLabelText(safeapps.recipientStr).type(constants.SAFE_APP_ADDRESS_2.substring(1))
getBody().findAllByText(safeapps.transferEverythingStr).click()
getBody().findByText(safeapps.validRecipientAddressStr)
})
})

it('should not allow to perform a drain when no assets are selected', () => {
it('Verify a drain cannot be created when no assets are selected [C56633]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.selectAllRowsChbxStr).click()
getBody().findByLabelText(safeapps.recipientStr).type(constants.SAFE_APP_ADDRESS_2)
getBody().findAllByText('No tokens selected').should('be.visible')
getBody().findAllByText(safeapps.noTokensSelectedStr).should('be.visible')
})
})

it('should not allow to perform a drain when no assets and recipient are selected', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.selectAllRowsChbxStr).click()
getBody().findAllByText('No tokens selected').should('be.visible')
getBody().findAllByText(safeapps.noTokensSelectedStr).should('be.visible')
})
})
})
46 changes: 21 additions & 25 deletions cypress/e2e/safe-apps/tx-builder.spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as constants from '../../support/constants'
import * as main from '../pages/main.page'
import * as safeapps from '../pages/safeapps.pages'

describe('Tx-builder Safe App tests', { defaultCommandTimeout: 12000 }, () => {
describe('Tx-builder Safe App tests', { defaultCommandTimeout: 20000 }, () => {
const appUrl = constants.TX_Builder_url
const iframeSelector = `iframe[id="iframe-${appUrl}"]`
const visitUrl = `/apps/open?safe=${constants.GOERLI_SAFE_APPS_SAFE}&appUrl=${encodeURIComponent(appUrl)}`
Expand All @@ -14,7 +14,7 @@ describe('Tx-builder Safe App tests', { defaultCommandTimeout: 12000 }, () => {
safeapps.clickOnContinueBtn()
})

it('should allow to create and send a simple batch', () => {
it('Verify a simple batch can be created [C56609]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.enterAddressStr).type(constants.SAFE_APP_ADDRESS)
getBody().find(safeapps.contractMethodIndex).parent().click()
Expand All @@ -32,7 +32,7 @@ describe('Tx-builder Safe App tests', { defaultCommandTimeout: 12000 }, () => {
cy.findAllByText(constants.SAFE_APP_ADDRESS_2_SHORT).should('have.length', 1)
})

it('should allow to create and send a complex batch', () => {
it('Verify a complex batch can be created [C56610]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.enterAddressStr).type(constants.SAFE_APP_ADDRESS)
getBody().find(safeapps.contractMethodIndex).parent().click()
Expand All @@ -54,7 +54,7 @@ describe('Tx-builder Safe App tests', { defaultCommandTimeout: 12000 }, () => {
cy.findAllByText('True').should('have.length', 3)
})

it('should allow to create and send a batch to an ENS name', () => {
it('Verify a batch can be created using ENS name [C56611]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.enterAddressStr).type(constants.ENS_TEST_GOERLI)
getBody().findByRole('button', { name: safeapps.useImplementationABI }).click()
Expand All @@ -72,24 +72,20 @@ describe('Tx-builder Safe App tests', { defaultCommandTimeout: 12000 }, () => {
cy.findByText(safeapps.thresholdStr2).should('exist')
})

it('should allow to a create and send a batch from an ABI', () => {
it('Verify a batch can be created from an ABI [C56612]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody()
.findByLabelText(safeapps.enterABIStr)
.type(
'[{{}"inputs":[{{}"internalType":"address","name":"_singleton","type":"address"{}}],"stateMutability":"nonpayable","type":"constructor"{}},{{}"stateMutability":"payable","type":"fallback"{}}]',
)
getBody().findByLabelText(safeapps.enterABIStr).type(safeapps.abi)
getBody().findByLabelText(safeapps.toAddressStr).type(constants.SAFE_APP_ADDRESS_2)
getBody().findByLabelText(safeapps.gorValue).type('0')
getBody().findByText(safeapps.addTransactionStr).click()
getBody().findByText(safeapps.createBatchStr).click()
getBody().findByText(safeapps.sendBatchStr).click()
})
cy.findByRole('heading', { name: /transaction builder/i }).should('be.visible')
cy.get('h4').contains(safeapps.transactionBuilderStr).should('be.visible')
cy.findByText(constants.SAFE_APP_ADDRESS_2).should('be.visible')
})

it('should allow to create and send a batch using custom data', () => {
it('Verify a batch with custom data can be created [C56613]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().find('.MuiSwitch-root').click()
getBody().findByLabelText(safeapps.enterAddressStr).type(constants.SAFE_APP_ADDRESS_3)
Expand All @@ -103,7 +99,7 @@ describe('Tx-builder Safe App tests', { defaultCommandTimeout: 12000 }, () => {
cy.findByText(constants.SAFE_APP_ADDRESS_3).should('be.visible')
})

it('should allow to cancel a created batch', () => {
it('Verify a batch can be cancelled [C56614]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.enterAddressStr).type(constants.SAFE_APP_ADDRESS)
getBody().find(safeapps.contractMethodIndex).parent().click()
Expand All @@ -118,7 +114,7 @@ describe('Tx-builder Safe App tests', { defaultCommandTimeout: 12000 }, () => {
})
})

it('should allow to revert a cancel and continue with the flow', () => {
it('Verify cancel operation can be reverted [C56615]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.enterAddressStr).type(constants.SAFE_APP_ADDRESS)
getBody().find(safeapps.contractMethodIndex).parent().click()
Expand All @@ -133,7 +129,7 @@ describe('Tx-builder Safe App tests', { defaultCommandTimeout: 12000 }, () => {
})
})

it('should allow to go back without removing data and add more transactions to the batch', () => {
it('Verify it is allowed to go back without removing data and add more transactions to the batch [C56616]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.enterAddressStr).type(constants.SAFE_APP_ADDRESS)
getBody().find(safeapps.contractMethodIndex).parent().click()
Expand All @@ -154,30 +150,30 @@ describe('Tx-builder Safe App tests', { defaultCommandTimeout: 12000 }, () => {
cy.get('p').contains('2').should('be.visible')
})

it('should not allow to create a batch given invalid address', () => {
it('Verify a batch cannot be created with invalid address [C56617]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.enterAddressStr).type(constants.SAFE_APP_ADDRESS_3)
getBody().findAllByText(safeapps.addressNotValidStr).should('have.css', 'color', 'rgb(244, 67, 54)')
})
})

it('should not allow to create a batch given no asset amount', () => {
it('Verify a batch cannot be created without asset amount [C56618]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.enterAddressStr).type(constants.SAFE_APP_ADDRESS_3)
getBody().findByText(safeapps.addTransactionStr).click()
getBody().findAllByText(safeapps.requiredStr).should('have.css', 'color', 'rgb(244, 67, 54)')
})
})

it('should not allow to create a batch given no method data', () => {
it('Verify a batch cannot be created without method data [C56619]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.enterAddressStr).type(constants.SAFE_APP_ADDRESS_2)
getBody().findByText(safeapps.addTransactionStr).click()
getBody().findAllByText(safeapps.requiredStr).should('have.css', 'color', 'rgb(244, 67, 54)')
})
})

it('should allow to upload a batch, save it to the library, download it & remove it', () => {
it('Verify a batch can be uploaded, saved, downloaded and removed [C56620]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findAllByText('choose a file').attachFile('test-working-batch.json', { subjectType: 'drag-n-drop' })
getBody().findAllByText('uploaded').wait(300)
Expand All @@ -194,23 +190,23 @@ describe('Tx-builder Safe App tests', { defaultCommandTimeout: 12000 }, () => {
cy.readFile('cypress/downloads/E2E test.json').should('exist')
})

it('should notify when the uploaded batch is from a different chain', () => {
it('Verify there is notification if uploaded batch is from a different chain [C56621]', () => {
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('should show an error when a modified batch is uploaded', () => {
it('Verify there is error message when a modified batch is uploaded [C56622]', () => {
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('should not allow to upload an invalid batch', () => {
it('Verify an invalid batch cannot be uploaded [C56623]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody()
.findAllByText('choose a file')
Expand All @@ -220,7 +216,7 @@ describe('Tx-builder Safe App tests', { defaultCommandTimeout: 12000 }, () => {
})
})

it('should not allow to upload an empty batch', () => {
it('Verify an empty batch cannot be uploaded [C56624]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody()
.findAllByText('choose a file')
Expand All @@ -230,7 +226,7 @@ describe('Tx-builder Safe App tests', { defaultCommandTimeout: 12000 }, () => {
})
})

it('should simulate a valid batch as successful', () => {
it('Verify a valid batch as successful can be simulated [C56625]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.enterAddressStr).type(constants.SAFE_APP_ADDRESS_3)
getBody().findByLabelText(safeapps.gorValue).type('0')
Expand All @@ -242,7 +238,7 @@ describe('Tx-builder Safe App tests', { defaultCommandTimeout: 12000 }, () => {
})
})

it('should simulate an invalid batch as failed', () => {
it('Verify an invalid batch as failed can be simulated [C56626]', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.enterAddressStr).type(constants.TEST_SAFE_2)
getBody().findByText(safeapps.keepProxiABIStr).click()
Expand Down

0 comments on commit ef39efb

Please sign in to comment.