Skip to content

Commit

Permalink
Merge with dev
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Feb 14, 2024
2 parents efe33dd + 7567012 commit a5a5c45
Show file tree
Hide file tree
Showing 129 changed files with 3,242 additions and 678 deletions.
171 changes: 148 additions & 23 deletions cypress/e2e/pages/address_book.page.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,164 @@
export const acceptSelection = 'Save settings'
export const addressBook = 'Address book'
const createEntryBtn = 'Create entry'
import * as constants from '../../support/constants'
import * as main from '../pages/main.page'

export const addressBookRecipient = '[data-testid="address-book-recipient"]'
const beameriFrameContainer = '#beamerOverlay .iframeCointaner'
const beamerInput = 'input[id="beamer"]'
const nameInput = 'input[name="name"]'
const addressInput = 'input[name="address"]'
export const addressBookRecipient = '[data-testid="address-book-recipient"]'
const saveBtn = 'Save'
const exportModalBtn = '[data-testid="export-modal-btn"]'
export const editEntryBtn = 'button[aria-label="Edit entry"]'
export const deleteEntryBtn = 'button[aria-label="Delete entry"]'
export const deleteEntryModalBtnSection = '.MuiDialogActions-root'
const tableContainer = '[data-testid="table-container"]'
const tableRow = '[data-testid="table-row"]'
const importBtn = '[data-testid="import-btn"]'
const cancelImportBtn = '[data-testid="cancel-btn"]'
const uploadErrorMsg = '[data-testid="error-message"]'
const modalSummaryMessage = '[data-testid="summary-message"]'
const saveBtn = '[data-testid="save-btn"]'
const divInput = '[data-testid="name-input"]'
const exportSummary = '[data-testid="export-summary"]'
const sendBtn = '[data-testid="send-btn"]'
const nextPageBtn = 'button[aria-label="Go to next page"]'
const previousPageBtn = 'button[aria-label="Go to previous page"]'

//TODO Move to specific component
const moreActionIcon = '[data-testid="MoreHorizIcon"]'

export const acceptSelection = 'Save settings'
export const addressBook = 'Address book'
const createEntryBtn = 'Create entry'
export const delteEntryModaldeleteBtn = 'Delete'
const importBtn = 'Import'
const exportBtn = 'Export'
const exportModalBtn = '[data-testid="export-modal-btn"]'
// const saveBtn = 'Save'
const whatsNewBtnStr = "What's new"
const beamrCookiesStr = 'accept the "Beamer" cookies'
const headerImportBtnStr = 'Import'
const mandatoryNameStr = 'Name *'
const nameSortBtn = 'Name'
const addressortBtn = 'Address'
const addToAddressBookStr = 'Add to address book'

export const emptyCSVFile = '../fixtures/address_book_empty_test.csv'
export const nonCSVFile = '../fixtures/balances.json'
export const duplicatedCSVFile = 'address_book_duplicated.csv'
export const validCSVFile = '../fixtures/address_book_test.csv'
export const networksCSVFile = '../fixtures/address_book_networks.csv'
export const addedSafesCSVFile = '../fixtures/address_book_addedsafes.csv'

const sortSafe1 = 'AA Safe'
const sortSafe2 = 'BB Safe'

export const entries = [
'0x6E834E9D04ad6b26e1525dE1a37BFd9b215f40B7',
'test-sepolia-3',
'0xf405BC611F4a4c89CCB3E4d083099f9C36D966f8',
'sepolia-test-4',
'0x03042B890b99552b60A073F808100517fb148F60',
'sepolia-test-5',
'0xBd69b0a9DC90eB6F9bAc3E4a5875f437348b6415',
'assets-test-sepolia',
]

export function clickOnNextPageBtn() {
cy.get(nextPageBtn).click()
}

export function clickOnPrevPageBtn() {
cy.get(previousPageBtn).click()
}

export function verifyCountOfSafes(count) {
main.verifyElementsCount(tableRow, count)
}
export function verifyRecipientData(data) {
main.verifyValuesExist(addressBookRecipient, data)
}

export function clickOnSendBtn() {
cy.get(sendBtn).click()
}

export function clickOnMoreActionsBtn() {
cy.get(moreActionIcon).click()
}

export function clickOnAddToAddressBookBtn() {
cy.get('li span').contains(addToAddressBookStr).click()
}

export function verifyExportMessage(count) {
let msg = `${count} address book`
cy.get(exportSummary).should('contain', msg)
}

export function clickOnNameSortBtn() {
cy.get(tableContainer).contains(nameSortBtn).click()
cy.wait(500)
}

export function clickOnAddrressSortBtn() {
cy.get(tableContainer).contains(addressortBtn).click()
cy.wait(500)
}

export function verifyEntriesOrder(option = 'ascending') {
let address = constants.DEFAULT_OWNER_ADDRESS
let name = sortSafe1
if (option == 'descending') {
address = constants.RECIPIENT_ADDRESS
name = sortSafe2
}

cy.get(tableRow).eq(0).contains(address)
cy.get(tableRow).eq(0).contains(name)
}

export function addEntryByENS(name, ens) {
typeInName(name)
typeInAddress(ens)
clickOnSaveEntryBtn()
verifyNewEntryAdded(name, constants.SEPOLIA_TEST_SAFE_7)
}

export function verifyModalSummaryMessage(entryCount, chainCount) {
cy.get(modalSummaryMessage).should(
'contain',
`Found ${entryCount} entries on ${chainCount} ${chainCount > 1 ? 'chains' : 'chain'}`,
)
}
export const uploadErrorMessages = {
fileType: 'File type must be text/csv',
emptyFile: 'No entries found in address book',
}

export function verifyUploadExportMessage(msg) {
main.verifyValuesExist(uploadErrorMsg, msg)
}

export function verifyImportBtnStatus(status) {
main.verifyElementsStatus([importBtn], status)
}

export function verifyNumberOfRows(number) {
main.verifyElementsCount(tableRow, number)
}

export function clickOnImportFileBtn() {
cy.contains(importBtn).click()
cy.contains(headerImportBtnStr).click()
}

export function importFile() {
cy.get('[type="file"]').attachFile('../fixtures/address_book_test.csv')
// Import button should be enabled
cy.get('.MuiDialogActions-root').contains('Import').should('not.be.disabled')
cy.get('.MuiDialogActions-root').contains('Import').click()
export function importCSVFile(file) {
cy.get('[type="file"]').attachFile(file)
}

export function verifyImportModalIsClosed() {
cy.get('Import address book').should('not.exist')
export function clickOnImportBtn() {
cy.get(importBtn).click()
}

export function verifyDataImported(name, address) {
cy.contains(name).should('exist')
cy.contains(address).should('exist')
export function verifyDataImported(data) {
main.verifyValuesExist(tableContainer, data)
}

export function clickOnExportFileBtn() {
Expand All @@ -59,7 +182,7 @@ export function typeInAddress(address) {
}

export function clickOnSaveEntryBtn() {
cy.contains('button', saveBtn).click()
cy.get(saveBtn).click()
}

export function verifyNewEntryAdded(name, address) {
Expand All @@ -82,10 +205,6 @@ export function typeInNameInput(name) {
cy.get(nameInput).clear().type(name).should('have.value', name)
}

export function clickOnSaveButton() {
cy.contains('button', saveBtn).click()
}

export function verifyNameWasChanged(name, editedName) {
cy.get(name).should('not.exist')
cy.contains(editedName).should('exist')
Expand Down Expand Up @@ -119,3 +238,9 @@ export function verifyBeameriFrameExists() {
cy.wait(1000)
cy.get(beameriFrameContainer).should('exist')
}

export function verifyEmptyOwnerNameNotAllowed() {
cy.get(nameInput).clear()
main.verifyElementsStatus([saveBtn], constants.enabledStates.disabled)
cy.get(divInput).contains(mandatoryNameStr)
}
11 changes: 11 additions & 0 deletions cypress/e2e/pages/assets.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const hiddenTokenSaveBtn = 'span[data-track="assets: Save hide dialog"]'
const hiddenTokenCancelBtn = 'span[data-track="assets: Cancel hide dialog"]'
const hiddenTokenDeselectAllBtn = 'span[data-track="assets: Deselect all hide dialog"]'
const hiddenTokenIcon = 'svg[data-testid="VisibilityOffOutlinedIcon"]'
const currencySelector = '[data-testid="currency-selector"]'
const currencyItem = '[data-testid="currency-item"]'

const hideTokenDefaultString = 'Hide tokens'
const assetNameSortBtnStr = 'Asset'
Expand Down Expand Up @@ -91,6 +93,15 @@ export const currentcyGnosisFormat = '< 0.00001 GNO'
export const currencyOx = /^0x$/
export const currentcyOxFormat = '1.003 ZRX'

function clickOnCurrencySelector() {
cy.get(currencySelector).click()
}

export function changeCurrency(currency) {
clickOnCurrencySelector()
cy.get(currencyItem).contains(currency).click()
}

export function clickOnSendBtn(index) {
cy.get('button')
.contains(sendBtnStr)
Expand Down
7 changes: 6 additions & 1 deletion cypress/e2e/pages/create_wallet.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const ownerAddress = 'input[name^="owners"][name$="address"]'
const thresholdInput = 'input[name="threshold"]'
export const removeOwnerBtn = 'button[aria-label="Remove owner"]'
const connectingContainer = 'div[class*="connecting-container"]'
const createNewSafeBtn = 'span[data-track="create-safe: Continue to creation"]'
const createNewSafeBtn = '[data-testid="create-safe-btn"]'
const continueWithWalletBtn = 'span[data-track="create-safe: Continue to my accounts"]'
const connectWalletBtn = 'Connect wallet'
const googleConnectBtn = '[data-testid="google-connect-btn"]'
const googleSignedinBtn = '[data-testid="signed-in-account-btn"]'
Expand Down Expand Up @@ -110,6 +111,10 @@ export function clickOnCreateNewSafeBtn() {
cy.get(createNewSafeBtn).click().wait(1000)
}

export function clickOnContinueWithWalletBtn() {
cy.get(continueWithWalletBtn).click().wait(1000)
}

export function clickOnConnectWalletBtn() {
cy.get(welcomeLoginScreen).within(() => {
cy.get('button').contains(connectWalletBtn).should('be.visible').should('be.enabled').click().wait(1000)
Expand Down
5 changes: 4 additions & 1 deletion cypress/e2e/pages/navigation.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const sentinelStart = 'div[data-testid="sentinelStart"]'
const disconnectBtnStr = 'Disconnect'
const notConnectedStatus = 'Connect'

export function verifyTxBtnStatus(status) {
cy.get(newTxBtn).should(status)
}
export function clickOnSideNavigation(option) {
cy.get(option).should('exist').click()
}
Expand All @@ -23,7 +26,7 @@ export function clickOnNewTxBtn() {

export function clickOnWalletExpandMoreIcon() {
cy.get(expandMoreIcon).eq(0).click()
cy.get(sentinelStart).next().should('be.visible')
cy.get(sentinelStart).next().should('exist')
}

export function clickOnDisconnectBtn() {
Expand Down
44 changes: 26 additions & 18 deletions cypress/e2e/pages/sidebar.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const sideBarListItem = '[data-testid="sidebar-list-item"]'
const sideBarListItemWhatsNew = '[data-testid="list-item-whats-new"]'
const sideBarListItemNeedHelp = '[data-testid="list-item-need-help"]'
const sideSafeListItem = '[data-testid="safe-list-item"]'
const sidebarSafeHeader = '[data-testid="sidebar-safe-header"]'
const sidebarSafeHeader = '[data-testid="safe-header-info"]'
const sidebarSafeContainer = '[data-testid="sidebar-safe-container"]'
const safeItemOptionsBtn = '[data-testid="safe-options-btn"]'
const safeItemOptionsRenameBtn = '[data-testid="rename-btn"]'
Expand All @@ -26,8 +26,10 @@ const cancelBtn = '[data-testid="cancel-btn"]'
const deleteBtn = '[data-testid="delete-btn"]'
const readOnlyVisibility = '[data-testid="read-only-visibility"]'
const currencySection = '[data-testid="currency-section"]'
const missingSignatureInfo = '[data-testid="missing-signature-info"]'
const queuedTxInfo = '[data-testid="queued-tx-info"]'

export const addedSafesGnosis = ['0x17b3...98C8', '0x11A6...F1BB', '0xB8d7...642A']
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]
Expand Down Expand Up @@ -113,34 +115,34 @@ export function verifySafesByNetwork(netwrok, safes) {
cy.get(sidebarSafeContainer).within(() => {
cy.get(chainLogo)
.contains(netwrok)
.parent()
.next()
.within(() => {
main.verifyValuesExist(sideSafeListItem, safes)
})
})
}

function getSafeItemByName(name) {
return cy.get(sidebarSafeContainer).find(sideSafeListItem).contains(name).parents('li')
}

export function verifySafeReadOnlyState(safe) {
cy.get(sidebarSafeContainer).within(() => {
cy.get(sideSafeListItem)
.contains(safe)
.parents('li')
.within(() => {
cy.get(readOnlyVisibility).should('exist')
})
})
getSafeItemByName(safe).find(readOnlyVisibility).should('exist')
}

export function verifyMissingSignature(safe) {
getSafeItemByName(safe).find(missingSignatureInfo).should('exist')
}

export function verifyQueuedTx(safe) {
return getSafeItemByName(safe).find(queuedTxInfo).should('exist')
}

function clickOnSafeItemOptionsBtn(name) {
cy.get(sidebarSafeContainer).within(() => {
cy.get(sideSafeListItem)
.contains(name)
.parents('li')
.within(() => {
cy.get(safeItemOptionsBtn).click()
})
})
getSafeItemByName(name).find(safeItemOptionsBtn).click()
}

export function renameSafeItem(oldName, newName) {
clickOnSafeItemOptionsBtn(oldName)
clickOnRenameBtn()
Expand Down Expand Up @@ -188,3 +190,9 @@ export function clickOnSaveBtn() {
function verifyModalRemoved() {
main.verifyElementsCount(modal.modalTitle, 0)
}

export function checkCurrencyInHeader(currency) {
cy.get(sidebarSafeHeader).within(() => {
cy.get(currencySection).contains(currency)
})
}
Loading

0 comments on commit a5a5c45

Please sign in to comment.