Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mike10ca committed Nov 17, 2023
1 parent b93e392 commit cdaae40
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 17 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/pages/create_wallet.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const createNewSafeBtn = 'span[data-track="create-safe: Continue to creation"]'
const connectWalletBtn = 'Connect wallet'
const googleConnectBtn = '[data-testid="google-connect-btn"]'
const googleSignedinBtn = '[data-testid="signed-in-account-btn"]'
const googleAccountInfoHeader = '[data-testid="open-account-center"]'
export const accountInfoHeader = '[data-testid="open-account-center"]'
const reviewStepOwnerInfo = '[data-testid="review-step-owner-info"]'
const reviewStepNextBtn = '[data-testid="review-step-next-btn"]'
const safeCreationStatusInfo = '[data-testid="safe-status-info"]'
Expand Down Expand Up @@ -68,7 +68,7 @@ export function verifyGoogleSignin() {
}

export function verifyGoogleAccountInfoInHeader() {
return cy.get(googleAccountInfoHeader).should('exist')
return cy.get(accountInfoHeader).should('exist')
}

export function verifyPolicy1_1() {
Expand Down
4 changes: 4 additions & 0 deletions cypress/e2e/pages/main.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export function clickOnSideMenuItem(item) {
cy.get('p').contains(item).click()
}

export function waitForTrnsactionHistoryToComplete() {
cy.intercept('GET', constants.transactionHistoryEndpoint).as('History')
cy.wait('@History')
}
export function acceptCookies(index = 0) {
cy.wait(1000)

Expand Down
2 changes: 2 additions & 0 deletions cypress/e2e/pages/navigation.page.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const sideNavSettingsIcon = '[data-testid="settings-nav-icon"]'
export const setupSection = '[data-testid="setup-section"]'
export const modalBackBtn = '[data-testid="modal-back-btn"]'

export function clickOnSideNavigation(option) {
cy.get(option).should('exist').click()
Expand Down
15 changes: 8 additions & 7 deletions cypress/e2e/pages/owners.pages.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as constants from '../../support/constants'
import * as main from '../pages/main.page'
import * as createWallet from '../pages/create_wallet.pages'
import * as navigation from '../pages/navigation.page'

const copyToClipboardBtn = 'button[aria-label="Copy to clipboard"]'
const tooltipLabel = (label) => `span[aria-label="${label}"]`
const removeOwnerBtn = 'span[data-track="settings: Remove owner"] > span > button'
const replaceOwnerBtn = 'span[data-track="settings: Replace owner"] > span > button'
const addOwnerBtn = 'span[data-track="settings: Add owner"] > button'
const tooltip = 'div[role="tooltip"]'
const expandMoreIcon = 'svg[data-testid="ExpandMoreIcon"]'
const sentinelStart = 'div[data-testid="sentinelStart"]'
Expand All @@ -21,12 +22,13 @@ const existingOwnerAddressInput = (index) => `input[name="owners.${index}.addres
const existingOwnerNameInput = (index) => `input[name="owners.${index}.name"]`
const singleOwnerNameInput = 'input[name="name"]'
const finishTransactionBtn = '[data-testid="finish-transaction-btn"]'
const addOwnerBtn = '[data-testid="add-owner-btn"]'
const addOwnerNextBtn = '[data-testid="add-owner-next-btn"]'

const disconnectBtnStr = 'Disconnect'
const notConnectedStatus = 'Connect'
const e2eWalletStr = 'E2E Wallet'
const max50charsLimitStr = 'Maximum 50 symbols'
const nextBtnStr = 'Next'
const executeBtnStr = 'Execute'
const backbtnStr = 'Back'
const removeOwnerStr = 'Remove owner'
Expand Down Expand Up @@ -160,12 +162,11 @@ export function clickOnConnectBtn() {
}

export function waitForConnectionStatus() {
cy.get('div').contains(e2eWalletStr)
cy.get(createWallet.accountInfoHeader).should('exist')
}

export function openAddOwnerWindow() {
cy.get('span').contains(addNewOwnerStr).click()
cy.wait(1000)
cy.get(addOwnerBtn).should('be.enabled').click()
cy.get(newOwnerName).should('be.visible')
cy.get(newOwnerAddress).should('be.visible')
}
Expand Down Expand Up @@ -203,11 +204,11 @@ export function verifyNewOwnerName(name) {
}

export function clickOnNextBtn() {
cy.get('button').contains(nextBtnStr).click()
cy.get(addOwnerNextBtn).should('be.enabled').click()
}

export function clickOnBackBtn() {
cy.get('button').contains(backbtnStr).click()
cy.get(navigation.modalBackBtn).should('be.enabled').click()
}

export function verifyConfirmTransactionWindowDisplayed() {
Expand Down
9 changes: 5 additions & 4 deletions cypress/e2e/smoke/add_owner.cy.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import * as constants from '../../support/constants'
import * as main from '../../e2e/pages/main.page'
import * as owner from '../pages/owners.pages'
import * as navigation from '../pages/navigation.page'

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

it('[SMOKE] Verify the presence of "Add Owner" button', () => {
Expand All @@ -16,6 +18,7 @@ describe('[SMOKE] Add Owners tests', () => {

it('[SMOKE] Verify “Add new owner” button tooltip displays correct message for Non-Owner', () => {
cy.visit(constants.setupUrl + constants.SEPOLIA_TEST_SAFE_2)
main.waitForTrnsactionHistoryToComplete()
owner.verifyAddOwnerBtnIsDisabled()
})

Expand Down Expand Up @@ -52,9 +55,7 @@ describe('[SMOKE] Add Owners tests', () => {
owner.typeOwnerAddress(constants.SEPOLIA_OWNER_2)
owner.clickOnNextBtn()
owner.verifyConfirmTransactionWindowDisplayed()
cy.reload()
owner.waitForConnectionStatus()
owner.openAddOwnerWindow()
owner.clickOnBackBtn()
owner.typeOwnerAddress(constants.SEPOLIA_TEST_SAFE_2)
owner.clickOnNextBtn()
owner.verifyConfirmTransactionWindowDisplayed()
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/smoke/address_book.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('[SMOKE] Address book tests', () => {
beforeEach(() => {
cy.clearLocalStorage()
cy.visit(constants.addressBookUrl + constants.SEPOLIA_TEST_SAFE_1)
main.waitForTrnsactionHistoryToComplete()
main.acceptCookies()
})

Expand All @@ -28,7 +29,6 @@ describe('[SMOKE] Address book tests', () => {
addressBook.verifyEditedNameNotExists(EDITED_NAME)
})

// TODO: Update Goerli title in TestRail
it('[SMOKE] Verify csv file can be imported', () => {
addressBook.clickOnImportFileBtn()
addressBook.importFile()
Expand Down
1 change: 1 addition & 0 deletions cypress/support/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const validAppUrl = 'https://my-valid-custom-app.com'

export const proposeEndpoint = '/**/propose'
export const appsEndpoint = '/**/safe-apps'
export const transactionHistoryEndpoint = '**/history'

export const mainSideMenuOptions = {
home: 'Home',
Expand Down
1 change: 1 addition & 0 deletions src/components/settings/owner/OwnerList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const OwnerList = () => {
{(isOk) => (
<Track {...SETTINGS_EVENTS.SETUP.ADD_OWNER}>
<Button
data-testid="add-owner-btn"
onClick={() => setTxFlow(<AddOwnerFlow />)}
variant="text"
startIcon={<SvgIcon component={AddIcon} inheritViewBox fontSize="small" />}
Expand Down
4 changes: 2 additions & 2 deletions src/components/tx-flow/flows/AddOwner/ChooseOwner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const ChooseOwner = ({
control={control}
name="threshold"
render={({ field }) => (
<TextField select {...field}>
<TextField data-testid="owner-number-dropdown" select {...field}>
{safe.owners.map((_, idx) => (
<MenuItem key={idx + 1} value={idx + 1}>
{idx + 1}
Expand All @@ -178,7 +178,7 @@ export const ChooseOwner = ({
<Divider className={commonCss.nestedDivider} />

<CardActions>
<Button variant="contained" type="submit" disabled={!isValid || resolving}>
<Button data-testid="add-owner-next-btn" variant="contained" type="submit" disabled={!isValid || resolving}>
Next
</Button>
</CardActions>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Setup: NextPage = () => {
<SettingsHeader />

<main>
<Paper sx={{ p: 4, mb: 2 }}>
<Paper data-testid="setup-section" sx={{ p: 4, mb: 2 }}>
<Grid container spacing={3}>
<Grid item lg={4} xs={12}>
<Typography variant="h4" fontWeight={700}>
Expand Down

0 comments on commit cdaae40

Please sign in to comment.