Removes code from serializer in favor to api call of Project.readDetails

Adds necessary tests.
This commit is contained in:
Alex Corey 2020-01-14 14:53:38 -05:00
parent 790942c0f2
commit 078dc666c1
5 changed files with 16 additions and 9 deletions

View File

@ -26,6 +26,7 @@ const jobTemplateData = {
allow_simultaneous: false,
use_fact_cache: false,
host_config_key: '',
scm_branch: '',
};
describe('<JobTemplateAdd />', () => {

View File

@ -196,12 +196,7 @@ class JobTemplateDetail extends Component {
) : (
renderMissingDataDetail(i18n._(t`Project`))
)}
{template.scm_branch && (
<Detail
label={i18n._(t`SCM Branch`)}
value={template.scm_branch}
/>
)}
<Detail label={i18n._(t`SCM Branch`)} value={template.scm_branch} />
<Detail label={i18n._(t`Playbook`)} value={playbook} />
<Detail label={i18n._(t`Forks`)} value={forks || '0'} />
<Detail label={i18n._(t`Limit`)} value={limit} />

View File

@ -29,6 +29,7 @@ const mockJobTemplate = {
allow_simultaneous: false,
use_fact_cache: false,
host_config_key: '',
scm_branch: '',
summary_fields: {
user_capabilities: {
edit: true,

View File

@ -139,7 +139,7 @@ class JobTemplateForm extends Component {
handleProjectUpdate(project) {
const { setFieldValue } = this.props;
setFieldValue('project', project.id);
setFieldValue('playbook', undefined);
setFieldValue('playbook', 0);
setFieldValue('scm_branch', '');
this.setState({ project });
}

View File

@ -27,7 +27,6 @@ describe('<JobTemplateForm />', () => {
project: {
id: 3,
name: 'qux',
allow_override: true,
},
labels: { results: [{ name: 'Sushi', id: 1 }, { name: 'Major', id: 2 }] },
credentials: [
@ -133,7 +132,6 @@ describe('<JobTemplateForm />', () => {
/>
);
});
await waitForElement(wrapper, 'EmptyStateBody', el => el.length === 0);
await act(async () => {
wrapper.find('input#template-name').simulate('change', {
@ -154,15 +152,25 @@ describe('<JobTemplateForm />', () => {
name: 'project',
allow_override: true,
});
});
wrapper.update();
await act(async () => {
wrapper.find('input#scm_branch').simulate('change', {
target: { value: 'devel', name: 'scm_branch' },
});
wrapper.find('AnsibleSelect[name="playbook"]').simulate('change', {
target: { value: 'new baz type', name: 'playbook' },
});
});
await act(async () => {
wrapper
.find('CredentialChip')
.at(0)
.prop('onClick')();
});
wrapper.update();
expect(wrapper.find('input#template-name').prop('value')).toEqual(
'new foo'
);
@ -179,7 +187,9 @@ describe('<JobTemplateForm />', () => {
expect(wrapper.find('ProjectLookup').prop('value')).toEqual({
id: 4,
name: 'project',
allow_override: true,
});
expect(wrapper.find('input#scm_branch').prop('value')).toEqual('devel');
expect(
wrapper.find('AnsibleSelect[name="playbook"]').prop('value')
).toEqual('new baz type');