diff options
Diffstat (limited to 'spec/features/groups/members')
9 files changed, 114 insertions, 134 deletions
diff --git a/spec/features/groups/members/filter_members_spec.rb b/spec/features/groups/members/filter_members_spec.rb index d667690af29..b6d33b3f4aa 100644 --- a/spec/features/groups/members/filter_members_spec.rb +++ b/spec/features/groups/members/filter_members_spec.rb @@ -2,16 +2,19 @@ require 'spec_helper' -RSpec.describe 'Groups > Members > Filter members' do +RSpec.describe 'Groups > Members > Filter members', :js do + include Spec::Support::Helpers::Features::MembersHelpers + let(:user) { create(:user) } let(:nested_group_user) { create(:user) } let(:user_with_2fa) { create(:user, :two_factor_via_otp) } let(:group) { create(:group) } let(:nested_group) { create(:group, parent: group) } - before do - stub_feature_flags(vue_group_members_list: false) + two_factor_auth_dropdown_toggle_selector = '[data-testid="member-filter-2fa-dropdown"] [data-testid="dropdown-toggle"]' + active_inherited_members_filter_selector = '[data-testid="filter-members-with-inherited-permissions"] a.is-active' + before do group.add_owner(user) group.add_maintainer(user_with_2fa) nested_group.add_maintainer(nested_group_user) @@ -24,23 +27,23 @@ RSpec.describe 'Groups > Members > Filter members' do expect(member(0)).to include(user.name) expect(member(1)).to include(user_with_2fa.name) - expect(page).to have_css('.member-filter-2fa-dropdown .dropdown-toggle-text', text: 'Everyone') + expect(page).to have_css(two_factor_auth_dropdown_toggle_selector, text: 'Everyone') end it 'shows only 2FA members' do visit_members_list(group, two_factor: 'enabled') expect(member(0)).to include(user_with_2fa.name) - expect(members_list.size).to eq(1) - expect(page).to have_css('.member-filter-2fa-dropdown .dropdown-toggle-text', text: 'Enabled') + expect(all_rows.size).to eq(1) + expect(page).to have_css(two_factor_auth_dropdown_toggle_selector, text: 'Enabled') end it 'shows only non 2FA members' do visit_members_list(group, two_factor: 'disabled') expect(member(0)).to include(user.name) - expect(members_list.size).to eq(1) - expect(page).to have_css('.member-filter-2fa-dropdown .dropdown-toggle-text', text: 'Disabled') + expect(all_rows.size).to eq(1) + expect(page).to have_css(two_factor_auth_dropdown_toggle_selector, text: 'Disabled') end it 'shows inherited members by default' do @@ -49,35 +52,31 @@ RSpec.describe 'Groups > Members > Filter members' do expect(member(0)).to include(user.name) expect(member(1)).to include(user_with_2fa.name) expect(member(2)).to include(nested_group_user.name) - expect(members_list.size).to eq(3) + expect(all_rows.size).to eq(3) - expect(page).to have_css('[data-qa-selector="filter-members-with-inherited-permissions"] a.is-active', text: 'Show all members') + expect(page).to have_css(active_inherited_members_filter_selector, text: 'Show all members', visible: false) end it 'shows only group members' do visit_members_list(nested_group, with_inherited_permissions: 'exclude') expect(member(0)).to include(nested_group_user.name) - expect(members_list.size).to eq(1) - expect(page).to have_css('[data-qa-selector="filter-members-with-inherited-permissions"] a.is-active', text: 'Show only direct members') + expect(all_rows.size).to eq(1) + expect(page).to have_css(active_inherited_members_filter_selector, text: 'Show only direct members', visible: false) end it 'shows only inherited members' do visit_members_list(nested_group, with_inherited_permissions: 'only') expect(member(0)).to include(user.name) expect(member(1)).to include(user_with_2fa.name) - expect(members_list.size).to eq(2) - expect(page).to have_css('[data-qa-selector="filter-members-with-inherited-permissions"] a.is-active', text: 'Show only inherited members') + expect(all_rows.size).to eq(2) + expect(page).to have_css(active_inherited_members_filter_selector, text: 'Show only inherited members', visible: false) end def visit_members_list(group, options = {}) visit group_group_members_path(group.to_param, options) end - def members_list - page.all('ul.content-list > li') - end - def member(number) - members_list[number].text + all_rows[number].text end end diff --git a/spec/features/groups/members/leave_group_spec.rb b/spec/features/groups/members/leave_group_spec.rb index 32acf7edd2a..b73313745e9 100644 --- a/spec/features/groups/members/leave_group_spec.rb +++ b/spec/features/groups/members/leave_group_spec.rb @@ -3,14 +3,14 @@ require 'spec_helper' RSpec.describe 'Groups > Members > Leave group' do + include Spec::Support::Helpers::Features::MembersHelpers + let(:user) { create(:user) } let(:other_user) { create(:user) } let(:group) { create(:group) } before do - stub_feature_flags(vue_group_members_list: false) - - gitlab_sign_in(user) + sign_in(user) end it 'guest leaves the group' do @@ -61,7 +61,7 @@ RSpec.describe 'Groups > Members > Leave group' do expect(group.users).not_to include(user) end - it 'owner can not leave the group if they are the last owner' do + it 'owner can not leave the group if they are the last owner', :js do group.add_owner(user) visit group_path(group) @@ -70,7 +70,7 @@ RSpec.describe 'Groups > Members > Leave group' do visit group_group_members_path(group) - expect(find(:css, '.project-members-page li', text: user.name)).to have_no_selector(:css, 'a.btn-danger') + expect(members_table).not_to have_selector 'button[title="Leave"]' end it 'owner can not leave the group by url param if they are the last owner', :js do diff --git a/spec/features/groups/members/list_members_spec.rb b/spec/features/groups/members/list_members_spec.rb index bcec2b50a24..b0a896ec8cb 100644 --- a/spec/features/groups/members/list_members_spec.rb +++ b/spec/features/groups/members/list_members_spec.rb @@ -2,9 +2,8 @@ require 'spec_helper' -RSpec.describe 'Groups > Members > List members' do - include Select2Helper - include Spec::Support::Helpers::Features::ListRowsHelpers +RSpec.describe 'Groups > Members > List members', :js do + include Spec::Support::Helpers::Features::MembersHelpers let(:user1) { create(:user, name: 'John Doe') } let(:user2) { create(:user, name: 'Mary Jane') } @@ -12,8 +11,6 @@ RSpec.describe 'Groups > Members > List members' do let(:nested_group) { create(:group, parent: group) } before do - stub_feature_flags(vue_group_members_list: false) - sign_in(user1) end @@ -42,10 +39,12 @@ RSpec.describe 'Groups > Members > List members' do group.add_developer(user2) end - subject { visit group_group_members_path(group) } + it 'shows the status' do + create(:user_status, user: user2, emoji: 'smirk', message: 'Authoring this object') + + visit group_group_members_path(nested_group) - it_behaves_like 'showing user status' do - let(:user_with_status) { user2 } + expect(first_row).to have_selector('gl-emoji[data-name="smirk"]') end end end diff --git a/spec/features/groups/members/manage_groups_spec.rb b/spec/features/groups/members/manage_groups_spec.rb index 33caa3af36d..31a2c868cac 100644 --- a/spec/features/groups/members/manage_groups_spec.rb +++ b/spec/features/groups/members/manage_groups_spec.rb @@ -4,13 +4,11 @@ require 'spec_helper' RSpec.describe 'Groups > Members > Manage groups', :js do include Select2Helper - include Spec::Support::Helpers::Features::ListRowsHelpers + include Spec::Support::Helpers::Features::MembersHelpers let_it_be(:user) { create(:user) } before do - stub_feature_flags(vue_group_members_list: false) - sign_in(user) end @@ -51,7 +49,6 @@ RSpec.describe 'Groups > Members > Manage groups', :js do end before do - travel_to Time.now.utc.beginning_of_day group_link.update!(additional_link_attrs) shared_group.add_owner(user) @@ -63,8 +60,12 @@ RSpec.describe 'Groups > Members > Manage groups', :js do expect(page).to have_content(shared_with_group.name) - accept_confirm do - find(:css, '#tab-groups li', text: shared_with_group.name).find(:css, 'a.btn-danger').click + page.within(first_row) do + click_button 'Remove group' + end + + page.within('[role="dialog"]') do + click_button('Remove group') end expect(page).not_to have_content(shared_with_group.name) @@ -75,7 +76,7 @@ RSpec.describe 'Groups > Members > Manage groups', :js do page.within(first_row) do click_button('Developer') - click_link('Maintainer') + click_button('Maintainer') wait_for_requests @@ -86,33 +87,30 @@ RSpec.describe 'Groups > Members > Manage groups', :js do it 'updates expiry date' do click_groups_tab - expires_at_field = "member_expires_at_#{shared_with_group.id}" - fill_in "member_expires_at_#{shared_with_group.id}", with: 3.days.from_now.to_date + page.within first_row do + fill_in 'Expiration date', with: 5.days.from_now.to_date + find_field('Expiration date').native.send_keys :enter - find_field(expires_at_field).native.send_keys :enter - wait_for_requests + wait_for_requests - page.within(find('li.group_member')) do - expect(page).to have_content('Expires in 3 days') + expect(page).to have_content(/in \d days/) end end context 'when expiry date is set' do - let(:additional_link_attrs) { { expires_at: 3.days.from_now.to_date } } + let(:additional_link_attrs) { { expires_at: 5.days.from_now.to_date } } it 'clears expiry date' do click_groups_tab - page.within(find('li.group_member')) do - expect(page).to have_content('Expires in 3 days') + page.within first_row do + expect(page).to have_content(/in \d days/) - page.within(find('.js-edit-member-form')) do - find('.js-clear-input').click - end + find('[data-testid="clear-button"]').click wait_for_requests - expect(page).not_to have_content('Expires in') + expect(page).to have_content('No expiration set') end end end @@ -128,6 +126,7 @@ RSpec.describe 'Groups > Members > Manage groups', :js do end def click_groups_tab + expect(page).to have_link 'Groups' 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 aedb7c170f8..e6da05c4873 100644 --- a/spec/features/groups/members/manage_members_spec.rb +++ b/spec/features/groups/members/manage_members_spec.rb @@ -4,15 +4,13 @@ require 'spec_helper' RSpec.describe 'Groups > Members > Manage members' do include Select2Helper - include Spec::Support::Helpers::Features::ListRowsHelpers + include Spec::Support::Helpers::Features::MembersHelpers let(:user1) { create(:user, name: 'John Doe') } let(:user2) { create(:user, name: 'Mary Jane') } let(:group) { create(:group) } before do - stub_feature_flags(vue_group_members_list: false) - sign_in(user1) end @@ -24,7 +22,7 @@ RSpec.describe 'Groups > Members > Manage members' do page.within(second_row) do click_button('Developer') - click_link('Owner') + click_button('Owner') expect(page).to have_button('Owner') end @@ -71,11 +69,14 @@ 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-danger').click - - expect(page).to have_unchecked_field 'Also unassign this user from related issues and merge requests' + page.within(second_row) do + click_button 'Remove member' + end - click_on('Remove member') + page.within('[role="dialog"]') do + expect(page).to have_unchecked_field 'Also unassign this user from related issues and merge requests' + click_button('Remove member') + end wait_for_requests @@ -103,16 +104,17 @@ RSpec.describe 'Groups > Members > Manage members' do add_user('test@example.com', 'Reporter') - click_link('Invited') + expect(page).to have_link 'Invited' + click_link 'Invited' - page.within('.content-list.members-list') 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 end - it 'guest can not manage other users' do + it 'guest can not manage other users', :js do group.add_guest(user1) group.add_developer(user2) @@ -126,7 +128,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-danger') + expect(page).not_to have_selector 'button[title="Remove member"]' end end diff --git a/spec/features/groups/members/master_adds_member_with_expiration_date_spec.rb b/spec/features/groups/members/master_adds_member_with_expiration_date_spec.rb index dd708c243a8..de9b32e00aa 100644 --- a/spec/features/groups/members/master_adds_member_with_expiration_date_spec.rb +++ b/spec/features/groups/members/master_adds_member_with_expiration_date_spec.rb @@ -4,17 +4,13 @@ require 'spec_helper' RSpec.describe 'Groups > Members > Owner adds member with expiration date', :js do include Select2Helper - include ActiveSupport::Testing::TimeHelpers + include Spec::Support::Helpers::Features::MembersHelpers let_it_be(:user1) { create(:user, name: 'John Doe') } let_it_be(:group) { create(:group) } let(:new_member) { create(:user, name: 'Mary Jane') } before do - stub_feature_flags(vue_group_members_list: false) - - travel_to Time.now.utc.beginning_of_day - group.add_owner(user1) sign_in(user1) end @@ -22,17 +18,17 @@ RSpec.describe 'Groups > Members > Owner adds member with expiration date', :js it 'expiration date is displayed in the members list' do visit group_group_members_path(group) - page.within '.invite-users-form' do + page.within invite_users_form do select2(new_member.id, from: '#user_ids', multiple: true) - fill_in 'expires_at', with: 3.days.from_now.to_date + fill_in 'expires_at', with: 5.days.from_now.to_date find_field('expires_at').native.send_keys :enter click_on 'Invite' end - page.within "#group_member_#{group_member_id}" do - expect(page).to have_content('Expires in 3 days') + page.within second_row do + expect(page).to have_content(/in \d days/) end end @@ -40,32 +36,28 @@ RSpec.describe 'Groups > Members > Owner adds member with expiration date', :js group.add_developer(new_member) visit group_group_members_path(group) - page.within "#group_member_#{group_member_id}" do - fill_in 'Expiration date', with: 3.days.from_now.to_date + page.within second_row do + fill_in 'Expiration date', with: 5.days.from_now.to_date find_field('Expiration date').native.send_keys :enter wait_for_requests - expect(page).to have_content('Expires in 3 days') + expect(page).to have_content(/in \d days/) end end it 'clears expiration date' do - create(:group_member, :developer, user: new_member, group: group, expires_at: 3.days.from_now.to_date) + create(:group_member, :developer, user: new_member, group: group, expires_at: 5.days.from_now.to_date) visit group_group_members_path(group) - page.within "#group_member_#{group_member_id}" do - expect(page).to have_content('Expires in 3 days') + page.within second_row do + expect(page).to have_content(/in \d days/) - find('.js-clear-input').click + find('[data-testid="clear-button"]').click wait_for_requests - expect(page).not_to have_content('Expires in') + expect(page).to have_content('No expiration set') end end - - def group_member_id - group.members.find_by(user_id: new_member).id - 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 44fd7380b79..71c9b280ebe 100644 --- a/spec/features/groups/members/master_manages_access_requests_spec.rb +++ b/spec/features/groups/members/master_manages_access_requests_spec.rb @@ -3,10 +3,6 @@ require 'spec_helper' RSpec.describe 'Groups > Members > Maintainer manages access requests' do - before do - stub_feature_flags(vue_group_members_list: false) - end - it_behaves_like 'Maintainer manages access requests' do let(:has_tabs) { true } let(:entity) { create(:group, :public) } diff --git a/spec/features/groups/members/search_members_spec.rb b/spec/features/groups/members/search_members_spec.rb index a95b59cece1..0b2d2fd478d 100644 --- a/spec/features/groups/members/search_members_spec.rb +++ b/spec/features/groups/members/search_members_spec.rb @@ -2,7 +2,9 @@ require 'spec_helper' -RSpec.describe 'Search group member' do +RSpec.describe 'Search group member', :js do + include Spec::Support::Helpers::Features::MembersHelpers + let(:user) { create :user } let(:member) { create :user } @@ -14,8 +16,6 @@ RSpec.describe 'Search group member' do end before do - stub_feature_flags(vue_group_members_list: false) - sign_in(user) visit group_group_members_path(guest_group) end @@ -23,11 +23,10 @@ RSpec.describe 'Search group member' do it 'renders member users' do page.within '[data-testid="user-search-form"]' do fill_in 'search', with: member.name - find('.user-search-btn').click + find('[data-testid="user-search-submit"]').click end - group_members_list = find('[data-qa-selector="members_list"]') - expect(group_members_list).to have_content(member.name) - expect(group_members_list).not_to have_content(user.name) + expect(members_table).to have_content(member.name) + expect(members_table).not_to have_content(user.name) end end diff --git a/spec/features/groups/members/sort_members_spec.rb b/spec/features/groups/members/sort_members_spec.rb index d940550b18a..f03cc36df18 100644 --- a/spec/features/groups/members/sort_members_spec.rb +++ b/spec/features/groups/members/sort_members_spec.rb @@ -2,14 +2,16 @@ require 'spec_helper' -RSpec.describe 'Groups > Members > Sort members' do +RSpec.describe 'Groups > Members > Sort members', :js do + include Spec::Support::Helpers::Features::MembersHelpers + let(:owner) { create(:user, name: 'John Doe') } let(:developer) { create(:user, name: 'Mary Jane', last_sign_in_at: 5.days.ago) } let(:group) { create(:group) } - before do - stub_feature_flags(vue_group_members_list: false) + dropdown_toggle_selector = '[data-testid="user-sort-dropdown"] [data-testid="dropdown-toggle"]' + before do create(:group_member, :owner, user: owner, group: group, created_at: 5.days.ago) create(:group_member, :developer, user: developer, group: group, created_at: 3.days.ago) @@ -19,84 +21,76 @@ RSpec.describe 'Groups > Members > Sort members' do it 'sorts alphabetically by default' do visit_members_list(sort: nil) - expect(first_member).to include(owner.name) - expect(second_member).to include(developer.name) - expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Name, ascending') + expect(first_row.text).to include(owner.name) + expect(second_row.text).to include(developer.name) + expect(page).to have_css(dropdown_toggle_selector, text: 'Name, ascending') end it 'sorts by access level ascending' do visit_members_list(sort: :access_level_asc) - expect(first_member).to include(developer.name) - expect(second_member).to include(owner.name) - expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Access level, ascending') + expect(first_row.text).to include(developer.name) + expect(second_row.text).to include(owner.name) + expect(page).to have_css(dropdown_toggle_selector, text: 'Access level, ascending') end it 'sorts by access level descending' do visit_members_list(sort: :access_level_desc) - expect(first_member).to include(owner.name) - expect(second_member).to include(developer.name) - expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Access level, descending') + expect(first_row.text).to include(owner.name) + expect(second_row.text).to include(developer.name) + expect(page).to have_css(dropdown_toggle_selector, text: 'Access level, descending') end it 'sorts by last joined' do visit_members_list(sort: :last_joined) - expect(first_member).to include(developer.name) - expect(second_member).to include(owner.name) - expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Last joined') + expect(first_row.text).to include(developer.name) + expect(second_row.text).to include(owner.name) + expect(page).to have_css(dropdown_toggle_selector, text: 'Last joined') end it 'sorts by oldest joined' do visit_members_list(sort: :oldest_joined) - expect(first_member).to include(owner.name) - expect(second_member).to include(developer.name) - expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Oldest joined') + expect(first_row.text).to include(owner.name) + expect(second_row.text).to include(developer.name) + expect(page).to have_css(dropdown_toggle_selector, text: 'Oldest joined') end it 'sorts by name ascending' do visit_members_list(sort: :name_asc) - expect(first_member).to include(owner.name) - expect(second_member).to include(developer.name) - expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Name, ascending') + expect(first_row.text).to include(owner.name) + expect(second_row.text).to include(developer.name) + expect(page).to have_css(dropdown_toggle_selector, text: 'Name, ascending') end it 'sorts by name descending' do visit_members_list(sort: :name_desc) - expect(first_member).to include(developer.name) - expect(second_member).to include(owner.name) - expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Name, descending') + expect(first_row.text).to include(developer.name) + expect(second_row.text).to include(owner.name) + expect(page).to have_css(dropdown_toggle_selector, text: 'Name, descending') end it 'sorts by recent sign in', :clean_gitlab_redis_shared_state do visit_members_list(sort: :recent_sign_in) - expect(first_member).to include(owner.name) - expect(second_member).to include(developer.name) - expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Recent sign in') + expect(first_row.text).to include(owner.name) + expect(second_row.text).to include(developer.name) + expect(page).to have_css(dropdown_toggle_selector, text: 'Recent sign in') end it 'sorts by oldest sign in', :clean_gitlab_redis_shared_state do visit_members_list(sort: :oldest_sign_in) - expect(first_member).to include(developer.name) - expect(second_member).to include(owner.name) - expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Oldest sign in') + expect(first_row.text).to include(developer.name) + expect(second_row.text).to include(owner.name) + expect(page).to have_css(dropdown_toggle_selector, text: 'Oldest sign in') end def visit_members_list(sort:) visit group_group_members_path(group.to_param, sort: sort) end - - def first_member - page.all('ul.content-list > li').first.text - end - - def second_member - page.all('ul.content-list > li').last.text - end end |