diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee index 58720cbc3dd1f558ef096e176773880b9a92ed9b..f90f91b4fabcd90bb4425d58ed9b3490d9cf3b83 100644 --- a/app/assets/javascripts/notes.js.coffee +++ b/app/assets/javascripts/notes.js.coffee @@ -41,6 +41,9 @@ class Notes # add diff note $(document).on "click", ".js-add-diff-note-button", @addDiffNote + # hide diff note form + $(document).on "click", ".js-close-discussion-note-form", @cancelDiscussionForm + cleanBinding: -> $(document).off "ajax:success", ".js-main-target-form" $(document).off "ajax:success", ".js-discussion-note-form" @@ -350,6 +353,15 @@ class Notes form.removeClass "js-new-note-form" form.removeClass "js-new-note-form" GitLab.GfmAutoComplete.setup() + + # setup preview buttons + previewButton = form.find(".js-note-preview-button") + form.find(".js-note-text").on "input", -> + if $(this).val().trim() isnt "" + previewButton.removeClass("turn-off").addClass "turn-on" + else + previewButton.removeClass("turn-on").addClass "turn-off" + form.show() ### @@ -394,4 +406,11 @@ class Notes # only remove the form form.remove() + + cancelDiscussionForm: (e) => + e.preventDefault() + form = $(".js-new-note-form") + form = $(e.target).closest(".js-discussion-note-form") + @removeDiscussionNoteForm(form) + @Notes = Notes diff --git a/features/steps/project/project_merge_requests.rb b/features/steps/project/project_merge_requests.rb index 3dc934a6118fb2a7e0ed2b9a8c8df84e81a14b49..7b0f8cc7ad2c52f353b323086c5eaf03bcabc573 100644 --- a/features/steps/project/project_merge_requests.rb +++ b/features/steps/project/project_merge_requests.rb @@ -115,19 +115,26 @@ class ProjectMergeRequests < Spinach::FeatureSteps And 'I leave a comment on the diff page' do init_diff_note - within('.js-temp-notes-holder') do + within('.js-discussion-note-form') do fill_in "note_note", with: "One comment to rule them all" click_button "Add Comment" end + + within ".note-text" do + page.should have_content "One comment to rule them all" + end end And 'I leave a comment like "Line is wrong" on line 185 of the first file' do init_diff_note - within(".js-temp-notes-holder") do + within(".js-discussion-note-form") do fill_in "note_note", with: "Line is wrong" click_button "Add Comment" - sleep 0.05 + end + + within ".note-text" do + page.should have_content "Line is wrong" end end