From 22029b9d7c5f3ab713c03127f7e1f1160a5baccd Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Tue, 3 Nov 2020 14:09:13 -0500 Subject: [PATCH 1/2] fixes broken select --- .../BecomeMethodField.jsx | 2 +- .../BecomeMethodField.test.jsx | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 awx/ui_next/src/screens/Credential/shared/CredentialFormFields/BecomeMethodField.test.jsx 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..7b83a14c18 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,7 @@ function BecomeMethodField({ fieldOptions, isRequired }) { helpers.setValue(option); setIsOpen(false); }} - isExpanded={isOpen} + isOpen={isOpen} 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); + }); +}); From 314fdd60663c35973c9319f3217a5d6ed7755442 Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Thu, 5 Nov 2020 11:44:33 -0500 Subject: [PATCH 2/2] add identifier --- .../Credential/shared/CredentialFormFields/BecomeMethodField.jsx | 1 + 1 file changed, 1 insertion(+) 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 7b83a14c18..a4049c7695 100644 --- a/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/BecomeMethodField.jsx +++ b/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/BecomeMethodField.jsx @@ -53,6 +53,7 @@ function BecomeMethodField({ fieldOptions, isRequired }) { setIsOpen(false); }} isOpen={isOpen} + id="privilege-escalation-methods" selections={becomeMethodField.value} isCreatable onCreateOption={option => {