Fix random failing test - delete attachment
Make sure we wait for AJAX request to finish before end test and cleanup database Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
2928e19d43
commit
bdb4945dcf
3 changed files with 16 additions and 4 deletions
|
@ -369,8 +369,8 @@ class @Notes
|
|||
note = $(this).closest(".note")
|
||||
note.find(".note-attachment").remove()
|
||||
note.find(".note-body > .note-text").show()
|
||||
note.find(".js-note-attachment-delete").hide()
|
||||
note.find(".note-edit-form").hide()
|
||||
note.find(".note-header").show()
|
||||
note.find(".current-note-edit-form").remove()
|
||||
|
||||
###
|
||||
Called when clicking on the "reply" button for a diff line.
|
||||
|
|
|
@ -2,6 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe 'Comments', feature: true do
|
||||
include RepoHelpers
|
||||
include WaitForAjax
|
||||
|
||||
describe 'On a merge request', js: true, feature: true do
|
||||
let!(:merge_request) { create(:merge_request) }
|
||||
|
@ -123,8 +124,8 @@ describe 'Comments', feature: true do
|
|||
it 'removes the attachment div and resets the edit form' do
|
||||
find('.js-note-attachment-delete').click
|
||||
is_expected.not_to have_css('.note-attachment')
|
||||
expect(find('.current-note-edit-form', visible: false)).
|
||||
not_to be_visible
|
||||
is_expected.not_to have_css('.current-note-edit-form')
|
||||
wait_for_ajax
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
11
spec/support/wait_for_ajax.rb
Normal file
11
spec/support/wait_for_ajax.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
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
|
Loading…
Reference in a new issue