From 40be8921f6969fb1506765499c0a938ee9e7a95d Mon Sep 17 00:00:00 2001 From: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com> Date: Fri, 13 Oct 2023 19:25:02 +0100 Subject: [PATCH] Small refactor with clickOnConnect test function (#403) --- packages/ui/cypress/tests/login.cy.ts | 7 ++----- packages/ui/cypress/tests/transactions.cy.ts | 7 ++----- packages/ui/cypress/utils/clickOnConnect.ts | 9 +++++++++ 3 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 packages/ui/cypress/utils/clickOnConnect.ts diff --git a/packages/ui/cypress/tests/login.cy.ts b/packages/ui/cypress/tests/login.cy.ts index 2bbb2301..99e52acd 100644 --- a/packages/ui/cypress/tests/login.cy.ts +++ b/packages/ui/cypress/tests/login.cy.ts @@ -2,18 +2,16 @@ import { injectedAccounts } from '../fixtures/injectedAccounts' import { landingPageUrl } from '../fixtures/landingData' import { landingPage } from '../support/page-objects/landingPage' import { topMenuItems } from '../support/page-objects/topMenuItems' -import { waitForAuthRequest } from '../utils/waitForAuthRequests' +import { clickOnConnect } from '../utils/clickOnConnect' describe('Connect Account', () => { beforeEach(() => { cy.visit(landingPageUrl) cy.initExtension(injectedAccounts) - topMenuItems.connectButton().click() - landingPage.accountsLoader().should('contain', 'Loading accounts') + clickOnConnect() }) it('Reject connection', () => { - waitForAuthRequest() cy.getAuthRequests().then((authRequests) => { const requests = Object.values(authRequests) // we should have 1 connection request to the extension @@ -28,7 +26,6 @@ describe('Connect Account', () => { }) it('Connects with Alice', () => { - waitForAuthRequest() const AliceAddress = Object.values(injectedAccounts)[0].address cy.getAuthRequests().then((authRequests) => { const requests = Object.values(authRequests) diff --git a/packages/ui/cypress/tests/transactions.cy.ts b/packages/ui/cypress/tests/transactions.cy.ts index b3499f95..215fa2f3 100644 --- a/packages/ui/cypress/tests/transactions.cy.ts +++ b/packages/ui/cypress/tests/transactions.cy.ts @@ -1,12 +1,11 @@ import { injectedAccounts } from '../fixtures/injectedAccounts' import { knownMultisigs } from '../fixtures/knownMultisigs' import { landingPageUrl } from '../fixtures/landingData' -import { landingPage } from '../support/page-objects/landingPage' import { multisigPage } from '../support/page-objects/multisigPage' import { notifications } from '../support/page-objects/notifications' import { sendTxModal } from '../support/page-objects/sendTxModal' import { topMenuItems } from '../support/page-objects/topMenuItems' -import { waitForAuthRequest } from '../utils/waitForAuthRequests' +import { clickOnConnect } from '../utils/clickOnConnect' import { waitForTxRequest } from '../utils/waitForTxRequests' const AliceAddress = Object.values(injectedAccounts)[0].address @@ -21,9 +20,7 @@ describe('Perform transactions', () => { beforeEach(() => { cy.visit(landingPageUrl) cy.initExtension(injectedAccounts) - topMenuItems.connectButton().click() - landingPage.accountsLoader().should('contain', 'Loading accounts') - waitForAuthRequest() + clickOnConnect() cy.getAuthRequests().then((authRequests) => { const requests = Object.values(authRequests) // we should have 1 connection request to the extension diff --git a/packages/ui/cypress/utils/clickOnConnect.ts b/packages/ui/cypress/utils/clickOnConnect.ts new file mode 100644 index 00000000..46ae4c9f --- /dev/null +++ b/packages/ui/cypress/utils/clickOnConnect.ts @@ -0,0 +1,9 @@ +import { landingPage } from '../support/page-objects/landingPage' +import { topMenuItems } from '../support/page-objects/topMenuItems' +import { waitForAuthRequest } from './waitForAuthRequests' + +export const clickOnConnect = () => { + topMenuItems.connectButton().click() + landingPage.accountsLoader().should('contain', 'Loading accounts') + waitForAuthRequest() +}