2020-03-13 15:44:24 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
RSpec.describe 'Groups > Members > Manage groups', :js, 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
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
let_it_be(:user) { create(:user) }
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
context 'when group link does not exist' do
|
|
|
|
it 'can share a group with group' do
|
|
|
|
group = create(:group)
|
|
|
|
group_to_add = create(:group)
|
|
|
|
group.add_owner(user)
|
|
|
|
group_to_add.add_owner(user)
|
|
|
|
|
|
|
|
visit group_group_members_path(group)
|
|
|
|
invite_group(group_to_add.name, role: 'Reporter')
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
click_groups_tab
|
|
|
|
|
|
|
|
page.within(first_row) do
|
|
|
|
expect(page).to have_content(group_to_add.name)
|
|
|
|
expect(page).to have_content('Reporter')
|
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
context 'when group link exists' do
|
|
|
|
let_it_be(:shared_with_group) { create(:group) }
|
|
|
|
let_it_be(:shared_group) { create(:group) }
|
2021-11-18 22:05:49 +05:30
|
|
|
let_it_be(:expiration_date) { 5.days.from_now.to_date }
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
let(:additional_link_attrs) { {} }
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
let_it_be(:group_link, refind: true) do
|
|
|
|
create(
|
|
|
|
:group_group_link,
|
|
|
|
shared_group: shared_group,
|
|
|
|
shared_with_group: shared_with_group,
|
|
|
|
group_access: ::Gitlab::Access::DEVELOPER
|
|
|
|
)
|
|
|
|
end
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
before do
|
|
|
|
group_link.update!(additional_link_attrs)
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
shared_group.add_owner(user)
|
|
|
|
visit group_group_members_path(shared_group)
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it 'remove group from group' do
|
|
|
|
click_groups_tab
|
|
|
|
|
|
|
|
expect(page).to have_content(shared_with_group.name)
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
page.within(first_row) do
|
|
|
|
click_button 'Remove group'
|
|
|
|
end
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
within_modal do
|
2021-01-29 00:20:46 +05:30
|
|
|
click_button('Remove group')
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).not_to have_content(shared_with_group.name)
|
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it 'update group to owner level' do
|
|
|
|
click_groups_tab
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
page.within(first_row) do
|
|
|
|
click_button('Developer')
|
2021-01-29 00:20:46 +05:30
|
|
|
click_button('Maintainer')
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
wait_for_requests
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
expect(page).to have_button('Maintainer')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates expiry date' do
|
|
|
|
click_groups_tab
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
page.within first_row do
|
2021-11-18 22:05:49 +05:30
|
|
|
fill_in 'Expiration date', with: expiration_date
|
2021-01-29 00:20:46 +05:30
|
|
|
find_field('Expiration date').native.send_keys :enter
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
wait_for_requests
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
expect(page).to have_field('Expiration date', with: expiration_date)
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when expiry date is set' do
|
2021-11-18 22:05:49 +05:30
|
|
|
let(:additional_link_attrs) { { expires_at: expiration_date } }
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
it 'clears expiry date' do
|
|
|
|
click_groups_tab
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
page.within first_row do
|
2021-11-18 22:05:49 +05:30
|
|
|
expect(page).to have_field('Expiration date', with: expiration_date)
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
find('[data-testid="clear-button"]').click
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
expect(page).to have_field('Expiration date', with: '')
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
describe 'group search results' do
|
|
|
|
let_it_be(:group, refind: true) { create(:group) }
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
it_behaves_like 'inviting groups search results' do
|
|
|
|
let_it_be(:entity) { group }
|
2022-06-21 17:19:12 +05:30
|
|
|
let_it_be(:group_within_hierarchy) { create(:group, parent: group) }
|
2022-07-16 23:28:13 +05:30
|
|
|
let_it_be(:members_page_path) { group_group_members_path(entity) }
|
|
|
|
let_it_be(:members_page_path_within_hierarchy) { group_group_members_path(group_within_hierarchy) }
|
2021-09-04 01:27:46 +05:30
|
|
|
end
|
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|