Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCT-1481 CY: AllocationItem #100

Merged
merged 190 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
17bfdcd
test: in progress
aziolek Mar 26, 2024
392008b
feat: AW open tests in progress
aziolek Mar 26, 2024
865ce52
test: checks
aziolek Mar 26, 2024
4aaf6fc
test: checks
aziolek Mar 27, 2024
27322e8
test: checks
aziolek Mar 27, 2024
f6e8926
test: checks
aziolek Mar 27, 2024
5133e0d
test: checks
aziolek Mar 27, 2024
0d9d77c
test: checks
aziolek Mar 27, 2024
eee729f
test: checks
aziolek Mar 27, 2024
9ae97d4
test: checks
aziolek Mar 27, 2024
4db5fe7
test: checks
aziolek Mar 27, 2024
edf61b0
test: checks
aziolek Mar 27, 2024
2d84cf8
Merge branch 'develop' into test/oct-1481-cy-allocation-item
aziolek Mar 27, 2024
84f20cf
test: checks
aziolek Mar 27, 2024
bd96544
test: checks
aziolek Mar 27, 2024
0aaa4d9
test: checks
aziolek Mar 27, 2024
bc4e4b1
test: checks
aziolek Mar 27, 2024
bf307ca
test: checks
aziolek Mar 27, 2024
80cd366
test: checks
aziolek Mar 27, 2024
e408519
test: checks
aziolek Mar 27, 2024
2a0a86b
test: checks
aziolek Mar 27, 2024
c55854b
test: checks
aziolek Mar 27, 2024
db4d0c7
test: checks
aziolek Mar 27, 2024
9e1f29a
move to AW closed separated to other hook
aziolek Mar 27, 2024
28f44df
test: checks
aziolek Mar 28, 2024
6616c5f
test: checks
aziolek Mar 28, 2024
8706090
test: checks
aziolek Mar 28, 2024
3361654
fix: epochOverrideForDataFetch for mainnet only
aziolek Mar 28, 2024
acf6ba6
Merge branch 'develop' into test/oct-1481-cy-allocation-item
aziolek Mar 28, 2024
7a26f69
test: checks
aziolek Mar 28, 2024
0db8621
Merge branch 'develop' into test/oct-1481-cy-allocation-item
aziolek Mar 28, 2024
38e74b9
test: in progress
aziolek Mar 28, 2024
26190ee
Merge branch 'develop' into test/oct-1481-cy-allocation-item
aziolek Mar 28, 2024
2fce559
Merge branch 'develop' into test/oct-1481-cy-allocation-item
aziolek Mar 29, 2024
fdf4eb0
Merge branch 'develop' into test/oct-1481-cy-allocation-item
aziolek Mar 29, 2024
f31c118
test: checks
aziolek Mar 29, 2024
7b94138
test: merge & adjustment of moveEpoch to open/close AW
aziolek Mar 30, 2024
170c53b
fix: finalized snapshot conditionally only
aziolek Mar 30, 2024
5685bf2
test: move time before POST snapshots/finalized
aziolek Mar 31, 2024
ea50500
test: rechain promises
aziolek Mar 31, 2024
412eafc
test: rechain promises
aziolek Mar 31, 2024
d204575
test: promises rechaining
aziolek Apr 1, 2024
8b42ac3
test: promises rechaining
aziolek Apr 1, 2024
9397c00
test: debugging
aziolek Apr 1, 2024
f205c2e
test: debugging
aziolek Apr 1, 2024
28b1226
test: debugging
aziolek Apr 2, 2024
b15e6ca
feat: expose Cypress helpers locally
aziolek Apr 2, 2024
877819b
test: debugging
aziolek Apr 2, 2024
ef91b21
test: debugging
aziolek Apr 2, 2024
9c6ac27
test: debugging
aziolek Apr 2, 2024
9d73b0a
test: debugging
aziolek Apr 2, 2024
672276a
test: debugging
aziolek Apr 2, 2024
b42399c
test: debugging
aziolek Apr 2, 2024
21bd2b7
test: debugging
aziolek Apr 2, 2024
0a23d73
test: debugging
aziolek Apr 3, 2024
fcd85e3
test: debugging
aziolek Apr 3, 2024
2baf5ee
test: debugging
aziolek Apr 3, 2024
3a75565
test: debugging
aziolek Apr 3, 2024
68b80bd
test: debugging
aziolek Apr 3, 2024
79e5c63
test: debugging
aziolek Apr 3, 2024
af3192a
test: debugging
aziolek Apr 3, 2024
2a2d7a4
Merge branch 'develop' into test/oct-1481-cy-allocation-item
aziolek Apr 3, 2024
01bf69a
test: debugging
aziolek Apr 3, 2024
9c258ee
test: debugging
aziolek Apr 3, 2024
8d4b172
test: debugging
aziolek Apr 3, 2024
86abc13
test: debugging
aziolek Apr 3, 2024
c04b85d
test: debugging
aziolek Apr 3, 2024
2d11faf
test: debugging
aziolek Apr 3, 2024
3297d98
test: debugging
aziolek Apr 3, 2024
ddc0363
test: debugging
aziolek Apr 3, 2024
5fa5c36
test: debugging
aziolek Apr 3, 2024
cb45f6b
test: debugging
aziolek Apr 3, 2024
faa476f
test: debugging
aziolek Apr 4, 2024
74a3b60
test: move time in the client
aziolek Apr 4, 2024
034af56
test: debugging
aziolek Apr 4, 2024
6c581c3
test: debugging
aziolek Apr 4, 2024
d80e2cd
test: debugging
aziolek Apr 4, 2024
e307d47
test: debugging
aziolek Apr 4, 2024
f5c4d70
test: return timeToIncrease from promise
aziolek Apr 4, 2024
cc1b572
test: debugging
aziolek Apr 4, 2024
6ae4b23
Merge branch 'develop' into test/oct-1481-cy-allocation-item
aziolek Apr 4, 2024
b0e587e
test: debugging
aziolek Apr 4, 2024
917f83a
test: debugging
aziolek Apr 4, 2024
6da6ace
test: debugging
aziolek Apr 4, 2024
52733ae
test: debugging
aziolek Apr 5, 2024
c7361fb
test: debugging
aziolek Apr 5, 2024
ba59114
test: debugging
aziolek Apr 5, 2024
3ba4676
test: debugging
aziolek Apr 5, 2024
2fb127e
test: debugging
aziolek Apr 5, 2024
e0e02c0
test: debugging
aziolek Apr 5, 2024
e2d49a3
test: debugging
aziolek Apr 5, 2024
2c18ae3
test: debugging
aziolek Apr 5, 2024
5db07cc
test: debugging
aziolek Apr 5, 2024
3bc2dbb
test: debugging
aziolek Apr 5, 2024
856e32f
test: debugging
aziolek Apr 5, 2024
7021418
test: debugging
aziolek Apr 5, 2024
21f9b1b
test: debugging
aziolek Apr 5, 2024
dce14b1
test: debugging
aziolek Apr 5, 2024
adf5f1c
test: debugging
aziolek Apr 5, 2024
8287e7d
test: debugging
aziolek Apr 6, 2024
4614ee1
test: debugging
aziolek Apr 6, 2024
992097f
test: revert to the last working version
aziolek Apr 6, 2024
2d47107
test: debugging
aziolek Apr 7, 2024
8d10910
test: debugging
aziolek Apr 7, 2024
2a83280
test: debugging
aziolek Apr 7, 2024
9e50920
test: debugging
aziolek Apr 8, 2024
15507ca
test: debugging
aziolek Apr 8, 2024
bd223f5
test: debugging
aziolek Apr 8, 2024
f15427b
test: debugging
aziolek Apr 8, 2024
aa3f7f9
test: debugging
aziolek Apr 8, 2024
f4feaad
test: debugging
aziolek Apr 8, 2024
e48c32a
test: debugging
aziolek Apr 8, 2024
b29db04
test: debugging
aziolek Apr 8, 2024
0666757
test: debugging
aziolek Apr 8, 2024
8e97939
Merge branch 'develop' into test/oct-1481-cy-allocation-item
aziolek Apr 8, 2024
ad60e4f
test: debugging
aziolek Apr 9, 2024
7eb0759
test: debugging
aziolek Apr 9, 2024
706a48d
test: debugging
aziolek Apr 9, 2024
84d9cef
test: debugging
aziolek Apr 9, 2024
4596835
test: debugging
aziolek Apr 9, 2024
4588315
test: debugging
aziolek Apr 9, 2024
06c382c
test: debugging
aziolek Apr 9, 2024
cf5089b
test: debugging
aziolek Apr 9, 2024
8962cea
test: debugging
aziolek Apr 9, 2024
d233108
test: debugging
aziolek Apr 9, 2024
54b767a
test: debugging
aziolek Apr 9, 2024
8f5243a
test: debugging
aziolek Apr 9, 2024
ee6c47b
test: debugging
aziolek Apr 9, 2024
f4adc0f
test: debugging
aziolek Apr 9, 2024
8172453
test: debugging
aziolek Apr 9, 2024
d54313c
style: simplify calls to mutations in the app
aziolek Apr 9, 2024
8573abc
style: simplify calls to mutations in the app
aziolek Apr 9, 2024
e4765e1
style: further cleanup
aziolek Apr 9, 2024
14780e1
style: move time once, re-nest tests
aziolek Apr 9, 2024
e9517da
style: revert debug changes
aziolek Apr 9, 2024
b0c768c
test: debugging
aziolek Apr 10, 2024
d49f59b
test: debugging
aziolek Apr 10, 2024
a361612
Merge branch 'develop' into test/oct-1481-cy-allocation-item
aziolek Apr 10, 2024
e211812
test: revert to the last working version
aziolek Apr 10, 2024
062c141
test: revert to the last working version
aziolek Apr 10, 2024
c207768
test: revert to the last working version
aziolek Apr 10, 2024
041097e
test: revert to the last working version
aziolek Apr 10, 2024
e886532
test: revert to the last working version
aziolek Apr 10, 2024
7457bfd
test: revert to the last working version
aziolek Apr 10, 2024
df898ca
style: move utils to separate dir, remove test for data-iserror
aziolek Apr 10, 2024
c00aed3
style: cleanup
aziolek Apr 10, 2024
dd48677
style: remove lack of retries
aziolek Apr 10, 2024
4f878bb
style: extract common parts to utils
aziolek Apr 10, 2024
d602548
style: extract common parts to utils
aziolek Apr 10, 2024
bd3b8d3
style: extract common parts to utils
aziolek Apr 10, 2024
0a04d7d
sync: with develop
aziolek Apr 10, 2024
cf24edf
sync: with develop
aziolek Apr 10, 2024
6a32409
sync: with develop
aziolek Apr 10, 2024
af3d943
sync: with develop
aziolek Apr 10, 2024
9a62dea
sync: with develop
aziolek Apr 10, 2024
6933856
test: revert changes
aziolek Apr 10, 2024
3dd3231
style: sync with develop
aziolek Apr 10, 2024
8219be0
style: sync with develop
aziolek Apr 10, 2024
1cfe963
style: remove debug packages
aziolek Apr 10, 2024
bb5b98a
style: cleanup
aziolek Apr 10, 2024
79b8fa7
test: revert to the last stable
aziolek Apr 10, 2024
4a1e98f
Merge branch 'develop' into test/oct-1481-cy-allocation-item
aziolek Apr 10, 2024
4adf5c7
style: cleanup in progress
aziolek Apr 10, 2024
4346f77
style: cleanup in progress
aziolek Apr 10, 2024
9c71a71
style: cleanup in progress
aziolek Apr 10, 2024
1e49902
style: cleanup in progress
aziolek Apr 10, 2024
938f451
style: cleanup in progress
aziolek Apr 10, 2024
438fd34
style: cleanup in progress
aziolek Apr 10, 2024
7cfe36e
style: cleanup in progress
aziolek Apr 10, 2024
2c97779
style: cleanup in progress
aziolek Apr 10, 2024
1b4358b
style: cleanup in progress
aziolek Apr 10, 2024
ef1df2f
style: cleanup in progress
aziolek Apr 10, 2024
c9013ef
style: cleanup in progress
aziolek Apr 10, 2024
ec79baf
style: cleanup in progress
aziolek Apr 10, 2024
3e863f6
style: cleanup in progress
aziolek Apr 10, 2024
f115506
style: cleanup in progress
aziolek Apr 10, 2024
16e5838
style: cleanup in progress
aziolek Apr 10, 2024
4056178
style: cleanup in progress
aziolek Apr 10, 2024
e05a7b2
style: cleanup in progress
aziolek Apr 11, 2024
fbe89c3
style: cleanup in progress
aziolek Apr 11, 2024
2b4268e
style: cleanup in progress
aziolek Apr 11, 2024
d8e8b88
test: bring back the rest of hte CYs
aziolek Apr 11, 2024
78bce72
test: bring back the rest of hte CYs
aziolek Apr 11, 2024
6cd874e
Merge branch 'develop' into test/oct-1481-cy-allocation-item
aziolek Apr 11, 2024
7462b26
style: add definitions to window properties
aziolek Apr 11, 2024
5fa323d
style: extract setupAndMoveToPlayground util
aziolek Apr 11, 2024
12e65c5
style: extract setupAndMoveToPlayground util
aziolek Apr 11, 2024
49fb4fa
style: extract setupAndMoveToPlayground util
aziolek Apr 11, 2024
551f254
style: more verbose variable value, comment w/ explanation added
aziolek Apr 12, 2024
50fd5c8
fix: typo in file name
aziolek Apr 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from 'axios';

import { mockCoinPricesServer, visitWithLoader } from 'cypress/utils/e2e';
import { QUERY_KEYS } from 'src/api/queryKeys';
import { IS_ONBOARDING_ALWAYS_VISIBLE, IS_ONBOARDING_DONE } from 'src/constants/localStorageKeys';
import env from 'src/env';
import { ROOT_ROUTES } from 'src/routes/RootRoutes/routes';
Expand All @@ -21,13 +22,25 @@ describe('Make pending snapshot', () => {
mockCoinPricesServer();
localStorage.setItem(IS_ONBOARDING_ALWAYS_VISIBLE, 'false');
localStorage.setItem(IS_ONBOARDING_DONE, 'true');
visitWithLoader(ROOT_ROUTES.earn.absolute);
visitWithLoader(ROOT_ROUTES.playground.absolute);
});

it('make pending snapshot', () => {
cy.window().then(async () => {
await axios.post(`${env.serverEndpoint}snapshots/pending`);
cy.get('[data-test=SyncView]', { timeout: 60000 }).should('not.exist');
cy.window().then(async win => {
const isDecisionWindowOpen = win.clientReactQuery.getQueryData(
QUERY_KEYS.isDecisionWindowOpen,
);

if (!isDecisionWindowOpen) {
expect(true).to.be.true;
return;
}

cy.wrap(null).then(() => {
axios.post(`${env.serverEndpoint}snapshots/pending`).then(() => {
cy.get('[data-test=SyncView]', { timeout: 60000 }).should('not.exist');
});
});
});
});
});
108 changes: 108 additions & 0 deletions client/cypress/e2e/allocationItemWindowClosed.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import {
connectWallet,
visitWithLoader,
mockCoinPricesServer,
navigateWithCheck,
} from 'cypress/utils/e2e';
import { moveTime, setupAndMoveToPlayground } from 'cypress/utils/moveTime';
import viewports from 'cypress/utils/viewports';
import { QUERY_KEYS } from 'src/api/queryKeys';
import {
ALLOCATION_ITEMS_KEY,
IS_ONBOARDING_ALWAYS_VISIBLE,
IS_ONBOARDING_DONE,
} from 'src/constants/localStorageKeys';
import { ROOT_ROUTES } from 'src/routes/RootRoutes/routes';

describe('allocation (allocation window closed)', () => {
describe('move time', () => {
before(() => {
/**
* Global Metamask setup done by Synpress is not always done.
* Since Synpress needs to have valid provider to fetch the data from contracts,
* setupMetamask is required in each test suite.
*/
cy.setupMetamask();
});

it('allocation window is closed, when it is not, move time', () => {
setupAndMoveToPlayground();

cy.window().then(async win => {
moveTime(win, 'nextEpochDecisionWindowClosed').then(() => {
cy.get('[data-test=PlaygroundView]').should('be.visible');
const isDecisionWindowOpenAfter = win.clientReactQuery.getQueryData(
QUERY_KEYS.isDecisionWindowOpen,
);
expect(isDecisionWindowOpenAfter).to.be.false;
});
});
});
});

Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight, isDesktop }) => {
describe(`test cases: ${device}`, { viewportHeight, viewportWidth }, () => {
before(() => {
/**
* Global Metamask setup done by Synpress is not always done.
* Since Synpress needs to have valid provider to fetch the data from contracts,
* setupMetamask is required in each test suite.
*/
cy.setupMetamask();
});

beforeEach(() => {
cy.disconnectMetamaskWalletFromAllDapps();
mockCoinPricesServer();
localStorage.setItem(IS_ONBOARDING_ALWAYS_VISIBLE, 'false');
localStorage.setItem(IS_ONBOARDING_DONE, 'true');
localStorage.setItem(ALLOCATION_ITEMS_KEY, '[]');
visitWithLoader(ROOT_ROUTES.projects.absolute);

cy.get('[data-test^=ProjectItemSkeleton').should('not.exist');
cy.get('[data-test^=ProjectsView__ProjectsListItem]')
.eq(0)
.should('be.visible')
.find('[data-test=ProjectsListItem__name]')
.then($text => {
cy.wrap($text.text()).as('projectName');
});

cy.get('[data-test^=ProjectsView__ProjectsListItem')
.eq(0)
.find('[data-test=ProjectsListItem__ButtonAddToAllocate]')
.click();
navigateWithCheck(ROOT_ROUTES.allocation.absolute);
});

it('AllocationItem shows all the elements', () => {
connectWallet(true, false);
cy.get('[data-test=AllocationItem]')
.eq(0)
.find('[data-test=AllocationItem__name]')
.then($allocationItemName => {
cy.get('@projectName').then(projectName => {
expect(projectName).to.eq($allocationItemName.text());
});
});

cy.get('[data-test=AllocationItem]')
.eq(0)
.find('[data-test=AllocationItem__imageProfile]')
.should(isDesktop ? 'be.visible' : 'not.be.visible');
cy.get('[data-test=AllocationItem]')
.eq(0)
.find('[data-test=AllocationItemRewards]')
.contains(isDesktop ? 'Threshold data unavailable' : 'No threshold data');
cy.get('[data-test=AllocationItem]')
.eq(0)
.find('[data-test=AllocationItem__InputText]')
.should('be.disabled');
cy.get('[data-test=AllocationItem]')
.eq(0)
.find('[data-test=AllocationItem__InputText__suffix]')
.contains('GWEI');
});
});
});
});
139 changes: 139 additions & 0 deletions client/cypress/e2e/allocationItemWindowOpen.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import chaiColors from 'chai-colors';

import {
visitWithLoader,
mockCoinPricesServer,
navigateWithCheck,
connectWallet,
} from 'cypress/utils/e2e';
import { moveTime, setupAndMoveToPlayground } from 'cypress/utils/moveTime';
import viewports from 'cypress/utils/viewports';
import { QUERY_KEYS } from 'src/api/queryKeys';
import {
ALLOCATION_ITEMS_KEY,
IS_ONBOARDING_ALWAYS_VISIBLE,
IS_ONBOARDING_DONE,
} from 'src/constants/localStorageKeys';
import { ROOT_ROUTES } from 'src/routes/RootRoutes/routes';

chai.use(chaiColors);

const budget = '10000000000'; // 10 GWEI.

describe('allocation (allocation window open)', () => {
describe('move time', () => {
before(() => {
/**
* Global Metamask setup done by Synpress is not always done.
* Since Synpress needs to have valid provider to fetch the data from contracts,
* setupMetamask is required in each test suite.
*/
cy.setupMetamask();
});

it('allocation window is open, when it is not, move time', () => {
setupAndMoveToPlayground();

cy.window().then(async win => {
moveTime(win, 'nextEpochDecisionWindowOpen').then(() => {
const isDecisionWindowOpenAfter = win.clientReactQuery.getQueryData(
QUERY_KEYS.isDecisionWindowOpen,
);
expect(isDecisionWindowOpenAfter).to.be.true;
});
});
});
});

Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight, isDesktop }) => {
describe(`test cases: ${device}`, { viewportHeight, viewportWidth }, () => {
before(() => {
/**
* Global Metamask setup done by Synpress is not always done.
* Since Synpress needs to have valid provider to fetch the data from contracts,
* setupMetamask is required in each test suite.
*/
cy.setupMetamask();
});

beforeEach(() => {
cy.intercept('GET', '/rewards/budget/*/epoch/*', { body: { budget } });
cy.disconnectMetamaskWalletFromAllDapps();
mockCoinPricesServer();
localStorage.setItem(IS_ONBOARDING_ALWAYS_VISIBLE, 'false');
localStorage.setItem(IS_ONBOARDING_DONE, 'true');
localStorage.setItem(ALLOCATION_ITEMS_KEY, '[]');
visitWithLoader(ROOT_ROUTES.projects.absolute);
connectWallet(true, false);

cy.get('[data-test^=ProjectItemSkeleton').should('not.exist');
cy.get('[data-test^=ProjectsView__ProjectsListItem]')
.eq(0)
.should('be.visible')
.find('[data-test=ProjectsListItem__name]')
.then($text => {
cy.wrap($text.text()).as('projectName');
});

cy.get('[data-test^=ProjectsView__ProjectsListItem')
.eq(0)
.find('[data-test=ProjectsListItem__ButtonAddToAllocate]')
.click();
navigateWithCheck(ROOT_ROUTES.allocation.absolute);
cy.get('[data-test=AllocationItemSkeleton]').should('not.exist');
});

it('AllocationItem shows all the elements', () => {
cy.get('[data-test=AllocationItem]')
.eq(0)
.find('[data-test=AllocationItem__name]')
.then($allocationItemName => {
cy.get('@projectName').then(projectName => {
expect(projectName).to.eq($allocationItemName.text());
});
});
cy.get('[data-test=AllocationItem]')
.eq(0)
.find('[data-test=AllocationItem__imageProfile]')
.should(isDesktop ? 'be.visible' : 'not.be.visible');
cy.get('[data-test=AllocationItem]')
.eq(0)
.find('[data-test=AllocationItem__InputText]')
.should('be.enabled');
});

it('AllocationItem__InputText correctly changes background color on focus', () => {
cy.get('[data-test=AllocationItem]')
.eq(0)
.find('[data-test=AllocationItem__InputText]')
.focus();
cy.get('[data-test=AllocationItem]')
.eq(0)
.find('[data-test=AllocationItem__InputText]')
.should('have.focus');
cy.get('[data-test=AllocationItem]')
.eq(0)
.find('[data-test=AllocationItem__InputText]')
.should('have.css', 'background-color')
.and('be.colored', '#f1faf8');
});

it('AllocationItem__InputText correctly changes background color on error', () => {
cy.get('[data-test=AllocationItem]')
.eq(0)
.find('[data-test=AllocationItem__InputText__suffix]')
.contains('GWEI');
cy.get('[data-test=AllocationItem]')
.eq(0)
.find('[data-test=AllocationItem__InputText]')
.type('99');
cy.get('[data-test=AllocationItem]')
.eq(0)
.find('[data-test=AllocationItem__InputText]')
.should('have.css', 'background-color')
.and('be.colored', '#f1faf8');
});
});
});
});
5 changes: 3 additions & 2 deletions client/cypress/e2e/earn.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { visitWithLoader, mockCoinPricesServer, moveEpoch } from 'cypress/utils/e2e';
import { visitWithLoader, mockCoinPricesServer } from 'cypress/utils/e2e';
import { moveTime } from 'cypress/utils/moveTime';
import viewports from 'cypress/utils/viewports';
import { IS_ONBOARDING_ALWAYS_VISIBLE, IS_ONBOARDING_DONE } from 'src/constants/localStorageKeys';
import { ROOT_ROUTES } from 'src/routes/RootRoutes/routes';
Expand Down Expand Up @@ -248,7 +249,7 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight, isDes
}).should('not.exist');
cy.window().then(async win => {
cy.wrap(null).then(() => {
return moveEpoch(win).then(() => {
return moveTime(win, 'nextEpochDecisionWindowClosed').then(() => {
cy.get('[data-test=BoxGlmLock__Section--current__DoubleValue__primary]', {
timeout: 60000,
})
Expand Down
5 changes: 3 additions & 2 deletions client/cypress/e2e/projectsArchive.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { checkLocationWithLoader, moveEpoch, visitWithLoader } from 'cypress/utils/e2e';
import { checkLocationWithLoader, visitWithLoader } from 'cypress/utils/e2e';
import { moveTime } from 'cypress/utils/moveTime';
import viewports from 'cypress/utils/viewports';
import { QUERY_KEYS } from 'src/api/queryKeys';
import { IS_ONBOARDING_ALWAYS_VISIBLE, IS_ONBOARDING_DONE } from 'src/constants/localStorageKeys';
Expand All @@ -23,7 +24,7 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight }) =>
);

cy.wrap(null).then(() => {
return moveEpoch(win).then(() => {
return moveTime(win, 'nextEpochDecisionWindowClosed').then(() => {
const currentEpochAfter = Number(
win.clientReactQuery.getQueryData(QUERY_KEYS.currentEpoch),
);
Expand Down
4 changes: 3 additions & 1 deletion client/cypress/support/e2e.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ declare namespace Cypress {
interface ApplicationWindow {
// Importing QueryClient breaks <reference types="cypress" /> making these types not visible.
clientReactQuery: any;
mutateAsyncMoveEpoch: () => Promise<void>;
mutateAsyncMakeSnapshot: (type: 'pending' | 'finalized') => Promise<void>;
mutateAsyncMoveToDecisionWindowClosed: () => Promise<void>;
mutateAsyncMoveToDecisionWindowOpen: () => Promise<void>;
}
}
32 changes: 0 additions & 32 deletions client/cypress/utils/e2e.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import axios from 'axios';

import { navigationTabs } from 'src/constants/navigationTabs/navigationTabs';
import env from 'src/env';

import Chainable = Cypress.Chainable;

Expand Down Expand Up @@ -49,32 +46,3 @@ export const connectWallet = (
cy.switchToMetamaskNotification();
return cy.acceptMetamaskAccess();
};

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);
});
});
});
});
};
Loading