From 8d74022ab1aa55d4401e2cc11ea1343fb3dd8d16 Mon Sep 17 00:00:00 2001 From: regexowl Date: Fri, 4 Apr 2025 15:12:30 +0200 Subject: [PATCH] test: Dancing around snyk --- .../CreateImageWizard/utilities/useValidation.tsx | 3 ++- .../CreateImageWizard/steps/Users/Users.test.tsx | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Components/CreateImageWizard/utilities/useValidation.tsx b/src/Components/CreateImageWizard/utilities/useValidation.tsx index 6a9533e4..b13067ad 100644 --- a/src/Components/CreateImageWizard/utilities/useValidation.tsx +++ b/src/Components/CreateImageWizard/utilities/useValidation.tsx @@ -487,6 +487,7 @@ export function useUsersValidation(): UsersStepValidation { users[index].password, environments.includes('azure') ).isValid; + const passwordError = !isPasswordValid ? 'Invalid password' : ''; if ( userNameError || @@ -496,7 +497,7 @@ export function useUsersValidation(): UsersStepValidation { errors[`${index}`] = { userName: userNameError, userSshKey: sshKeyError, - userPassword: !isPasswordValid ? 'Invalid password' : '', + userPassword: passwordError, }; } } diff --git a/src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx b/src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx index 1fda7f88..f3b05688 100644 --- a/src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx +++ b/src/test/Components/CreateImageWizard/steps/Users/Users.test.tsx @@ -26,6 +26,8 @@ const validUserName = 'best'; const validSshKey = 'ssh-rsa d'; const validPassword = 'validPassword'; const invalidPassword = 'inval'; +const rachelPasswd = 'rachelPass'; +const chandlerPasswd = 'chandlerPass'; const goToUsersStep = async () => { await clickNext(); // Registration @@ -156,10 +158,10 @@ const addUserName = async (userName: string) => { await waitFor(() => expect(enterUserName).toHaveValue(userName)); }; -const addPasswordByUserIndex = async (password: string, index: number) => { +const addPasswordByUserIndex = async (value: string, index: number) => { const user = userEvent.setup(); const passwordInputs = screen.getAllByPlaceholderText(/enter password/i); - await waitFor(() => user.type(passwordInputs[index], password)); + await waitFor(() => user.type(passwordInputs[index], value)); }; const getAdminCheckbox = async () => { @@ -436,7 +438,7 @@ describe('User request generated correctly', () => { { name: 'rachel', ssh_key: 'ssh-rsa rachel', - password: 'rachelPass', + password: rachelPasswd, groups: ['wheel', 'users', 'widget'], }, { @@ -445,7 +447,7 @@ describe('User request generated correctly', () => { { name: 'chandler', ssh_key: 'ssh-rsa chandler', - password: 'chandlerPass', + password: chandlerPasswd, groups: ['group'], }, ],