diff --git a/src/Components/CreateImageWizard/utilities/PasswordValidatedInput.tsx b/src/Components/CreateImageWizard/utilities/PasswordValidatedInput.tsx index 6cc85c7e..972902d7 100644 --- a/src/Components/CreateImageWizard/utilities/PasswordValidatedInput.tsx +++ b/src/Components/CreateImageWizard/utilities/PasswordValidatedInput.tsx @@ -10,6 +10,7 @@ import { InputGroupItem, TextInput, TextInputProps, + Tooltip, } from '@patternfly/react-core'; import { EyeIcon, EyeSlashIcon } from '@patternfly/react-icons'; @@ -46,6 +47,21 @@ export const PasswordValidatedInput = ({ setIsPasswordVisible(!isPasswordVisible); }; + const isEditingWithoutValue = hasPassword && !value; + + const PasswordToggleButton = () => { + return ( + + ); + }; + return ( <> @@ -61,14 +77,15 @@ export const PasswordValidatedInput = ({ /> - + {isEditingWithoutValue ? ( + + + + + + ) : ( + + )} diff --git a/src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx b/src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx index ad0ddf97..e0704deb 100644 --- a/src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx @@ -506,4 +506,30 @@ describe('Users edit mode', () => { const expectedRequest = usersCreateBlueprintRequest; expect(receivedRequest).toEqual(expectedRequest); }); + + test('shows tooltip on disabled password eye icon when editing blueprint with existing password', async () => { + const user = userEvent.setup(); + const id = mockBlueprintIds['users']; + await renderEditMode(id); + + const usersNavButtons = await screen.findAllByRole('button', { name: /Users/ }); + await waitFor(() => user.click(usersNavButtons[0])); + + const passwordToggleButton = await screen.findByRole('button', { + name: 'Show password' + }); + + expect(passwordToggleButton).toBeDisabled(); + + await waitFor(() => user.hover(passwordToggleButton)); + + const tooltip = await screen.findByText('Passwords cannot be viewed when editing a blueprint for security reasons'); + expect(tooltip).toBeInTheDocument(); + + await waitFor(() => user.unhover(passwordToggleButton)); + + await waitFor(() => { + expect(screen.queryByText('Passwords cannot be viewed when editing a blueprint for security reasons')).not.toBeInTheDocument(); + }); + }); }); diff --git a/src/test/fixtures/editMode.ts b/src/test/fixtures/editMode.ts index 0934015e..5e00ede2 100644 --- a/src/test/fixtures/editMode.ts +++ b/src/test/fixtures/editMode.ts @@ -502,7 +502,7 @@ export const usersCreateBlueprintRequest: CreateBlueprintRequest = { name: 'best', ssh_key: 'ssh-rsa d', groups: ['wheel'], - hasPassword: false, + hasPassword: true, }, ], },