vega-frontend-monorepo/apps/trading/components/vega-wallet-connect-button/vega-wallet-connect-button.tsx
Matthew Russell 9941c9bfaa
Fix/trading app tests (#539)
* 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
2022-06-10 12:00:02 -07:00

39 lines
1.0 KiB
TypeScript

import { truncateByChars } from '@vegaprotocol/react-helpers';
import { useVegaWallet } from '@vegaprotocol/wallet';
export interface VegaWalletConnectButtonProps {
setConnectDialog: (isOpen: boolean) => void;
setManageDialog: (isOpen: boolean) => void;
}
export const VegaWalletConnectButton = ({
setConnectDialog,
setManageDialog,
}: VegaWalletConnectButtonProps) => {
const { keypair } = useVegaWallet();
const isConnected = keypair !== null;
const handleClick = () => {
if (isConnected) {
setManageDialog(true);
} else {
setConnectDialog(true);
}
};
return (
<span>
{isConnected && (
<span className="text-ui-small font-mono mr-2">Vega key:</span>
)}
<button
data-testid={isConnected ? 'manage-vega-wallet' : 'connect-vega-wallet'}
onClick={handleClick}
className="ml-auto inline-block text-ui-small font-mono hover:underline"
>
{isConnected ? truncateByChars(keypair.pub) : 'Connect Vega wallet'}
</button>
</span>
);
};