Skip to content

Commit

Permalink
OCT-1611 CY: enable projects "user is able to add & remove the first …
Browse files Browse the repository at this point in the history
…and the last project (...)" test (#192)
  • Loading branch information
aziolek authored May 7, 2024
2 parents a8c3e9f + 1d287ea commit 4b6a4d0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
4 changes: 1 addition & 3 deletions client/cypress/e2e/projects.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight }) =>
}
});

// TODO OCT-1611 enable this test.
// eslint-disable-next-line jest/no-disabled-tests
it.skip('user is able to add & remove the first and the last project to/from allocation, triggering change of the icon, change of the number in navbar', () => {
it('user is able to add & remove the first and the last project to/from allocation, triggering change of the icon, change of the number in navbar', () => {
// This test checks the first and the last elements only to save time.
cy.get('[data-test=Navbar__numberOfAllocations]').should('not.exist');

Expand Down
18 changes: 17 additions & 1 deletion client/src/views/ProjectsView/ProjectsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,23 @@ const ProjectsView = (): ReactElement => {
? Array.from(Array(lastArchivedEpochNumber)).map((_, idx, array) => array.length - idx)
: [];

const onLoadNextEpochArchive = () => setLoadedArchivedEpochsNumber(prev => prev + 1);
const onLoadNextEpochArchive = () => {
setLoadedArchivedEpochsNumber(prev => {
/**
* While in CY, onLoadNextEpochArchive is sometimes called twice in a row for the same project.
*
* The reason for it is unknown, but without below check the same number can be loaded twice.
* This results in random failure of the CY tests for projects view.
*
* During "normal" usage problem could not be reproduced,
* yet might be possible, so better avoid that.
*
* Issue is not resolved in the library:
* https://github.com/danbovey/react-infinite-scroller/issues/143
*/
return loadedArchivedEpochsNumber !== prev ? prev : prev + 1;
});
};

useLayoutEffect(() => {
const projectsScrollY = window[WINDOW_PROJECTS_SCROLL_Y];
Expand Down
2 changes: 1 addition & 1 deletion client/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ i18n.init({

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
process.env = {...process.env, ...loadEnv(mode, process.cwd())};
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };

const isProduction = mode === 'production';
const isStaging = mode === 'staging';
Expand Down

0 comments on commit 4b6a4d0

Please sign in to comment.