Commit 5c6a49e7 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch...

Merge branch '33093-correct-misleading-error-message-regarding-related-issues-should-say-the-issue-is-already-linked' into 'master'

Used correct backend error message for related issues

See merge request gitlab-org/gitlab!19115
parents a38176d7 2cd8fda6
......@@ -149,11 +149,11 @@ export default {
// Close the form on submission
this.isFormVisible = false;
})
.catch(res => {
.catch(({ response }) => {
this.isSubmitting = false;
let errorMessage = addRelatedIssueErrorMap[this.issuableType];
if (res.data && res.data.message) {
errorMessage = res.data.message;
if (response && response.data && response.data.message) {
errorMessage = response.data.message;
}
Flash(errorMessage);
});
......
......@@ -184,6 +184,22 @@ describe('RelatedIssuesRoot', () => {
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', () => {
......
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