Skip to content
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

Tests: Migrate safe apps tests to Sepolia #2680

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions cypress/e2e/pages/nfts.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ const sendNFTStr = 'Send NFTs'
const recipientAddressStr = 'Recipient address or ENS'
const selectedNFTStr = 'Selected NFTs'
const executeBtnStr = 'Execute'
const signBtnStr = 'Sign'
const nextBtnStr = 'Next'
const sendStr = 'Send'
const toStr = 'To'
const transferFromStr = 'safeTransferFrom'

export function clickOnNftsTab() {
cy.get('p').contains('NFTs').click()
}
function verifyTableRows(number) {
cy.get('tbody tr').should('have.length', number)
}
Expand All @@ -22,11 +26,10 @@ export function verifyNFTNumber(number) {
verifyTableRows(number)
}

export function verifyDataInTable(name, address, tokenID, link) {
export function verifyDataInTable(name, address, tokenID) {
cy.get('tbody tr:first-child').contains('td:first-child', name)
cy.get('tbody tr:first-child').contains('td:first-child', address)
cy.get('tbody tr:first-child').contains('td:nth-child(2)', tokenID)
cy.get(`tbody tr:first-child td:nth-child(3) a[href="${link}"]`)
}

export function openFirstNFT() {
Expand All @@ -37,8 +40,8 @@ export function verifyNameInNFTModal(name) {
cy.get(nftModal).contains(name)
}

export function preventBaseMainnetGoerliFromBeingSelected() {
cy.get(nftModal).contains(constants.networks.goerli)
export function verifySelectedNetwrokSepolia() {
cy.get(nftModal).contains(constants.networks.sepolia)
}

export function verifyNFTModalLink(link) {
Expand All @@ -50,8 +53,8 @@ export function closeNFTModal() {
cy.get(nftModal).should('not.exist')
}

export function clickOnThirdNFT() {
cy.get('tbody tr:nth-child(3) td:nth-child(2)').click()
export function clickOn6thNFT() {
cy.get('tbody tr:nth-child(6) td:nth-child(2)').click()
}
export function verifyNFTModalDoesNotExist() {
cy.get(nftModal).should('not.exist')
Expand Down Expand Up @@ -106,7 +109,7 @@ export function verifyReviewModalData(NFTcount) {
cy.contains(toStr)
cy.wait(1000)
cy.get(`b:contains(${transferFromStr})`).should('have.length', NFTcount)
cy.contains('button:not([disabled])', executeBtnStr)
cy.contains('button:not([disabled])', signBtnStr)
if (NFTcount > 1) {
const numbersArr = Array.from({ length: NFTcount }, (_, index) => index + 1)
numbersArr.forEach((number) => {
Expand Down
9 changes: 8 additions & 1 deletion cypress/e2e/pages/safeapps.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ 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'
const warningDefaultAppStr = 'The application you are trying to access is not in the default Safe Apps list'
export const localStorageItem =
'{"https://safe-test-app.com":[{"feature":"camera","status":"granted"},{"feature":"microphone","status":"denied"}]}'
export const gridItem = 'main .MuiPaper-root > .MuiGrid-item'
Expand All @@ -50,6 +51,12 @@ export const permissionCheckboxNames = {
geolocation: 'Geolocation',
fullscreen: 'Fullscreen',
}

export function verifyWarningDefaultAppMsgIsDisplayed() {
cy.get('p').contains(warningDefaultAppStr).should('be.visible')
cy.wait(1000)
}

export function typeAppName(name) {
cy.get(searchAppInput).clear().type(name)
}
Expand Down Expand Up @@ -157,7 +164,7 @@ export function storeAndVerifyPermissions() {

expect(browserPermissions.feature).to.eq('camera')
expect(browserPermissions.status).to.eq('granted')
expect(storedInfoModal['5'].consentsAccepted).to.eq(true)
expect(storedInfoModal['11155111'].consentsAccepted).to.eq(true)
})
})
}
Expand Down
9 changes: 7 additions & 2 deletions cypress/e2e/safe-apps/apps_list.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const myCustomAppTitle = 'Cypress Test App'
const myCustomAppDescrAdded = 'Cypress Test App Description'

describe('Safe Apps tests', () => {
before(() => {
beforeEach(() => {
cy.clearLocalStorage()
cy.visit(constants.TEST_SAFE_2 + constants.appsUrl, { failOnStatusCode: false })
cy.visit(constants.SEPOLIA_TEST_SAFE_4 + constants.appsUrl, { failOnStatusCode: false })
main.acceptCookies()
})

Expand Down Expand Up @@ -41,6 +41,9 @@ describe('Safe Apps tests', () => {
it('Verify apps can be unpinned [C56134]', () => {
safeapps.pinApp(safeapps.pinWalletConnectStr)
safeapps.pinApp(safeapps.transactionBuilderStr)
safeapps.pinApp(safeapps.pinWalletConnectStr, false)
safeapps.pinApp(safeapps.transactionBuilderStr, false)
safeapps.clickOnBookmarkedAppsTab()
safeapps.verifyAppCount(0)
})

Expand All @@ -61,6 +64,8 @@ describe('Safe Apps tests', () => {
icons: [{ src: 'logo.svg', sizes: 'any', type: 'image/svg+xml' }],
})

safeapps.clickOnCustomAppsTab()
safeapps.clickOnAddCustomApp()
safeapps.typeCustomAppUrl(constants.validAppUrl)
safeapps.verifyAppTitle(myCustomAppTitle)
safeapps.acceptTC()
Expand Down
7 changes: 5 additions & 2 deletions cypress/e2e/safe-apps/browser_permissions.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ describe('Browser permissions tests', () => {

it('Verify a permissions slide to the user is displayed [C56137]', () => {
cy.visitSafeApp(`${constants.testAppUrl}/app`)
main.acceptCookies()
safeapps.clickOnContinueBtn()
safeapps.verifyCameraCheckBoxExists()
safeapps.verifyMicrofoneCheckBoxExists()
})

it('Verify the selection can be changed, accepted and stored [C56138]', () => {
main.acceptCookies()
safeapps.verifyMicrofoneCheckBoxExists().click()

safeapps.clickOnContinueBtn()
safeapps.verifyWarningDefaultAppMsgIsDisplayed()
safeapps.verifyCameraCheckBoxExists()
safeapps.clickOnContinueBtn().should(() => {
expect(window.localStorage.getItem(constants.BROWSER_PERMISSIONS_KEY)).to.eq(safeapps.localStorageItem)
})
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/safe-apps/info_modal.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as safeapps from '../pages/safeapps.pages'
describe('Safe Apps info modal tests', () => {
before(() => {
cy.clearLocalStorage()
cy.visit(constants.TEST_SAFE_2 + constants.appsUrl, { failOnStatusCode: false })
cy.visit(constants.SEPOLIA_TEST_SAFE_5 + constants.appsUrl, { failOnStatusCode: false })
main.acceptCookies()
})

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/safe-apps/permissions_settings.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('Safe Apps permissions settings tests', () => {
)
})

cy.visit(constants.TEST_SAFE_2 + constants.appSettingsUrl, { failOnStatusCode: false })
cy.visit(constants.SEPOLIA_TEST_SAFE_5 + constants.appSettingsUrl, { failOnStatusCode: false })
main.acceptCookies()
})

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/safe-apps/preview_drawer.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as safeapps from '../pages/safeapps.pages'
describe('Safe Apps info modal tests', () => {
before(() => {
cy.clearLocalStorage()
cy.visit(`/${constants.TEST_SAFE_2}/apps`, { failOnStatusCode: false })
cy.visit(`/${constants.SEPOLIA_TEST_SAFE_5}/apps`, { failOnStatusCode: false })
main.acceptCookies()
})

Expand Down
10 changes: 10 additions & 0 deletions cypress/e2e/safe-apps/safe_permissions.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as constants from '../../support/constants'
import * as safeapps from '../pages/safeapps.pages'
import * as main from '../pages/main.page'

describe('Safe permissions system tests', () => {
before(() => {
Expand All @@ -18,6 +19,11 @@ describe('Safe permissions system tests', () => {

it('Verify that requesting permissions with wallet_requestPermissions shows the permissions prompt and return the permissions on accept [C56150]', () => {
cy.visitSafeApp(constants.testAppUrl + constants.requestPermissionsUrl)
main.acceptCookies()
safeapps.clickOnContinueBtn()
safeapps.verifyWarningDefaultAppMsgIsDisplayed()
safeapps.clickOnContinueBtn()

safeapps.verifyPermissionsRequestExists()
safeapps.verifyAccessToAddressBookExists()
safeapps.clickOnAcceptBtn()
Expand Down Expand Up @@ -52,6 +58,10 @@ describe('Safe permissions system tests', () => {
})

cy.visitSafeApp(constants.testAppUrl + constants.getPermissionsUrl)
main.acceptCookies()
safeapps.clickOnContinueBtn()
safeapps.verifyWarningDefaultAppMsgIsDisplayed()
safeapps.clickOnContinueBtn()

cy.get('@safeAppsMessage').should('have.been.calledWithMatch', {
data: [
Expand Down
5 changes: 4 additions & 1 deletion cypress/e2e/safe-apps/tx_modal.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as constants from '../../support/constants'
import * as main from '../pages/main.page'
import * as safeapps from '../pages/safeapps.pages'

const testAppName = 'Cypress Test App'
const testAppDescr = 'Cypress Test App Description'
Expand All @@ -24,8 +25,10 @@ describe('Transaction modal tests', () => {
{ defaultCommandTimeout: 12000 },
() => {
cy.visitSafeApp(`${constants.testAppUrl}/dummy`)

main.acceptCookies()
safeapps.clickOnContinueBtn()
safeapps.verifyWarningDefaultAppMsgIsDisplayed()
safeapps.clickOnContinueBtn()
cy.findByRole('dialog').within(() => {
cy.findByText(testAppName)
})
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/smoke/dashboard.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ describe('Dashboard tests', () => {
dashboard.verifyConnectTransactStrIsVisible()
})

it('Verify the overview widget is displayed [C56107]', () => {
it.skip('Verify the overview widget is displayed [C56107]', () => {
dashboard.verifyOverviewWidgetData()
})

it('Verify the transaction queue widget is displayed [C56108]', () => {
it.skip('Verify the transaction queue widget is displayed [C56108]', () => {
dashboard.verifyTxQueueWidget()
})

it('Verify the featured Safe Apps are displayed [C56109]', () => {
it.skip('Verify the featured Safe Apps are displayed [C56109]', () => {
dashboard.verifyFeaturedAppsSection()
})

it('Verify the Safe Apps Section is displayed [C56110]', () => {
it.skip('Verify the Safe Apps Section is displayed [C56110]', () => {
dashboard.verifySafeAppsSection()
})
})
32 changes: 15 additions & 17 deletions cypress/e2e/smoke/nfts.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,45 @@ import * as constants from '../../support/constants'
import * as main from '../pages/main.page'
import * as nfts from '../pages/nfts.pages'

const nftsName = 'BillyNFT721'
const nftsAddress = '0x0000...816D'
const nftsTokenID = 'Kitaro World #261'
const nftsLink = 'https://testnets.opensea.io/assets/0x000000000faE8c6069596c9C805A1975C657816D/443'
const nftsName = 'CatFactory'
const nftsAddress = '0x373B...866c'
const nftsTokenID = 'CF'

describe('NFTs tests', () => {
before(() => {
cy.clearLocalStorage()
cy.visit(constants.balanceNftsUrl + constants.GOERLI_TEST_SAFE)
cy.visit(constants.BALANCE_URL + constants.SEPOLIA_TEST_SAFE_5)
main.acceptCookies()
cy.contains(constants.goerlyE2EWallet)
nfts.clickOnNftsTab()
})

it('Verify that NFTs exist in the table [C56123]', () => {
nfts.verifyNFTNumber(5)
it.skip('Verify that NFTs exist in the table [C56123]', () => {
nfts.verifyNFTNumber(20)
})

it('Verify NFT row contains data [C56124]', () => {
nfts.verifyDataInTable(nftsName, nftsAddress, nftsTokenID, nftsLink)
it.skip('Verify NFT row contains data [C56124]', () => {
nfts.verifyDataInTable(nftsName, nftsAddress, nftsTokenID)
})

it('Verify NFT preview window can be opened [C56125]', () => {
it.skip('Verify NFT preview window can be opened [C56125]', () => {
nfts.openFirstNFT()
nfts.verifyNameInNFTModal(nftsTokenID)
nfts.preventBaseMainnetGoerliFromBeingSelected()
nfts.verifyNFTModalLink(nftsLink)
nfts.verifySelectedNetwrokSepolia()
nfts.closeNFTModal()
})

it('Verify NFT open does not open if no NFT exits [C56126]', () => {
nfts.clickOnThirdNFT()
it.skip('Verify NFT open does not open if no NFT exits [C56126]', () => {
nfts.clickOn6thNFT()
nfts.verifyNFTModalDoesNotExist()
})

it('Verify multipls NFTs can be selected and reviewed [C56127]', () => {
it.skip('Verify multipls NFTs can be selected and reviewed [C56127]', () => {
nfts.verifyInitialNFTData()
nfts.selectNFTs(3)
nfts.deselectNFTs([2], 3)
nfts.sendNFT(2)
nfts.verifyNFTModalData()
nfts.typeRecipientAddress(constants.GOERLI_TEST_SAFE)
nfts.typeRecipientAddress(constants.SEPOLIA_TEST_SAFE_4)
nfts.clikOnNextBtn()
nfts.verifyReviewModalData(2)
})
Expand Down
6 changes: 4 additions & 2 deletions cypress/e2e/smoke/tx_history.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ describe('Transaction history tests', () => {
main.acceptCookies()
})

it('Verify October 9th transactions are displayed [C56128]', () => {
//Skipping this due to test data creation
it.skip('Verify October 9th transactions are displayed [C56128]', () => {
const DATE = 'Oct 9, 2023'
const NEXT_DATE_LABEL = 'Oct 11, 2023'
const amount = '0.1 ETH'
Expand All @@ -38,10 +39,11 @@ describe('Transaction history tests', () => {
createTx.verifyDateExists(DATE)
createTx.verifyDateExists(NEXT_DATE_LABEL)

main.scrollToBottomAndWaitForPageLoad()
// Transaction summaries from October 9th
const rows = cy.contains('div', DATE).nextUntil(`div:contains(${NEXT_DATE_LABEL})`)

rows.should('have.length', 9)
rows.should('have.length', 3)

rows
.last()
Expand Down
6 changes: 4 additions & 2 deletions cypress/support/safe-apps-commands.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { INFO_MODAL_KEY, TEST_SAFE } from '../e2e/safe-apps/constants'
import { INFO_MODAL_KEY } from '../e2e/safe-apps/constants'
import * as constants from '../support/constants'

const allowedApps = ['https://safe-test-app.com']
const TEST_SAFE = constants.SEPOLIA_TEST_SAFE_5

Cypress.Commands.add('visitSafeApp', (appUrl, testSafe = TEST_SAFE) => {
Cypress.Commands.add('visitSafeApp', (appUrl) => {
cy.on('window:before:load', (window) => {
window.localStorage.setItem(
INFO_MODAL_KEY,
Expand Down
Loading