Skip to content

Commit

Permalink
OCT-1506 Enable earn.cy.ts lock 1000 GLM scenario (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
aziolek authored Mar 30, 2024
1 parent 5b6c39c commit abdb237
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 35 deletions.
52 changes: 33 additions & 19 deletions client/cypress/e2e/earn.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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]')
Expand All @@ -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);
});
});
});
});
});
});
Expand Down
16 changes: 10 additions & 6 deletions client/cypress/e2e/projectsArchive.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
37 changes: 27 additions & 10 deletions client/cypress/utils/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,31 @@ export const connectWallet = (
return cy.acceptMetamaskAccess();
};

export const moveEpoch = async (cypressWindow: Cypress.AUTWindow): Promise<void> => {
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<boolean> => {
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);
});
});
});
});
};

0 comments on commit abdb237

Please sign in to comment.