Skip to content

Commit

Permalink
Update tests structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mike10ca committed Nov 16, 2023
1 parent 3598c18 commit fd0e97b
Show file tree
Hide file tree
Showing 38 changed files with 787 additions and 1,017 deletions.
12 changes: 11 additions & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from 'cypress'
import * as fs from 'fs'

export default defineConfig({
projectId: 'exhdra',
Expand All @@ -8,8 +9,17 @@ export default defineConfig({
runMode: 1,
openMode: 0,
},

e2e: {
setupNodeEvents(on, config) {
on('after:spec', (spec, results) => {
if (results && results.video) {
const failures = results.tests.some((test) => test.attempts.some((attempt) => attempt.state === 'failed'))
if (!failures) {
fs.unlinkSync(results.video)
}
}
})
},
baseUrl: 'http://localhost:3000',
testIsolation: false,
hideXHR: true,
Expand Down
21 changes: 0 additions & 21 deletions cypress/e2e/create_safe.cy.js

This file was deleted.

29 changes: 0 additions & 29 deletions cypress/e2e/custom_apps.cy.js

This file was deleted.

44 changes: 0 additions & 44 deletions cypress/e2e/intercom.cy.js

This file was deleted.

54 changes: 0 additions & 54 deletions cypress/e2e/non_owner_spending_limit.cy.js

This file was deleted.

2 changes: 1 addition & 1 deletion cypress/e2e/pages/balances.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const hiddenTokenIcon = 'svg[data-testid="VisibilityOffOutlinedIcon"]'
const hideTokenDefaultString = 'Hide tokens'
const assetNameSortBtnStr = 'Asset'
const assetBalanceSortBtnStr = 'Balance'
const sendBtnStr = 'Send'
export const sendBtnStr = 'Send'
const sendTokensStr = 'Send tokens'

const pageRowsDefault = '25'
Expand Down
55 changes: 55 additions & 0 deletions cypress/e2e/regression/add_owner.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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'

describe('Add Owners tests', () => {
beforeEach(() => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_1)
cy.clearLocalStorage()
main.acceptCookies()
cy.contains(owner.safeAccountNonceStr, { timeout: 10000 })
})

it('Verify Tooltip displays correct message for disconnected user', () => {
owner.waitForConnectionStatus()
owner.clickOnWalletExpandMoreIcon()
owner.clickOnDisconnectBtn()
owner.verifyAddOwnerBtnIsDisabled()
})

it('Verify the Add New Owner Form can be opened', () => {
owner.waitForConnectionStatus()
owner.openAddOwnerWindow()
})

it('Verify error message displayed if character limit is exceeded in Name input', () => {
owner.waitForConnectionStatus()
owner.openAddOwnerWindow()
owner.typeOwnerName(main.generateRandomString(51))
owner.verifyErrorMsgInvalidAddress(constants.addressBookErrrMsg.exceedChars)
})

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)
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)
owner.waitForConnectionStatus()
owner.openAddOwnerWindow()
owner.typeOwnerAddress(constants.addresBookContacts.user1.address)
owner.selectNewOwner(constants.addresBookContacts.user1.name)
owner.verifyNewOwnerName(constants.addresBookContacts.user1.name)
})

it('Verify that Name field not mandatory', () => {
owner.waitForConnectionStatus()
owner.openAddOwnerWindow()
owner.typeOwnerAddress(constants.SEPOLIA_OWNER_2)
owner.clickOnNextBtn()
owner.verifyConfirmTransactionWindowDisplayed()
})
})
65 changes: 65 additions & 0 deletions cypress/e2e/regression/address_book.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import 'cypress-file-upload'
const path = require('path')
import { format } from 'date-fns'
import * as constants from '../../support/constants'
import * as addressBook from '../../e2e/pages/address_book.page'
import * as main from '../../e2e/pages/main.page'

const NAME = 'Owner1'
const EDITED_NAME = 'Edited Owner1'

describe('Address book tests', () => {
beforeEach(() => {
cy.clearLocalStorage()
cy.visit(constants.addressBookUrl + constants.SEPOLIA_TEST_SAFE_1)
main.acceptCookies()
})

//TODO: Use localstorage for setting up/deleting entries
it('Verify entered entry in Name input can be saved', () => {
addressBook.clickOnCreateEntryBtn()
addressBook.addEntry(NAME, constants.RECIPIENT_ADDRESS)
addressBook.clickOnEditEntryBtn()
addressBook.typeInNameInput(EDITED_NAME)
addressBook.clickOnSaveButton()
addressBook.verifyNameWasChanged(NAME, EDITED_NAME)
})

//TODO: Rework to use Polygon. Replace Verify csv file can be imported (Goerli) with this test
it.skip('Verify that Sepolia and Polygon addresses can be imported', () => {
// Go to a Safe on Gnosis Chain
cy.get('header')
.contains(/^G(ö|oe)rli$/)
.click()
cy.contains('Gnosis Chain').click()

// Navigate to the Address Book page
cy.visit(`/address-book?safe=${constants.GNO_TEST_SAFE}`)

// Waits for the Address Book table to be in the page
cy.contains('p', 'Address book').should('be.visible')

// Finds the imported Gnosis Chain address
cy.contains(constants.GNO_CSV_ENTRY.name).should('exist')
cy.contains(constants.GNO_CSV_ENTRY.address).should('exist')
})

// TODO: Rework with localstorage. Change title in Testrail. New title "...exported"
it('Verify the address book file can be downloaded', () => {
addressBook.clickOnImportFileBtn()
addressBook.importFile()
// Download the export file
const date = format(new Date(), 'yyyy-MM-dd', { timeZone: 'UTC' })
const fileName = `safe-address-book-${date}.csv` //name that is given to the file automatically

addressBook.clickOnExportFileBtn()
//This is the submit button for the Export modal. It requires an actuall class or testId to differentiate
//from the Export button at the top of the AB table
addressBook.confirmExport()

const downloadsFolder = Cypress.config('downloadsFolder')
//File reading is failing in the CI. Can be tested locally
cy.readFile(path.join(downloadsFolder, fileName)).should('exist')
// TODO: Add verifications on address and chain from file, import and export files should be equal including all chains from origin
})
})
Loading

0 comments on commit fd0e97b

Please sign in to comment.