diff options
Diffstat (limited to 'spec/features/groups/members')
5 files changed, 129 insertions, 8 deletions
diff --git a/spec/features/groups/members/manage_groups_spec.rb b/spec/features/groups/members/manage_groups_spec.rb index f1cf04417c0..faf455e4ed9 100644 --- a/spec/features/groups/members/manage_groups_spec.rb +++ b/spec/features/groups/members/manage_groups_spec.rb @@ -20,26 +20,28 @@ RSpec.describe 'Groups > Members > Manage groups', :js do add_group(shared_with_group.id, 'Reporter') + click_groups_tab + page.within(first_row) do expect(page).to have_content(shared_with_group.name) expect(page).to have_content('Reporter') end end - it 'remove user from group' do + it 'remove group from group' do create(:group_group_link, shared_group: shared_group, shared_with_group: shared_with_group, group_access: ::Gitlab::Access::DEVELOPER) visit group_group_members_path(shared_group) + click_groups_tab + expect(page).to have_content(shared_with_group.name) accept_confirm do - find(:css, '#existing_shares li', text: shared_with_group.name).find(:css, 'a.btn-remove').click + find(:css, '#tab-groups li', text: shared_with_group.name).find(:css, 'a.btn-remove').click end - wait_for_requests - expect(page).not_to have_content(shared_with_group.name) end @@ -49,6 +51,8 @@ RSpec.describe 'Groups > Members > Manage groups', :js do visit group_group_members_path(shared_group) + click_groups_tab + page.within(first_row) do click_button('Developer') click_link('Maintainer') @@ -67,4 +71,8 @@ RSpec.describe 'Groups > Members > Manage groups', :js do click_button "Invite" end end + + def click_groups_tab + click_link "Groups" + end end diff --git a/spec/features/groups/members/manage_members_spec.rb b/spec/features/groups/members/manage_members_spec.rb index 99846ecee27..0267bea2f53 100644 --- a/spec/features/groups/members/manage_members_spec.rb +++ b/spec/features/groups/members/manage_members_spec.rb @@ -69,7 +69,7 @@ RSpec.describe 'Groups > Members > Manage members' do visit group_group_members_path(group) # Open modal - find(:css, '.project-members-page li', text: user2.name).find(:css, 'button.btn-remove').click + find(:css, '.project-members-page li', text: user2.name).find(:css, 'button.btn-danger').click expect(page).to have_unchecked_field 'Also unassign this user from related issues and merge requests' @@ -101,7 +101,7 @@ RSpec.describe 'Groups > Members > Manage members' do add_user('test@example.com', 'Reporter') - click_link('Pending') + click_link('Invited') page.within('.content-list.members-list') do expect(page).to have_content('test@example.com') @@ -124,7 +124,7 @@ RSpec.describe 'Groups > Members > Manage members' do expect(page).not_to have_button 'Developer' # Can not remove user2 - expect(page).not_to have_css('a.btn-remove') + expect(page).not_to have_css('a.btn-danger') end end diff --git a/spec/features/groups/members/master_manages_access_requests_spec.rb b/spec/features/groups/members/master_manages_access_requests_spec.rb index 2a17e7d2a5c..71c9b280ebe 100644 --- a/spec/features/groups/members/master_manages_access_requests_spec.rb +++ b/spec/features/groups/members/master_manages_access_requests_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'Groups > Members > Maintainer manages access requests' do it_behaves_like 'Maintainer manages access requests' do + let(:has_tabs) { true } let(:entity) { create(:group, :public) } let(:members_page_path) { group_group_members_path(entity) } end diff --git a/spec/features/groups/members/search_members_spec.rb b/spec/features/groups/members/search_members_spec.rb index 4c34ccf87c3..ad4f5c0b579 100644 --- a/spec/features/groups/members/search_members_spec.rb +++ b/spec/features/groups/members/search_members_spec.rb @@ -19,7 +19,7 @@ RSpec.describe 'Search group member' do end it 'renders member users' do - page.within '.user-search-form' do + page.within '[data-testid="user-search-form"]' do fill_in 'search', with: member.name find('.user-search-btn').click end diff --git a/spec/features/groups/members/tabs_spec.rb b/spec/features/groups/members/tabs_spec.rb new file mode 100644 index 00000000000..fa77d1a2ff8 --- /dev/null +++ b/spec/features/groups/members/tabs_spec.rb @@ -0,0 +1,112 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Groups > Members > Tabs' do + using RSpec::Parameterized::TableSyntax + + shared_examples 'active "Members" tab' do + it 'displays "Members" tab' do + expect(page).to have_selector('.nav-link.active', text: 'Members') + end + end + + shared_examples 'active "Invited" tab' do + it 'displays "Invited" tab' do + expect(page).to have_selector('.nav-link.active', text: 'Invited') + end + end + + let(:owner) { create(:user) } + let(:group) { create(:group) } + + before do + stub_const('Groups::GroupMembersController::MEMBER_PER_PAGE_LIMIT', 1) + allow_any_instance_of(Member).to receive(:send_request).and_return(true) + + group.add_owner(owner) + sign_in(owner) + + create_list(:group_member, 2, group: group) + create_list(:group_member, 2, :invited, group: group) + create_list(:group_group_link, 2, shared_group: group) + create_list(:group_member, 2, :access_request, group: group) + end + + where(:tab, :count) do + 'Members' | 3 + 'Invited' | 2 + 'Groups' | 2 + 'Access requests' | 2 + end + + with_them do + it "renders #{params[:tab]} tab" do + visit group_group_members_path(group) + + expect(page).to have_selector('.nav-link', text: "#{tab} #{count}") + end + end + + context 'displays "Members" tab by default' do + before do + visit group_group_members_path(group) + end + + it_behaves_like 'active "Members" tab' + end + + context 'when searching "Invited"', :js do + before do + visit group_group_members_path(group) + + click_link 'Invited' + + page.within '[data-testid="user-search-form"]' do + fill_in 'search_invited', with: 'email' + find('button[type="submit"]').click + end + end + + it_behaves_like 'active "Invited" tab' + + context 'and then searching "Members"' do + before do + click_link 'Members' + + page.within '[data-testid="user-search-form"]' do + fill_in 'search', with: 'test' + find('button[type="submit"]').click + end + end + + it_behaves_like 'active "Members" tab' + end + end + + context 'when using "Invited" pagination', :js do + before do + visit group_group_members_path(group) + + click_link 'Invited' + + page.within '.pagination' do + click_link '2' + end + end + + it_behaves_like 'active "Invited" tab' + + context 'and then using "Members" pagination' do + before do + click_link 'Members' + + page.within '.pagination' do + click_link '2' + end + end + + it_behaves_like 'active "Members" tab' + end + end +end |