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 <dexter.edwards93@gmail.com>
Co-authored-by: Rado <rado@vegaprotocol.io>
This commit is contained in:
Radosław Szpiech 2022-07-01 16:57:20 +02:00 committed by GitHub
parent 457caf4e8c
commit acef1a8e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 89 additions and 6 deletions

View File

@ -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');
});
});
});

View File

@ -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');
});
});
});

View File

@ -3,4 +3,5 @@ export default {
sectionHeader: 'h2', sectionHeader: 'h2',
link: '[data-testid="link"]', link: '[data-testid="link"]',
warning: '[data-testid="callout"]', warning: '[data-testid="callout"]',
connectToVegaBtn: '[data-testid="connect-to-vega-wallet-btn"]',
}; };

View File

@ -0,0 +1,6 @@
import common from './common.locators';
export default {
...common,
noProposals: '[data-testid="no-proposals"]',
};

View File

@ -2,5 +2,4 @@ import common from './common.locators';
export default { export default {
...common, ...common,
connectToVegaBtn: '[data-testid="connect-to-vega-wallet-btn"]',
}; };

View File

@ -7,5 +7,4 @@ export default {
step2: '[data-testid="staking-step-2"]', step2: '[data-testid="staking-step-2"]',
step3: '[data-testid="staking-step-3"]', step3: '[data-testid="staking-step-3"]',
connectToEthBtn: '[data-testid="connect-to-eth-btn"]', connectToEthBtn: '[data-testid="connect-to-eth-btn"]',
connectToVegaBtn: '[data-testid="connect-to-vega-wallet-btn"]',
}; };

View File

@ -0,0 +1,5 @@
import common from './common.locators';
export default {
...common,
};

View File

@ -22,6 +22,7 @@ export const VegaWalletContainer = ({ children }: VegaWalletContainerProps) => {
return ( return (
<p> <p>
<Button <Button
data-testid="connect-to-vega-wallet-btn"
onClick={() => onClick={() =>
appDispatch({ appDispatch({
type: AppStateActionType.SET_VEGA_WALLET_OVERLAY, type: AppStateActionType.SET_VEGA_WALLET_OVERLAY,

View File

@ -3,7 +3,6 @@ import { format, isFuture } from 'date-fns';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { Heading } from '../../../../components/heading';
import { KeyValueTable, KeyValueTableRow } from '@vegaprotocol/ui-toolkit'; import { KeyValueTable, KeyValueTableRow } from '@vegaprotocol/ui-toolkit';
import { getProposalName } from '../../../../lib/type-policies/proposal'; import { getProposalName } from '../../../../lib/type-policies/proposal';
import type { Proposals_proposals } from '../../proposals/__generated__/Proposals'; import type { Proposals_proposals } from '../../proposals/__generated__/Proposals';
@ -17,12 +16,11 @@ export const ProposalsList = ({ proposals }: ProposalsListProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
if (proposals.length === 0) { if (proposals.length === 0) {
return <p>{t('noProposals')}</p>; return <p data-testid="no-proposals">{t('noProposals')}</p>;
} }
return ( return (
<> <>
<Heading title={t('pageTitleGovernance')} />
<p>{t('proposedChangesToVegaNetwork')}</p> <p>{t('proposedChangesToVegaNetwork')}</p>
<p>{t('vegaTokenHoldersCanVote')}</p> <p>{t('vegaTokenHoldersCanVote')}</p>
<p>{t('requiredMajorityDescription')}</p> <p>{t('requiredMajorityDescription')}</p>

View File

@ -1,5 +1,6 @@
import { gql, useQuery } from '@apollo/client'; import { gql, useQuery } from '@apollo/client';
import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit'; import { Callout, Intent, Splash } from '@vegaprotocol/ui-toolkit';
import { Heading } from '../../../components/heading';
import compact from 'lodash/compact'; import compact from 'lodash/compact';
import flow from 'lodash/flow'; import flow from 'lodash/flow';
import orderBy from 'lodash/orderBy'; import orderBy from 'lodash/orderBy';
@ -63,5 +64,10 @@ export const ProposalsContainer = () => {
); );
} }
return <ProposalsList proposals={proposals} />; return (
<>
<Heading title={t('pageTitleGovernance')} />
<ProposalsList proposals={proposals} />
</>
);
}; };