Commit 2cd8fda6 authored by Donald Cook's avatar Donald Cook Committed by Natalia Tepluhina

Used correct backend error message for related issues

parent a38176d7
...@@ -149,11 +149,11 @@ export default { ...@@ -149,11 +149,11 @@ export default {
// Close the form on submission // Close the form on submission
this.isFormVisible = false; this.isFormVisible = false;
}) })
.catch(res => { .catch(({ response }) => {
this.isSubmitting = false; this.isSubmitting = false;
let errorMessage = addRelatedIssueErrorMap[this.issuableType]; let errorMessage = addRelatedIssueErrorMap[this.issuableType];
if (res.data && res.data.message) { if (response && response.data && response.data.message) {
errorMessage = res.data.message; errorMessage = response.data.message;
} }
Flash(errorMessage); Flash(errorMessage);
}); });
......
...@@ -184,6 +184,22 @@ describe('RelatedIssuesRoot', () => { ...@@ -184,6 +184,22 @@ describe('RelatedIssuesRoot', () => {
done(); done();
}); });
}); });
it('displays a message from the backend upon error', done => {
const input = '#123';
const message = 'error';
mock.onAny().reply(409, { message });
document.body.innerHTML += '<div class="flash-container"></div>';
vm.onPendingFormSubmit(input);
setTimeout(() => {
expect(document.querySelector('.flash-text').innerText.trim()).toContain(message);
document.querySelector('.flash-container').remove();
done();
});
});
}); });
describe('onPendingFormCancel', () => { describe('onPendingFormCancel', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment