diff --git a/client/cypress/e2e/earn.cy.ts b/client/cypress/e2e/earn.cy.ts index fa5cabafe7..31234e86ca 100644 --- a/client/cypress/e2e/earn.cy.ts +++ b/client/cypress/e2e/earn.cy.ts @@ -149,6 +149,8 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight, isDes cy.get('[data-test=GlmLockTabs__Button]').click(); cy.get( '[data-test=BoxGlmLock__Section--current__DoubleValue__DoubleValueSkeleton]', + // Small timeout ensures skeleton shows up quickly after the transaction. + { timeout: 1000 }, ).should('be.visible'); cy.get('[data-test=BoxGlmLock__Section--current__DoubleValue__primary]', { timeout: 60000, @@ -194,6 +196,8 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight, isDes cy.get('[data-test=GlmLockTabs__Button]').click(); cy.get( '[data-test=BoxGlmLock__Section--current__DoubleValue__DoubleValueSkeleton]', + // Small timeout ensures skeleton shows up quickly after the transaction. + { timeout: 1000 }, ).should('be.visible'); cy.get('[data-test=BoxGlmLock__Section--current__DoubleValue__primary]', { timeout: 60000, @@ -210,9 +214,7 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight, isDes }); }); - // TODO OCT-1506 enable this scenario. - // eslint-disable-next-line jest/no-disabled-tests - it.skip('Wallet connected: Effective deposit after locking 1000 GLM and moving epoch is equal to current deposit', () => { + it('Wallet connected: Effective deposit after locking 1000 GLM and moving epoch is equal to current deposit', () => { connectWallet(); cy.get('[data-test=BoxGlmLock__Section--current__DoubleValue__primary]') @@ -235,24 +237,36 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight, isDes ); cy.get('[data-test=GlmLockNotification--success]').should('be.visible'); cy.get('[data-test=GlmLockTabs__Button]').click(); + cy.get( + '[data-test=BoxGlmLock__Section--current__DoubleValue__DoubleValueSkeleton]', + // Small timeout ensures skeleton shows up quickly after the transaction. + { timeout: 1000 }, + ).should('be.visible'); + // Waiting for skeletons to disappear ensures Graph indexed lock/unlock. + cy.get('[data-test=BoxGlmLock__Section--current__DoubleValue__DoubleValueSkeleton]', { + timeout: 60000, + }).should('not.exist'); cy.window().then(async win => { - await moveEpoch(win); - cy.get('[data-test=BoxGlmLock__Section--current__DoubleValue__primary]', { - timeout: 60000, - }) - .invoke('text') - .then(nextText => { - const lockedGlmsAfterLock = parseInt(nextText.replace(/\u200a/g, ''), 10); - expect(lockedGlms + amountToLock).to.be.eq(lockedGlmsAfterLock); - }); - cy.get('[data-test=BoxGlmLock__Section--effective__DoubleValue__primary]', { - timeout: 60000, - }) - .invoke('text') - .then(nextText => { - const lockedGlmsAfterLock = parseInt(nextText.replace(/\u200a/g, ''), 10); - expect(lockedGlms + amountToLock).to.be.eq(lockedGlmsAfterLock); + cy.wrap(null).then(() => { + return moveEpoch(win).then(() => { + cy.get('[data-test=BoxGlmLock__Section--current__DoubleValue__primary]', { + timeout: 60000, + }) + .invoke('text') + .then(nextText => { + const lockedGlmsAfterLock = parseInt(nextText.replace(/\u200a/g, ''), 10); + expect(lockedGlms + amountToLock).to.be.eq(lockedGlmsAfterLock); + }); + cy.get('[data-test=BoxGlmLock__Section--effective__DoubleValue__primary]', { + timeout: 60000, + }) + .invoke('text') + .then(nextText => { + const lockedGlmsAfterLock = parseInt(nextText.replace(/\u200a/g, ''), 10); + expect(lockedGlms + amountToLock).to.be.eq(lockedGlmsAfterLock); + }); }); + }); }); }); }); diff --git a/client/cypress/e2e/projectsArchive.cy.ts b/client/cypress/e2e/projectsArchive.cy.ts index 43e05b930d..d80fe1f16b 100644 --- a/client/cypress/e2e/projectsArchive.cy.ts +++ b/client/cypress/e2e/projectsArchive.cy.ts @@ -21,12 +21,16 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight }) => const currentEpochBefore = Number( win.clientReactQuery.getQueryData(QUERY_KEYS.currentEpoch), ); - await moveEpoch(win); - const currentEpochAfter = Number( - win.clientReactQuery.getQueryData(QUERY_KEYS.currentEpoch), - ); - wasEpochMoved = true; - expect(currentEpochBefore + 1).to.eq(currentEpochAfter); + + cy.wrap(null).then(() => { + return moveEpoch(win).then(() => { + const currentEpochAfter = Number( + win.clientReactQuery.getQueryData(QUERY_KEYS.currentEpoch), + ); + wasEpochMoved = true; + expect(currentEpochBefore + 1).to.eq(currentEpochAfter); + }); + }); }); } else { expect(true).to.be.true; diff --git a/client/cypress/utils/e2e.ts b/client/cypress/utils/e2e.ts index a673ac807a..d5e8bd7580 100644 --- a/client/cypress/utils/e2e.ts +++ b/client/cypress/utils/e2e.ts @@ -50,14 +50,31 @@ export const connectWallet = ( return cy.acceptMetamaskAccess(); }; -export const moveEpoch = async (cypressWindow: Cypress.AUTWindow): Promise => { - await cypressWindow.mutateAsyncMoveEpoch(); - // Waiting 2s is a way to prevent the effects of slowing down the e2e environment (data update). - cy.wait(2000); - // Manually taking a pending snapshot after the epoch shift ensures that the snapshot is taken. Passing epoch multiple times without manually triggering pending snapshot in a short period of time may cause the e2e environment to fail. - await axios.post(`${env.serverEndpoint}snapshots/pending`); - // Waiting 2s is a way to prevent the effects of slowing down the e2e environment (data update). - cy.wait(2000); - // reload is needed to get updated data in the app - cy.reload(); +export const moveEpoch = (cypressWindow: Cypress.AUTWindow): Promise => { + return new Promise(resolve => { + cypressWindow.mutateAsyncMoveEpoch().then(() => { + // Waiting 2s is a way to prevent the effects of slowing down the e2e environment (data update). + cy.wait(2000); + // Manually taking a pending snapshot after the epoch shift ensures that the snapshot is taken. Passing epoch multiple times without manually triggering pending snapshot in a short period of time may cause the e2e environment to fail. + axios.post(`${env.serverEndpoint}snapshots/pending`).then(() => { + // Waiting 2s is a way to prevent the effects of slowing down the e2e environment (data update). + cy.wait(2000); + // reload is needed to get updated data in the app + cy.reload(); + cy.get('[data-test=SyncView]', { timeout: 60000 }).should('not.exist'); + // reload is needed to get updated data in the app + cy.reload(); + axios.post(`${env.serverEndpoint}snapshots/finalized`).then(() => { + // Waiting 2s is a way to prevent the effects of slowing down the e2e environment (data update). + cy.wait(2000); + // reload is needed to get updated data in the app + cy.reload(); + cy.get('[data-test=SyncView]', { timeout: 60000 }).should('not.exist'); + // reload is needed to get updated data in the app + cy.reload(); + resolve(true); + }); + }); + }); + }); };