Commit 21b028b5 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve tests and make preview for notes

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 9305ef89
...@@ -41,6 +41,9 @@ class Notes ...@@ -41,6 +41,9 @@ class Notes
# add diff note # add diff note
$(document).on "click", ".js-add-diff-note-button", @addDiffNote $(document).on "click", ".js-add-diff-note-button", @addDiffNote
# hide diff note form
$(document).on "click", ".js-close-discussion-note-form", @cancelDiscussionForm
cleanBinding: -> cleanBinding: ->
$(document).off "ajax:success", ".js-main-target-form" $(document).off "ajax:success", ".js-main-target-form"
$(document).off "ajax:success", ".js-discussion-note-form" $(document).off "ajax:success", ".js-discussion-note-form"
...@@ -350,6 +353,15 @@ class Notes ...@@ -350,6 +353,15 @@ class Notes
form.removeClass "js-new-note-form" form.removeClass "js-new-note-form"
form.removeClass "js-new-note-form" form.removeClass "js-new-note-form"
GitLab.GfmAutoComplete.setup() 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() form.show()
### ###
...@@ -394,4 +406,11 @@ class Notes ...@@ -394,4 +406,11 @@ class Notes
# only remove the form # only remove the form
form.remove() form.remove()
cancelDiscussionForm: (e) =>
e.preventDefault()
form = $(".js-new-note-form")
form = $(e.target).closest(".js-discussion-note-form")
@removeDiscussionNoteForm(form)
@Notes = Notes @Notes = Notes
...@@ -115,19 +115,26 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -115,19 +115,26 @@ class ProjectMergeRequests < Spinach::FeatureSteps
And 'I leave a comment on the diff page' do And 'I leave a comment on the diff page' do
init_diff_note 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" fill_in "note_note", with: "One comment to rule them all"
click_button "Add Comment" click_button "Add Comment"
end end
within ".note-text" do
page.should have_content "One comment to rule them all"
end
end end
And 'I leave a comment like "Line is wrong" on line 185 of the first file' do And 'I leave a comment like "Line is wrong" on line 185 of the first file' do
init_diff_note init_diff_note
within(".js-temp-notes-holder") do within(".js-discussion-note-form") do
fill_in "note_note", with: "Line is wrong" fill_in "note_note", with: "Line is wrong"
click_button "Add Comment" click_button "Add Comment"
sleep 0.05 end
within ".note-text" do
page.should have_content "Line is wrong"
end end
end end
......
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