Commit 52b07c80 authored by Sean McGivern's avatar Sean McGivern

Merge branch '56867-wait-for-requests-before-select2' into 'master'

Wait for requests in specs before interacting with select2

Closes #56867

See merge request gitlab-org/gitlab-ce!24694
parents 436a4334 654f7fe8
...@@ -15,9 +15,6 @@ describe 'Projects > Settings > User changes default branch' do ...@@ -15,9 +15,6 @@ describe 'Projects > Settings > User changes default branch' do
let(:project) { create(:project, :repository, namespace: user.namespace) } let(:project) { create(:project, :repository, namespace: user.namespace) }
it 'allows to change the default branch', :js do it 'allows to change the default branch', :js do
# Otherwise, running JS may overwrite our change to project_default_branch
wait_for_requests
select2('fix', from: '#project_default_branch') select2('fix', from: '#project_default_branch')
page.within '#default-branch-settings' do page.within '#default-branch-settings' do
......
...@@ -11,9 +11,13 @@ ...@@ -11,9 +11,13 @@
# #
module Select2Helper module Select2Helper
include WaitForRequests
def select2(value, options = {}) def select2(value, options = {})
raise ArgumentError, 'options must be a Hash' unless options.is_a?(Hash) raise ArgumentError, 'options must be a Hash' unless options.is_a?(Hash)
wait_for_requests unless options[:async]
selector = options.fetch(:from) selector = options.fetch(:from)
first(selector, visible: false) first(selector, visible: false)
......
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