Skip to content

Commit

Permalink
OCT-1395 Unify "projects" and "proposals" to "projects" in the client (
Browse files Browse the repository at this point in the history
  • Loading branch information
aziolek authored Mar 14, 2024
1 parent 93b5222 commit 273d24a
Show file tree
Hide file tree
Showing 202 changed files with 1,662 additions and 1,702 deletions.
4 changes: 2 additions & 2 deletions client/cypress/e2e/layout.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight }) =>
navigateWithCheck(ROOT_ROUTES.settings.absolute);
cy.get('[data-test=SettingsView]').should('be.visible');
cy.get('[data-test=MainLayout__Logo]').click();
cy.get('[data-test=ProposalsView]').should('be.visible');
cy.get('[data-test=ProjectsView]').should('be.visible');
});

it('Clicking on Octant logo redirects to projects view (outside projects view) with memorized scrollY', () => {
cy.scrollTo(0, 500);
navigateWithCheck(ROOT_ROUTES.settings.absolute);
cy.get('[data-test=SettingsView]').should('be.visible');
cy.get('[data-test=MainLayout__Logo]').click();
cy.get('[data-test=ProposalsView]').should('be.visible');
cy.get('[data-test=ProjectsView]').should('be.visible');
cy.window().then(cyWindow => {
expect(cyWindow.scrollY).to.be.eq(500);
});
Expand Down
6 changes: 3 additions & 3 deletions client/cypress/e2e/onboarding.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const connectWallet = (
cy.intercept('GET', '/user/*/tos', { body: { accepted: isTOSAccepted } });
cy.disconnectMetamaskWalletFromAllDapps();
if (shouldVisit) {
visitWithLoader(ROOT.absolute, ROOT_ROUTES.proposals.absolute);
visitWithLoader(ROOT.absolute, ROOT_ROUTES.projects.absolute);
}
if (shouldReload) {
cy.reload();
Expand Down Expand Up @@ -239,14 +239,14 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight }) =>
.click();
cy.get('[data-test=ModalOnboarding__Button]').click();
cy.get('[data-test=ModalOnboarding]').should('not.exist');
cy.get('[data-test=ProposalsView__ProposalsList]').should('be.visible');
cy.get('[data-test=ProjectsView__ProjectsList]').should('be.visible');
});

it('user is able to close the modal by clicking button in the top-right', () => {
cy.get('[data-test=ModalOnboarding]').should('be.visible');
cy.get('[data-test=ModalOnboarding__Button]').click();
cy.get('[data-test=ModalOnboarding]').should('not.exist');
cy.get('[data-test=ProposalsView__ProposalsList]').should('be.visible');
cy.get('[data-test=ProjectsView__ProjectsList]').should('be.visible');
});

it('renders every time page is refreshed when "Always show Allocate onboarding" option is checked', () => {
Expand Down
8 changes: 4 additions & 4 deletions client/cypress/e2e/patronMode.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight, isDes
});

it('route /allocate redirects to /projects', () => {
visitWithLoader(ROOT_ROUTES.allocation.absolute, ROOT_ROUTES.proposals.absolute);
cy.get('[data-test=ProposalsView]').should('be.visible');
visitWithLoader(ROOT_ROUTES.allocation.absolute, ROOT_ROUTES.projects.absolute);
cy.get('[data-test=ProjectsView]').should('be.visible');
});

it('BoxPersonalAllocation has correct title and sections labels', () => {
Expand Down Expand Up @@ -710,8 +710,8 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight, isDes
});

it('when entering project view, button icon changes to chevronLeft', () => {
visitWithLoader(ROOT_ROUTES.proposals.absolute);
cy.get('[data-test^=ProposalsView__ProposalsListItem').first().click();
visitWithLoader(ROOT_ROUTES.projects.absolute);
cy.get('[data-test^=ProjectsView__ProjectsListItem').first().click();
cy.get('[data-test=Navbar__Button--Projects]')
.find('svg')
// HTML tag can't be self-closing in CY.
Expand Down
181 changes: 181 additions & 0 deletions client/cypress/e2e/project.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
import { connectWallet, mockCoinPricesServer, visitWithLoader } from 'cypress/utils/e2e';
import { getNamesOfProjects } from 'cypress/utils/projects';
import viewports from 'cypress/utils/viewports';
import { IS_ONBOARDING_DONE } from 'src/constants/localStorageKeys';
import { ROOT_ROUTES } from 'src/routes/RootRoutes/routes';

import Chainable = Cypress.Chainable;

const getButtonAddToAllocate = (): Chainable<any> => {
const projectListItemFirst = cy.get('[data-test=ProjectListItem').first();

return projectListItemFirst.find('[data-test=ProjectListItemHeader__ButtonAddToAllocate]');
};

const checkProjectItemElements = (): Chainable<any> => {
cy.get('[data-test^=ProjectsView__ProjectsListItem').first().click();
const projectListItemFirst = cy.get('[data-test=ProjectListItem').first();
projectListItemFirst.get('[data-test=ProjectListItemHeader__Img]').should('be.visible');
projectListItemFirst.get('[data-test=ProjectListItemHeader__name]').should('be.visible');
getButtonAddToAllocate().should('be.visible');
projectListItemFirst.get('[data-test=ProjectListItemHeader__Button]').should('be.visible');
projectListItemFirst.get('[data-test=ProjectListItem__Description]').should('be.visible');

cy.get('[data-test=ProjectListItem__Donors]')
.first()
.scrollIntoView({ offset: { left: 0, top: 100 } });

cy.get('[data-test=ProjectListItem__Donors]').first().should('be.visible');
cy.get('[data-test=ProjectListItem__Donors__DonorsHeader__count]')
.first()
.should('be.visible')
.should('have.text', '0');
return cy.get('[data-test=ProjectListItem__Donors__noDonationsYet]').first().should('be.visible');
};

Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight }) => {
describe(`project: ${device}`, { viewportHeight, viewportWidth }, () => {
let projectNames: string[] = [];

beforeEach(() => {
mockCoinPricesServer();
localStorage.setItem(IS_ONBOARDING_DONE, 'true');
visitWithLoader(ROOT_ROUTES.projects.absolute);
cy.get('[data-test^=ProjectItemSkeleton').should('not.exist');

/**
* This could be done in before hook, but CY wipes the state after each test
* (could be disabled, but creates other problems)
*/
if (projectNames.length === 0) {
projectNames = getNamesOfProjects();
}
});

it('entering project view directly renders content', () => {
cy.get('[data-test^=ProjectsView__ProjectsListItem').first().click();
cy.reload();
const projectListItemFirst = cy.get('[data-test=ProjectListItem').first();
projectListItemFirst.get('[data-test=ProjectListItemHeader__Img]').should('be.visible');
projectListItemFirst.get('[data-test=ProjectListItemHeader__name]').should('be.visible');
});

it('entering project view renders all its elements', () => {
checkProjectItemElements();
});

it('entering project view renders all its elements with fallback IPFS provider', () => {
cy.intercept('GET', '**/ipfs/**', req => {
if (req.url.includes('infura')) {
req.destroy();
}
});

checkProjectItemElements();
});

it('entering project view shows Toast with info about IPFS failure when all providers fail', () => {
cy.intercept('GET', '**/ipfs/**', req => {
req.destroy();
});

cy.get('[data-test=Toast--ipfsMessage').should('be.visible');
});

it('entering project view allows to add it to allocation and remove, triggering change of the icon, change of the number in navbar', () => {
cy.get('[data-test^=ProjectsView__ProjectsListItem').first().click();

getButtonAddToAllocate().click();

// cy.get('@buttonAddToAllocate').click();
cy.get('[data-test=Navbar__numberOfAllocations]').contains(1);
getButtonAddToAllocate().click();
cy.get('[data-test=Navbar__numberOfAllocations]').should('not.exist');
});

it('Entering project view allows scroll only to the last project', () => {
cy.get('[data-test^=ProjectsView__ProjectsListItem]').first().click();

for (let i = 0; i < projectNames.length; i++) {
cy.get('[data-test=ProjectListItem]').should(
'have.length.greaterThan',
i === projectNames.length - 1 ? projectNames.length - 1 : i,
);
cy.get('[data-test=ProjectListItemHeader__name]')
.eq(i)
.scrollIntoView({ offset: { left: 0, top: -150 } })
.contains(projectNames[i]);
cy.get('[data-test=ProjectListItem__Donors]')
.eq(i)
.scrollIntoView({ offset: { left: 0, top: -150 } })
.should('be.visible');
}
});

it('"Back to top" button is displayed if the user has scrolled past the start of the final project description', () => {
cy.get('[data-test^=ProjectsView__ProjectsListItem]').first().click();

for (let i = 0; i < projectNames.length - 1; i++) {
cy.get('[data-test=ProjectListItem__Donors]')
.eq(i)
.scrollIntoView({ offset: { left: 0, top: 100 } });

if (i === projectNames.length - 1) {
cy.get('[data-test=ProjectBackToTopButton__Button]').should('be.visible');
}
}
});

it('Clicking on "Back to top" button scrolls to the top of view (first project is visible)', () => {
cy.get('[data-test^=ProjectsView__ProjectsListItem]').first().click();

for (let i = 0; i < projectNames.length - 1; i++) {
cy.get('[data-test=ProjectListItem__Donors]')
.eq(i)
.scrollIntoView({ offset: { left: 0, top: 100 } });

if (i === projectNames.length - 1) {
cy.get('[data-test=ProjectBackToTopButton__Button]').click();
cy.get('[data-test=ProjectListItem]').eq(0).should('be.visible');
}
}
});
});

describe(`project (patron mode): ${device}`, { viewportHeight, viewportWidth }, () => {
let projectNames: string[] = [];

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(() => {
mockCoinPricesServer();
localStorage.setItem(IS_ONBOARDING_DONE, 'true');
visitWithLoader(ROOT_ROUTES.projects.absolute);
connectWallet(true, true);
cy.get('[data-test^=ProjectItemSkeleton').should('not.exist');

/**
* This could be done in before hook, but CY wipes the state after each test
* (could be disabled, but creates other problems)
*/
if (projectNames.length === 0) {
projectNames = getNamesOfProjects();
}
});

it('button "add to allocate" is disabled', () => {
for (let i = 0; i < projectNames.length; i++) {
cy.get('[data-test^=ProjectsView__ProjectsListItem]').eq(i).click();
getButtonAddToAllocate().should('be.visible').should('be.disabled');
cy.go('back');
}
});
});
});
Loading

0 comments on commit 273d24a

Please sign in to comment.