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..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') +} diff --git a/packages/ui/cypress/utils/waitForAuthRequests.ts b/packages/ui/cypress/utils/waitForAuthRequests.ts deleted file mode 100644 index 33b7cccc..00000000 --- a/packages/ui/cypress/utils/waitForAuthRequests.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const waitForAuthRequest = () => - cy.waitUntil(() => cy.getAuthRequests().then((req) => Object.entries(req).length > 0))