Skip to content

Commit

Permalink
Merge pull request #36 from input-output-hk/test/LW-10799-create-wall…
Browse files Browse the repository at this point in the history
…et-e2e [LW-10799]

test: add test ids for PasswordBox [LW-10799]
  • Loading branch information
przemyslaw-wlodek authored Jul 26, 2024
2 parents aad2e00 + cb2bfa2 commit e219e74
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ interface PasswordBoxButtonProps {
onClick: (event: Readonly<React.MouseEvent<HTMLButtonElement>>) => void;
disabled: boolean;
isPasswordVisible: boolean;
testId?: string;
}

export const PasswordInputButton = ({
onClick,
disabled,
isPasswordVisible,
testId,
}: Readonly<PasswordBoxButtonProps>): JSX.Element => {
return (
<button
type="button"
className={cx.inputButton}
onClick={onClick}
disabled={disabled}
data-testid={testId}
>
{isPasswordVisible ? (
<CloseEye
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface PasswordInputProps extends Form.FormControlProps {
defaultIsPasswordVisible?: boolean;
containerClassName?: string;
containerStyle?: React.CSSProperties;
testId?: string;
}

export const PasswordInput = ({
Expand All @@ -35,6 +36,7 @@ export const PasswordInput = ({
onChange,
defaultIsPasswordVisible = false,
containerStyle,
testId,
}: Readonly<PasswordInputProps>): JSX.Element => {
const [isPasswordVisible, setIsPasswordVisible] = useState(
defaultIsPasswordVisible,
Expand Down Expand Up @@ -62,6 +64,7 @@ export const PasswordInput = ({
value={value}
onChange={onChange}
id={id}
data-testid={testId}
/>
</Form.Control>
<Form.Label
Expand All @@ -70,6 +73,7 @@ export const PasswordInput = ({
{label}
</Form.Label>
<PasswordInputButton
testId={testId && `${testId}-toggle`}
onClick={(event): void => {
event.preventDefault();
setIsPasswordVisible(!isPasswordVisible);
Expand Down

0 comments on commit e219e74

Please sign in to comment.