mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 03:40:42 -03:30
update tests for form submit errors
This commit is contained in:
parent
352c8c3cb1
commit
d06d4d5a8c
@ -10,15 +10,4 @@ describe('FormActionGroup', () => {
|
||||
);
|
||||
expect(wrapper).toHaveLength(1);
|
||||
});
|
||||
|
||||
test('should display error message if given', () => {
|
||||
const wrapper = mountWithContexts(
|
||||
<FormActionGroup
|
||||
onSubmit={() => {}}
|
||||
onCancel={() => {}}
|
||||
errorMessage={<div className="error">oh noes</div>}
|
||||
/>
|
||||
);
|
||||
expect(wrapper.find('.error').text()).toEqual('oh noes');
|
||||
});
|
||||
});
|
||||
|
||||
@ -48,7 +48,7 @@ describe('<FormSubmitError>', () => {
|
||||
);
|
||||
});
|
||||
wrapper.update();
|
||||
expect(wrapper.text()).toEqual('There was an error');
|
||||
expect(wrapper.find('Alert').prop('title')).toEqual('There was an error');
|
||||
expect(global.console.error).toHaveBeenCalledWith(error);
|
||||
global.console = realConsole;
|
||||
});
|
||||
|
||||
@ -106,7 +106,8 @@ describe('<ProjectAdd />', () => {
|
||||
project_local_paths: ['foobar', 'qux'],
|
||||
project_base_dir: 'dir/foo/bar',
|
||||
};
|
||||
ProjectsAPI.create.mockImplementation(() => Promise.reject(new Error()));
|
||||
const error = new Error('oops');
|
||||
ProjectsAPI.create.mockImplementation(() => Promise.reject(error));
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(<ProjectAdd />, {
|
||||
context: { config },
|
||||
@ -121,7 +122,7 @@ describe('<ProjectAdd />', () => {
|
||||
});
|
||||
wrapper.update();
|
||||
expect(ProjectsAPI.create).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.find('ProjectAdd .formSubmitError').length).toBe(1);
|
||||
expect(wrapper.find('ProjectForm').prop('submitError')).toEqual(error);
|
||||
});
|
||||
|
||||
test('CardBody cancel button should navigate to projects list', async () => {
|
||||
|
||||
@ -120,7 +120,10 @@ describe('<ProjectEdit />', () => {
|
||||
project_local_paths: [],
|
||||
project_base_dir: 'foo/bar',
|
||||
};
|
||||
ProjectsAPI.update.mockImplementation(() => Promise.reject(new Error()));
|
||||
const error = new Error('oops');
|
||||
const realConsoleError = global.console.error;
|
||||
global.console.error = jest.fn();
|
||||
ProjectsAPI.update.mockImplementation(() => Promise.reject(error));
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(
|
||||
<ProjectEdit project={{ ...projectData, scm_type: 'manual' }} />,
|
||||
@ -135,7 +138,8 @@ describe('<ProjectEdit />', () => {
|
||||
});
|
||||
wrapper.update();
|
||||
expect(ProjectsAPI.update).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.find('ProjectEdit .formSubmitError').length).toBe(1);
|
||||
expect(wrapper.find('ProjectForm').prop('submitError')).toEqual(error);
|
||||
global.console.error = realConsoleError;
|
||||
});
|
||||
|
||||
test('CardBody cancel button should navigate to project details', async () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user