diff --git a/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/BecomeMethodField.jsx b/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/BecomeMethodField.jsx index e11f260ce5..a4049c7695 100644 --- a/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/BecomeMethodField.jsx +++ b/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/BecomeMethodField.jsx @@ -52,7 +52,8 @@ function BecomeMethodField({ fieldOptions, isRequired }) { helpers.setValue(option); setIsOpen(false); }} - isExpanded={isOpen} + isOpen={isOpen} + id="privilege-escalation-methods" selections={becomeMethodField.value} isCreatable onCreateOption={option => { diff --git a/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/BecomeMethodField.test.jsx b/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/BecomeMethodField.test.jsx new file mode 100644 index 0000000000..429f63391d --- /dev/null +++ b/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/BecomeMethodField.test.jsx @@ -0,0 +1,40 @@ +import React from 'react'; +import { act } from 'react-dom/test-utils'; +import { Formik } from 'formik'; +import { mountWithContexts } from '../../../../../testUtils/enzymeHelpers'; +import BecomeMethodField from './BecomeMethodField'; + +const fieldOptions = { + help_text: + "Specify a method for 'become' operations. This is equivalent to specifying the --become-method Ansible parameter.", + id: 'become_method', + label: 'Privilege Escalation Method', + type: 'string', +}; +describe('', () => { + let wrapper; + + test('should mount properly', async () => { + await act(async () => { + wrapper = mountWithContexts( + + + + ); + }); + expect(wrapper.find('BecomeMethodField').length).toBe(1); + }); + + test('should open privilege escalation properly', async () => { + await act(async () => { + wrapper = mountWithContexts( + + + + ); + }); + act(() => wrapper.find('Select').prop('onToggle')(true)); + wrapper.update(); + expect(wrapper.find('SelectOption').length).toBe(12); + }); +});