-
Notifications
You must be signed in to change notification settings - Fork 471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cypress tests refactoring: PO model, safe app tests #2522
Changes from 13 commits
62d51df
c105c23
1e31579
0aedd0b
df2bfa8
e0fb772
f71b6cd
2dc4e01
1202fd8
d71f6b8
2829ad0
04c352e
c42e53e
84ba024
6f07fe8
3c49bc1
eccea6d
0d04552
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,6 +8,7 @@ const amountInput = 'input[name="amount"]' | |||||
const nonceInput = 'input[name="nonce"]' | ||||||
const gasLimitInput = '[name="gasLimit"]' | ||||||
const rotateLeftIcon = '[data-testid="RotateLeftIcon"]' | ||||||
const transactionItemExpandable = 'div[id^="transfer"]' | ||||||
|
||||||
const viewTransactionBtn = 'View transaction' | ||||||
const transactionDetailsTitle = 'Transaction details' | ||||||
|
@@ -26,6 +27,8 @@ const editBtnStr = 'Edit' | |||||
const executionParamsStr = 'Execution parameters' | ||||||
const noLaterStr = 'No, later' | ||||||
const signBtnStr = 'Sign' | ||||||
const expandallbtnStr = 'Expand all' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const collapseAllBtnStr = 'Collapse all' | ||||||
|
||||||
export function clickOnNewtransactionBtn() { | ||||||
// Assert that "New transaction" button is visible | ||||||
|
@@ -90,7 +93,7 @@ export function changeNonce(value) { | |||||
} | ||||||
|
||||||
export function verifyConfirmTransactionData() { | ||||||
cy.contains(yesStr).should('exist') | ||||||
cy.contains(yesStr).should('exist').click() | ||||||
cy.contains(estimatedFeeStr).should('exist') | ||||||
|
||||||
// Asserting the sponsored info is present | ||||||
|
@@ -149,3 +152,40 @@ export function verifyQueueLabel() { | |||||
export function verifyTransactionSummary(sendValue) { | ||||||
cy.contains(TransactionSummary + `${sendValue} ${constants.tokenAbbreviation.gor}`).should('exist') | ||||||
} | ||||||
|
||||||
export function verifyDateExists(date) { | ||||||
cy.contains('div', date).should('exist') | ||||||
} | ||||||
|
||||||
export function verifyImageAlttxt(index, text) { | ||||||
mike10ca marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
cy.get('img').eq(index).should('have.attr', 'alt', text).should('be.visible') | ||||||
} | ||||||
|
||||||
export function verifyStatus(status) { | ||||||
cy.contains('div', status).should('exist') | ||||||
} | ||||||
|
||||||
export function verifyTransactionStrExists(str) { | ||||||
cy.contains(str).should('exist') | ||||||
} | ||||||
|
||||||
export function verifyTransactionStrNotVible(str) { | ||||||
cy.contains(str).should('not.be.visible') | ||||||
} | ||||||
|
||||||
export function clickOnTransactionExpandableItem(name, actions) { | ||||||
cy.contains('div', name) | ||||||
.next() | ||||||
.click() | ||||||
.within(() => { | ||||||
actions() | ||||||
}) | ||||||
} | ||||||
|
||||||
export function lickOnExpandAllBtn() { | ||||||
mike10ca marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
cy.contains(expandallbtnStr).click() | ||||||
} | ||||||
|
||||||
export function lickOnCollapseAllBtn() { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
cy.contains(collapseAllBtnStr).click() | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,193 @@ | ||||||
import * as constants from '../../support/constants' | ||||||
|
||||||
const searchappInput = 'input[id="search-by-name"]' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const appUrlInput = 'input[name="appUrl"]' | ||||||
const closePreviewWindowBtn = 'button[aria-label*="Close"][aria-label*="preview"]' | ||||||
|
||||||
const addBtnStr = /add/i | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: can we be a bit more specific that this is within the modal as there is also another add button in the list. (The same for the function which references this string.) |
||||||
const noAppsStr = /no Safe Apps found/i | ||||||
const bookmarkedAppsStr = /bookmarked Apps/i | ||||||
const customAppsStr = /my custom Apps/i | ||||||
const addCustomAppBtnStr = /add custom Safe App/i | ||||||
const openSafeAppBtnStr = /open Safe App/i | ||||||
const disclaimerTtle = /disclaimer/i | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const continueBtnStr = /continue/i | ||||||
const cameraCheckBoxStr = /camera/i | ||||||
const microfoneCheckBoxStr = /microphone/i | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const permissionRequestStr = /permissions request/i | ||||||
const accessToAddressBookStr = /access to your address book/i | ||||||
const acceptBtnStr = /accept/i | ||||||
const clearAllBtnStr = /clear all/i | ||||||
const allowAllPermissions = /allow all/i | ||||||
|
||||||
const appNotSupportedMsg = "The app doesn't support Safe App functionality" | ||||||
|
||||||
export const pinWalletConnectStr = /pin walletconnect/i | ||||||
export const transactionBuilderStr = /pin transaction builder/i | ||||||
export const logoWalletConnect = /logo.*walletconnect/i | ||||||
export const walletConnectHeadlinePreview = /walletconnect/i | ||||||
export const availableNetworksPreview = /available networks/i | ||||||
export const connecttextPreview = 'Connect your Safe to any dApp that supports WalletConnect' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
export const localStorageItem = | ||||||
'{"https://safe-test-app.com":[{"feature":"camera","status":"granted"},{"feature":"microphone","status":"denied"}]}' | ||||||
export const gridItem = 'main .MuiPaper-root > .MuiGrid-item' | ||||||
export const linkNames = { | ||||||
logo: /logo/i, | ||||||
} | ||||||
|
||||||
export const permissionCheckboxes = { | ||||||
camera: 'input[name="camera"]', | ||||||
addressbook: 'input[name="requestAddressBook"]', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
microphone: 'input[name="microphone"]', | ||||||
geolocation: 'input[name="geolocation"]', | ||||||
fullscreen: 'input[name="fullscreen"]', | ||||||
} | ||||||
|
||||||
export const permissionCheckboxNames = { | ||||||
camera: 'Camera', | ||||||
addressbook: 'Address Book', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
microphone: 'Microphone', | ||||||
geolocation: 'Geolocation', | ||||||
fullscreen: 'Fullscreen', | ||||||
} | ||||||
export function typeAppName(name) { | ||||||
cy.get(searchappInput).clear().type(name) | ||||||
} | ||||||
|
||||||
export function clearSearchAppInput() { | ||||||
cy.get(searchappInput).clear() | ||||||
} | ||||||
|
||||||
export function verifyLinkName(name) { | ||||||
cy.findAllByRole('link', { name: name }).should('have.length', 1) | ||||||
} | ||||||
|
||||||
export function clickOnApp(app) { | ||||||
cy.findByRole('link', { name: app }).click() | ||||||
} | ||||||
|
||||||
export function verifyNoAppsTextPresent() { | ||||||
cy.contains(noAppsStr).should('exist') | ||||||
} | ||||||
|
||||||
export function pinApp(app, pin = true) { | ||||||
let str = 'Unpin' | ||||||
if (!pin) str = 'Pin' | ||||||
cy.findByLabelText(app) | ||||||
.click() | ||||||
.should(($el) => { | ||||||
const ariaLabel = $el.attr('aria-label') | ||||||
expect(ariaLabel).to.include(str) | ||||||
}) | ||||||
} | ||||||
|
||||||
export function clickOnBookmarkedAppsTab() { | ||||||
cy.findByText(bookmarkedAppsStr).click() | ||||||
} | ||||||
|
||||||
export function verifyAppCount(count) { | ||||||
cy.findByText(`ALL (${count})`).should('be.visible') | ||||||
} | ||||||
|
||||||
export function clickOnCustomAppsTab() { | ||||||
cy.findByText(customAppsStr).click() | ||||||
} | ||||||
|
||||||
export function clickOnAddCustomApp() { | ||||||
cy.findByText(addCustomAppBtnStr).click() | ||||||
} | ||||||
|
||||||
export function typeCustomAppUrl(url) { | ||||||
cy.get(appUrlInput).clear().type(url) | ||||||
} | ||||||
|
||||||
export function verifyAppNotSupportedMsg() { | ||||||
cy.contains(appNotSupportedMsg).should('be.visible') | ||||||
} | ||||||
|
||||||
export function verifyAppTitle(title) { | ||||||
cy.findByRole('heading', { name: title }).should('exist') | ||||||
} | ||||||
|
||||||
export function acceptTC() { | ||||||
cy.findByRole('checkbox').click() | ||||||
} | ||||||
|
||||||
export function clickOnAddBtn() { | ||||||
cy.findByRole('button', { name: addBtnStr }).click() | ||||||
} | ||||||
|
||||||
export function verifyAppDescription(descr) { | ||||||
cy.findByText(descr).should('exist') | ||||||
} | ||||||
|
||||||
export function clickOnOpenSafeAppBtn() { | ||||||
cy.findByRole('link', { name: openSafeAppBtnStr }).click() | ||||||
cy.wait(500) | ||||||
verifyDisclaimerIsVisible() | ||||||
cy.wait(500) | ||||||
} | ||||||
|
||||||
function verifyDisclaimerIsVisible() { | ||||||
cy.findByRole('heading', { name: disclaimerTtle }).should('be.visible') | ||||||
} | ||||||
|
||||||
export function clickOnContinueBtn() { | ||||||
return cy.findByRole('button', { name: continueBtnStr }).click() | ||||||
} | ||||||
|
||||||
export function verifyCameraCheckBoxExists() { | ||||||
cy.findByRole('checkbox', { name: cameraCheckBoxStr }).should('exist') | ||||||
} | ||||||
|
||||||
export function verifyMicrofoneCheckBoxExists() { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return cy.findByRole('checkbox', { name: microfoneCheckBoxStr }).should('exist') | ||||||
} | ||||||
|
||||||
export function storeAndVerifyPermissions() { | ||||||
cy.waitForSelector(() => { | ||||||
return cy | ||||||
.findByRole('button', { name: continueBtnStr }) | ||||||
.click() | ||||||
.wait(500) | ||||||
.should(() => { | ||||||
const storedBrowserPermissions = JSON.parse(localStorage.getItem(constants.BROWSER_PERMISSIONS_KEY)) | ||||||
const browserPermissions = Object.values(storedBrowserPermissions)[0][0] | ||||||
const storedInfoModal = JSON.parse(localStorage.getItem(constants.INFO_MODAL_KEY)) | ||||||
|
||||||
expect(browserPermissions.feature).to.eq('camera') | ||||||
expect(browserPermissions.status).to.eq('granted') | ||||||
expect(storedInfoModal['5'].consentsAccepted).to.eq(true) | ||||||
}) | ||||||
}) | ||||||
} | ||||||
|
||||||
export function verifyPreviewWindow(str1, str2, str3) { | ||||||
cy.findByRole('heading', { name: str1 }).should('exist') | ||||||
cy.findByText(str2).should('exist') | ||||||
cy.findByText(str3).should('exist') | ||||||
} | ||||||
|
||||||
export function closePreviewWindow() { | ||||||
cy.get(closePreviewWindowBtn).click() | ||||||
} | ||||||
|
||||||
export function verifyPermissionsRequestExists() { | ||||||
cy.findByRole('heading', { name: permissionRequestStr }).should('exist') | ||||||
} | ||||||
|
||||||
export function verifyAccessToAddressBookExists() { | ||||||
cy.findByText(accessToAddressBookStr).should('exist') | ||||||
} | ||||||
|
||||||
export function clickOnAcceptBtn() { | ||||||
cy.findByRole('button', { name: acceptBtnStr }).click() | ||||||
} | ||||||
|
||||||
export function uncheckAllPermissions(element) { | ||||||
cy.wrap(element).findByText(clearAllBtnStr).click() | ||||||
} | ||||||
|
||||||
export function checkAllPermissions(element) { | ||||||
cy.wrap(element).findByText(allowAllPermissions).click() | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary? Latest is too new for Cypress? Or too old?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our Cypress tests started to fail due to using latest runner image which conflicts with Cypress version. -latest tag uses image which might not be that stable as previous one, or be in pre-release mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need to pin the ubuntu version if we also upgraded cypress?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By specifying a version, we ensure that there will be some control over it. When this version is planned to become unavailable, we will hopefully receive notification that will give us enough time for updating to newer version of Cypress/resolve any conflicts instead of reacting to this when it was unexpected.