Skip to content

Commit

Permalink
tests: fix drain account tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mike10ca committed Jan 31, 2024
1 parent 4658381 commit c65fbc3
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions cypress/e2e/safe-apps/drain_account.spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import 'cypress-file-upload'
import * as constants from '../../support/constants'
import * as main from '../pages/main.page'
import * as safeapps from '../pages/safeapps.pages'
import * as navigation from '../pages/navigation.page'

describe('Drain Account tests', { defaultCommandTimeout: 12000 }, () => {
const appUrl = constants.drainAccount_url
const iframeSelector = `iframe[id="iframe-${appUrl}"]`
const visitUrl = `/apps/open?safe=${constants.SEPOLIA_TEST_SAFE_5}&appUrl=${encodeURIComponent(appUrl)}`
const visitUrl = `/apps/open?safe=${constants.SEPOLIA_TEST_SAFE_9}&appUrl=${encodeURIComponent(appUrl)}`

beforeEach(() => {
cy.intercept(`**//v1/chains/5/safes/${constants.SEPOLIA_TEST_SAFE_5.substring(4)}/balances/**`, {
cy.intercept(`**//v1/chains/11155111/safes/${constants.SEPOLIA_TEST_SAFE_9.substring(4)}/balances/**`, {
fixture: 'balances.json',
})

Expand All @@ -19,72 +20,72 @@ describe('Drain Account tests', { defaultCommandTimeout: 12000 }, () => {
safeapps.clickOnContinueBtn()
})

it.skip('Verify drain can be created', () => {
it('Verify drain can be created', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.recipientStr).type(constants.SAFE_APP_ADDRESS_2)
getBody().findByLabelText(safeapps.recipientStr).type(constants.SEPOLIA_TEST_SAFE_10)
getBody().findAllByText(safeapps.transferEverythingStr).click()
})
cy.findByRole('button', { name: safeapps.testTransfer1 })
cy.findByRole('button', { name: safeapps.testNativeTransfer2 })
})

it.skip('Verify partial drain can be created', () => {
it('Verify partial drain can be created', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.selectAllRowsChbxStr).click()
getBody().findAllByLabelText(safeapps.selectRowChbxStr).eq(1).click()
getBody().findAllByLabelText(safeapps.selectRowChbxStr).eq(2).click()
getBody().findByLabelText(safeapps.recipientStr).clear().type(constants.SAFE_APP_ADDRESS_2)
getBody().findByLabelText(safeapps.recipientStr).clear().type(constants.SEPOLIA_TEST_SAFE_10)
getBody().findAllByText(safeapps.transfer2AssetsStr).click()
})
cy.findByRole('button', { name: safeapps.testTransfer2 })
cy.findByRole('button', { name: safeapps.testNativeTransfer1 })
})

// TODO: ENS does not resolve
it.skip('Verify a drain can be created when a ENS is specified', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.recipientStr).type('goerli-test-safe.eth').wait(2000)
getBody().findByLabelText(safeapps.recipientStr).type(constants.ENS_TEST_SEPOLIA).wait(2000)
getBody().findAllByText(safeapps.transferEverythingStr).click()
})
cy.findByRole('button', { name: safeapps.testTransfer1 })
cy.findByRole('button', { name: safeapps.testNativeTransfer2 })
})

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

it.skip('Verify a drain cannot be created with no recipient selected', () => {
it('Verify a drain cannot be created with no recipient selected', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findAllByText(safeapps.transferEverythingStr).click()
getBody().findByText(safeapps.validRecipientAddressStr)
})
})

it.skip('Verify a drain cannot be created with invalid recipient selected', () => {
it('Verify a drain cannot be created with invalid recipient selected', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.recipientStr).type(constants.SAFE_APP_ADDRESS_2.substring(1))
getBody().findByLabelText(safeapps.recipientStr).type(constants.SEPOLIA_TEST_SAFE_10.substring(1))
getBody().findAllByText(safeapps.transferEverythingStr).click()
getBody().findByText(safeapps.validRecipientAddressStr)
})
})

it.skip('Verify a drain cannot be created when no assets are selected', () => {
it('Verify a drain cannot be created when no assets are selected', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.selectAllRowsChbxStr).click()
getBody().findByLabelText(safeapps.recipientStr).type(constants.SAFE_APP_ADDRESS_2)
getBody().findByLabelText(safeapps.recipientStr).type(constants.SEPOLIA_TEST_SAFE_10)
getBody().findAllByText(safeapps.noTokensSelectedStr).should('be.visible')
})
})

it.skip('Verify a drain cannot be created when no assets and recipient are selected', () => {
it('Verify a drain cannot be created when no assets and recipient are selected', () => {
cy.enter(iframeSelector).then((getBody) => {
getBody().findByLabelText(safeapps.selectAllRowsChbxStr).click()
getBody().findAllByText(safeapps.noTokensSelectedStr).should('be.visible')
Expand Down

0 comments on commit c65fbc3

Please sign in to comment.