mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 23:07:42 -02:30
Fixes failing tests
This commit is contained in:
@@ -26,7 +26,7 @@ describe('<ProjectForm />', () => {
|
|||||||
id: 100,
|
id: 100,
|
||||||
credential_type_id: 4,
|
credential_type_id: 4,
|
||||||
kind: 'scm',
|
kind: 'scm',
|
||||||
name: 'alpha',
|
name: 'Foo',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -200,17 +200,22 @@ describe('<JobTemplateEdit />', () => {
|
|||||||
data: { ...updatedTemplateData },
|
data: { ...updatedTemplateData },
|
||||||
});
|
});
|
||||||
const formik = wrapper.find('Formik').instance();
|
const formik = wrapper.find('Formik').instance();
|
||||||
const changeState = new Promise(resolve => {
|
const changeState = await act(
|
||||||
const values = {
|
() =>
|
||||||
...mockJobTemplate,
|
new Promise(resolve => {
|
||||||
...updatedTemplateData,
|
const values = {
|
||||||
labels,
|
...mockJobTemplate,
|
||||||
instanceGroups: [],
|
...updatedTemplateData,
|
||||||
};
|
labels,
|
||||||
formik.setState({ values }, () => resolve());
|
instanceGroups: [],
|
||||||
});
|
};
|
||||||
|
formik.setState({ values }, () => resolve());
|
||||||
|
})
|
||||||
|
);
|
||||||
await changeState;
|
await changeState;
|
||||||
wrapper.find('button[aria-label="Save"]').simulate('click');
|
await act(async () => {
|
||||||
|
wrapper.find('button[aria-label="Save"]').simulate('click');
|
||||||
|
});
|
||||||
await sleep(0);
|
await sleep(0);
|
||||||
|
|
||||||
expect(JobTemplatesAPI.update).toHaveBeenCalledWith(1, {
|
expect(JobTemplatesAPI.update).toHaveBeenCalledWith(1, {
|
||||||
@@ -236,7 +241,9 @@ describe('<JobTemplateEdit />', () => {
|
|||||||
'button[aria-label="Cancel"]',
|
'button[aria-label="Cancel"]',
|
||||||
e => e.length === 1
|
e => e.length === 1
|
||||||
);
|
);
|
||||||
cancelButton.prop('onClick')();
|
await act(async () => {
|
||||||
|
cancelButton.prop('onClick')();
|
||||||
|
});
|
||||||
expect(history.location.pathname).toEqual(
|
expect(history.location.pathname).toEqual(
|
||||||
'/templates/job_template/1/details'
|
'/templates/job_template/1/details'
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -157,10 +157,12 @@ describe('<JobTemplateForm />', () => {
|
|||||||
target: { value: 'new baz type', name: 'playbook' },
|
target: { value: 'new baz type', name: 'playbook' },
|
||||||
});
|
});
|
||||||
expect(form.state('values').playbook).toEqual('new baz type');
|
expect(form.state('values').playbook).toEqual('new baz type');
|
||||||
wrapper
|
await act(async () => {
|
||||||
.find('CredentialChip')
|
wrapper
|
||||||
.at(0)
|
.find('CredentialChip')
|
||||||
.prop('onClick')();
|
.at(0)
|
||||||
|
.prop('onClick')();
|
||||||
|
});
|
||||||
expect(form.state('values').credentials).toEqual([
|
expect(form.state('values').credentials).toEqual([
|
||||||
{ id: 2, kind: 'ssh', name: 'Bar' },
|
{ id: 2, kind: 'ssh', name: 'Bar' },
|
||||||
]);
|
]);
|
||||||
@@ -180,7 +182,9 @@ describe('<JobTemplateForm />', () => {
|
|||||||
});
|
});
|
||||||
await waitForElement(wrapper, 'EmptyStateBody', el => el.length === 0);
|
await waitForElement(wrapper, 'EmptyStateBody', el => el.length === 0);
|
||||||
expect(handleSubmit).not.toHaveBeenCalled();
|
expect(handleSubmit).not.toHaveBeenCalled();
|
||||||
wrapper.find('button[aria-label="Save"]').simulate('click');
|
await act(async () => {
|
||||||
|
wrapper.find('button[aria-label="Save"]').simulate('click');
|
||||||
|
});
|
||||||
await sleep(1);
|
await sleep(1);
|
||||||
expect(handleSubmit).toBeCalled();
|
expect(handleSubmit).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user