Commit 21b028b548affbaefceb71286b3046899b659cd8
1 parent
9305ef89
Exists in
spb-stable
and in
3 other branches
Improve tests and make preview for notes
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
2 changed files
with
29 additions
and
3 deletions
Show diff stats
app/assets/javascripts/notes.js.coffee
| ... | ... | @@ -41,6 +41,9 @@ class Notes |
| 41 | 41 | # add diff note |
| 42 | 42 | $(document).on "click", ".js-add-diff-note-button", @addDiffNote |
| 43 | 43 | |
| 44 | + # hide diff note form | |
| 45 | + $(document).on "click", ".js-close-discussion-note-form", @cancelDiscussionForm | |
| 46 | + | |
| 44 | 47 | cleanBinding: -> |
| 45 | 48 | $(document).off "ajax:success", ".js-main-target-form" |
| 46 | 49 | $(document).off "ajax:success", ".js-discussion-note-form" |
| ... | ... | @@ -350,6 +353,15 @@ class Notes |
| 350 | 353 | form.removeClass "js-new-note-form" |
| 351 | 354 | form.removeClass "js-new-note-form" |
| 352 | 355 | GitLab.GfmAutoComplete.setup() |
| 356 | + | |
| 357 | + # setup preview buttons | |
| 358 | + previewButton = form.find(".js-note-preview-button") | |
| 359 | + form.find(".js-note-text").on "input", -> | |
| 360 | + if $(this).val().trim() isnt "" | |
| 361 | + previewButton.removeClass("turn-off").addClass "turn-on" | |
| 362 | + else | |
| 363 | + previewButton.removeClass("turn-on").addClass "turn-off" | |
| 364 | + | |
| 353 | 365 | form.show() |
| 354 | 366 | |
| 355 | 367 | ### |
| ... | ... | @@ -394,4 +406,11 @@ class Notes |
| 394 | 406 | # only remove the form |
| 395 | 407 | form.remove() |
| 396 | 408 | |
| 409 | + | |
| 410 | + cancelDiscussionForm: (e) => | |
| 411 | + e.preventDefault() | |
| 412 | + form = $(".js-new-note-form") | |
| 413 | + form = $(e.target).closest(".js-discussion-note-form") | |
| 414 | + @removeDiscussionNoteForm(form) | |
| 415 | + | |
| 397 | 416 | @Notes = Notes | ... | ... |
features/steps/project/project_merge_requests.rb
| ... | ... | @@ -115,19 +115,26 @@ class ProjectMergeRequests < Spinach::FeatureSteps |
| 115 | 115 | And 'I leave a comment on the diff page' do |
| 116 | 116 | init_diff_note |
| 117 | 117 | |
| 118 | - within('.js-temp-notes-holder') do | |
| 118 | + within('.js-discussion-note-form') do | |
| 119 | 119 | fill_in "note_note", with: "One comment to rule them all" |
| 120 | 120 | click_button "Add Comment" |
| 121 | 121 | end |
| 122 | + | |
| 123 | + within ".note-text" do | |
| 124 | + page.should have_content "One comment to rule them all" | |
| 125 | + end | |
| 122 | 126 | end |
| 123 | 127 | |
| 124 | 128 | And 'I leave a comment like "Line is wrong" on line 185 of the first file' do |
| 125 | 129 | init_diff_note |
| 126 | 130 | |
| 127 | - within(".js-temp-notes-holder") do | |
| 131 | + within(".js-discussion-note-form") do | |
| 128 | 132 | fill_in "note_note", with: "Line is wrong" |
| 129 | 133 | click_button "Add Comment" |
| 130 | - sleep 0.05 | |
| 134 | + end | |
| 135 | + | |
| 136 | + within ".note-text" do | |
| 137 | + page.should have_content "Line is wrong" | |
| 131 | 138 | end |
| 132 | 139 | end |
| 133 | 140 | ... | ... |