diff options
author | Phil Hughes <me@iamphill.com> | 2017-06-30 14:10:12 +0000 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2017-07-04 21:36:39 +0100 |
commit | 9883dae4e1b10b48ccafa1aa8a8bd2e2e1a1cdb3 (patch) | |
tree | 08914e9c4dc2eaf906aa0b274cbb727f3f63cfd8 /spec | |
parent | 55fe1fc927a26e3821e1369ab85ee1e6697878ae (diff) | |
download | gitlab-ce-9883dae4e1b10b48ccafa1aa8a8bd2e2e1a1cdb3.tar.gz |
Merge branch '34470-fix-award-slash-command-placeholder' into 'master'
Remove placeholder note when award emoji slash command is applied
Closes #34470
See merge request !12545
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/notes_spec.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/javascripts/notes_spec.js b/spec/javascripts/notes_spec.js index 0ae0b2fd103..470193b50f7 100644 --- a/spec/javascripts/notes_spec.js +++ b/spec/javascripts/notes_spec.js @@ -523,6 +523,51 @@ import '~/notes'; }); }); + describe('postComment with Slash commands', () => { + const sampleComment = '/assign @root\n/award :100:'; + const note = { + commands_changes: { + assignee_id: 1, + emoji_award: '100' + }, + errors: { + commands_only: ['Commands applied'] + }, + valid: false + }; + let $form; + let $notesContainer; + + beforeEach(() => { + this.notes = new Notes('', []); + window.gon.current_username = 'root'; + window.gon.current_user_fullname = 'Administrator'; + gl.awardsHandler = { + addAwardToEmojiBar: () => {}, + scrollToAwards: () => {} + }; + gl.GfmAutoComplete = { + dataSources: { + commands: '/root/test-project/autocomplete_sources/commands' + } + }; + $form = $('form.js-main-target-form'); + $notesContainer = $('ul.main-notes-list'); + $form.find('textarea.js-note-text').val(sampleComment); + }); + + it('should remove slash command placeholder when comment with slash commands is done posting', () => { + const deferred = $.Deferred(); + spyOn($, 'ajax').and.returnValue(deferred.promise()); + spyOn(gl.awardsHandler, 'addAwardToEmojiBar').and.callThrough(); + $('.js-comment-button').click(); + + expect($notesContainer.find('.system-note.being-posted').length).toEqual(1); // Placeholder shown + deferred.resolve(note); + expect($notesContainer.find('.system-note.being-posted').length).toEqual(0); // Placeholder removed + }); + }); + describe('update comment with script tags', () => { const sampleComment = '<script></script>'; const updatedComment = '<script></script>'; |