feat: info about test network in transaction dialogs (#1830)

* feat: info about test network in transaction dialogs

* feat: info about test network in transaction dialogs

* feat: info about test network in transaction dialogs

* feat: info about test network in transaction dialogs - add unit test

* feat: info about test network in transaction dialogs - add unit test

* feat: info about test network in transaction dialogs - add unit test

* feat: info about test network in transaction dialogs - add unit test

Co-authored-by: maciek <maciek@vegaprotocol.io>
This commit is contained in:
macqbat 2022-10-24 10:57:21 +02:00 committed by GitHub
parent 6dded8c2d2
commit da726ea439
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 6 deletions

View File

@ -7,7 +7,12 @@ import { VegaTransactionDialog } from './vega-transaction-dialog';
jest.mock('@vegaprotocol/environment', () => ({
useEnvironment: () => ({
VEGA_EXPLORER_URL: 'https://test.explorer.vega.network',
VEGA_ENV: 'TESTNET',
}),
Networks: {
MAINNET: 'MAINNET',
TESTNET: 'TESTNET',
},
}));
describe('VegaTransactionDialog', () => {
@ -33,6 +38,9 @@ describe('VegaTransactionDialog', () => {
expect(screen.getByTestId(VegaTxStatus.Requested)).toHaveTextContent(
/please open your wallet/i
);
expect(screen.getByTestId('testnet-transaction-info')).toHaveTextContent(
/^\[This is TESTNET transaction only\]$/
);
});
it('pending', () => {

View File

@ -1,4 +1,4 @@
import { useEnvironment } from '@vegaprotocol/environment';
import { Networks, useEnvironment } from '@vegaprotocol/environment';
import { t } from '@vegaprotocol/react-helpers';
import { Dialog, Icon, Intent, Loader } from '@vegaprotocol/ui-toolkit';
import type { ReactNode } from 'react';
@ -58,16 +58,23 @@ interface VegaDialogProps {
* Default dialog content
*/
export const VegaDialog = ({ transaction }: VegaDialogProps) => {
const { VEGA_EXPLORER_URL } = useEnvironment();
const { VEGA_EXPLORER_URL, VEGA_ENV } = useEnvironment();
let content = null;
if (transaction.status === VegaTxStatus.Requested) {
content = (
<p data-testid={transaction.status}>
{t(
'Please open your wallet application and confirm or reject the transaction'
<>
<p data-testid={transaction.status}>
{t(
'Please open your wallet application and confirm or reject the transaction'
)}
</p>
{VEGA_ENV !== Networks.MAINNET && (
<p data-testid="testnet-transaction-info">
{t('[This is %s transaction only]').replace('%s', VEGA_ENV)}
</p>
)}
</p>
</>
);
}