Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2018-04-27 13:12:37 +0300
committerGrzegorz Bizon <grzegorz@gitlab.com>2018-04-27 13:12:37 +0300
commit3ade2b6c43db20ebccc77b02480a42cc3daf6b1e (patch)
tree63e1dfa695c6554fcf94dbff42bde39d9e575cd8 /qa
parentb51f6e2c214df34a94b9097355775f29b269524b (diff)
parent01ed8a8ac0ba51dbb48a5dd2696bf4acbe186733 (diff)
Merge branch 'qa-fix-protected-branches-test-ce' into 'master'
CE: Fix QA protected branches tests See merge request gitlab-org/gitlab-ce!18585
Diffstat (limited to 'qa')
-rw-r--r--qa/qa/factory/resource/branch.rb19
-rw-r--r--qa/qa/page/project/settings/protected_branches.rb29
-rw-r--r--qa/qa/specs/features/repository/protected_branches_spec.rb7
3 files changed, 49 insertions, 6 deletions
diff --git a/qa/qa/factory/resource/branch.rb b/qa/qa/factory/resource/branch.rb
index d6bfdfa2356..1785441f5a8 100644
--- a/qa/qa/factory/resource/branch.rb
+++ b/qa/qa/factory/resource/branch.rb
@@ -2,7 +2,8 @@ module QA
module Factory
module Resource
class Branch < Factory::Base
- attr_accessor :project, :branch_name, :allow_to_push, :protected
+ attr_accessor :project, :branch_name,
+ :allow_to_push, :allow_to_merge, :protected
dependency Factory::Resource::Project, as: :project do |project|
project.name = 'protected-branch-project'
@@ -23,6 +24,7 @@ module QA
def initialize
@branch_name = 'test/branch'
@allow_to_push = true
+ @allow_to_merge = true
@protected = false
end
@@ -65,7 +67,22 @@ module QA
page.allow_no_one_to_push
end
+ if allow_to_merge
+ page.allow_devs_and_masters_to_merge
+ else
+ page.allow_no_one_to_merge
+ end
+
+ page.wait(reload: false) do
+ !page.first('.btn-create').disabled?
+ end
+
page.protect_branch
+
+ # Wait for page load, which resets the expanded sections
+ page.wait(reload: false) do
+ !page.has_content?('Collapse')
+ end
end
end
end
diff --git a/qa/qa/page/project/settings/protected_branches.rb b/qa/qa/page/project/settings/protected_branches.rb
index f3563401124..63bc3aaa2bc 100644
--- a/qa/qa/page/project/settings/protected_branches.rb
+++ b/qa/qa/page/project/settings/protected_branches.rb
@@ -11,6 +11,13 @@ module QA
view 'app/views/projects/protected_branches/_create_protected_branch.html.haml' do
element :allowed_to_push_select
element :allowed_to_push_dropdown
+ element :allowed_to_merge_select
+ element :allowed_to_merge_dropdown
+ end
+
+ view 'app/views/projects/protected_branches/_update_protected_branch.html.haml' do
+ element :allowed_to_push
+ element :allowed_to_merge
end
view 'app/views/projects/protected_branches/shared/_branches_list.html.haml' do
@@ -30,11 +37,19 @@ module QA
end
def allow_no_one_to_push
- allow_to_push('No one')
+ click_allow(:push, 'No one')
end
def allow_devs_and_masters_to_push
- allow_to_push('Developers + Masters')
+ click_allow(:push, 'Developers + Masters')
+ end
+
+ def allow_no_one_to_merge
+ click_allow(:merge, 'No one')
+ end
+
+ def allow_devs_and_masters_to_merge
+ click_allow(:merge, 'Developers + Masters')
end
def protect_branch
@@ -55,11 +70,15 @@ module QA
private
- def allow_to_push(text)
- click_element :allowed_to_push_select
+ def click_allow(action, text)
+ click_element :"allowed_to_#{action}_select"
- within_element(:allowed_to_push_dropdown) do
+ within_element(:"allowed_to_#{action}_dropdown") do
click_on text
+
+ wait(reload: false) do
+ has_css?('.is-active')
+ end
end
end
end
diff --git a/qa/qa/specs/features/repository/protected_branches_spec.rb b/qa/qa/specs/features/repository/protected_branches_spec.rb
index 89f0e0673af..406b2772b64 100644
--- a/qa/qa/specs/features/repository/protected_branches_spec.rb
+++ b/qa/qa/specs/features/repository/protected_branches_spec.rb
@@ -19,6 +19,13 @@ module QA
Page::Main::Login.act { sign_in_using_credentials }
end
+ after do
+ # We need to clear localStorage because we're using it for the dropdown,
+ # and capybara doesn't do this for us.
+ # https://github.com/teamcapybara/capybara/issues/1702
+ Capybara.execute_script 'localStorage.clear()'
+ end
+
scenario 'user is able to protect a branch' do
protected_branch = Factory::Resource::Branch.fabricate! do |resource|
resource.branch_name = branch_name