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:
parent
e4721d7722
commit
5319659d58
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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 || '',
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user