Skip to content

Commit

Permalink
Merge pull request #188 from lidofinance/feature/si-1134-set-test-id
Browse files Browse the repository at this point in the history
Add test ids
  • Loading branch information
itaven authored Dec 14, 2023
2 parents cb59327 + 79961fc commit e3ea954
Show file tree
Hide file tree
Showing 25 changed files with 82 additions and 41 deletions.
2 changes: 1 addition & 1 deletion features/stake/stake-form/stake-form-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const StakeFormInfo = () => {
const txCostInUsd = useEthUsd(gasCost);

return (
<DataTable>
<DataTable data-testid="stakeFormInfo">
<DataTableRow title="You will receive" data-testid="youWillReceive">
<FormatToken amount={amount ?? Zero} symbol="stETH" />
</DataTableRow>
Expand Down
2 changes: 1 addition & 1 deletion features/stake/stake-form/stake-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const StakeForm: FC = memo(() => {
<TransactionModalProvider>
<StakeFormProvider>
<Wallet />
<Block>
<Block data-testid="stakeForm">
<FormControllerStyled>
<StakeAmountInput />
<StakeSubmitButton />
Expand Down
2 changes: 1 addition & 1 deletion features/stake/stake-form/wallet/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const WalletComponent: WalletComponentType = (props) => {
const lidoApr = useLidoApr();

return (
<StyledCard {...props}>
<StyledCard data-testid="stakeCardSection" {...props}>
<CardRow>
<CardBalance
title={
Expand Down
2 changes: 1 addition & 1 deletion features/withdrawals/claim/form/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const ClaimForm = () => {

return (
<form onSubmit={onSubmit}>
<ClaimFormBody>
<ClaimFormBody data-testid="claimList">
{isBunker && <BunkerInfo />}
<div ref={refRequests}>
<RequestsList />
Expand Down
18 changes: 12 additions & 6 deletions features/withdrawals/claim/form/requests-list/request-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,29 @@ export const RequestItem = forwardRef<HTMLInputElement, RequestItemProps>(
const symbol = isClaimable ? 'ETH' : 'stETH';

const label = (
<FormatToken showAmountTip amount={amountValue} symbol={symbol} />
<FormatToken
data-testid="requestAmount"
showAmountTip
amount={amountValue}
symbol={symbol}
/>
);

return (
<RequestStyled $disabled={isDisabled}>
<RequestStyled data-testid={'requestItem'} $disabled={isDisabled}>
<Checkbox
{...props}
// TODO: Update Checkbox props in lido-ui
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
data-testid="requestCheckbox"
label={label}
disabled={isDisabled}
name={name}
ref={ref}
/>
<RequestStatus status={status.isFinalized ? 'ready' : 'pending'} />
<LinkStyled href={getNFTUrl(token_id, chainId)}>
<LinkStyled
data-testid="requestNftLink"
href={getNFTUrl(token_id, chainId)}
>
<External />
</LinkStyled>
</RequestStyled>
Expand Down
1 change: 1 addition & 0 deletions features/withdrawals/claim/form/submit-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const SubmitButton = () => {

return (
<Button
data-testid="claimButton"
fullwidth
disabled={disabled}
loading={isSubmitting || isValidating}
Expand Down
6 changes: 5 additions & 1 deletion features/withdrawals/claim/form/transaction-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ export const TransactionInfo = () => {
const { claimTxPriceInUsd, loading: claimTxPriceLoading } =
useClaimTxPrice(selectedRequests);
return (
<DataTableRow title="Max transaction cost" loading={claimTxPriceLoading}>
<DataTableRow
data-testid="maxTxCost"
title="Max transaction cost"
loading={claimTxPriceLoading}
>
<FormatPrice amount={claimTxPriceInUsd} />
</DataTableRow>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const WalletAvailableAmount = () => {
return (
<CardBalance
small
data-testid="availableToClaim"
title="Available to claim"
loading={initialLoading}
value={availableAmount}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const WalletPendingAmount = () => {
return (
<CardBalance
small
data-testid="myPendingAmount"
title="My pending amount"
loading={initialLoading}
value={pendingAmount}
Expand Down
2 changes: 1 addition & 1 deletion features/withdrawals/claim/wallet/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const WalletComponent = () => {
const { account } = useSDK();

return (
<WalletWrapperStyled>
<WalletWrapperStyled data-testid="claimCardSection">
<CardRow>
<WalletAvailableAmount />
<CardAccount account={account} />
Expand Down
2 changes: 1 addition & 1 deletion features/withdrawals/request/form/options/dex-options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const DexOptions: React.FC<
useWithdrawalRates();

return (
<DexOptionsContainer {...props}>
<DexOptionsContainer data-testid="dexOptionContainer" {...props}>
{initialLoading
? placeholder.map((_, i) => <DexOptionLoader key={i} />)
: data?.map(({ name, toReceive, rate }) => {
Expand Down
6 changes: 4 additions & 2 deletions features/withdrawals/request/form/options/lido-option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ import {
const TooltipWithdrawalAmount = () => {
return (
<Tooltip
data-testid="lidoOptionToolTip"
placement="topRight"
title={
<>
The final amount of claimable ETH can differ
<br /> For more info, please read{' '}
<Link href="#amountDifferentFromRequested">
<a
data-testid="lidoOptionToolTipFAQ"
aria-hidden="true"
onClick={() =>
trackMatomoEvent(
Expand Down Expand Up @@ -60,10 +62,10 @@ export const LidoOption = () => {
});

return (
<LidoOptionContainer>
<LidoOptionContainer data-testid="lidoOptionSection">
<LidoIcon />
Lido
<LidoOptionValue>
<LidoOptionValue data-testid="lidoOptionAmount">
<FormatTokenStyled
data-testid="lidoOptionAmount"
showAmountTip
Expand Down
28 changes: 19 additions & 9 deletions features/withdrawals/request/form/options/options-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,23 @@ const LidoButton: React.FC<OptionButtonProps> = ({ isActive, onClick }) => {
const ratio = isSteth ? '1 : 1' : `1 : ${formatBalance(wstethAsStethBN)}`;

return (
<OptionsPickerButton type="button" $active={isActive} onClick={onClick}>
<OptionsPickerButton
data-testid="lidoOption"
type="button"
$active={isActive}
onClick={onClick}
>
<OptionsPickerRow>
<OptionsPickerLabel>Use Lido</OptionsPickerLabel>
<OptionsPickerIcons>
<LidoIcon />
</OptionsPickerIcons>
</OptionsPickerRow>
<OptionsPickerRow>
<OptionsPickerRow data-testid="lidoOptionRate">
<OptionsPickerSubLabel>Rate:</OptionsPickerSubLabel>
{ratioLoading ? <InlineLoaderSmall /> : ratio}
</OptionsPickerRow>
<OptionsPickerRow>
<OptionsPickerRow data-testid="lidoOptionWaitingTime">
<OptionsPickerSubLabel>Waiting time:</OptionsPickerSubLabel>
{initialLoading ? <InlineLoaderSmall /> : waitingTime}
</OptionsPickerRow>
Expand All @@ -75,20 +80,25 @@ const DexButton: React.FC<OptionButtonProps> = ({ isActive, onClick }) => {
});
const bestRateValue = bestRate ? `1 : ${bestRate.toFixed(4)}` : '-';
return (
<OptionsPickerButton type="button" $active={isActive} onClick={onClick}>
<OptionsPickerButton
data-testid="dexOptions"
type="button"
$active={isActive}
onClick={onClick}
>
<OptionsPickerRow>
<OptionsPickerLabel>Use aggregators</OptionsPickerLabel>
<OptionsPickerIcons>
<OneInchIcon />
<CowSwapIcon />
<ParaSwapIcon />
<OneInchIcon data-testid="DexOneInchIcon" />
<CowSwapIcon data-testid="DexCowSwapIcon" />
<ParaSwapIcon data-testid="DexParaSwapIcon" />
</OptionsPickerIcons>
</OptionsPickerRow>
<OptionsPickerRow>
<OptionsPickerRow data-testid="dexBestRate">
<OptionsPickerSubLabel>Best Rate:</OptionsPickerSubLabel>
{loading ? <InlineLoaderSmall /> : bestRateValue}
</OptionsPickerRow>
<OptionsPickerRow>
<OptionsPickerRow data-testid="dexWaitingTime">
<OptionsPickerSubLabel>Waiting time:</OptionsPickerSubLabel>~&nbsp;1-5
minutes
</OptionsPickerRow>
Expand Down
2 changes: 1 addition & 1 deletion features/withdrawals/request/form/request-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const RequestForm = () => {
const mode = useWatch<RequestFormInputType, 'mode'>({ name: 'mode' });

return (
<Block>
<Block data-testid="requestForm">
{isPaused && <PausedInfo />}
{isBunker && <BunkerInfo />}
<form autoComplete="off" onSubmit={onSubmit}>
Expand Down
12 changes: 10 additions & 2 deletions features/withdrawals/request/form/transaction-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const TransactionInfo = () => {
return (
<>
<DataTableRow
data-testid="maxUnlockCost"
help={unlockCostTooltip}
title="Max unlock cost"
loading={isApprovalFlowLoading}
Expand All @@ -49,11 +50,16 @@ export const TransactionInfo = () => {
</DataTableRow>
<DataTableRow
title="Max transaction cost"
data-testid="maxTxCost"
loading={requestTxPriceLoading}
>
<FormatPrice amount={requestTxPriceInUsd} />
</DataTableRow>
<DataTableRow title="Allowance" loading={isApprovalFlowLoading}>
<DataTableRow
data-testid="allowance"
title="Allowance"
loading={isApprovalFlowLoading}
>
{isInfiniteAllowance ? (
'Infinite'
) : (
Expand All @@ -65,7 +71,9 @@ export const TransactionInfo = () => {
)}
</DataTableRow>
{token === TOKENS.STETH ? (
<DataTableRow title="Exchange rate">1 stETH = 1 ETH</DataTableRow>
<DataTableRow data-testid="exchangeRate" title="Exchange rate">
1 stETH = 1 ETH
</DataTableRow>
) : (
<DataTableRowStethByWsteth toSymbol="ETH" />
)}
Expand Down
1 change: 1 addition & 0 deletions features/withdrawals/request/wallet/wallet-mode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const WalletMode = () => {
return (
<CardBalance
small
data-testid="withdrawalsMode"
title={timeTitle}
loading={isWithdrawalsStatusLoading}
value={content}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const WalletQueueTooltip = () => {
<Link href="#withdrawalsPeriod">
<a
aria-hidden="true"
data-testid="otherFactorsLink"
onClick={() =>
trackMatomoEvent(
MATOMO_CLICK_EVENTS_TYPES.withdrawalOtherFactorsTooltipMode,
Expand Down
2 changes: 1 addition & 1 deletion features/withdrawals/request/wallet/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const WalletComponent = () => {
const token = useWatch<RequestFormInputType, 'token'>({ name: 'token' });
const isSteth = token === TOKENS.STETH;
return (
<WalletWrapperStyled>
<WalletWrapperStyled data-testid="requestCardSection">
<CardRow>
{isSteth ? <WalletStethBalance /> : <WalletWstethBalance />}
<CardAccount account={account} />
Expand Down
2 changes: 1 addition & 1 deletion features/wsteth/shared/wallet/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const WalletComponent: WalletComponentType = (props) => {
const stethByWstethBalance = useStethByWsteth(wstethBalance.data);

return (
<StyledCard {...props}>
<StyledCard data-testid="wrapCardSection" {...props}>
<CardRow>
<CardBalance
title="ETH Balance"
Expand Down
2 changes: 1 addition & 1 deletion features/wsteth/unwrap/unwrap-form/unwrap-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const UnwrapForm: FC = memo(() => {
return (
<TransactionModalProvider>
<UnwrapFormProvider>
<WrapBlock>
<WrapBlock data-testid="unwrapForm">
<FormController>
<InputWrap>
<TokenAmountInputUnwrap />
Expand Down
2 changes: 1 addition & 1 deletion features/wsteth/wrap/wrap-form/wrap-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const WrapForm: React.FC = memo(() => {
return (
<TransactionModalProvider>
<WrapFormProvider>
<WrapBlock>
<WrapBlock data-testid="wrapForm">
<FormControllerWrap>
<InputGroupHookForm errorField="amount">
<TokenSelectWrap />
Expand Down
8 changes: 6 additions & 2 deletions features/wsteth/wrap/wrap-form/wrap-stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const WrapFormStats = () => {
const wrapTxCostInUsd = useTxCostInUsd(wrapGasLimit && Number(wrapGasLimit));

return (
<DataTable>
<DataTable data-testid="wrapStats">
<DataTableRow
title="Max unlock cost"
data-testid="maxUnlockFee"
Expand All @@ -49,7 +49,11 @@ export const WrapFormStats = () => {
loading={!oneWstethConverted}
>
1 {isSteth ? 'stETH' : 'ETH'} ={' '}
<FormatToken amount={oneWstethConverted} symbol="wstETH" />
<FormatToken
data-testid="rate"
amount={oneWstethConverted}
symbol="wstETH"
/>
</DataTableRow>
<DataTableRow
data-testid="allowance"
Expand Down
4 changes: 2 additions & 2 deletions shared/banners/l2-wsteth/l2-wsteth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const linkClickHandler = () => trackEvent(...MATOMO_CLICK_EVENTS.l2BannerWrap);

export const L2Wsteth = () => {
return (
<Banner>
<Banner data-testid="L2wstETHbanner">
<TextContent>
Enjoy <b>lower gas</b> fees and <b>DeFi opportunities</b> using wstETH
across Arbitrum, Optimism, Base and zkSync.
Expand All @@ -27,7 +27,7 @@ export const L2Wsteth = () => {
target="_blank"
rel="noopener noreferrer"
>
<LinkButton>Learn More</LinkButton>
<LinkButton data-testid="l2WSstethlearnMore">Learn More</LinkButton>
</OverlayLink>
</FooterWrapper>
</Banner>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const HeaderWallet: FC = () => {
<Connect size="sm" />
)}
{dynamics.ipfsMode && <HeaderSettingsButton />}
<ThemeToggler />
<ThemeToggler data-testid="themeToggler" />
{dynamics.ipfsMode && (
<IPFSInfoBoxOnlyDesktopWrapper>
<IPFSInfoBox />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ export const TxStageModalContent = memo((props: TxStageModalContentProps) => {
const { icon, title, description, footerHint, footer } = props;

return (
<Wrap>
<Wrap data-testid="txStage">
{icon}
<Title>{title}</Title>
<Description>{description}</Description>
{footerHint && <FooterHint>{footerHint}</FooterHint>}
{footer && <Footer>{footer}</Footer>}
<Title data-testid="title">{title}</Title>
<Description data-testid="description">{description}</Description>
{footerHint && (
<FooterHint data-testid="footerHint">{footerHint}</FooterHint>
)}
{footer && <Footer data-testid="footer">{footer}</Footer>}
</Wrap>
);
});

0 comments on commit e3ea954

Please sign in to comment.