diff --git a/apps/token/src/i18n/translations/dev.json b/apps/token/src/i18n/translations/dev.json index 5f96f96fa..077b19080 100644 --- a/apps/token/src/i18n/translations/dev.json +++ b/apps/token/src/i18n/translations/dev.json @@ -636,6 +636,7 @@ "NewMarketProposal": "New market proposal", "UpdateMarketProposal": "Update market proposal", "NewAssetProposal": "New asset proposal", + "UpdateAssetProposal": "Update asset proposal", "NewFreeformProposal": "New freeform proposal", "NewRawProposal": "New raw proposal", "MinProposalRequirements": "You must have at least {{value}} VEGA associated to make a proposal", @@ -647,6 +648,7 @@ "NewMarket": "New market", "UpdateMarket": "Update market", "NewAsset": "New asset", + "UpdateAsset": "Update asset", "Freeform": "Freeform", "RawProposal": "Let me choose (raw proposal)", "UseMin": "Use minimum", diff --git a/apps/token/src/routes/governance/components/proposals-list-item/proposals-list-item-details.spec.tsx b/apps/token/src/routes/governance/components/proposals-list-item/proposals-list-item-details.spec.tsx index c5e5545dd..1aed2d962 100644 --- a/apps/token/src/routes/governance/components/proposals-list-item/proposals-list-item-details.spec.tsx +++ b/apps/token/src/routes/governance/components/proposals-list-item/proposals-list-item-details.spec.tsx @@ -26,7 +26,7 @@ import { lastWeek, nextWeek, } from '../../test-helpers/mocks'; -import type { ProposalsConnection_proposalsConnection_edges_node as ProposalNode } from '@vegaprotocol/governance'; +import type { Proposals_proposalsConnection_edges_node as ProposalNode } from '../../proposals/__generated__/Proposals'; const renderComponent = ( proposal: ProposalNode, @@ -172,7 +172,7 @@ describe('Proposals list item details', () => { datetime: lastWeek.toString(), party: { __typename: 'Party', - id: mockPubkey, + id: mockPubkey.publicKey, stakingSummary: { __typename: 'StakingSummary', currentStakeAvailable: '1000', @@ -210,7 +210,7 @@ describe('Proposals list item details', () => { datetime: lastWeek.toString(), party: { __typename: 'Party', - id: mockPubkey, + id: mockPubkey.publicKey, stakingSummary: { __typename: 'StakingSummary', currentStakeAvailable: '1000', diff --git a/apps/token/src/routes/governance/propose/freeform/propose-freeform.spec.tsx b/apps/token/src/routes/governance/propose/freeform/propose-freeform.spec.tsx index de6b8ad57..4bf639d83 100644 --- a/apps/token/src/routes/governance/propose/freeform/propose-freeform.spec.tsx +++ b/apps/token/src/routes/governance/propose/freeform/propose-freeform.spec.tsx @@ -1,4 +1,4 @@ -import { render, screen, waitFor } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import { ProposeFreeform } from './propose-freeform'; import { MockedProvider } from '@apollo/client/testing'; import { mockWalletContext } from '../../test-helpers/mocks'; @@ -81,16 +81,14 @@ describe('Propose Freeform', () => { it('should render the title', async () => { renderComponent(); - await waitFor(() => - expect(screen.getByText('New freeform proposal')).toBeInTheDocument() - ); + expect( + await screen.findByText('New freeform proposal') + ).toBeInTheDocument(); }); it('should render the form components', async () => { renderComponent(); - await waitFor(() => - expect(screen.getByTestId('freeform-proposal-form')).toBeTruthy() - ); + expect(await screen.findByTestId('freeform-proposal-form')).toBeTruthy(); expect(screen.getByTestId('min-proposal-requirements')).toBeTruthy(); expect(screen.getByTestId('proposal-docs-link')).toBeTruthy(); expect(screen.getByTestId('proposal-title')).toBeTruthy(); diff --git a/apps/token/src/routes/governance/propose/freeform/propose-freeform.tsx b/apps/token/src/routes/governance/propose/freeform/propose-freeform.tsx index 75b598b64..6f82bd335 100644 --- a/apps/token/src/routes/governance/propose/freeform/propose-freeform.tsx +++ b/apps/token/src/routes/governance/propose/freeform/propose-freeform.tsx @@ -27,7 +27,7 @@ export interface FreeformProposalFormFields { proposalReference: string; } -const docsLink = 'freeform-proposal'; +const DOCS_LINK = 'freeform-proposal'; export const ProposeFreeform = () => { const { params, loading, error } = useNetworkParams([ @@ -76,9 +76,9 @@ export const ProposeFreeform = () => {
{t('ProposalTermsText')} {`${VEGA_DOCS_URL}/tutorials/proposals/${docsLink}`} + >{`${VEGA_DOCS_URL}/tutorials/proposals/${DOCS_LINK}`}
)} diff --git a/apps/token/src/routes/governance/propose/network-parameter/propose-network-parameter.spec.tsx b/apps/token/src/routes/governance/propose/network-parameter/propose-network-parameter.spec.tsx index d6f9fe915..146466482 100644 --- a/apps/token/src/routes/governance/propose/network-parameter/propose-network-parameter.spec.tsx +++ b/apps/token/src/routes/governance/propose/network-parameter/propose-network-parameter.spec.tsx @@ -1,4 +1,4 @@ -import { fireEvent, render, screen, waitFor } from '@testing-library/react'; +import { fireEvent, render, screen } from '@testing-library/react'; import { ProposeNetworkParameter } from './propose-network-parameter'; import { MockedProvider } from '@apollo/client/testing'; import { mockWalletContext } from '../../test-helpers/mocks'; @@ -81,16 +81,16 @@ describe('Propose Network Parameter', () => { it('should render the correct title', async () => { renderComponent(); - await waitFor(() => - expect(screen.getByText('Update network parameter proposal')).toBeTruthy() - ); + expect( + await screen.findByText('Update network parameter proposal') + ).toBeTruthy(); }); it('should render the form components', async () => { renderComponent(); - await waitFor(() => - expect(screen.getByTestId('network-parameter-proposal-form')).toBeTruthy() - ); + expect( + await screen.findByTestId('network-parameter-proposal-form') + ).toBeTruthy(); expect(screen.getByTestId('min-proposal-requirements')).toBeTruthy(); expect(screen.getByTestId('proposal-docs-link')).toBeTruthy(); expect(screen.getByTestId('proposal-title')).toBeTruthy(); @@ -103,15 +103,15 @@ describe('Propose Network Parameter', () => { it('should render the network param select element with no initial value', async () => { renderComponent(); - await waitFor(() => - expect(screen.getByTestId('proposal-parameter-select')).toHaveValue('') + expect(await screen.findByTestId('proposal-parameter-select')).toHaveValue( + '' ); }); it('should render the current param value and a new value input when the network param select element is changed', async () => { renderComponent(); - await waitFor(() => - expect(screen.getByTestId('proposal-parameter-select')).toHaveValue('') + expect(await screen.findByTestId('proposal-parameter-select')).toHaveValue( + '' ); fireEvent.change(screen.getByTestId('proposal-parameter-select'), { diff --git a/apps/token/src/routes/governance/propose/network-parameter/propose-network-parameter.tsx b/apps/token/src/routes/governance/propose/network-parameter/propose-network-parameter.tsx index d07090e89..73fd0caec 100644 --- a/apps/token/src/routes/governance/propose/network-parameter/propose-network-parameter.tsx +++ b/apps/token/src/routes/governance/propose/network-parameter/propose-network-parameter.tsx @@ -69,7 +69,7 @@ export interface NetworkParameterProposalFormFields { proposalReference: string; } -const docsLink = '/network-parameter-proposal'; +const DOCS_LINK = '/network-parameter-proposal'; export const ProposeNetworkParameter = () => { const [selectedNetworkParam, setSelectedNetworkParam] = useState< @@ -141,9 +141,9 @@ export const ProposeNetworkParameter = () => {{t('ProposalTermsText')} {`${VEGA_DOCS_URL}/tutorials/proposals${docsLink}`} + >{`${VEGA_DOCS_URL}/tutorials/proposals${DOCS_LINK}`}
)} diff --git a/apps/token/src/routes/governance/propose/new-asset/propose-new-asset.spec.tsx b/apps/token/src/routes/governance/propose/new-asset/propose-new-asset.spec.tsx index 1ccd0f05e..e5d747ded 100644 --- a/apps/token/src/routes/governance/propose/new-asset/propose-new-asset.spec.tsx +++ b/apps/token/src/routes/governance/propose/new-asset/propose-new-asset.spec.tsx @@ -1,6 +1,6 @@ import { MockedProvider } from '@apollo/client/testing'; import { MemoryRouter as Router } from 'react-router-dom'; -import { render, screen, waitFor } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import { VegaWalletContext } from '@vegaprotocol/wallet'; import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider'; import { mockWalletContext } from '../../test-helpers/mocks'; @@ -81,16 +81,12 @@ describe('Propose New Asset', () => { it('should render the title', async () => { renderComponent(); - await waitFor(() => - expect(screen.getByText('New asset proposal')).toBeTruthy() - ); + expect(await screen.findByText('New asset proposal')).toBeTruthy(); }); it('should render the form components', async () => { renderComponent(); - await waitFor(() => - expect(screen.getByTestId('new-asset-proposal-form')).toBeTruthy() - ); + expect(await screen.findByTestId('new-asset-proposal-form')).toBeTruthy(); expect(screen.getByTestId('min-proposal-requirements')).toBeTruthy(); expect(screen.getByTestId('proposal-docs-link')).toBeTruthy(); expect(screen.getByTestId('proposal-title')).toBeTruthy(); diff --git a/apps/token/src/routes/governance/propose/new-asset/propose-new-asset.tsx b/apps/token/src/routes/governance/propose/new-asset/propose-new-asset.tsx index 07ddf9461..6e63d3ace 100644 --- a/apps/token/src/routes/governance/propose/new-asset/propose-new-asset.tsx +++ b/apps/token/src/routes/governance/propose/new-asset/propose-new-asset.tsx @@ -7,6 +7,7 @@ import { getValidationTimestamp, } from '@vegaprotocol/governance'; import { useEnvironment } from '@vegaprotocol/environment'; +import { validateJson } from '@vegaprotocol/react-helpers'; import { ProposalFormMinRequirements, ProposalFormTitle, @@ -32,7 +33,7 @@ export interface NewAssetProposalFormFields { proposalReference: string; } -const docsLink = '/new-asset-proposal'; +const DOCS_LINK = '/new-asset-proposal'; export const ProposeNewAsset = () => { const { @@ -100,9 +101,9 @@ export const ProposeNewAsset = () => {{t('ProposalTermsText')} {`${VEGA_DOCS_URL}/tutorials/proposals${docsLink}`} + >{`${VEGA_DOCS_URL}/tutorials/proposals${DOCS_LINK}`}
)} @@ -141,20 +142,11 @@ export const ProposeNewAsset = () => {{t('ProposalTermsText')} {`${VEGA_DOCS_URL}/tutorials/proposals/${docsLink}`} + >{`${VEGA_DOCS_URL}/tutorials/proposals${DOCS_LINK}`}
)} @@ -136,20 +137,11 @@ export const ProposeNewMarket = () => {+ + {t('UpdateAsset')} + +
+
{
data-testid="proposal-data"
{...register('rawProposalData', {
required: t('Required'),
- validate: {
- validateJson: (value) => {
- try {
- JSON.parse(value);
- return true;
- } catch (e) {
- return t('Must be valid JSON');
- }
- },
- },
+ validate: (value) => validateJson(value),
})}
/>
{errors.rawProposalData?.message && (
diff --git a/apps/token/src/routes/governance/propose/update-asset/index.tsx b/apps/token/src/routes/governance/propose/update-asset/index.tsx
new file mode 100644
index 000000000..06b069cbd
--- /dev/null
+++ b/apps/token/src/routes/governance/propose/update-asset/index.tsx
@@ -0,0 +1,4 @@
+export {
+ ProposeUpdateAsset,
+ ProposeUpdateAsset as default,
+} from './propose-update-asset';
diff --git a/apps/token/src/routes/governance/propose/update-asset/propose-update-asset.spec.tsx b/apps/token/src/routes/governance/propose/update-asset/propose-update-asset.spec.tsx
new file mode 100644
index 000000000..fd5e453e0
--- /dev/null
+++ b/apps/token/src/routes/governance/propose/update-asset/propose-update-asset.spec.tsx
@@ -0,0 +1,102 @@
+import { MockedProvider } from '@apollo/client/testing';
+import { MemoryRouter as Router } from 'react-router-dom';
+import { render, screen } from '@testing-library/react';
+import { VegaWalletContext } from '@vegaprotocol/wallet';
+import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider';
+import { mockWalletContext } from '../../test-helpers/mocks';
+import { ProposeUpdateAsset } from './propose-update-asset';
+import type { NetworkParamsQuery } from '@vegaprotocol/web3';
+import type { MockedResponse } from '@apollo/client/testing';
+import { NETWORK_PARAMETERS_QUERY } from '@vegaprotocol/react-helpers';
+
+jest.mock('@vegaprotocol/environment', () => ({
+ useEnvironment: () => ({
+ VEGA_DOCS_URL: 'https://docs.vega.xyz',
+ }),
+}));
+
+const updateAssetNetworkParamsQueryMock: MockedResponse
+ {t('ProposalTermsText')}
+ {`${VEGA_DOCS_URL}/tutorials/proposals${DOCS_LINK}`}
+
+ {t('MoreAssetsInfo')}{' '}
+ {`${VEGA_EXPLORER_URL}/assets`}
+
{t('ProposalTermsText')}
{`${VEGA_DOCS_URL}/tutorials/proposals${docsLink}`}
+ >{`${VEGA_DOCS_URL}/tutorials/proposals${DOCS_LINK}`}