2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'Groups > Members > Manage members' do
|
2021-01-29 00:20:46 +05:30
|
|
|
include Spec::Support::Helpers::Features::MembersHelpers
|
2021-06-08 01:23:25 +05:30
|
|
|
include Spec::Support::Helpers::Features::InviteMembersModalHelper
|
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
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
it 'add user to group', :js, :snowplow, :aggregate_failures do
|
2017-08-17 22:00:37 +05:30
|
|
|
group.add_owner(user1)
|
|
|
|
|
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
invite_member(user2.name, role: 'Reporter')
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
page.within(second_row) do
|
|
|
|
expect(page).to have_content(user2.name)
|
|
|
|
expect(page).to have_button('Reporter')
|
|
|
|
end
|
2021-09-04 01:27:46 +05:30
|
|
|
|
|
|
|
expect_snowplow_event(
|
|
|
|
category: 'Members::CreateService',
|
|
|
|
action: 'create_member',
|
|
|
|
label: 'group-members-page',
|
|
|
|
property: 'existing_user',
|
|
|
|
user: user1
|
|
|
|
)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'do not disclose email addresses', :js do
|
2018-03-17 18:26:18 +05:30
|
|
|
group.add_owner(user1)
|
|
|
|
create(:user, email: 'undisclosed_email@gitlab.com', name: "Jane 'invisible' Doe")
|
|
|
|
|
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
click_on 'Invite members'
|
2021-09-30 23:02:18 +05:30
|
|
|
find('[data-testid="members-token-select-input"]').set('@gitlab.com')
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_content('No matches found')
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
find('[data-testid="members-token-select-input"]').set('undisclosed_email@gitlab.com')
|
2018-03-17 18:26:18 +05:30
|
|
|
wait_for_requests
|
|
|
|
|
2022-02-05 19:09:49 +05:30
|
|
|
expect(page).to have_content('Invite "undisclosed_email@gitlab.com" by email')
|
2018-03-17 18:26:18 +05:30
|
|
|
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
|
|
|
|
click_button 'Remove member'
|
|
|
|
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'
|
|
|
|
click_button('Remove member')
|
|
|
|
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
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
it 'add yourself to group when already an owner', :js, :aggregate_failures do
|
2017-08-17 22:00:37 +05:30
|
|
|
group.add_owner(user1)
|
|
|
|
|
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
invite_member(user1.name, role: 'Reporter')
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
page.within(first_row) do
|
|
|
|
expect(page).to have_content(user1.name)
|
|
|
|
expect(page).to have_content('Owner')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
it 'invite user to group', :js, :snowplow do
|
2017-08-17 22:00:37 +05:30
|
|
|
group.add_owner(user1)
|
|
|
|
|
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
invite_member('test@example.com', role: 'Reporter')
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
expect(page).to have_link 'Invited'
|
|
|
|
click_link 'Invited'
|
2019-10-12 21:52:04 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
aggregate_failures do
|
|
|
|
page.within(members_table) do
|
|
|
|
expect(page).to have_content('test@example.com')
|
|
|
|
expect(page).to have_content('Invited')
|
|
|
|
expect(page).to have_button('Reporter')
|
|
|
|
end
|
|
|
|
|
|
|
|
expect_snowplow_event(
|
|
|
|
category: 'Members::InviteService',
|
|
|
|
action: 'create_member',
|
|
|
|
label: 'group-members-page',
|
|
|
|
property: 'net_new_user',
|
|
|
|
user: user1
|
|
|
|
)
|
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
|
|
|
|
end
|