diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/features/groups/members | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/features/groups/members')
-rw-r--r-- | spec/features/groups/members/manage_groups_spec.rb | 76 | ||||
-rw-r--r-- | spec/features/groups/members/manage_members_spec.rb | 59 | ||||
-rw-r--r-- | spec/features/groups/members/tabs_spec.rb | 6 |
3 files changed, 118 insertions, 23 deletions
diff --git a/spec/features/groups/members/manage_groups_spec.rb b/spec/features/groups/members/manage_groups_spec.rb index 40cd54c1e33..2dfcd941b4f 100644 --- a/spec/features/groups/members/manage_groups_spec.rb +++ b/spec/features/groups/members/manage_groups_spec.rb @@ -143,6 +143,82 @@ RSpec.describe 'Groups > Members > Manage groups', :js do end end + describe 'group search results' do + let_it_be(:group, refind: true) { create(:group) } + let_it_be(:group_within_hierarchy) { create(:group, parent: group) } + let_it_be(:group_outside_hierarchy) { create(:group) } + + before_all do + group.add_owner(user) + group_within_hierarchy.add_owner(user) + group_outside_hierarchy.add_owner(user) + end + + context 'when sharing with groups outside the hierarchy is enabled' do + context 'when the invite members group modal is disabled' do + before do + stub_feature_flags(invite_members_group_modal: false) + end + + it 'shows groups within and outside the hierarchy in search results' do + visit group_group_members_path(group) + + click_on 'Invite group' + click_on 'Search for a group' + + expect(page).to have_text group_within_hierarchy.name + expect(page).to have_text group_outside_hierarchy.name + end + end + + context 'when the invite members group modal is enabled' do + it 'shows groups within and outside the hierarchy in search results' do + visit group_group_members_path(group) + + click_on 'Invite a group' + click_on 'Select a group' + + expect(page).to have_text group_within_hierarchy.name + expect(page).to have_text group_outside_hierarchy.name + end + end + end + + context 'when sharing with groups outside the hierarchy is disabled' do + before do + group.namespace_settings.update!(prevent_sharing_groups_outside_hierarchy: true) + end + + context 'when the invite members group modal is disabled' do + before do + stub_feature_flags(invite_members_group_modal: false) + end + + it 'shows only groups within the hierarchy in search results' do + visit group_group_members_path(group) + + click_on 'Invite group' + click_on 'Search for a group' + + expect(page).to have_text group_within_hierarchy.name + expect(page).not_to have_text group_outside_hierarchy.name + end + end + + context 'when the invite members group modal is enabled' do + it 'shows only groups within the hierarchy in search results' do + visit group_group_members_path(group) + + click_on 'Invite a group' + click_on 'Select a group' + + expect(page).to have_text group_within_hierarchy.name + expect(page).not_to have_text group_outside_hierarchy.name + end + end + end + end + def add_group(id, role) page.click_link 'Invite group' page.within ".invite-group-form" do diff --git a/spec/features/groups/members/manage_members_spec.rb b/spec/features/groups/members/manage_members_spec.rb index c5e6479ec51..ee18298e894 100644 --- a/spec/features/groups/members/manage_members_spec.rb +++ b/spec/features/groups/members/manage_members_spec.rb @@ -3,20 +3,19 @@ require 'spec_helper' RSpec.describe 'Groups > Members > Manage members' do - include Select2Helper include Spec::Support::Helpers::Features::MembersHelpers include Spec::Support::Helpers::Features::InviteMembersModalHelper - let(:user1) { create(:user, name: 'John Doe') } - let(:user2) { create(:user, name: 'Mary Jane') } - let(:group) { create(:group) } + let_it_be(:user1) { create(:user, name: 'John Doe') } + let_it_be(:user2) { create(:user, name: 'Mary Jane') } + let_it_be(:group) { create(:group) } before do sign_in(user1) end shared_examples 'includes the correct Invite link' do |should_include, should_not_include| - it 'includes either the form or the modal trigger' do + it 'includes either the form or the modal trigger', :aggregate_failures do group.add_owner(user1) visit group_group_members_path(group) @@ -27,12 +26,12 @@ RSpec.describe 'Groups > Members > Manage members' do end shared_examples 'does not include either invite modal or either invite form' do - it 'does not include either of the invite members or invite group modal buttons' do + 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' end - it 'does not include either of the invite users or invite group forms' do + it 'does not include either of the invite users or invite group forms', :aggregate_failures do expect(page).not_to have_selector '.invite-users-form' expect(page).not_to have_selector '.invite-group-form' end @@ -66,7 +65,7 @@ RSpec.describe 'Groups > Members > Manage members' do end end - it 'add user to group', :js do + it 'add user to group', :js, :snowplow, :aggregate_failures do group.add_owner(user1) visit group_group_members_path(group) @@ -77,6 +76,14 @@ RSpec.describe 'Groups > Members > Manage members' do expect(page).to have_content(user2.name) expect(page).to have_button('Reporter') end + + expect_snowplow_event( + category: 'Members::CreateService', + action: 'create_member', + label: 'group-members-page', + property: 'existing_user', + user: user1 + ) end it 'do not disclose email addresses', :js do @@ -143,11 +150,13 @@ RSpec.describe 'Groups > Members > Manage members' do wait_for_requests - expect(page).not_to have_content(user2.name) - expect(group.users).not_to include(user2) + aggregate_failures do + expect(page).not_to have_content(user2.name) + expect(group.users).not_to include(user2) + end end - it 'add yourself to group when already an owner', :js do + it 'add yourself to group when already an owner', :js, :aggregate_failures do group.add_owner(user1) visit group_group_members_path(group) @@ -160,7 +169,7 @@ RSpec.describe 'Groups > Members > Manage members' do end end - it 'invite user to group', :js do + it 'invite user to group', :js, :snowplow do group.add_owner(user1) visit group_group_members_path(group) @@ -170,14 +179,24 @@ RSpec.describe 'Groups > Members > Manage members' do expect(page).to have_link 'Invited' click_link 'Invited' - 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') + 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 + ) end end - context 'as a guest', :js do + context 'when user is a guest' do before do group.add_guest(user1) group.add_developer(user2) @@ -187,7 +206,7 @@ RSpec.describe 'Groups > Members > Manage members' do it_behaves_like 'does not include either invite modal or either invite form' - it 'does not include a button on the members page list to manage or remove the existing member', :js do + it 'does not include a button on the members page list to manage or remove the existing member', :js, :aggregate_failures do page.within(second_row) do # Can not modify user2 role expect(page).not_to have_button 'Developer' @@ -198,7 +217,7 @@ RSpec.describe 'Groups > Members > Manage members' do end end - context 'As a guest when the :invite_members_group_modal feature flag is disabled', :js do + context 'when user is a guest and the :invite_members_group_modal feature flag is disabled' do before do stub_feature_flags(invite_members_group_modal: false) group.add_guest(user1) @@ -209,7 +228,7 @@ RSpec.describe 'Groups > Members > Manage members' do it_behaves_like 'does not include either invite modal or either invite form' - it 'does not include a button on the members page list to manage or remove the existing member', :js do + it 'does not include a button on the members page list to manage or remove the existing member', :js, :aggregate_failures do page.within(second_row) do # Can not modify user2 role expect(page).not_to have_button 'Developer' diff --git a/spec/features/groups/members/tabs_spec.rb b/spec/features/groups/members/tabs_spec.rb index 2f95e9fa6d3..2e9f332c0d6 100644 --- a/spec/features/groups/members/tabs_spec.rb +++ b/spec/features/groups/members/tabs_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Groups > Members > Tabs' do +RSpec.describe 'Groups > Members > Tabs', :js do using RSpec::Parameterized::TableSyntax shared_examples 'active "Members" tab' do @@ -56,7 +56,7 @@ RSpec.describe 'Groups > Members > Tabs' do it_behaves_like 'active "Members" tab' end - context 'when searching "Invited"', :js do + context 'when searching "Invited"' do before do visit group_group_members_path(group) @@ -86,7 +86,7 @@ RSpec.describe 'Groups > Members > Tabs' do end end - context 'when using "Invited" pagination', :js do + context 'when using "Invited" pagination' do before do visit group_group_members_path(group) |