diff --git a/src/views/credentials/__tests__/__snapshots__/addCredentialModal.test.tsx.snap b/src/views/credentials/__tests__/__snapshots__/addCredentialModal.test.tsx.snap index 51f22d40..9f958521 100644 --- a/src/views/credentials/__tests__/__snapshots__/addCredentialModal.test.tsx.snap +++ b/src/views/credentials/__tests__/__snapshots__/addCredentialModal.test.tsx.snap @@ -155,6 +155,8 @@ exports[`CredentialFormFields should render a basic component: basic 1`] = ` type="password" /> + + `; +exports[`CredentialFormFields should render ansible form appropriately: ansible, "Username and Password" 1`] = ` + + + + + + + + + + + + + +`; + +exports[`CredentialFormFields should render satellite form appropriately: satellite, "Username and Password" 1`] = ` + + + + + + + + + + + + + +`; + exports[`CredentialFormFields should render specific to authType for type network: network, SSH Key 1`] = ` + + + + + + + + + + + `; @@ -348,6 +496,8 @@ exports[`CredentialFormFields should render specific to authType for type networ type="password" /> + + + + +`; + +exports[`CredentialFormFields should render vcenter form appropriately: vcenter, "Username and Password" 1`] = ` + + + + + - - - diff --git a/src/views/credentials/__tests__/addCredentialModal.test.tsx b/src/views/credentials/__tests__/addCredentialModal.test.tsx index eb0f2128..d2522c5b 100644 --- a/src/views/credentials/__tests__/addCredentialModal.test.tsx +++ b/src/views/credentials/__tests__/addCredentialModal.test.tsx @@ -106,6 +106,21 @@ describe('CredentialFormFields', () => { expect(openshiftToken).toMatchSnapshot('openshift, "Token"'); }); + it('should render vcenter form appropriately', async () => { + const vcenter = await shallowComponent(); + expect(vcenter).toMatchSnapshot('vcenter, "Username and Password"'); + }); + + it('should render satellite form appropriately', async () => { + const satellite = await shallowComponent(); + expect(satellite).toMatchSnapshot('satellite, "Username and Password"'); + }); + + it('should render ansible form appropriately', async () => { + const ansible = await shallowComponent(); + expect(ansible).toMatchSnapshot('ansible, "Username and Password"'); + }); + it('should call handlers for setAuthType and handleInputChange', async () => { const mockHandleInputChange = jest.fn(); const mockSetAuthType = jest.fn(); diff --git a/src/views/credentials/addCredentialModal.tsx b/src/views/credentials/addCredentialModal.tsx index 3b291d8e..c77171d7 100644 --- a/src/views/credentials/addCredentialModal.tsx +++ b/src/views/credentials/addCredentialModal.tsx @@ -170,35 +170,6 @@ const CredentialFormFields: React.FC = ({ onChange={event => handleInputChange('password', (event.target as HTMLInputElement).value)} /> - - handleInputChange('become_method', (item !== 'Select option' && item) || '')} - dropdownItems={['Select option', 'sudo', 'su', 'pbrun', 'pfexec', 'doas', 'dzdo', 'ksu', 'runas']} - /> - - - handleInputChange('become_user', (event.target as HTMLInputElement).value)} - /> - - - handleInputChange('become_password', (event.target as HTMLInputElement).value)} - /> - )} @@ -241,9 +212,43 @@ const CredentialFormFields: React.FC = ({ )} + + {/* Render "Become" fields only if network is selected and authType is Username/Password or SSH Key */} + {typeValue === 'network' && ( + + + handleInputChange('become_method', (item !== 'Select option' && item) || '')} + dropdownItems={['Select option', 'sudo', 'su', 'pbrun', 'pfexec', 'doas', 'dzdo', 'ksu', 'runas']} + /> + + + handleInputChange('become_user', (event.target as HTMLInputElement).value)} + /> + + + handleInputChange('become_password', (event.target as HTMLInputElement).value)} + /> + + + )} ); - const AddCredentialModal: React.FC = ({ isOpen, credential,