From 7e6bd79d0e3f7515176d04c8e8f7dea11e3b0298 Mon Sep 17 00:00:00 2001 From: Thibaut Sardan Date: Thu, 12 Oct 2023 23:52:43 +0100 Subject: [PATCH] export in function --- packages/ui/cypress/tests/login.cy.ts | 8 ++------ packages/ui/cypress/tests/transactions.cy.ts | 9 ++------- packages/ui/cypress/utils/clickOnConnect.ts | 11 +++++++++++ 3 files changed, 15 insertions(+), 13 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 7c80daad..99e52acd 100644 --- a/packages/ui/cypress/tests/login.cy.ts +++ b/packages/ui/cypress/tests/login.cy.ts @@ -2,17 +2,13 @@ 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 { clickOnConnect } from '../utils/clickOnConnect' describe('Connect Account', () => { beforeEach(() => { cy.visit(landingPageUrl) cy.initExtension(injectedAccounts) - cy.clock() - topMenuItems.connectButton().click() - landingPage.accountsLoader().should('contain', 'Loading accounts') - cy.tick(500) - // restore the clock to prevent WS errors - cy.clock().invoke('restore') + clickOnConnect() }) it('Reject connection', () => { diff --git a/packages/ui/cypress/tests/transactions.cy.ts b/packages/ui/cypress/tests/transactions.cy.ts index 38fd1345..215fa2f3 100644 --- a/packages/ui/cypress/tests/transactions.cy.ts +++ b/packages/ui/cypress/tests/transactions.cy.ts @@ -1,11 +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 { clickOnConnect } from '../utils/clickOnConnect' import { waitForTxRequest } from '../utils/waitForTxRequests' const AliceAddress = Object.values(injectedAccounts)[0].address @@ -20,12 +20,7 @@ describe('Perform transactions', () => { beforeEach(() => { cy.visit(landingPageUrl) cy.initExtension(injectedAccounts) - cy.clock() - topMenuItems.connectButton().click() - landingPage.accountsLoader().should('contain', 'Loading accounts') - cy.tick(500) - // restore the clock to prevent WS errors - cy.clock().invoke('restore') + 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..da70d0eb --- /dev/null +++ b/packages/ui/cypress/utils/clickOnConnect.ts @@ -0,0 +1,11 @@ +import { landingPage } from '../support/page-objects/landingPage' +import { topMenuItems } from '../support/page-objects/topMenuItems' + +export const clickOnConnect = () => { + cy.clock() + topMenuItems.connectButton().click() + landingPage.accountsLoader().should('contain', 'Loading accounts') + cy.tick(500) + // restore the clock to prevent WS errors + cy.clock().invoke('restore') +}