1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-27 09:25:10 +03:00

Address PR feedback

* Set local_path default value to empty string
* Make playbook directory required
* Update unit tests
This commit is contained in:
Marliana Lara 2019-11-11 13:38:15 -05:00
parent e4721d7722
commit 5319659d58
No known key found for this signature in database
GPG Key ID: 38C73B40DFA809EE
3 changed files with 11 additions and 15 deletions

View File

@ -128,23 +128,14 @@ describe('<ProjectAdd />', () => {
});
});
await waitForElement(wrapper, 'ContentLoading', el => el.length === 0);
const formik = wrapper.find('Formik').instance();
const changeState = new Promise(resolve => {
formik.setState(
{
values: {
...projectData,
scm_type: 'manual',
},
},
() => resolve()
await act(async () => {
wrapper.find('ProjectForm').prop('handleSubmit')(
{ ...projectData },
{ scm_type: 'manual' }
);
});
await changeState;
await act(async () => {
wrapper.find('form').simulate('submit');
});
wrapper.update();
expect(ProjectsAPI.create).toHaveBeenCalledTimes(1);
expect(wrapper.find('ProjectAdd .formSubmitError').length).toBe(1);
});

View File

@ -183,7 +183,7 @@ function ProjectForm({ project, ...props }) {
credential: project.credential || '',
custom_virtualenv: project.custom_virtualenv || '',
description: project.description || '',
local_path: project.local_path || null,
local_path: project.local_path || '',
name: project.name || '',
organization: project.organization || '',
scm_branch: project.scm_branch || '',

View File

@ -2,6 +2,7 @@ import React from 'react';
import { withI18n } from '@lingui/react';
import { t } from '@lingui/macro';
import { Field } from 'formik';
import { required } from '@util/validators';
import AnsibleSelect from '@components/AnsibleSelect';
import FormField, { FieldTooltip } from '@components/FormField';
import { FormGroup, Alert } from '@patternfly/react-core';
@ -74,9 +75,13 @@ const ManualSubForm = ({
{options.length !== 1 && (
<Field
name="local_path"
validate={required(i18n._(t`Select a value for this field`), i18n)}
render={({ field, form }) => (
<FormGroup
fieldId="project-local-path"
helperTextInvalid={form.errors.local_path}
isRequired
isValid={!form.touched.local_path || !form.errors.local_path}
label={i18n._(t`Playbook Directory`)}
>
<FieldTooltip