Commit 8286c6f6 authored by Sanad Liaquat's avatar Sanad Liaquat

Add e2e test for Share groups with groups

Add necessary page objects and setup.
Refactor group/sub_menu/members into group/members
parent 8214da07
......@@ -26,7 +26,7 @@
= image_tag avatar_icon_for_user(project.creator, 48), class: "avatar s48", alt:''
- else
= project_icon(project, alt: '', class: 'avatar project-avatar s48', width: 48, height: 48)
.project-details.d-sm-flex.flex-sm-fill.align-items-center{ data: { qa_selector: 'project', qa_project_name: project.name } }
.project-details.d-sm-flex.flex-sm-fill.align-items-center{ data: { qa_selector: 'project_content', qa_project_name: project.name } }
.flex-wrapper
.d-flex.align-items-center.flex-wrap.project-title
%h2.d-flex.gl-mt-3
......@@ -51,7 +51,7 @@
-# haml-lint:disable UnnecessaryStringOutput
= ' ' # prevent haml from eating the space between elements
.metadata-info.gl-mt-3
%span.user-access-role.d-block= Gitlab::Access.human_access(access)
%span.user-access-role.d-block{ data: { qa_selector: 'user_role_content' } }= Gitlab::Access.human_access(access)
- if !explore_projects_tab?
.metadata-info.gl-mt-3
......
......@@ -208,6 +208,7 @@ module QA
autoload :New, 'qa/page/group/new'
autoload :Show, 'qa/page/group/show'
autoload :Menu, 'qa/page/group/menu'
autoload :Members, 'qa/page/group/members'
module Milestone
autoload :Index, 'qa/page/group/milestone/index'
......@@ -216,7 +217,6 @@ module QA
module SubMenus
autoload :Common, 'qa/page/group/sub_menus/common'
autoload :Members, 'qa/page/group/sub_menus/members'
end
module Settings
......
......@@ -8,6 +8,17 @@ module QA
element :project_filter_form, required: true
end
view 'app/views/shared/projects/_project.html.haml' do
element :project_content
element :user_role_content
end
def has_project_with_access_role?(project_name, access_role)
within_element(:project_content, text: project_name) do
has_element?(:user_role_content, text: access_role)
end
end
def go_to_project(name)
filter_by_name(name)
......
# frozen_string_literal: true
module QA
module Page
module Group
class Members < Page::Base
include QA::Page::Component::Select2
include Page::Component::UsersSelect
view 'app/assets/javascripts/vue_shared/components/remove_member_modal.vue' do
element :remove_member_modal_content
end
view 'app/views/shared/members/_invite_member.html.haml' do
element :member_select_field
element :invite_member_button
end
view 'app/views/shared/members/_member.html.haml' do
element :member_row
element :access_level_dropdown
element :delete_member_button
element :developer_access_level_link, 'qa_selector: "#{role.downcase}_access_level_link"' # rubocop:disable QA/ElementWithPattern, Lint/InterpolationCheck
end
view 'app/views/groups/group_members/index.html.haml' do
element :invite_group_tab
element :groups_list
end
view 'app/views/shared/members/_invite_group.html.haml' do
element :group_select_field
element :invite_group_button
end
view 'app/views/shared/members/_group.html.haml' do
element :group_row
end
def select_group(group_name)
click_element :group_select_field
search_and_select(group_name)
end
def invite_group(group_name)
click_element :invite_group_tab
select_group(group_name)
click_element :invite_group_button
end
def add_member(username)
select_user :member_select_field, username
click_element :invite_member_button
end
def update_access_level(username, access_level)
within_element(:member_row, text: username) do
click_element :access_level_dropdown
click_element "#{access_level.downcase}_access_level_link"
end
end
def remove_member(username)
within_element(:member_row, text: username) do
click_element :delete_member_button
end
within_element(:remove_member_modal_content) do
click_button("Remove member")
end
end
def has_existing_group_share?(group_name)
within_element(:groups_list) do
has_element?(:group_row, text: group_name)
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module Page
module Group
module SubMenus
class Members < Page::Base
include Page::Component::UsersSelect
view 'app/assets/javascripts/vue_shared/components/remove_member_modal.vue' do
element :remove_member_modal_content
end
view 'app/views/shared/members/_invite_member.html.haml' do
element :member_select_field
element :invite_member_button
end
view 'app/views/shared/members/_member.html.haml' do
element :member_row
element :access_level_dropdown
element :delete_member_button
element :developer_access_level_link, 'qa_selector: "#{role.downcase}_access_level_link"' # rubocop:disable QA/ElementWithPattern, Lint/InterpolationCheck
end
def add_member(username)
select_user :member_select_field, username
click_element :invite_member_button
end
def update_access_level(username, access_level)
within_element(:member_row, text: username) do
click_element :access_level_dropdown
click_element "#{access_level.downcase}_access_level_link"
end
end
def remove_member(username)
within_element(:member_row, text: username) do
click_element :delete_member_button
end
within_element(:remove_member_modal_content) do
click_button("Remove member")
end
end
end
end
end
end
end
......@@ -16,7 +16,7 @@ module QA
end
view 'app/views/shared/projects/_project.html.haml' do
element :project
element :project_content
end
def switch_to_code
......@@ -40,7 +40,7 @@ module QA
end
def has_project?(project_name)
has_element?(:project, project_name: project_name)
has_element?(:project_content, project_name: project_name)
end
private
......
......@@ -98,7 +98,7 @@ module QA
sign_in
@group.visit!
Page::Group::Menu.perform(&:click_group_members_item)
Page::Group::SubMenus::Members.perform do |members_page|
Page::Group::Members.perform do |members_page|
members_page.add_member(user.username)
members_page.update_access_level(user.username, "Developer")
members_page.remove_member(user.username)
......
# frozen_string_literal: true
module QA
RSpec.describe 'Manage' do
describe 'Group with members' do
let(:admin_api_client) { Runtime::API::Client.as_admin }
let(:source_group_with_members) do
Resource::Group.fabricate_via_api! do |group|
group.path = "source-group-with-members_#{SecureRandom.hex(8)}"
end
end
let(:target_group_with_project) do
Resource::Group.fabricate_via_api! do |group|
group.path = "target-group-with-project_#{SecureRandom.hex(8)}"
end
end
let!(:project) do
Resource::Project.fabricate_via_api! do |project|
project.group = target_group_with_project
project.initialize_with_readme = true
end
end
let(:maintainer_user) do
Resource::User.fabricate_via_api! do |resource|
resource.api_client = admin_api_client
end
end
before do
source_group_with_members.add_member(maintainer_user, Resource::Members::AccessLevel::MAINTAINER)
end
it 'can be shared with another group with correct access level', :requires_admin do
Flow::Login.sign_in
target_group_with_project.visit!
Page::Group::Menu.perform(&:click_group_members_item)
Page::Group::Members.perform do |members|
members.invite_group(source_group_with_members.path)
expect(members).to have_existing_group_share(source_group_with_members.path)
end
Page::Main::Menu.perform(&:sign_out)
Flow::Login.sign_in(as: maintainer_user)
Page::Dashboard::Projects.perform do |projects|
expect(projects).to have_project_with_access_role(project.name, "Guest")
end
end
end
end
end
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