From acef1a8e243c39e0911da945b834a626eba8774d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Szpiech?= Date: Fri, 1 Jul 2022 16:57:20 +0200 Subject: [PATCH] Test/toke add withdraw page validations (#701) * fix: always show heading on governance page * test(token): added validation for withdraw and governance pages * chore: remove semicolon Co-authored-by: Dexter Co-authored-by: Rado --- .../src/integration/governance.cy.js | 32 +++++++++++++++++ apps/token-e2e/src/integration/withdraw.cy.js | 36 +++++++++++++++++++ .../token-e2e/src/locators/common.locators.js | 1 + .../src/locators/governance.locators.js | 6 ++++ .../src/locators/rewards.locators.js | 1 - .../src/locators/staking.locators.js | 1 - .../src/locators/withdraw.locators.js | 5 +++ .../vega-wallet-container.tsx | 1 + .../proposals-list/proposals-list.tsx | 4 +-- .../proposals/proposals-container.tsx | 8 ++++- 10 files changed, 89 insertions(+), 6 deletions(-) create mode 100644 apps/token-e2e/src/integration/governance.cy.js create mode 100644 apps/token-e2e/src/integration/withdraw.cy.js create mode 100644 apps/token-e2e/src/locators/governance.locators.js create mode 100644 apps/token-e2e/src/locators/withdraw.locators.js diff --git a/apps/token-e2e/src/integration/governance.cy.js b/apps/token-e2e/src/integration/governance.cy.js new file mode 100644 index 000000000..4e4aef0b4 --- /dev/null +++ b/apps/token-e2e/src/integration/governance.cy.js @@ -0,0 +1,32 @@ +import navigation from '../locators/navigation.locators'; +import governance from '../locators/governance.locators'; + +context('Governance Page - verify elements on page', function () { + before('navigate to governance page', function () { + cy.visit('/') + .get(navigation.section) + .within(() => { + cy.get(navigation.governance).click(); + }); + }); + + describe('with no network change proposals', function () { + it('should have governance tab highlighted', function () { + cy.get(navigation.section).within(() => { + cy.get(navigation.governance).should('have.attr', 'aria-current'); + }); + }); + + it('should have GOVERNANCE header visible', function () { + cy.get(governance.pageHeader) + .should('be.visible') + .and('have.text', 'Governance'); + }); + + it('should have information box visible', function () { + cy.get(governance.noProposals) + .should('be.visible') + .and('have.text', 'There are no active network change proposals'); + }); + }); +}); diff --git a/apps/token-e2e/src/integration/withdraw.cy.js b/apps/token-e2e/src/integration/withdraw.cy.js new file mode 100644 index 000000000..0000ae619 --- /dev/null +++ b/apps/token-e2e/src/integration/withdraw.cy.js @@ -0,0 +1,36 @@ +import navigation from '../locators/navigation.locators'; +import withdraw from '../locators/withdraw.locators'; + +context('Withdraw Page - verify elements on page', function () { + before('navigate to withdraw page', function () { + cy.visit('/') + .get(navigation.section) + .within(() => { + cy.get(navigation.withdraw).click(); + }); + }); + + describe('with wallets disconnected', function () { + it('should have withdraw tab highlighted', function () { + cy.get(navigation.section).within(() => { + cy.get(navigation.withdraw).should('have.attr', 'aria-current'); + }); + }); + + it('should have WITHDRAW header visible', function () { + cy.get(withdraw.pageHeader) + .should('be.visible') + .and('have.text', 'Withdraw'); + }); + + it('should have connect Vega wallet button', function () { + cy.get(withdraw.connectToVegaBtn) + .should('be.visible') + .and('have.text', 'Connect Vega wallet'); + }); + + it('should have withdraw information box', function () { + cy.get(withdraw.warning).should('be.visible'); + }); + }); +}); diff --git a/apps/token-e2e/src/locators/common.locators.js b/apps/token-e2e/src/locators/common.locators.js index 8886e2115..11eee5f21 100644 --- a/apps/token-e2e/src/locators/common.locators.js +++ b/apps/token-e2e/src/locators/common.locators.js @@ -3,4 +3,5 @@ export default { sectionHeader: 'h2', link: '[data-testid="link"]', warning: '[data-testid="callout"]', + connectToVegaBtn: '[data-testid="connect-to-vega-wallet-btn"]', }; diff --git a/apps/token-e2e/src/locators/governance.locators.js b/apps/token-e2e/src/locators/governance.locators.js new file mode 100644 index 000000000..ec3d43f05 --- /dev/null +++ b/apps/token-e2e/src/locators/governance.locators.js @@ -0,0 +1,6 @@ +import common from './common.locators'; + +export default { + ...common, + noProposals: '[data-testid="no-proposals"]', +}; diff --git a/apps/token-e2e/src/locators/rewards.locators.js b/apps/token-e2e/src/locators/rewards.locators.js index 2999773e6..343ef2607 100644 --- a/apps/token-e2e/src/locators/rewards.locators.js +++ b/apps/token-e2e/src/locators/rewards.locators.js @@ -2,5 +2,4 @@ import common from './common.locators'; export default { ...common, - connectToVegaBtn: '[data-testid="connect-to-vega-wallet-btn"]', }; diff --git a/apps/token-e2e/src/locators/staking.locators.js b/apps/token-e2e/src/locators/staking.locators.js index ffebddbae..234529965 100644 --- a/apps/token-e2e/src/locators/staking.locators.js +++ b/apps/token-e2e/src/locators/staking.locators.js @@ -7,5 +7,4 @@ export default { step2: '[data-testid="staking-step-2"]', step3: '[data-testid="staking-step-3"]', connectToEthBtn: '[data-testid="connect-to-eth-btn"]', - connectToVegaBtn: '[data-testid="connect-to-vega-wallet-btn"]', }; diff --git a/apps/token-e2e/src/locators/withdraw.locators.js b/apps/token-e2e/src/locators/withdraw.locators.js new file mode 100644 index 000000000..343ef2607 --- /dev/null +++ b/apps/token-e2e/src/locators/withdraw.locators.js @@ -0,0 +1,5 @@ +import common from './common.locators'; + +export default { + ...common, +}; diff --git a/apps/token/src/components/vega-wallet-container/vega-wallet-container.tsx b/apps/token/src/components/vega-wallet-container/vega-wallet-container.tsx index 41d698973..7d7f67fe1 100644 --- a/apps/token/src/components/vega-wallet-container/vega-wallet-container.tsx +++ b/apps/token/src/components/vega-wallet-container/vega-wallet-container.tsx @@ -22,6 +22,7 @@ export const VegaWalletContainer = ({ children }: VegaWalletContainerProps) => { return (