mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 18:07:36 -02:30
fixing JT Form tests post-rebase
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { shallow } from 'enzyme';
|
||||||
|
import CollapsibleSection from './CollapsibleSection';
|
||||||
|
|
||||||
|
describe('<CollapsibleSection>', () => {
|
||||||
|
it('should render contents', () => {
|
||||||
|
const wrapper = shallow(
|
||||||
|
<CollapsibleSection label="Advanced">foo</CollapsibleSection>
|
||||||
|
);
|
||||||
|
expect(wrapper.find('Button > *').prop('isExpanded')).toEqual(false);
|
||||||
|
expect(wrapper.find('ExpandingContainer').prop('isExpanded')).toEqual(
|
||||||
|
false
|
||||||
|
);
|
||||||
|
expect(wrapper.find('ExpandingContainer').prop('children')).toEqual('foo');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should toggle when clicked', () => {
|
||||||
|
const wrapper = shallow(
|
||||||
|
<CollapsibleSection label="Advanced">foo</CollapsibleSection>
|
||||||
|
);
|
||||||
|
expect(wrapper.find('Button > *').prop('isExpanded')).toEqual(false);
|
||||||
|
wrapper.find('Button').simulate('click');
|
||||||
|
expect(wrapper.find('Button > *').prop('isExpanded')).toEqual(true);
|
||||||
|
expect(wrapper.find('ExpandingContainer').prop('isExpanded')).toEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -29,6 +29,8 @@ const ToolbarItem = styled(PFToolbarItem)`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
// TODO: Recommend renaming this component to avoid confusion
|
||||||
|
// with ExpandingContainer
|
||||||
class ExpandCollapse extends React.Component {
|
class ExpandCollapse extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const { isCompact, onCompact, onExpand, i18n } = this.props;
|
const { isCompact, onCompact, onExpand, i18n } = this.props;
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ function JobTemplateAdd({ history, i18n }) {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitInstanceGroups(templateId, addedGroups) {
|
function submitInstanceGroups(templateId, addedGroups = []) {
|
||||||
const associatePromises = addedGroups.map(group =>
|
const associatePromises = addedGroups.map(group =>
|
||||||
JobTemplatesAPI.associateInstanceGroup(templateId, group.id)
|
JobTemplatesAPI.associateInstanceGroup(templateId, group.id)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ describe('<JobTemplateAdd />', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('handleSubmit should post to api', async done => {
|
test.only('handleSubmit should post to api', async done => {
|
||||||
const jobTemplateData = {
|
const jobTemplateData = {
|
||||||
description: 'Baz',
|
description: 'Baz',
|
||||||
inventory: 1,
|
inventory: 1,
|
||||||
@@ -70,6 +70,9 @@ describe('<JobTemplateAdd />', () => {
|
|||||||
name: 'Foo',
|
name: 'Foo',
|
||||||
playbook: 'Bar',
|
playbook: 'Bar',
|
||||||
project: 2,
|
project: 2,
|
||||||
|
verbosity: '0',
|
||||||
|
job_tags: '',
|
||||||
|
skip_tags: '',
|
||||||
};
|
};
|
||||||
JobTemplatesAPI.create.mockResolvedValueOnce({
|
JobTemplatesAPI.create.mockResolvedValueOnce({
|
||||||
data: {
|
data: {
|
||||||
@@ -106,6 +109,9 @@ describe('<JobTemplateAdd />', () => {
|
|||||||
name: 'Foo',
|
name: 'Foo',
|
||||||
playbook: 'Bar',
|
playbook: 'Bar',
|
||||||
project: 2,
|
project: 2,
|
||||||
|
verbosity: '0',
|
||||||
|
job_tags: '',
|
||||||
|
skip_tags: '',
|
||||||
};
|
};
|
||||||
JobTemplatesAPI.create.mockResolvedValueOnce({
|
JobTemplatesAPI.create.mockResolvedValueOnce({
|
||||||
data: {
|
data: {
|
||||||
@@ -118,7 +124,7 @@ describe('<JobTemplateAdd />', () => {
|
|||||||
context: { router: { history } },
|
context: { router: { history } },
|
||||||
});
|
});
|
||||||
|
|
||||||
await wrapper.find('JobTemplateForm').prop('handleSubmit')(jobTemplateData);
|
await wrapper.find('JobTemplateForm').invoke('handleSubmit')(jobTemplateData);
|
||||||
await sleep(0);
|
await sleep(0);
|
||||||
expect(history.push).toHaveBeenCalledWith(
|
expect(history.push).toHaveBeenCalledWith(
|
||||||
'/templates/job_template/1/details'
|
'/templates/job_template/1/details'
|
||||||
@@ -134,7 +140,7 @@ describe('<JobTemplateAdd />', () => {
|
|||||||
context: { router: { history } },
|
context: { router: { history } },
|
||||||
});
|
});
|
||||||
await waitForElement(wrapper, 'EmptyStateBody', el => el.length === 0);
|
await waitForElement(wrapper, 'EmptyStateBody', el => el.length === 0);
|
||||||
wrapper.find('button[aria-label="Cancel"]').prop('onClick')();
|
wrapper.find('button[aria-label="Cancel"]').invoke('onClick')();
|
||||||
expect(history.push).toHaveBeenCalledWith('/templates');
|
expect(history.push).toHaveBeenCalledWith('/templates');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ const mockJobTemplate = {
|
|||||||
project: 3,
|
project: 3,
|
||||||
playbook: 'Baz',
|
playbook: 'Baz',
|
||||||
type: 'job_template',
|
type: 'job_template',
|
||||||
|
job_tags: '',
|
||||||
|
skip_tags: '',
|
||||||
summary_fields: {
|
summary_fields: {
|
||||||
user_capabilities: {
|
user_capabilities: {
|
||||||
edit: true,
|
edit: true,
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ describe('<JobTemplateForm />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('handleNewLabel should arrange new labels properly', async () => {
|
test('handleNewLabel should arrange new labels properly', async () => {
|
||||||
const event = { key: 'Enter' };
|
const event = { key: 'Enter', preventDefault: () => {} };
|
||||||
const wrapper = mountWithContexts(
|
const wrapper = mountWithContexts(
|
||||||
<JobTemplateForm
|
<JobTemplateForm
|
||||||
template={mockData}
|
template={mockData}
|
||||||
|
|||||||
Reference in New Issue
Block a user