diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/features/projects/members/list_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/features/projects/members/list_spec.rb')
-rw-r--r-- | spec/features/projects/members/list_spec.rb | 222 |
1 files changed, 167 insertions, 55 deletions
diff --git a/spec/features/projects/members/list_spec.rb b/spec/features/projects/members/list_spec.rb index 62115f2dce6..b0fe5b9c48a 100644 --- a/spec/features/projects/members/list_spec.rb +++ b/spec/features/projects/members/list_spec.rb @@ -4,7 +4,6 @@ require 'spec_helper' RSpec.describe 'Project members list' do include Select2Helper - include Spec::Support::Helpers::Features::ListRowsHelpers let(:user1) { create(:user, name: 'John Doe') } let(:user2) { create(:user, name: 'Mary Jane') } @@ -13,102 +12,215 @@ RSpec.describe 'Project members list' do before do stub_feature_flags(invite_members_group_modal: false) + sign_in(user1) group.add_owner(user1) end - it 'show members from project and group' do - project.add_developer(user2) + context 'when `vue_project_members_list` feature flag is enabled', :js do + include Spec::Support::Helpers::Features::MembersHelpers - visit_members_page + it 'pushes `vue_project_members_list` feature flag to the frontend' do + visit_members_page - expect(first_row.text).to include(user1.name) - expect(second_row.text).to include(user2.name) - end + expect(page).to have_pushed_frontend_feature_flags(vueProjectMembersList: true) + end - it 'show user once if member of both group and project' do - project.add_developer(user1) + it 'show members from project and group' do + project.add_developer(user2) - visit_members_page + visit_members_page - expect(first_row.text).to include(user1.name) - expect(second_row).to be_blank - end + expect(first_row).to have_content(user1.name) + expect(second_row).to have_content(user2.name) + end + + it 'show user once if member of both group and project' do + project.add_developer(user1) - it 'update user access level', :js do - project.add_developer(user2) + visit_members_page + + expect(first_row).to have_content(user1.name) + expect(second_row).to be_blank + end + + it 'update user access level', :js do + project.add_developer(user2) - visit_members_page + visit_members_page - page.within(second_row) do - click_button('Developer') - click_link('Reporter') + page.within find_member_row(user2) do + click_button('Developer') + click_button('Reporter') - expect(page).to have_button('Reporter') + expect(page).to have_button('Reporter') + end end - end - it 'add user to project', :js do - visit_members_page + it 'add user to project', :js do + visit_members_page - add_user(user2.id, 'Reporter') + add_user(user2.id, 'Reporter') - page.within(second_row) do - expect(page).to have_content(user2.name) - expect(page).to have_button('Reporter') + page.within find_member_row(user2) do + expect(page).to have_button('Reporter') + end end - end - it 'remove user from project', :js do - other_user = create(:user) - project.add_developer(other_user) + it 'remove user from project', :js do + other_user = create(:user) + project.add_developer(other_user) - visit_members_page + visit_members_page - # Open modal - find(:css, 'li.project_member', text: other_user.name).find(:css, 'button.btn-danger').click + # Open modal + page.within find_member_row(other_user) do + click_button 'Remove member' + end - expect(page).to have_unchecked_field 'Also unassign this user from related issues and merge requests' + 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 - click_on('Remove member') + wait_for_requests - wait_for_requests + expect(members_table).not_to have_content(other_user.name) + end - expect(page).not_to have_content(other_user.name) - expect(project.users).not_to include(other_user) - end + it 'invite user to project', :js do + visit_members_page + + add_user('test@example.com', 'Reporter') + + click_link 'Invited' + + page.within find_invited_member_row('test@example.com') do + expect(page).to have_button('Reporter') + end + end - it 'invite user to project', :js do - visit_members_page + context 'project bots' do + let(:project_bot) { create(:user, :project_bot, name: 'project_bot') } - add_user('test@example.com', 'Reporter') + before do + project.add_maintainer(project_bot) + end - click_link 'Invited' + it 'does not show form used to change roles and "Expiration date" or the remove user button' do + visit_members_page - page.within(first_row) do - expect(page).to have_content('test@example.com') - expect(page).to have_content('Invited') - expect(page).to have_button('Reporter') + page.within find_member_row(project_bot) do + expect(page).not_to have_button('Maintainer') + expect(page).to have_field('Expiration date', disabled: true) + expect(page).not_to have_button('Remove member') + end + end end end - context 'project bots' do - let(:project_bot) { create(:user, :project_bot, name: 'project_bot') } + context 'when `vue_project_members_list` feature flag is disabled' do + include Spec::Support::Helpers::Features::ListRowsHelpers before do - project.add_maintainer(project_bot) + stub_feature_flags(vue_project_members_list: false) + end + + it 'show members from project and group' do + project.add_developer(user2) + + visit_members_page + + expect(first_row.text).to include(user1.name) + expect(second_row.text).to include(user2.name) + end + + it 'show user once if member of both group and project' do + project.add_developer(user1) + + visit_members_page + + expect(first_row.text).to include(user1.name) + expect(second_row).to be_blank end - it 'does not show form used to change roles and "Expiration date" or the remove user button' do - project_member = project.project_members.find_by(user_id: project_bot.id) + it 'update user access level', :js do + project.add_developer(user2) + + visit_members_page + + page.within(second_row) do + click_button('Developer') + click_link('Reporter') + + expect(page).to have_button('Reporter') + end + end + it 'add user to project', :js do visit_members_page - expect(page).not_to have_selector("#edit_project_member_#{project_member.id}") - expect(page).to have_no_selector("#project_member_#{project_member.id} .btn-danger") + add_user(user2.id, 'Reporter') + + page.within(second_row) do + expect(page).to have_content(user2.name) + expect(page).to have_button('Reporter') + end + end + + it 'remove user from project', :js do + other_user = create(:user) + project.add_developer(other_user) + + visit_members_page + + # Open modal + find(:css, 'li.project_member', text: other_user.name).find(:css, 'button.btn-danger').click + + expect(page).to have_unchecked_field 'Also unassign this user from related issues and merge requests' + + click_on('Remove member') + + wait_for_requests + + expect(page).not_to have_content(other_user.name) + expect(project.users).not_to include(other_user) + end + + it 'invite user to project', :js do + visit_members_page + + add_user('test@example.com', 'Reporter') + + click_link 'Invited' + + page.within(first_row) do + expect(page).to have_content('test@example.com') + expect(page).to have_content('Invited') + expect(page).to have_button('Reporter') + end + end + + context 'project bots' do + let(:project_bot) { create(:user, :project_bot, name: 'project_bot') } + + before do + project.add_maintainer(project_bot) + end + + it 'does not show form used to change roles and "Expiration date" or the remove user button' do + project_member = project.project_members.find_by(user_id: project_bot.id) + + visit_members_page + + expect(page).not_to have_selector("#edit_project_member_#{project_member.id}") + expect(page).to have_no_selector("#project_member_#{project_member.id} .btn-danger") + end end end + private + def add_user(id, role) page.within ".invite-users-form" do select2(id, from: "#user_ids", multiple: true) |