update JT form tests

This commit is contained in:
Keith Grant
2019-10-01 11:03:36 -07:00
parent 554a63d8fc
commit ba4e79fd3a
6 changed files with 25 additions and 66 deletions

View File

@@ -693,7 +693,7 @@ exports[`<OrganizationAccessItem /> initially renders succesfully 1`] = `
isReadOnly={false} isReadOnly={false}
onClick={[Function]} onClick={[Function]}
> >
<Chip <PFChip
className="Chip-sc-1rzr8oo-0 dgUGLg" className="Chip-sc-1rzr8oo-0 dgUGLg"
closeBtnAriaLabel="close" closeBtnAriaLabel="close"
component="li" component="li"
@@ -771,7 +771,7 @@ exports[`<OrganizationAccessItem /> initially renders succesfully 1`] = `
</ChipButton> </ChipButton>
</li> </li>
</GenerateId> </GenerateId>
</Chip> </PFChip>
</StyledComponent> </StyledComponent>
</Chip> </Chip>
</ul> </ul>

View File

@@ -385,10 +385,6 @@ exports[`<OrganizationNotifications /> initially renders succesfully 1`] = `
onSort={[Function]} onSort={[Function]}
qsConfig={ qsConfig={
Object { Object {
"dateFields": Array [
"modified",
"created",
],
"defaultParams": Object { "defaultParams": Object {
"order_by": "name", "order_by": "name",
"page": 1, "page": 1,
@@ -443,10 +439,6 @@ exports[`<OrganizationNotifications /> initially renders succesfully 1`] = `
onSort={[Function]} onSort={[Function]}
qsConfig={ qsConfig={
Object { Object {
"dateFields": Array [
"modified",
"created",
],
"defaultParams": Object { "defaultParams": Object {
"order_by": "name", "order_by": "name",
"page": 1, "page": 1,
@@ -626,24 +618,6 @@ exports[`<OrganizationNotifications /> initially renders succesfully 1`] = `
] ]
} }
onSearch={[Function]} onSearch={[Function]}
qsConfig={
Object {
"dateFields": Array [
"modified",
"created",
],
"defaultParams": Object {
"order_by": "name",
"page": 1,
"page_size": 5,
},
"integerFields": Array [
"page",
"page_size",
],
"namespace": "notification",
}
}
sortedColumnKey="name" sortedColumnKey="name"
> >
<I18n <I18n
@@ -675,24 +649,6 @@ exports[`<OrganizationNotifications /> initially renders succesfully 1`] = `
} }
i18n={"/i18n/"} i18n={"/i18n/"}
onSearch={[Function]} onSearch={[Function]}
qsConfig={
Object {
"dateFields": Array [
"modified",
"created",
],
"defaultParams": Object {
"order_by": "name",
"page": 1,
"page_size": 5,
},
"integerFields": Array [
"page",
"page_size",
],
"namespace": "notification",
}
}
sortedColumnKey="name" sortedColumnKey="name"
> >
<Form <Form

View File

@@ -27,6 +27,8 @@ const jobTemplateData = {
host_config_key: '', host_config_key: '',
}; };
// TODO: Needs React/React-router upgrade to remove `act()` warnings
// See https://github.com/ansible/awx/issues/4817
describe('<JobTemplateAdd />', () => { describe('<JobTemplateAdd />', () => {
const defaultProps = { const defaultProps = {
description: '', description: '',
@@ -94,7 +96,10 @@ describe('<JobTemplateAdd />', () => {
const changeState = new Promise(resolve => { const changeState = new Promise(resolve => {
formik.setState( formik.setState(
{ {
values: jobTemplateData, values: {
...jobTemplateData,
labels: [],
}
}, },
() => resolve() () => resolve()
); );

View File

@@ -34,6 +34,9 @@ const mockJobTemplate = {
labels: { labels: {
results: [{ name: 'Sushi', id: 1 }, { name: 'Major', id: 2 }], results: [{ name: 'Sushi', id: 1 }, { name: 'Major', id: 2 }],
}, },
inventory: {
organization_id: 1,
},
}, },
}; };
@@ -170,16 +173,12 @@ describe('<JobTemplateEdit />', () => {
description: 'new description', description: 'new description',
job_type: 'check', job_type: 'check',
}; };
const newLabels = [ const labels = [
{ associate: true, id: 3 }, { id: 3, name: 'Foo', isNew: true },
{ associate: true, id: 3 }, { id: 4, name: 'Bar', isNew: true },
{ name: 'Maple', organization: 1 }, { id: 5, name: 'Maple' },
{ name: 'Tree', organization: 1 }, { id: 6, name: 'Tree' },
]; ]
const removedLabels = [
{ disassociate: true, id: 1 },
{ disassociate: true, id: 2 },
];
JobTemplatesAPI.update.mockResolvedValue({ JobTemplatesAPI.update.mockResolvedValue({
data: { ...updatedTemplateData }, data: { ...updatedTemplateData },
}); });
@@ -190,8 +189,7 @@ describe('<JobTemplateEdit />', () => {
values: { values: {
...mockJobTemplate, ...mockJobTemplate,
...updatedTemplateData, ...updatedTemplateData,
newLabels, labels,
removedLabels,
}, },
}, },
() => resolve() () => resolve()

View File

@@ -588,7 +588,7 @@ const FormikApp = withFormik({
inventory: template.inventory || '', inventory: template.inventory || '',
project: template.project || '', project: template.project || '',
playbook: template.playbook || '', playbook: template.playbook || '',
labels: summary_fields.labels.results, labels: summary_fields.labels.results || [],
forks: template.forks || 0, forks: template.forks || 0,
limit: template.limit || '', limit: template.limit || '',
verbosity: template.verbosity || '0', verbosity: template.verbosity || '0',

View File

@@ -70,7 +70,7 @@ describe('<JobTemplateForm />', () => {
jest.clearAllMocks(); jest.clearAllMocks();
}); });
test('should render labels MultiSelect', async () => { test('should render LabelsSelect', async () => {
const wrapper = mountWithContexts( const wrapper = mountWithContexts(
<JobTemplateForm <JobTemplateForm
template={mockData} template={mockData}
@@ -82,11 +82,11 @@ describe('<JobTemplateForm />', () => {
expect(LabelsAPI.read).toHaveBeenCalled(); expect(LabelsAPI.read).toHaveBeenCalled();
expect(JobTemplatesAPI.readInstanceGroups).toHaveBeenCalled(); expect(JobTemplatesAPI.readInstanceGroups).toHaveBeenCalled();
wrapper.update(); wrapper.update();
expect( const select = wrapper.find('LabelSelect');
wrapper expect(select).toHaveLength(1);
.find('FormGroup[fieldId="template-labels"] MultiSelect') expect(select.prop('value')).toEqual(
.prop('associatedItems') mockData.summary_fields.labels.results
).toEqual(mockData.summary_fields.labels.results); );
}); });
test('should update form values on input changes', async () => { test('should update form values on input changes', async () => {