From 1332e145f12826952c0ca688ab64bf17d82b3d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Miko=C5=82ajczyk?= Date: Fri, 27 Dec 2024 12:23:17 +0100 Subject: [PATCH 01/14] oct-2132: home uq e2e --- client/cypress/e2e/_23uq.cy.ts | 58 +++++++++++++++++++ .../Home/HomeGridUQScore/HomeGridUQScore.tsx | 4 ++ 2 files changed, 62 insertions(+) create mode 100644 client/cypress/e2e/_23uq.cy.ts diff --git a/client/cypress/e2e/_23uq.cy.ts b/client/cypress/e2e/_23uq.cy.ts new file mode 100644 index 0000000000..42e7b5a2b0 --- /dev/null +++ b/client/cypress/e2e/_23uq.cy.ts @@ -0,0 +1,58 @@ +// eslint-disable-next-line import/no-extraneous-dependencies +import chaiColors from 'chai-colors'; + +import { connectWallet, mockCoinPricesServer, visitWithLoader } from 'cypress/utils/e2e'; +import viewports from 'cypress/utils/viewports'; +import { + HAS_ONBOARDING_BEEN_CLOSED, + IS_ONBOARDING_ALWAYS_VISIBLE, + IS_ONBOARDING_DONE, +} from 'src/constants/localStorageKeys'; +import { ROOT_ROUTES } from 'src/routes/RootRoutes/routes'; + +chai.use(chaiColors); + +Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight }) => { + describe(`[AW IS OPEN] UQ: ${device}`, { viewportHeight, viewportWidth }, () => { + before(() => { + cy.clearLocalStorage(); + /** + * 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(HAS_ONBOARDING_BEEN_CLOSED, 'true'); + visitWithLoader(ROOT_ROUTES.home.absolute); + connectWallet({ isPatronModeEnabled: false }); + }); + + it('Each element of UQ tile is visible and has correct value', () => { + cy.get('[data-test=HomeGridUQScore__Button--whatIsThis]').should('be.visible'); + cy.get('[data-test=HomeGridUQScore__Button--whatIsThis]').click(); + cy.wait(500); + cy.get('[data-test=ModalCalculatingYourUniqueness]').should('be.visible'); + cy.get('[data-test=ModalCalculatingYourUniqueness__ProgressStepperSlim__element]').should( + 'have.length', + 3, + ); + cy.get('[data-test=ModalCalculatingYourUniqueness__Button]').click(); + cy.wait(500); + cy.get('[data-test=ModalCalculatingYourUniqueness]').should('not.exist'); + cy.get('[data-test=HomeGridUQScoreAddresses]').should('be.visible'); + cy.get('[data-test=HomeGridUQScore__Button--scoreTooLow]').should('be.visible'); + cy.get('[data-test=HomeGridUQScore__Button--scoreTooLow]') + .invoke('attr', 'href') + .should('eq', 'https://passport.gitcoin.co/#/octant/'); + cy.get('[data-test=HomeGridUQScore__Button--recalculate]').should('be.visible'); + cy.get('[data-test=HomeGridUQScore__Button--delegate]').should('be.visible'); + }); + }); +}); diff --git a/client/src/components/Home/HomeGridUQScore/HomeGridUQScore.tsx b/client/src/components/Home/HomeGridUQScore/HomeGridUQScore.tsx index be61227116..c5c17fb2e7 100644 --- a/client/src/components/Home/HomeGridUQScore/HomeGridUQScore.tsx +++ b/client/src/components/Home/HomeGridUQScore/HomeGridUQScore.tsx @@ -249,6 +249,7 @@ const HomeGridUQScore: FC = ({ className }) => { titleSuffix={