Skip to content
代码片段 群组 项目
未验证 提交 531bbcb4 编辑于 作者: Paulina Sedlak-Jakubowska's avatar Paulina Sedlak-Jakubowska 提交者: GitLab
浏览文件

Merge branch '430214-forking-error' into 'master'

No related branches found
No related tags found
无相关合并请求
......@@ -283,10 +283,11 @@ export default {
redirectTo(data.web_url); // eslint-disable-line import/no-deprecated
} catch (error) {
this.isSaving = false;
const message =
error?.response?.data?.message?.join('. ') ||
s__('ForkProject|An error occurred while forking the project. Please try again.');
createAlert({
message: s__(
'ForkProject|An error occurred while forking the project. Please try again.',
),
message,
});
}
},
......
......@@ -578,7 +578,21 @@ describe('ForkForm component', () => {
expect(urlUtility.redirectTo).toHaveBeenCalledWith(webUrl); // eslint-disable-line import/no-deprecated
});
it('displays an alert when POST is unsuccessful', async () => {
it('displays an alert with message coming from server when POST is unsuccessful', async () => {
const error = { response: { data: { message: ['Update error'] } } };
jest.spyOn(axios, 'post').mockRejectedValue(error);
setupComponent();
await submitForm();
expect(urlUtility.redirectTo).not.toHaveBeenCalled(); // eslint-disable-line import/no-deprecated
expect(createAlert).toHaveBeenCalledWith({
message: 'Update error',
});
});
it('displays an alert with general error when POST is unsuccessful', async () => {
const dummyError = 'Fork project failed';
jest.spyOn(axios, 'post').mockRejectedValue(dummyError);
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册