Merge pull request #8531 from AlexSCorey/8196-PrivilegeEscalation

Fixes broken select

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2020-11-05 19:06:15 +00:00 committed by GitHub
commit 13f2b3f632
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 1 deletions

View File

@ -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 => {

View File

@ -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('<BecomeMethodField>', () => {
let wrapper;
test('should mount properly', async () => {
await act(async () => {
wrapper = mountWithContexts(
<Formik>
<BecomeMethodField fieldOptions={fieldOptions} isRequired />
</Formik>
);
});
expect(wrapper.find('BecomeMethodField').length).toBe(1);
});
test('should open privilege escalation properly', async () => {
await act(async () => {
wrapper = mountWithContexts(
<Formik>
<BecomeMethodField fieldOptions={fieldOptions} isRequired />
</Formik>
);
});
act(() => wrapper.find('Select').prop('onToggle')(true));
wrapper.update();
expect(wrapper.find('SelectOption').length).toBe(12);
});
});