Merge branch 'ml-qa-add-members' into 'master'

QA: Add test of adding a member to a project

See merge request gitlab-org/gitlab-ce!21753
This commit is contained in:
Rémy Coutable 2018-10-11 08:40:59 +00:00
commit f5c8923ac2
8 changed files with 83 additions and 4 deletions

View file

@ -309,7 +309,7 @@
%span
= _('General')
= nav_link(controller: :project_members) do
= link_to project_project_members_path(@project), title: _('Members') do
= link_to project_project_members_path(@project), title: _('Members'), class: 'qa-link-members-settings' do
%span
= _('Members')
- if can_edit

View file

@ -3,7 +3,7 @@
= form_for @project_member, as: :project_member, url: project_project_members_path(@project), html: { class: 'users-project-form' } do |f|
.form-group
= label_tag :user_ids, "Select members to invite", class: "label-bold"
= users_select_tag(:user_ids, multiple: true, class: "input-clamp", scope: :all, email_user: true, placeholder: "Search for members to update or invite")
= users_select_tag(:user_ids, multiple: true, class: "input-clamp qa-member-select-input", scope: :all, email_user: true, placeholder: "Search for members to update or invite")
.form-group
= label_tag :access_level, "Choose a role permission", class: "label-bold"
.select-wrapper
@ -17,5 +17,5 @@
= label_tag :expires_at, 'Access expiration date', class: 'label-bold'
= text_field_tag :expires_at, nil, class: 'form-control js-access-expiration-date', placeholder: 'Expiration date'
%i.clear-icon.js-clear-input
= f.submit "Add to project", class: "btn btn-success"
= f.submit "Add to project", class: "btn btn-success qa-add-member-button"
= link_to "Import", import_project_project_members_path(@project), class: "btn btn-default", title: "Import members from another project"

View file

@ -14,5 +14,5 @@
%button.member-search-btn{ type: "submit", "aria-label" => "Submit search" }
= icon("search")
= render 'shared/members/sort_dropdown'
%ul.content-list.members-list
%ul.content-list.members-list.qa-members-list
= render partial: 'shared/members/member', collection: members, as: :member

View file

@ -180,6 +180,7 @@ module QA
autoload :SecretVariables, 'qa/page/project/settings/secret_variables'
autoload :Runners, 'qa/page/project/settings/runners'
autoload :MergeRequest, 'qa/page/project/settings/merge_request'
autoload :Members, 'qa/page/project/settings/members'
end
module Issue
@ -267,6 +268,7 @@ module QA
autoload :GroupsFilter, 'qa/page/component/groups_filter'
autoload :Select2, 'qa/page/component/select2'
autoload :DropdownFilter, 'qa/page/component/dropdown_filter'
autoload :UsersSelect, 'qa/page/component/users_select'
module Issuable
autoload :Common, 'qa/page/component/issuable/common'

View file

@ -0,0 +1,14 @@
# frozen_string_literal: true
module QA
module Page
module Component
module UsersSelect
def select_user(element, username)
find("#{element_selector_css(element)} input").set(username)
find('.ajax-users-dropdown .user-username', text: "@#{username}").click
end
end
end
end
end

View file

@ -9,6 +9,7 @@ module QA
element :settings_link, 'link_to edit_project_path'
element :repository_link, "title: _('Repository')"
element :link_pipelines
element :link_members_settings
element :pipelines_settings_link, "title: _('CI / CD')"
element :operations_kubernetes_link, "title: _('Kubernetes')"
element :operations_environments_link
@ -51,6 +52,14 @@ module QA
end
end
def click_members_settings
hover_settings do
within_submenu do
click_element :link_members_settings
end
end
end
def click_operations_kubernetes
hover_operations do
within_submenu do

View file

@ -0,0 +1,27 @@
# frozen_string_literal: true
module QA
module Page
module Project
module Settings
class Members < Page::Base
include Page::Component::UsersSelect
view 'app/views/projects/project_members/_new_project_member.html.haml' do
element :member_select_input
element :add_member_button
end
view 'app/views/projects/project_members/_team.html.haml' do
element :members_list
end
def add_member(username)
select_user :member_select_input, username
click_element :add_member_button
end
end
end
end
end
end

View file

@ -0,0 +1,27 @@
# frozen_string_literal: true
module QA
context :manage do
describe 'Add project member' do
it 'user adds project member' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
user = Factory::Resource::User.fabricate!
Page::Main::Menu.perform { |main| main.sign_out }
Page::Main::Login.act { sign_in_using_credentials }
Factory::Resource::Project.fabricate! do |resource|
resource.name = 'add-member-project'
end
Page::Project::Menu.act { click_members_settings }
Page::Project::Settings::Members.perform do |page|
page.add_member(user.username)
end
expect(page).to have_content("#{user.name} @#{user.username} Given access")
end
end
end
end