fix: polling not working on governance page (#1255)
* fix: polling not working on governance page * style: lint
This commit is contained in:
parent
f401870848
commit
bacd2a509e
@ -1,10 +1,10 @@
|
|||||||
# App configuration variables
|
# App configuration variables
|
||||||
NX_VEGA_ENV=TESTNET
|
NX_VEGA_ENV=TESTNET
|
||||||
NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/testnet-network.json
|
NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/testnet-network.json
|
||||||
NX_VEGA_URL=https://api.n11.testnet.vega.xyz/graphql
|
NX_VEGA_URL=https://api.n07.testnet.vega.xyz/graphql
|
||||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||||
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
NX_ETHERSCAN_URL=https://ropsten.etherscan.io
|
||||||
NX_VEGA_REST=https://api.n11.testnet.vega.xyz
|
NX_VEGA_REST=https://api.n07.testnet.vega.xyz
|
||||||
NX_FAIRGROUND=false
|
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_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_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
import { render, screen } from '@testing-library/react';
|
||||||
|
import { generateProposal } from '../../test-helpers/generate-proposals';
|
||||||
|
import { Proposal } from './proposal';
|
||||||
|
|
||||||
|
jest.mock('../proposal-detail-header/proposal-header', () => ({
|
||||||
|
ProposalHeader: () => <div data-testid="proposal-header"></div>,
|
||||||
|
}));
|
||||||
|
jest.mock('../proposal-change-table', () => ({
|
||||||
|
ProposalChangeTable: () => <div data-testid="proposal-change-table"></div>,
|
||||||
|
}));
|
||||||
|
jest.mock('../proposal-terms-json', () => ({
|
||||||
|
ProposalTermsJson: () => <div data-testid="proposal-terms-json"></div>,
|
||||||
|
}));
|
||||||
|
jest.mock('../proposal-votes-table', () => ({
|
||||||
|
ProposalVotesTable: () => <div data-testid="proposal-votes-table"></div>,
|
||||||
|
}));
|
||||||
|
jest.mock('../vote-details', () => ({
|
||||||
|
VoteDetails: () => <div data-testid="proposal-vote-details"></div>,
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('Renders with data-testid', () => {
|
||||||
|
const proposal = generateProposal();
|
||||||
|
render(<Proposal proposal={proposal} />);
|
||||||
|
expect(screen.getByTestId('proposal')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders each section', () => {
|
||||||
|
const proposal = generateProposal();
|
||||||
|
render(<Proposal proposal={proposal} />);
|
||||||
|
expect(screen.getByTestId('proposal-header')).toBeInTheDocument();
|
||||||
|
expect(screen.getByTestId('proposal-change-table')).toBeInTheDocument();
|
||||||
|
expect(screen.getByTestId('proposal-terms-json')).toBeInTheDocument();
|
||||||
|
expect(screen.getByTestId('proposal-votes-table')).toBeInTheDocument();
|
||||||
|
expect(screen.getByTestId('proposal-vote-details')).toBeInTheDocument();
|
||||||
|
});
|
@ -1,8 +1,5 @@
|
|||||||
import { ProposalHeader } from '../proposal-detail-header/proposal-header';
|
import { ProposalHeader } from '../proposal-detail-header/proposal-header';
|
||||||
import type {
|
import type { Proposal_proposal } from '../../proposal/__generated__/Proposal';
|
||||||
Proposal_proposal,
|
|
||||||
Proposal_proposal_terms,
|
|
||||||
} from '../../proposal/__generated__/Proposal';
|
|
||||||
import { ProposalChangeTable } from '../proposal-change-table';
|
import { ProposalChangeTable } from '../proposal-change-table';
|
||||||
import { ProposalTermsJson } from '../proposal-terms-json';
|
import { ProposalTermsJson } from '../proposal-terms-json';
|
||||||
import { ProposalVotesTable } from '../proposal-votes-table';
|
import { ProposalVotesTable } from '../proposal-votes-table';
|
||||||
@ -10,16 +7,15 @@ import { VoteDetails } from '../vote-details';
|
|||||||
|
|
||||||
interface ProposalProps {
|
interface ProposalProps {
|
||||||
proposal: Proposal_proposal;
|
proposal: Proposal_proposal;
|
||||||
terms: Proposal_proposal_terms;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Proposal = ({ proposal, terms }: ProposalProps) => {
|
export const Proposal = ({ proposal }: ProposalProps) => {
|
||||||
if (!proposal) {
|
if (!proposal) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<section data-testid="proposal">
|
||||||
<ProposalHeader proposal={proposal} />
|
<ProposalHeader proposal={proposal} />
|
||||||
<div className="mb-8">
|
<div className="mb-8">
|
||||||
<ProposalChangeTable proposal={proposal} />
|
<ProposalChangeTable proposal={proposal} />
|
||||||
@ -30,7 +26,7 @@ export const Proposal = ({ proposal, terms }: ProposalProps) => {
|
|||||||
<div className="mb-8">
|
<div className="mb-8">
|
||||||
<ProposalVotesTable proposal={proposal} />
|
<ProposalVotesTable proposal={proposal} />
|
||||||
</div>
|
</div>
|
||||||
<ProposalTermsJson terms={terms} />
|
<ProposalTermsJson terms={proposal.terms} />
|
||||||
</>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { gql, useQuery } from '@apollo/client';
|
import { gql, useQuery } from '@apollo/client';
|
||||||
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
||||||
|
import { useEffect } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
import { Proposal } from '../components/proposal';
|
import { Proposal } from '../components/proposal';
|
||||||
@ -20,22 +21,23 @@ export const PROPOSAL_QUERY = gql`
|
|||||||
|
|
||||||
export const ProposalContainer = () => {
|
export const ProposalContainer = () => {
|
||||||
const params = useParams<{ proposalId: string }>();
|
const params = useParams<{ proposalId: string }>();
|
||||||
|
const { data, loading, error, refetch } = useQuery<
|
||||||
const { data, loading, error } = useQuery<
|
|
||||||
ProposalQueryResult,
|
ProposalQueryResult,
|
||||||
ProposalVariables
|
ProposalVariables
|
||||||
>(PROPOSAL_QUERY, {
|
>(PROPOSAL_QUERY, {
|
||||||
fetchPolicy: 'no-cache',
|
fetchPolicy: 'network-only',
|
||||||
variables: { proposalId: params.proposalId || '' },
|
variables: { proposalId: params.proposalId || '' },
|
||||||
skip: !params.proposalId,
|
skip: !params.proposalId,
|
||||||
pollInterval: 5000,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const interval = setInterval(refetch, 1000);
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}, [refetch]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AsyncRenderer loading={loading} error={error} data={data}>
|
<AsyncRenderer loading={loading} error={error} data={data}>
|
||||||
{data && (
|
{data && <Proposal proposal={data.proposal} />}
|
||||||
<Proposal proposal={data.proposal} terms={data.proposal.terms} />
|
|
||||||
)}
|
|
||||||
</AsyncRenderer>
|
</AsyncRenderer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user