test: test ids

This commit is contained in:
dalebennett1992 2023-12-12 10:16:47 +00:00
parent fa28d31ef3
commit 51c426ef4b
No known key found for this signature in database
2 changed files with 37 additions and 7 deletions

View File

@ -212,6 +212,7 @@ export const Statistics = ({
).toString(), ).toString(),
} }
)} )}
testId="base-commission-rate"
overrideWithNoProgram={!details} overrideWithNoProgram={!details}
> >
{baseCommissionValue * 100}% {baseCommissionValue * 100}%
@ -221,6 +222,7 @@ export const Statistics = ({
const stakingMultiplierTile = ( const stakingMultiplierTile = (
<StatTile <StatTile
title={t('Staking multiplier')} title={t('Staking multiplier')}
testId="staking-multiplier"
description={ description={
<span <span
className={classNames({ className={classNames({
@ -254,6 +256,7 @@ export const Statistics = ({
? `(${baseCommissionFormatted}% ⨉ ${multiplier} = ${finalCommissionFormatted}%)` ? `(${baseCommissionFormatted}% ⨉ ${multiplier} = ${finalCommissionFormatted}%)`
: undefined : undefined
} }
testId="final-commission-rate"
overrideWithNoProgram={!details} overrideWithNoProgram={!details}
> >
{finalCommissionFormatted}% {finalCommissionFormatted}%
@ -261,7 +264,9 @@ export const Statistics = ({
); );
const numberOfTradersValue = data.referees.length; const numberOfTradersValue = data.referees.length;
const numberOfTradersTile = ( const numberOfTradersTile = (
<StatTile title={t('Number of traders')}>{numberOfTradersValue}</StatTile> <StatTile title={t('Number of traders')} testId="number-of-traders">
{numberOfTradersValue}
</StatTile>
); );
const codeTile = ( const codeTile = (
@ -276,6 +281,7 @@ export const Statistics = ({
title={t('myVolume', 'My volume (last {{count}} epochs)', { title={t('myVolume', 'My volume (last {{count}} epochs)', {
count: details?.windowLength || DEFAULT_AGGREGATION_DAYS, count: details?.windowLength || DEFAULT_AGGREGATION_DAYS,
})} })}
testId="my-volume"
overrideWithNoProgram={!details} overrideWithNoProgram={!details}
> >
{compactNumFormat.format(referrerVolumeValue)} {compactNumFormat.format(referrerVolumeValue)}
@ -291,6 +297,7 @@ export const Statistics = ({
count: details?.windowLength || DEFAULT_AGGREGATION_DAYS, count: details?.windowLength || DEFAULT_AGGREGATION_DAYS,
})} })}
description={<QUSDTooltip />} description={<QUSDTooltip />}
testId="total-commission"
> >
{getNumberFormat(0).format(Number(totalCommissionValue))} {getNumberFormat(0).format(Number(totalCommissionValue))}
</StatTile> </StatTile>
@ -316,6 +323,7 @@ export const Statistics = ({
const currentBenefitTierTile = ( const currentBenefitTierTile = (
<StatTile <StatTile
title={t('Current tier')} title={t('Current tier')}
testId="current-tier"
description={ description={
nextBenefitTierValue?.tier nextBenefitTierValue?.tier
? t('(Next tier: {{nextTier}})', { ? t('(Next tier: {{nextTier}})', {
@ -331,7 +339,11 @@ export const Statistics = ({
</StatTile> </StatTile>
); );
const discountFactorTile = ( const discountFactorTile = (
<StatTile title={t('Discount')} overrideWithNoProgram={!details}> <StatTile
title={t('Discount')}
testId="discount"
overrideWithNoProgram={!details}
>
{isApplyCodePreview && benefitTiers.length >= 1 {isApplyCodePreview && benefitTiers.length >= 1
? benefitTiers[0].discountFactor * 100 ? benefitTiers[0].discountFactor * 100
: discountFactorValue * 100} : discountFactorValue * 100}
@ -347,23 +359,34 @@ export const Statistics = ({
count: details?.windowLength, count: details?.windowLength,
} }
)} )}
testId="combined-volume"
overrideWithNoProgram={!details} overrideWithNoProgram={!details}
> >
{compactNumFormat.format(runningVolumeValue)} {compactNumFormat.format(runningVolumeValue)}
</StatTile> </StatTile>
); );
const epochsTile = ( const epochsTile = (
<StatTile title={t('Epochs in set')}>{epochsValue}</StatTile> <StatTile title={t('Epochs in set')} testId="epochs-in-set">
{epochsValue}
</StatTile>
); );
const nextTierVolumeTile = ( const nextTierVolumeTile = (
<StatTile title={t('Volume to next tier')} overrideWithNoProgram={!details}> <StatTile
title={t('Volume to next tier')}
testId="vol-to-next-tier"
overrideWithNoProgram={!details}
>
{nextBenefitTierVolumeValue <= 0 {nextBenefitTierVolumeValue <= 0
? '0' ? '0'
: compactNumFormat.format(nextBenefitTierVolumeValue)} : compactNumFormat.format(nextBenefitTierVolumeValue)}
</StatTile> </StatTile>
); );
const nextTierEpochsTile = ( const nextTierEpochsTile = (
<StatTile title={t('Epochs to next tier')} overrideWithNoProgram={!details}> <StatTile
title={t('Epochs to next tier')}
testId="epochs-to-next-tier"
overrideWithNoProgram={!details}
>
{nextBenefitTierEpochsValue <= 0 ? '0' : nextBenefitTierEpochsValue} {nextBenefitTierEpochsValue <= 0 ? '0' : nextBenefitTierEpochsValue}
</StatTile> </StatTile>
); );

View File

@ -32,6 +32,7 @@ export const Tile = ({
type StatTileProps = { type StatTileProps = {
title: string; title: string;
testId?: string;
description?: ReactNode; description?: ReactNode;
children?: ReactNode; children?: ReactNode;
overrideWithNoProgram?: boolean; overrideWithNoProgram?: boolean;
@ -40,6 +41,7 @@ export const StatTile = ({
title, title,
description, description,
children, children,
testId,
overrideWithNoProgram = false, overrideWithNoProgram = false,
}: StatTileProps) => { }: StatTileProps) => {
if (overrideWithNoProgram) { if (overrideWithNoProgram) {
@ -47,10 +49,15 @@ export const StatTile = ({
} }
return ( return (
<Tile> <Tile>
<h3 className="mb-1 text-sm text-vega-clight-100 dark:text-vega-cdark-100 calt"> <h3
data-testid={testId}
className="mb-1 text-sm text-vega-clight-100 dark:text-vega-cdark-100 calt"
>
{title} {title}
</h3> </h3>
<div className="text-5xl text-left">{children}</div> <div data-testid={`${testId}-value`} className="text-5xl text-left">
{children}
</div>
{description && ( {description && (
<div className="text-sm text-left text-vega-clight-100 dark:text-vega-cdark-100"> <div className="text-sm text-left text-vega-clight-100 dark:text-vega-cdark-100">
{description} {description}