From 654f7fe8ffbce488c11c38f46e2b2f3bea3b9fee Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Sat, 26 Jan 2019 00:39:28 +0000 Subject: [PATCH] Wait for requests in specs before interacting with select2 --- .../projects/settings/user_changes_default_branch_spec.rb | 3 --- spec/support/helpers/select2_helper.rb | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/features/projects/settings/user_changes_default_branch_spec.rb b/spec/features/projects/settings/user_changes_default_branch_spec.rb index 7dc18601f50..fcf05e04a5c 100644 --- a/spec/features/projects/settings/user_changes_default_branch_spec.rb +++ b/spec/features/projects/settings/user_changes_default_branch_spec.rb @@ -15,9 +15,6 @@ describe 'Projects > Settings > User changes default branch' do let(:project) { create(:project, :repository, namespace: user.namespace) } 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') page.within '#default-branch-settings' do diff --git a/spec/support/helpers/select2_helper.rb b/spec/support/helpers/select2_helper.rb index 90618ba5b19..100e62489ab 100644 --- a/spec/support/helpers/select2_helper.rb +++ b/spec/support/helpers/select2_helper.rb @@ -11,9 +11,13 @@ # module Select2Helper + include WaitForRequests + def select2(value, options = {}) raise ArgumentError, 'options must be a Hash' unless options.is_a?(Hash) + wait_for_requests unless options[:async] + selector = options.fetch(:from) first(selector, visible: false) -- GitLab