diff options
author | Stan Hu <stanhu@gmail.com> | 2018-06-06 08:34:06 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-06-06 11:40:55 +0300 |
commit | 3a722ff53fe86ce6194f81ade810196f4f8e870c (patch) | |
tree | 86e7e1b0f8ff5baf148f8f3d03314f942ed0465d /spec/javascripts/importer_status_spec.js | |
parent | af07c490b2a32ed4c88e387d1133e7882f79abc5 (diff) |
Show a more helpful error for import status
Importing a project from GitHub for a project namespace that already exists
would show an unhelpful error, "An error occurred while importing project."
We now add the base message from Projects::CreateService when this fails.
Closes #47365
Diffstat (limited to 'spec/javascripts/importer_status_spec.js')
-rw-r--r-- | spec/javascripts/importer_status_spec.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/javascripts/importer_status_spec.js b/spec/javascripts/importer_status_spec.js index 87b46ccf7c3..63cdb3d5114 100644 --- a/spec/javascripts/importer_status_spec.js +++ b/spec/javascripts/importer_status_spec.js @@ -50,6 +50,24 @@ describe('Importer Status', () => { }) .catch(done.fail); }); + + it('shows error message after failed POST request', (done) => { + appendSetFixtures('<div class="flash-container"></div>'); + + mock.onPost(importUrl).reply(422, { + errors: 'You forgot your lunch', + }); + + instance.addToImport({ + currentTarget: document.querySelector('.js-add-to-import'), + }) + .then(() => { + const flashMessage = document.querySelector('.flash-text'); + expect(flashMessage.textContent.trim()).toEqual('An error occurred while importing project: You forgot your lunch'); + done(); + }) + .catch(done.fail); + }); }); describe('autoUpdate', () => { |