From dcb8cbd10f0c97b1709147fc8db27bc5be34807f Mon Sep 17 00:00:00 2001 From: Jorge Galat Date: Fri, 6 Oct 2023 15:58:17 -0300 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=85=20e2e:=20add=20tests=20for=20'get?= =?UTF-8?q?=20EXA'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/SocketAssetSelector/index.tsx | 14 ++- components/getEXA/ChainSelector.tsx | 4 +- components/getEXA/ReviewRoute.tsx | 17 ++- components/getEXA/RouteSteps.tsx | 2 +- components/getEXA/SelectRoute.tsx | 8 +- components/getEXA/TXStatus.tsx | 9 +- contexts/GetEXAContext.tsx | 6 +- e2e/common/balance.ts | 10 +- e2e/fixture/base.ts | 4 +- e2e/fixture/socket.ts | 55 +++++++++ e2e/page/getEXA.ts | 135 +++++++++++++++++++++++ e2e/specs/9-get-exa/same-chain.spec.ts | 102 +++++++++++++++++ e2e/utils/contracts.ts | 8 ++ types/contracts.ts | 2 + 14 files changed, 357 insertions(+), 19 deletions(-) create mode 100644 e2e/fixture/socket.ts create mode 100644 e2e/page/getEXA.ts create mode 100644 e2e/specs/9-get-exa/same-chain.spec.ts diff --git a/components/SocketAssetSelector/index.tsx b/components/SocketAssetSelector/index.tsx index 0fbcca214..23fb1b8c2 100644 --- a/components/SocketAssetSelector/index.tsx +++ b/components/SocketAssetSelector/index.tsx @@ -13,13 +13,20 @@ type AssetOptionProps = { option?: boolean; optionSize?: number; selectedSize?: number; + 'data-testid'?: string; }; -function AssetOption({ asset, option = false, optionSize = 20, selectedSize = 20 }: AssetOptionProps) { +function AssetOption({ + asset, + option = false, + optionSize = 20, + selectedSize = 20, + 'data-testid': testId, +}: AssetOptionProps) { const size = option ? optionSize : selectedSize; return ( - + {asset.logoURI && ( } - renderOption={(o: AssetBalance) => } + renderOption={(o: AssetBalance) => } disabled={disabled} onClick={onClick} + data-testid="get-exa-asset" /> ); } diff --git a/components/getEXA/ChainSelector.tsx b/components/getEXA/ChainSelector.tsx index fa227db7f..2a227f2ed 100644 --- a/components/getEXA/ChainSelector.tsx +++ b/components/getEXA/ChainSelector.tsx @@ -41,7 +41,7 @@ function ChainOption({ chain, option = false, optionSize = 17, selectedSize = 14 }} /> )} - + {chain.name} @@ -71,7 +71,7 @@ const ChainSelector = ({ disabled }: { disabled?: boolean }) => { onChange={handleChainChange} renderValue={} renderOption={(o: string) => o === name)} />} - data-testid="modal-asset-selector" + data-testid="get-exa-chain" disabled={disabled} /> ); diff --git a/components/getEXA/ReviewRoute.tsx b/components/getEXA/ReviewRoute.tsx index 7dd9f3dcb..cb4064f0f 100644 --- a/components/getEXA/ReviewRoute.tsx +++ b/components/getEXA/ReviewRoute.tsx @@ -23,7 +23,7 @@ const ReviewRoute = () => { } return ( - + {t('Transaction Summary')} @@ -177,11 +177,22 @@ const ReviewRoute = () => { {txError?.status && } {txStep === TXStep.CONFIRM || txStep === TXStep.CONFIRM_PENDING ? ( - + {t('Confirm')} ) : ( - + {t('Approve')} )} diff --git a/components/getEXA/RouteSteps.tsx b/components/getEXA/RouteSteps.tsx index dbed9e35a..95248fc48 100644 --- a/components/getEXA/RouteSteps.tsx +++ b/components/getEXA/RouteSteps.tsx @@ -54,7 +54,7 @@ const RouteSteps = () => { ]; return ( - + {displaySteps.map((step, index) => ( <> {index !== 0 && ( diff --git a/components/getEXA/SelectRoute.tsx b/components/getEXA/SelectRoute.tsx index 440101b4a..a02998865 100644 --- a/components/getEXA/SelectRoute.tsx +++ b/components/getEXA/SelectRoute.tsx @@ -53,7 +53,7 @@ const SelectRoute = () => { return ( <> - + {t('Pay with')}: @@ -91,6 +91,9 @@ const SelectRoute = () => { placeholder="0.0" value={qtyIn || ''} onChange={({ target: { value } }) => setQtyIn(value)} + inputProps={{ + 'data-testid': 'get-exa-input', + }} /> {asset ? ( { cursor: 'pointer', }, }} + data-testid="get-exa-balance" > {t('Balance')}: {formatNumber(asset.amount, asset.symbol)} @@ -203,7 +207,6 @@ const SelectRoute = () => { onClick={() => switchNetwork?.(chain?.chainId)} variant="contained" loading={switchIsLoading} - data-testid="modal-switch-network" > {t('Please switch to {{network}} network', { network: chain?.name })} @@ -213,6 +216,7 @@ const SelectRoute = () => { variant="contained" onClick={handleSubmit} loading={txStep === TXStep.CONFIRM_PENDING} + data-testid={nativeSwap ? 'get-exa-submit' : 'get-exa-review'} > {insufficientBalance ? t('Insufficient {{symbol}} balance', { symbol: asset?.symbol }) diff --git a/components/getEXA/TXStatus.tsx b/components/getEXA/TXStatus.tsx index 2b93323bf..76d473f79 100644 --- a/components/getEXA/TXStatus.tsx +++ b/components/getEXA/TXStatus.tsx @@ -63,10 +63,10 @@ const SpinnerThing = ({ /> )} - - {isLoading && t('Transaction processing...')} - {status === 'success' && t('Transaction Success')} - {status === 'error' && t('Transaction Error')} + + {isLoading && t('Processing transaction...')} + {status === 'success' && t('Transaction success')} + {status === 'error' && t('Transaction error')}