9941c9bfaa
* fix: deposits tests, also convert to basic cypress * add new home tests which test redirect to trading page and markets page * chore: replace portfolio page feature with raw cypress * chore: replace market page feature with raw cypress tests * chore: replace home page tests with global.ts for wallet connections * chore: add raw cypress withdrawals tests with mocks * fix: complete withdrawals prompt and add assertion for it * chore: remove unnecessary cypress envs now that we are mocking assets * chore: ignore lint errors temporarily * chore: add mock for deposit page query, add wait for mocked queries to resolve * fix: order of waiting for withdraw page query * fix: validate vega wallet connection * chore: remove rest of page objects and convert trading page feature to regular cypress * fix: assertion on transaction dialog after withdrawal * chore: split withdraw and withdrawals pages into separate files * chore: split trading tests into own files, connect wallet once for deal ticket * feat: convert home page tests to raw cypress
97 lines
2.4 KiB
TypeScript
97 lines
2.4 KiB
TypeScript
import { gql } from '@apollo/client';
|
|
import { t } from '@vegaprotocol/react-helpers';
|
|
import { Splash } from '@vegaprotocol/ui-toolkit';
|
|
import { useVegaWallet } from '@vegaprotocol/wallet';
|
|
import { WithdrawManager } from '@vegaprotocol/withdraws';
|
|
import { ASSET_FRAGMENT } from '../../../lib/query-fragments';
|
|
import Link from 'next/link';
|
|
import { PageQueryContainer } from '../../../components/page-query-container';
|
|
import type {
|
|
WithdrawPageQuery,
|
|
WithdrawPageQueryVariables,
|
|
} from './__generated__/WithdrawPageQuery';
|
|
|
|
const WITHDRAW_PAGE_QUERY = gql`
|
|
${ASSET_FRAGMENT}
|
|
query WithdrawPageQuery($partyId: ID!) {
|
|
party(id: $partyId) {
|
|
id
|
|
withdrawals {
|
|
id
|
|
txHash
|
|
}
|
|
accounts {
|
|
type
|
|
balance
|
|
asset {
|
|
id
|
|
symbol
|
|
}
|
|
}
|
|
}
|
|
assets {
|
|
...AssetFields
|
|
}
|
|
}
|
|
`;
|
|
|
|
interface WithdrawPageContainerProps {
|
|
assetId?: string;
|
|
}
|
|
|
|
/**
|
|
* Fetches data required for the Deposit page
|
|
*/
|
|
export const WithdrawPageContainer = ({
|
|
assetId,
|
|
}: WithdrawPageContainerProps) => {
|
|
const { keypair } = useVegaWallet();
|
|
|
|
return (
|
|
<PageQueryContainer<WithdrawPageQuery, WithdrawPageQueryVariables>
|
|
query={WITHDRAW_PAGE_QUERY}
|
|
options={{
|
|
variables: { partyId: keypair?.pub || '' },
|
|
skip: !keypair?.pub,
|
|
}}
|
|
render={(data) => {
|
|
if (!data.assets?.length) {
|
|
return (
|
|
<Splash>
|
|
<p>{t('No assets on this network')}</p>
|
|
</Splash>
|
|
);
|
|
}
|
|
|
|
const hasIncompleteWithdrawals = data.party?.withdrawals?.some(
|
|
(w) => w.txHash === null
|
|
);
|
|
|
|
return (
|
|
<>
|
|
{hasIncompleteWithdrawals ? (
|
|
<p className="mb-12">
|
|
{t('You have incomplete withdrawals.')}{' '}
|
|
<Link href="/portfolio/withdrawals">
|
|
<a
|
|
className="underline"
|
|
data-testid="complete-withdrawals-prompt"
|
|
>
|
|
{t('Click here to finish withdrawal')}
|
|
</a>
|
|
</Link>
|
|
</p>
|
|
) : null}
|
|
<WithdrawManager
|
|
assets={data.assets}
|
|
accounts={data.party?.accounts || []}
|
|
initialAssetId={assetId}
|
|
isNewContract={true}
|
|
/>
|
|
</>
|
|
);
|
|
}}
|
|
/>
|
|
);
|
|
};
|