2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
RSpec.describe 'Groups > Members > Manage members', feature_category: :subgroups do
|
2023-06-20 00:43:36 +05:30
|
|
|
include Features::MembersHelpers
|
|
|
|
include Features::InviteMembersModalHelpers
|
2022-01-26 12:08:38 +05:30
|
|
|
include Spec::Support::Helpers::ModalHelpers
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
let_it_be(:user1) { create(:user, name: 'John Doe') }
|
|
|
|
let_it_be(:user2) { create(:user, name: 'Mary Jane') }
|
|
|
|
let_it_be(:group) { create(:group) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
before do
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(user1)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
shared_examples 'includes the correct Invite link' do |should_include|
|
|
|
|
it 'includes the modal trigger', :aggregate_failures do
|
2021-03-08 18:12:59 +05:30
|
|
|
group.add_owner(user1)
|
|
|
|
|
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
|
|
|
expect(page).to have_selector(should_include)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
it_behaves_like 'includes the correct Invite link', '.js-invite-members-trigger'
|
|
|
|
it_behaves_like 'includes the correct Invite link', '.js-invite-group-trigger'
|
2021-03-08 18:12:59 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'update user to owner level', :js do
|
2017-08-17 22:00:37 +05:30
|
|
|
group.add_owner(user1)
|
|
|
|
group.add_developer(user2)
|
|
|
|
|
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
|
|
|
page.within(second_row) do
|
|
|
|
click_button('Developer')
|
2021-01-29 00:20:46 +05:30
|
|
|
click_button('Owner')
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
expect(page).to have_button('Owner')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'remove user from group', :js do
|
2017-09-10 17:25:29 +05:30
|
|
|
group.add_owner(user1)
|
|
|
|
group.add_developer(user2)
|
|
|
|
|
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
# Open modal
|
2021-01-29 00:20:46 +05:30
|
|
|
page.within(second_row) do
|
2023-03-17 16:20:25 +05:30
|
|
|
show_actions
|
|
|
|
click_button _('Remove member')
|
2021-01-29 00:20:46 +05:30
|
|
|
end
|
2020-07-28 23:09:34 +05:30
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
within_modal do
|
2021-01-29 00:20:46 +05:30
|
|
|
expect(page).to have_unchecked_field 'Also unassign this user from related issues and merge requests'
|
2023-03-17 16:20:25 +05:30
|
|
|
click_button _('Remove member')
|
2021-01-29 00:20:46 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
wait_for_requests
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
aggregate_failures do
|
|
|
|
expect(page).not_to have_content(user2.name)
|
|
|
|
expect(group.users).not_to include(user2)
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
context 'when inviting' do
|
|
|
|
it 'add yourself to group when already an owner', :js do
|
|
|
|
group.add_owner(user1)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
visit group_group_members_path(group)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
invite_member(user1.name, role: 'Reporter')
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
invite_modal = page.find(invite_modal_selector)
|
|
|
|
expect(invite_modal).to have_content("not authorized to update member")
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
page.refresh
|
2019-10-12 21:52:04 +05:30
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
page.within find_member_row(user1) do
|
|
|
|
expect(page).to have_content('Owner')
|
2021-09-04 01:27:46 +05:30
|
|
|
end
|
2022-06-21 17:19:12 +05:30
|
|
|
end
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
it_behaves_like 'inviting members', 'group-members-page' do
|
|
|
|
let_it_be(:entity) { group }
|
|
|
|
let_it_be(:members_page_path) { group_group_members_path(entity) }
|
|
|
|
let_it_be(:subentity) { create(:group, parent: group) }
|
|
|
|
let_it_be(:subentity_members_page_path) { group_group_members_path(subentity) }
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
context 'when user is a guest' do
|
2021-06-08 01:23:25 +05:30
|
|
|
before do
|
|
|
|
group.add_guest(user1)
|
|
|
|
group.add_developer(user2)
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
visit group_group_members_path(group)
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
it 'does not include either of the invite members or invite group modal buttons', :aggregate_failures do
|
|
|
|
expect(page).not_to have_selector '.js-invite-members-modal'
|
|
|
|
expect(page).not_to have_selector '.js-invite-group-modal'
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
it 'does not include a button on the members page list to manage or remove the existing member', :js, :aggregate_failures do
|
2021-06-08 01:23:25 +05:30
|
|
|
page.within(second_row) do
|
|
|
|
# Can not modify user2 role
|
|
|
|
expect(page).not_to have_button 'Developer'
|
|
|
|
|
|
|
|
# Can not remove user2
|
|
|
|
expect(page).not_to have_selector 'button[title="Remove member"]'
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
2022-06-21 17:19:12 +05:30
|
|
|
|
|
|
|
describe 'member search results', :js do
|
|
|
|
before do
|
|
|
|
group.add_owner(user1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not disclose email addresses' do
|
|
|
|
create(:user, email: 'undisclosed_email@gitlab.com', name: "Jane 'invisible' Doe")
|
|
|
|
|
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
|
|
|
click_on 'Invite members'
|
|
|
|
find(member_dropdown_selector).set('@gitlab.com')
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_content('No matches found')
|
|
|
|
|
|
|
|
find(member_dropdown_selector).set('undisclosed_email@gitlab.com')
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_content('Invite "undisclosed_email@gitlab.com" by email')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show project_bots', :aggregate_failures do
|
|
|
|
internal_project_bot = create(:user, :project_bot, name: '_internal_project_bot_')
|
|
|
|
project = create(:project, group: group)
|
|
|
|
project.add_maintainer(internal_project_bot)
|
|
|
|
|
|
|
|
external_group = create(:group)
|
|
|
|
external_project_bot = create(:user, :project_bot, name: '_external_project_bot_')
|
|
|
|
external_project = create(:project, group: external_group)
|
|
|
|
external_project.add_maintainer(external_project_bot)
|
|
|
|
external_project.add_maintainer(user1)
|
|
|
|
|
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
|
|
|
click_on 'Invite members'
|
|
|
|
|
|
|
|
page.within invite_modal_selector do
|
|
|
|
field = find(member_dropdown_selector)
|
|
|
|
field.native.send_keys :tab
|
|
|
|
field.click
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_content(user1.name)
|
|
|
|
expect(page).to have_content(user2.name)
|
|
|
|
expect(page).not_to have_content(internal_project_bot.name)
|
|
|
|
expect(page).not_to have_content(external_project_bot.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|