Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT/ADDED-TESTIDS Added a few test ids #52

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/app/user/Balances/StakeRIFCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ export const StakeRIFCell = () => {
const { stakeModal } = useBalancesContext()

return (
<p onClick={stakeModal.openModal} className="text-link underline cursor-pointer">
<p
onClick={stakeModal.openModal}
className="text-link underline cursor-pointer"
data-testid={'StakeRIFParagraph'}
>
Stake
</p>
)
Expand Down
6 changes: 5 additions & 1 deletion src/app/user/Balances/UnStakeRIFCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ export const UnStakeRIFCell = () => {
const { unstakeModal } = useBalancesContext()

return (
<p onClick={unstakeModal.openModal} className="text-link underline cursor-pointer">
<p
onClick={unstakeModal.openModal}
className="text-link underline cursor-pointer"
data-testid="UnstakeRIFParagraph"
>
Unstake
</p>
)
Expand Down
8 changes: 6 additions & 2 deletions src/app/user/Stake/StakePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ export const StakePreview = ({
{customComponentBeforeFooter}
{/* Stake Actions */}
<div className="flex justify-center pt-10 gap-4">
<Button variant="secondary" onClick={onCancel}>
<Button variant="secondary" onClick={onCancel} buttonProps={{ 'data-testid': 'Cancel' }}>
Cancel
</Button>
<Button onClick={!disableConfirm ? onConfirm : undefined} disabled={disableConfirm}>
<Button
onClick={!disableConfirm ? onConfirm : undefined}
disabled={disableConfirm}
buttonProps={{ 'data-testid': 'Confirm' }}
>
Confirm
</Button>
</div>
Expand Down
11 changes: 10 additions & 1 deletion src/app/user/Stake/StakeRIF.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ export const StakeRIF = ({
{/* @TODO if we're unstaking we should have a component here - check design */}
{/* Stake */}
<div className="flex justify-center pt-10">
<Button onClick={shouldEnableGoNext ? onGoNext : undefined} disabled={!shouldEnableGoNext}>
<Button
onClick={shouldEnableGoNext ? onGoNext : undefined}
disabled={!shouldEnableGoNext}
buttonProps={{
'data-testid': 'StakeRIF',
}}
>
{textsDependingOnAction[actionName].confirmButtonText}
</Button>
</div>
Expand Down Expand Up @@ -108,6 +114,9 @@ const PercentageButton = ({ amount, percentage, totalAmountAllowed, onClick }: P
<Button
variant={isActive ? 'secondary-full' : 'secondary'}
onClick={onPercentageButtonClick}
buttonProps={{
'data-testid': `Percentage${percentage}`,
}}
>{`${percentage}%`}</Button>
)
}
10 changes: 8 additions & 2 deletions src/app/user/Stake/StakeStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,16 @@ export const StakeStatus = ({
</div>
{/* Stake Actions */}
<div className="flex justify-center pt-10 gap-4">
<Button variant="secondary" onClick={onViewOnExplorer}>
<Button
variant="secondary"
onClick={onViewOnExplorer}
buttonProps={{ 'data-testid': 'GoToExplorer' }}
>
View on explorer
</Button>
<Button onClick={onReturnToBalances}>Return to balances</Button>
<Button onClick={onReturnToBalances} buttonProps={{ 'data-testid': 'ReturnToBalances' }}>
Return to balances
</Button>
</div>
</div>
)
Expand Down
11 changes: 9 additions & 2 deletions src/app/user/Stake/hooks/useStakeRIF.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,22 @@ function CustomStakingRIFFooter({
return (
<div className="flex flex-col mt-2 gap-2 items-center">
<Paragraph>You need to request allowance for stRIF to be able to stake.</Paragraph>
<Button onClick={onRequestAllowance}>Request allowance</Button>
<Button onClick={onRequestAllowance} buttonProps={{ 'data-testid': 'Allowance' }}>
Request allowance
</Button>
</div>
)
case isAllowanceNeeded && isAllowanceTxPending && !!hash:
return (
<div className="flex flex-col mt-2 gap-2 items-center">
<Paragraph>Allowance TX is in process.</Paragraph>
<Paragraph>Wait for Allowance TX to be mined.</Paragraph>
<Button onClick={() => goToExplorerWithTxHash(hash)}>Click here to go to the explorer</Button>
<Button
onClick={() => goToExplorerWithTxHash(hash)}
buttonProps={{ 'data-testid': 'GoToExplorer' }}
>
Click here to go to the explorer
</Button>
</div>
)
default:
Expand Down
12 changes: 10 additions & 2 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ interface Props {
disabled?: boolean
className?: string
textClassName?: string
buttonProps?: JSX.IntrinsicElements['button']
buttonProps?: JSX.IntrinsicElements['button'] & { 'data-testid': string }
}

const DEFAULT_DATA_TESTID = 'Button'

export const Button: FC<Props> = ({
children: text,
onClick,
Expand Down Expand Up @@ -54,7 +56,13 @@ export const Button: FC<Props> = ({
})

return (
<button type="button" className={classes} onClick={e => !disabled && onClick?.(e)} {...buttonProps}>
<button
type="button"
className={classes}
onClick={e => !disabled && onClick?.(e)}
{...buttonProps}
data-testid={`${DEFAULT_DATA_TESTID}${buttonProps['data-testid']}`}
>
<span className={textClasses}>
<span className="absolute left-[-20px] top-[4px]">{startIcon}</span>
{text}
Expand Down
4 changes: 2 additions & 2 deletions src/components/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const TextInput: FC<Props> = ({
'text-text-secondary focus-visible:ring-0': readonly,
})
return (
<div className={className}>
<div className={className} data-testid={`Input_Container_${name}`}>
{label && (
<div className="pb-[10px]" {...labelWrapperProps}>
<Label variant="semibold">{label}</Label>
Expand All @@ -65,7 +65,7 @@ export const TextInput: FC<Props> = ({
value={value}
onChange={handleOnChange}
name={name}
data-testid={name}
data-testid={`Input_${name}`}
readOnly={readonly}
{...inputProps}
/>
Expand Down