Commit 88b727d7 authored by Mark Lapierre's avatar Mark Lapierre

CE backport of EE MR approvals E2E test

Includes API methods to add members to projects and groups
parent 34357e03
...@@ -167,6 +167,18 @@ There are two supported methods of defining elements within a view. ...@@ -167,6 +167,18 @@ There are two supported methods of defining elements within a view.
Any existing `.qa-selector` class should be considered deprecated Any existing `.qa-selector` class should be considered deprecated
and we should prefer the `data-qa-selector` method of definition. and we should prefer the `data-qa-selector` method of definition.
### Exceptions
In some cases it might not be possible or worthwhile to add a selector.
Some UI components use external libraries, including some maintained by third parties.
Even if a library is maintained by GitLab, the selector sanity test only runs
on code within the GitLab project, so it's not possible to specify the path for
the view for code in a library.
In such rare cases it's reasonable to use CSS selectors in page object methods,
with a comment explaining why an `element` can't be added.
## Running the test locally ## Running the test locally
During development, you can run the `qa:selectors` test by running During development, you can run the `qa:selectors` test by running
......
...@@ -61,6 +61,10 @@ module QA ...@@ -61,6 +61,10 @@ module QA
end end
end end
def sign_out_if_signed_in
sign_out if has_personal_area?(wait: 0)
end
def click_settings_link def click_settings_link
retry_until(reload: false) do retry_until(reload: false) do
within_user_menu do within_user_menu do
......
...@@ -64,3 +64,5 @@ module QA ...@@ -64,3 +64,5 @@ module QA
end end
end end
end end
QA::Page::MergeRequest::New.prepend_if_ee('QA::EE::Page::MergeRequest::New')
...@@ -10,6 +10,7 @@ module QA ...@@ -10,6 +10,7 @@ module QA
end end
attribute :id attribute :id
attribute :name
def initialize def initialize
@path = Runtime::Namespace.name @path = Runtime::Namespace.name
...@@ -47,6 +48,11 @@ module QA ...@@ -47,6 +48,11 @@ module QA
super super
end end
def add_member(user, access_level = '30')
# 30 = developer access
post Runtime::API::Request.new(api_client, api_members_path).url, { user_id: user.id, access_level: access_level }
end
def api_get_path def api_get_path
"/groups/#{CGI.escape("#{sandbox.path}/#{path}")}" "/groups/#{CGI.escape("#{sandbox.path}/#{path}")}"
end end
......
...@@ -5,7 +5,8 @@ require 'securerandom' ...@@ -5,7 +5,8 @@ require 'securerandom'
module QA module QA
module Resource module Resource
class MergeRequest < Base class MergeRequest < Base
attr_accessor :id, attr_accessor :approval_rules,
:id,
:title, :title,
:description, :description,
:source_branch, :source_branch,
...@@ -46,6 +47,7 @@ module QA ...@@ -46,6 +47,7 @@ module QA
end end
def initialize def initialize
@approval_rules = nil
@title = 'QA test - merge request' @title = 'QA test - merge request'
@description = 'This is a test merge request' @description = 'This is a test merge request'
@source_branch = "qa-test-feature-#{SecureRandom.hex(8)}" @source_branch = "qa-test-feature-#{SecureRandom.hex(8)}"
...@@ -63,16 +65,17 @@ module QA ...@@ -63,16 +65,17 @@ module QA
project.visit! project.visit!
Page::Project::Show.perform(&:new_merge_request) Page::Project::Show.perform(&:new_merge_request)
Page::MergeRequest::New.perform do |page| Page::MergeRequest::New.perform do |new|
page.fill_title(@title) new.fill_title(@title)
page.fill_description(@description) new.fill_description(@description)
page.choose_milestone(@milestone) if @milestone new.choose_milestone(@milestone) if @milestone
page.assign_to_me if @assignee == 'me' new.assign_to_me if @assignee == 'me'
labels.each do |label| labels.each do |label|
page.select_label(label) new.select_label(label)
end end
new.add_approval_rules(approval_rules) if approval_rules
page.create_merge_request new.create_merge_request
end end
end end
......
...@@ -75,6 +75,11 @@ module QA ...@@ -75,6 +75,11 @@ module QA
super super
end end
def add_member(user, access_level = '30')
# 30 = developer access
post Runtime::API::Request.new(api_client, api_members_path).url, { user_id: user.id, access_level: access_level }
end
def api_get_path def api_get_path
"/projects/#{CGI.escape(path_with_namespace)}" "/projects/#{CGI.escape(path_with_namespace)}"
end end
...@@ -83,6 +88,10 @@ module QA ...@@ -83,6 +88,10 @@ module QA
"#{api_get_path}/repository/archive.#{type}" "#{api_get_path}/repository/archive.#{type}"
end end
def api_members_path
"#{api_get_path}/members"
end
def api_post_path def api_post_path
'/projects' '/projects'
end end
......
...@@ -9,6 +9,7 @@ module QA ...@@ -9,6 +9,7 @@ module QA
attr_writer :username, :password attr_writer :username, :password
attr_accessor :provider, :extern_uid attr_accessor :provider, :extern_uid
attribute :id
attribute :name attribute :name
attribute :email attribute :email
......
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