From 17ad0cc975111d1a6ca4d2267f63e5696c129cbc Mon Sep 17 00:00:00 2001 From: Joe Tsang <30622993+jtsang586@users.noreply.github.com> Date: Mon, 3 Apr 2023 09:16:42 +0100 Subject: [PATCH] test(governance): add e2e tests for banner and footer links (#3340) --- apps/governance-e2e/.env | 2 + .../src/integration/view/home.cy.ts | 328 ++++++++++-------- apps/governance/.env.capsule | 2 +- 3 files changed, 189 insertions(+), 143 deletions(-) diff --git a/apps/governance-e2e/.env b/apps/governance-e2e/.env index 7463399fc..de1f22211 100644 --- a/apps/governance-e2e/.env +++ b/apps/governance-e2e/.env @@ -13,6 +13,8 @@ NX_LOCAL_PROVIDER_URL=http://localhost:8545/ NX_VEGA_WALLET_URL=http://localhost:1789 NX_VEGA_DOCS_URL=https://docs.vega.xyz/mainnet NX_TRANCHES_SERVICE_URL=https://tranches-stagnet3-k8s.ops.vega.xyz +NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json +NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions #Test configuration variables CYPRESS_FAIRGROUND=false diff --git a/apps/governance-e2e/src/integration/view/home.cy.ts b/apps/governance-e2e/src/integration/view/home.cy.ts index 0cce3da85..248a765b4 100644 --- a/apps/governance-e2e/src/integration/view/home.cy.ts +++ b/apps/governance-e2e/src/integration/view/home.cy.ts @@ -6,159 +6,203 @@ context('Home Page - verify elements on page', { tags: '@smoke' }, function () { cy.get('nav', { timeout: 10000 }).should('be.visible'); }); - describe('with wallets disconnected', function () { - describe('Links and buttons', function () { - it('should have link for proposal page', function () { - cy.getByTestId('home-proposals').within(() => { - cy.get('[href="/proposals"]') - .should('exist') - .and('have.text', 'Browse, vote, and propose'); - }); - }); - it('should show open or enacted proposals with proposal summary', function () { - cy.get('body').then(($body) => { - if (!$body.find('[data-testid="proposals-list-item"]').length) { - cy.createMarket(); - cy.reload(); - waitForSpinner(); - } - }); - cy.getByTestId('proposals-list-item') - .should('have.length.at.least', 1) - .first() - .within(() => { - cy.getByTestId('proposal-title') - .invoke('text') - .should('not.be.empty'); - cy.getByTestId('proposal-type') - .invoke('text') - .should('not.be.empty'); - cy.getByTestId('proposal-description') - .invoke('text') - .should('not.be.empty'); - cy.getByTestId('proposal-details') - .invoke('text') - .should('not.be.empty'); - cy.getByTestId('proposal-status') - .invoke('text') - .should('not.be.empty'); - cy.getByTestId('vote-details') - .invoke('text') - .should('not.be.empty'); - cy.getByTestId('view-proposal-btn').should('be.visible'); - }); - }); - it('should have external link for governance', function () { - cy.getByTestId('home-proposals').within(() => { - cy.getByTestId('external-link') - .should('have.attr', 'href') - .and('contain', 'https://vega.xyz/governance'); - }); - }); - it('should have link for validator page', function () { - cy.getByTestId('home-validators').within(() => { - cy.get('[href="/validators"]') - .first() - .should('exist') - .and('have.text', 'Browse, and stake'); - }); - }); - it('should have external link for validators', function () { - cy.getByTestId('home-validators').within(() => { - cy.getByTestId('external-link') - .should('have.attr', 'href') - .and( - 'contain', - 'https://community.vega.xyz/c/mainnet-validator-candidates' - ); - }); - }); - it('should have information on active nodes', function () { - cy.getByTestId('node-information') - .first() - .should('contain.text', '2') - .and('contain.text', 'active nodes'); - }); - it('should have information on consensus nodes', function () { - cy.getByTestId('node-information') - .last() - .should('contain.text', '2') - .and('contain.text', 'consensus nodes'); - }); - it('should contain link to specific validators', function () { - cy.getByTestId('validators') - .should('have.length', '2') - .each(($validator) => { - cy.wrap($validator).find('a').should('have.attr', 'href'); - }); - }); - it('should have link for rewards page', function () { - cy.getByTestId('home-rewards').within(() => { - cy.get('[href="/rewards"]') - .first() - .should('exist') - .and('have.text', 'See rewards'); - }); - }); - it('should have link for withdrawal page', function () { - cy.getByTestId('home-vega-token').within(() => { - cy.get('[href="/token/withdraw"]') - .first() - .should('exist') - .and('have.text', 'Manage tokens'); - }); + describe('Links and buttons', function () { + it('should have link for proposal page', function () { + cy.getByTestId('home-proposals').within(() => { + cy.get('[href="/proposals"]') + .should('exist') + .and('have.text', 'Browse, vote, and propose'); }); }); - describe('Mobile view - navigation bar', function () { - before('Change to mobile resolution', function () { - cy.viewport('iphone-xr'); - }); - - it('should have burger button', () => { - cy.getByTestId('button-menu-drawer').should('be.visible').click(); - cy.getByTestId('menu-drawer').should('be.visible'); - }); - - it('should have link for proposal page', function () { - cy.getByTestId('menu-drawer').within(() => { - cy.get('[href="/proposals"]') - .should('exist') - .and('have.text', 'Proposals'); + it('should display announcement banner', function () { + cy.getByTestId('app-announcement') + .should('be.visible') + .within(() => { + cy.getByTestId('external-link').should('exist'); }); + cy.getByTestId('app-announcement-close').should('be.visible').click(); + cy.getByTestId('app-announcement').should('not.exist'); + }); + + it('should show open or enacted proposals with proposal summary', function () { + cy.get('body').then(($body) => { + if (!$body.find('[data-testid="proposals-list-item"]').length) { + cy.createMarket(); + cy.reload(); + waitForSpinner(); + } }); - it('should have link for validator page', function () { - cy.getByTestId('menu-drawer').within(() => { - cy.get('[href="/validators"]') + cy.getByTestId('proposals-list-item') + .should('have.length.at.least', 1) + .first() + .within(() => { + cy.getByTestId('proposal-title') + .invoke('text') + .should('not.be.empty'); + cy.getByTestId('proposal-type').invoke('text').should('not.be.empty'); + cy.getByTestId('proposal-description') + .invoke('text') + .should('not.be.empty'); + cy.getByTestId('proposal-details') + .invoke('text') + .should('not.be.empty'); + cy.getByTestId('proposal-status') + .invoke('text') + .should('not.be.empty'); + cy.getByTestId('vote-details').invoke('text').should('not.be.empty'); + cy.getByTestId('view-proposal-btn').should('be.visible'); + }); + }); + + it('should have external link for governance', function () { + cy.getByTestId('home-proposals').within(() => { + cy.getByTestId('external-link') + .should('have.attr', 'href') + .and('contain', 'https://vega.xyz/governance'); + }); + }); + + it('should have link for validator page', function () { + cy.getByTestId('home-validators').within(() => { + cy.get('[href="/validators"]') + .first() + .should('exist') + .and('have.text', 'Browse, and stake'); + }); + }); + + it('should have external link for validators', function () { + cy.getByTestId('home-validators').within(() => { + cy.getByTestId('external-link') + .should('have.attr', 'href') + .and( + 'contain', + 'https://community.vega.xyz/c/mainnet-validator-candidates' + ); + }); + }); + + it('should have information on active nodes', function () { + cy.getByTestId('node-information') + .first() + .should('contain.text', '2') + .and('contain.text', 'active nodes'); + }); + + it('should have information on consensus nodes', function () { + cy.getByTestId('node-information') + .last() + .should('contain.text', '2') + .and('contain.text', 'consensus nodes'); + }); + + it('should contain link to specific validators', function () { + cy.getByTestId('validators') + .should('have.length', '2') + .each(($validator) => { + cy.wrap($validator).find('a').should('have.attr', 'href'); + }); + }); + + it('should have link for rewards page', function () { + cy.getByTestId('home-rewards').within(() => { + cy.get('[href="/rewards"]') + .first() + .should('exist') + .and('have.text', 'See rewards'); + }); + }); + + it('should have link for withdrawal page', function () { + cy.getByTestId('home-vega-token').within(() => { + cy.get('[href="/token/withdraw"]') + .first() + .should('exist') + .and('have.text', 'Manage tokens'); + }); + }); + + it('should display network data', function () { + cy.getByTestId('git-network-data') + .should('contain.text', 'Reading network data from') + .within(() => { + cy.get('span') .first() - .should('exist') - .and('have.text', 'Validators'); + .should('have.text', 'http://localhost:3028/query'); + cy.getByTestId('link').should('exist'); }); - }); + }); - it('should have link for rewards page', function () { - cy.getByTestId('menu-drawer').within(() => { - cy.get('[href="/rewards"]') - .first() - .should('exist') - .and('have.text', 'Rewards'); + it('should display eth data', function () { + cy.getByTestId('git-eth-data') + .should('contain.text', 'Reading Ethereum data from') + .within(() => { + cy.get('span').should('have.text', 'http://localhost:8545'); }); - }); - it('should have link for withdrawal page', function () { - cy.getByTestId('menu-drawer').within(() => { - cy.get('[href="/token/withdraw"]') - .first() - .should('exist') - .and('have.text', 'Withdraw'); - }); - }); + }); - after(function () { - cy.viewport( - Cypress.config('viewportWidth'), - Cypress.config('viewportHeight') - ); + it('should contain link for known issues on Github', function () { + cy.getByTestId('git-info').within(() => { + cy.contains('Known issues and feedback on') + .find('[data-testid="link"]') + .should( + 'have.attr', + 'href', + 'https://github.com/vegaprotocol/feedback/discussions' + ); }); }); }); + + describe('Mobile view - navigation bar', function () { + before('Change to mobile resolution', function () { + cy.viewport('iphone-xr'); + }); + + it('should have burger button', () => { + cy.getByTestId('button-menu-drawer').should('be.visible').click(); + cy.getByTestId('menu-drawer').should('be.visible'); + }); + + it('should have link for proposal page', function () { + cy.getByTestId('menu-drawer').within(() => { + cy.get('[href="/proposals"]') + .should('exist') + .and('have.text', 'Proposals'); + }); + }); + it('should have link for validator page', function () { + cy.getByTestId('menu-drawer').within(() => { + cy.get('[href="/validators"]') + .first() + .should('exist') + .and('have.text', 'Validators'); + }); + }); + + it('should have link for rewards page', function () { + cy.getByTestId('menu-drawer').within(() => { + cy.get('[href="/rewards"]') + .first() + .should('exist') + .and('have.text', 'Rewards'); + }); + }); + it('should have link for withdrawal page', function () { + cy.getByTestId('menu-drawer').within(() => { + cy.get('[href="/token/withdraw"]') + .first() + .should('exist') + .and('have.text', 'Withdraw'); + }); + }); + + after(function () { + cy.viewport( + Cypress.config('viewportWidth'), + Cypress.config('viewportHeight') + ); + }); + }); }); diff --git a/apps/governance/.env.capsule b/apps/governance/.env.capsule index 37f49fcd2..eeb84ea5b 100644 --- a/apps/governance/.env.capsule +++ b/apps/governance/.env.capsule @@ -5,6 +5,7 @@ NX_ETHERSCAN_URL=https://sepolia.etherscan.io NX_FAIRGROUND=false NX_VEGA_NETWORKS='{"DEVNET":"https://dev.token.vega.xyz","STAGNET3":"https://stagnet3.token.vega.xyz","TESTNET":"https://token.fairground.wtf","MAINNET":"https://token.vega.xyz"}' NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions +NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json NX_VEGA_CONFIG_URL='' NX_VEGA_URL=http://localhost:3028/query @@ -16,7 +17,6 @@ NX_VEGA_WALLET_URL=http://localhost:1789 NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet NX_DELEGATIONS_PAGINATION=50 NX_TRANCHES_SERVICE_URL=https://tranches-stagnet3-k8s.ops.vega.xyz -NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/main/announcements.json #Test configuration variables CYPRESS_FAIRGROUND=false