File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed
src/design-system/password-box Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -10,19 +10,22 @@ interface PasswordBoxButtonProps {
10
10
onClick : ( event : Readonly < React . MouseEvent < HTMLButtonElement > > ) => void ;
11
11
disabled : boolean ;
12
12
isPasswordVisible : boolean ;
13
+ testId ?: string ;
13
14
}
14
15
15
16
export const PasswordInputButton = ( {
16
17
onClick,
17
18
disabled,
18
19
isPasswordVisible,
20
+ testId,
19
21
} : Readonly < PasswordBoxButtonProps > ) : JSX . Element => {
20
22
return (
21
23
< button
22
24
type = "button"
23
25
className = { cx . inputButton }
24
26
onClick = { onClick }
25
27
disabled = { disabled }
28
+ data-testid = { testId }
26
29
>
27
30
{ isPasswordVisible ? (
28
31
< CloseEye
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export interface PasswordInputProps extends Form.FormControlProps {
21
21
defaultIsPasswordVisible ?: boolean ;
22
22
containerClassName ?: string ;
23
23
containerStyle ?: React . CSSProperties ;
24
+ testId ?: string ;
24
25
}
25
26
26
27
export const PasswordInput = ( {
@@ -35,6 +36,7 @@ export const PasswordInput = ({
35
36
onChange,
36
37
defaultIsPasswordVisible = false ,
37
38
containerStyle,
39
+ testId,
38
40
} : Readonly < PasswordInputProps > ) : JSX . Element => {
39
41
const [ isPasswordVisible , setIsPasswordVisible ] = useState (
40
42
defaultIsPasswordVisible ,
@@ -62,6 +64,7 @@ export const PasswordInput = ({
62
64
value = { value }
63
65
onChange = { onChange }
64
66
id = { id }
67
+ data-testid = { testId }
65
68
/>
66
69
</ Form . Control >
67
70
< Form . Label
@@ -70,6 +73,7 @@ export const PasswordInput = ({
70
73
{ label }
71
74
</ Form . Label >
72
75
< PasswordInputButton
76
+ testId = { testId && `${ testId } -toggle` }
73
77
onClick = { ( event ) : void => {
74
78
event . preventDefault ( ) ;
75
79
setIsPasswordVisible ( ! isPasswordVisible ) ;
You can’t perform that action at this time.
0 commit comments