Commit bdb4945d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix random failing test - delete attachment

Make sure we wait for AJAX request to finish before end test and cleanup
database
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 2928e19d
...@@ -369,8 +369,8 @@ class @Notes ...@@ -369,8 +369,8 @@ class @Notes
note = $(this).closest(".note") note = $(this).closest(".note")
note.find(".note-attachment").remove() note.find(".note-attachment").remove()
note.find(".note-body > .note-text").show() note.find(".note-body > .note-text").show()
note.find(".js-note-attachment-delete").hide() note.find(".note-header").show()
note.find(".note-edit-form").hide() note.find(".current-note-edit-form").remove()
### ###
Called when clicking on the "reply" button for a diff line. Called when clicking on the "reply" button for a diff line.
......
...@@ -2,6 +2,7 @@ require 'spec_helper' ...@@ -2,6 +2,7 @@ require 'spec_helper'
describe 'Comments', feature: true do describe 'Comments', feature: true do
include RepoHelpers include RepoHelpers
include WaitForAjax
describe 'On a merge request', js: true, feature: true do describe 'On a merge request', js: true, feature: true do
let!(:merge_request) { create(:merge_request) } let!(:merge_request) { create(:merge_request) }
...@@ -123,8 +124,8 @@ describe 'Comments', feature: true do ...@@ -123,8 +124,8 @@ describe 'Comments', feature: true do
it 'removes the attachment div and resets the edit form' do it 'removes the attachment div and resets the edit form' do
find('.js-note-attachment-delete').click find('.js-note-attachment-delete').click
is_expected.not_to have_css('.note-attachment') is_expected.not_to have_css('.note-attachment')
expect(find('.current-note-edit-form', visible: false)). is_expected.not_to have_css('.current-note-edit-form')
not_to be_visible wait_for_ajax
end end
end end
end end
......
module WaitForAjax
def wait_for_ajax
Timeout.timeout(Capybara.default_wait_time) do
loop until finished_all_ajax_requests?
end
end
def finished_all_ajax_requests?
page.evaluate_script('jQuery.active').zero?
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