mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 02:50:02 -03:30
Removes code from serializer in favor to api call of Project.readDetails
Adds necessary tests.
This commit is contained in:
parent
790942c0f2
commit
078dc666c1
@ -26,6 +26,7 @@ const jobTemplateData = {
|
||||
allow_simultaneous: false,
|
||||
use_fact_cache: false,
|
||||
host_config_key: '',
|
||||
scm_branch: '',
|
||||
};
|
||||
|
||||
describe('<JobTemplateAdd />', () => {
|
||||
|
||||
@ -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} />
|
||||
|
||||
@ -29,6 +29,7 @@ const mockJobTemplate = {
|
||||
allow_simultaneous: false,
|
||||
use_fact_cache: false,
|
||||
host_config_key: '',
|
||||
scm_branch: '',
|
||||
summary_fields: {
|
||||
user_capabilities: {
|
||||
edit: true,
|
||||
|
||||
@ -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 });
|
||||
}
|
||||
|
||||
@ -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');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user