Commit b59f3a4b authored by Peter Hegman's avatar Peter Hegman Committed by James Fargher

Remove stubbed `vue_group_members_list` FF

Also update selectors
Preparation for enabling the `vue_group_members_list` feature flag
parent 6b59284b
...@@ -48,6 +48,7 @@ export default { ...@@ -48,6 +48,7 @@ export default {
<div> <div>
<gl-table <gl-table
class="members-table" class="members-table"
data-testid="members-table"
head-variant="white" head-variant="white"
stacked="lg" stacked="lg"
:fields="filteredFields" :fields="filteredFields"
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
= sprite_icon('search', css_class: 'gl-vertical-align-middle!') = sprite_icon('search', css_class: 'gl-vertical-align-middle!')
= label_tag :sort_by, _('Sort by'), class: 'col-form-label label-bold px-2' = label_tag :sort_by, _('Sort by'), class: 'col-form-label label-bold px-2'
= render 'shared/members/sort_dropdown' = render 'shared/members/sort_dropdown'
%ul.content-list.members-list{ data: { qa_selector: 'members_list' } } %ul.content-list.members-list{ data: { qa_selector: 'members_list', testid: 'members-table' } }
= render partial: 'shared/members/member', = render partial: 'shared/members/member',
collection: members, as: :member, collection: members, as: :member,
locals: { membership_source: project, locals: { membership_source: project,
......
- filter = params[:two_factor] || 'everyone' - filter = params[:two_factor] || 'everyone'
- filter_options = { 'everyone' => _('Everyone'), 'enabled' => _('Enabled'), 'disabled' => _('Disabled') } - filter_options = { 'everyone' => _('Everyone'), 'enabled' => _('Enabled'), 'disabled' => _('Disabled') }
.dropdown.inline.member-filter-2fa-dropdown .dropdown.inline.member-filter-2fa-dropdown{ data: { testid: 'member-filter-2fa-dropdown' } }
= dropdown_toggle(filter_options[filter], { toggle: 'dropdown' }) = dropdown_toggle(filter_options[filter], { toggle: 'dropdown', testid: 'dropdown-toggle' })
%ul.dropdown-menu.dropdown-menu-align-right.dropdown-menu-selectable %ul.dropdown-menu.dropdown-menu-align-right.dropdown-menu-selectable
%li.dropdown-header %li.dropdown-header
= _("Filter by two-factor authentication") = _("Filter by two-factor authentication")
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
- import_path = local_assigns[:import_path] - import_path = local_assigns[:import_path]
.row .row
.col-sm-12 .col-sm-12
= form_tag submit_url, class: 'invite-users-form', method: :post do = form_tag submit_url, class: 'invite-users-form', data: { testid: 'invite-users-form' }, method: :post do
.form-group .form-group
= label_tag :user_ids, _("GitLab member or Email address"), class: "label-bold" = label_tag :user_ids, _("GitLab member or Email address"), class: "label-bold"
= users_select_tag(:user_ids, multiple: true, class: 'input-clamp qa-member-select-field', scope: :all, email_user: true, placeholder: 'Search for members to update or invite') = users_select_tag(:user_ids, multiple: true, class: 'input-clamp qa-member-select-field', scope: :all, email_user: true, placeholder: 'Search for members to update or invite')
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
.search-control-wrap.gl-relative .search-control-wrap.gl-relative
= search_field_tag name, params[name], { placeholder: _('Search'), class: 'form-control', spellcheck: false } = search_field_tag name, params[name], { placeholder: _('Search'), class: 'form-control', spellcheck: false }
%button.user-search-btn.border-left.gl-display-flex.gl-align-items-center.gl-justify-content-center{ type: 'submit', 'aria': { label: _('Submit search') } } %button.user-search-btn.border-left.gl-display-flex.gl-align-items-center.gl-justify-content-center{ type: 'submit', 'aria': { label: _('Submit search') }, data: { testid: 'user-search-submit' } }
= sprite_icon('search') = sprite_icon('search')
.dropdown.inline.qa-user-sort-dropdown .dropdown.inline.qa-user-sort-dropdown{ data: { testid: 'user-sort-dropdown' } }
= dropdown_toggle(member_sort_options_hash[@sort], { toggle: 'dropdown' }) = dropdown_toggle(member_sort_options_hash[@sort], { toggle: 'dropdown', testid: 'dropdown-toggle' })
%ul.dropdown-menu.dropdown-menu-right.dropdown-menu-selectable %ul.dropdown-menu.dropdown-menu-right.dropdown-menu-selectable
%li.dropdown-header %li.dropdown-header
= _("Sort by") = _("Sort by")
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
= link_to filter_group_project_member_path(sort: value), class: ("is-active" if @sort == value) do = link_to filter_group_project_member_path(sort: value), class: ("is-active" if @sort == value) do
= title = title
%li.divider %li.divider
%li{ data: { 'qa-selector': 'filter-members-with-inherited-permissions' } } %li{ data: { testid: 'filter-members-with-inherited-permissions' } }
= link_to filter_group_project_member_path(with_inherited_permissions: nil), class: ("is-active" unless params[:with_inherited_permissions].present?) do = link_to filter_group_project_member_path(with_inherited_permissions: nil), class: ("is-active" unless params[:with_inherited_permissions].present?) do
= _("Show all members") = _("Show all members")
%li{ data: { 'qa-selector': 'filter-members-with-inherited-permissions' } } %li{ data: { testid: 'filter-members-with-inherited-permissions' } }
= link_to filter_group_project_member_path(with_inherited_permissions: 'exclude'), class: ("is-active" if params[:with_inherited_permissions] == 'exclude') do = link_to filter_group_project_member_path(with_inherited_permissions: 'exclude'), class: ("is-active" if params[:with_inherited_permissions] == 'exclude') do
= _("Show only direct members") = _("Show only direct members")
%li{ data: { 'qa-selector': 'filter-members-with-inherited-permissions' } } %li{ data: { testid: 'filter-members-with-inherited-permissions' } }
= link_to filter_group_project_member_path(with_inherited_permissions: 'only'), class: ("is-active" if params[:with_inherited_permissions] == 'only') do = link_to filter_group_project_member_path(with_inherited_permissions: 'only'), class: ("is-active" if params[:with_inherited_permissions] == 'only') do
= _("Show only inherited members") = _("Show only inherited members")
...@@ -4,6 +4,7 @@ require 'spec_helper' ...@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe 'Admin Groups' do RSpec.describe 'Admin Groups' do
include Select2Helper include Select2Helper
include Spec::Support::Helpers::Features::MembersHelpers
let(:internal) { Gitlab::VisibilityLevel::INTERNAL } let(:internal) { Gitlab::VisibilityLevel::INTERNAL }
let(:user) { create :user } let(:user) { create :user }
...@@ -11,8 +12,6 @@ RSpec.describe 'Admin Groups' do ...@@ -11,8 +12,6 @@ RSpec.describe 'Admin Groups' do
let!(:current_user) { create(:admin) } let!(:current_user) { create(:admin) }
before do before do
stub_feature_flags(vue_group_members_list: false)
sign_in(current_user) sign_in(current_user)
stub_application_setting(default_group_visibility: internal) stub_application_setting(default_group_visibility: internal)
end end
...@@ -176,7 +175,7 @@ RSpec.describe 'Admin Groups' do ...@@ -176,7 +175,7 @@ RSpec.describe 'Admin Groups' do
click_button 'Invite' click_button 'Invite'
page.within '[data-qa-selector="members_list"]' do page.within members_table do
expect(page).to have_content(current_user.name) expect(page).to have_content(current_user.name)
expect(page).to have_content('Developer') expect(page).to have_content('Developer')
end end
......
...@@ -2,16 +2,19 @@ ...@@ -2,16 +2,19 @@
require 'spec_helper' 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(:user) { create(:user) }
let(:nested_group_user) { create(:user) } let(:nested_group_user) { create(:user) }
let(:user_with_2fa) { create(:user, :two_factor_via_otp) } let(:user_with_2fa) { create(:user, :two_factor_via_otp) }
let(:group) { create(:group) } let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) } let(:nested_group) { create(:group, parent: group) }
before do two_factor_auth_dropdown_toggle_selector = '[data-testid="member-filter-2fa-dropdown"] [data-testid="dropdown-toggle"]'
stub_feature_flags(vue_group_members_list: false) active_inherited_members_filter_selector = '[data-testid="filter-members-with-inherited-permissions"] a.is-active'
before do
group.add_owner(user) group.add_owner(user)
group.add_maintainer(user_with_2fa) group.add_maintainer(user_with_2fa)
nested_group.add_maintainer(nested_group_user) nested_group.add_maintainer(nested_group_user)
...@@ -24,23 +27,23 @@ RSpec.describe 'Groups > Members > Filter members' do ...@@ -24,23 +27,23 @@ RSpec.describe 'Groups > Members > Filter members' do
expect(member(0)).to include(user.name) expect(member(0)).to include(user.name)
expect(member(1)).to include(user_with_2fa.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 end
it 'shows only 2FA members' do it 'shows only 2FA members' do
visit_members_list(group, two_factor: 'enabled') visit_members_list(group, two_factor: 'enabled')
expect(member(0)).to include(user_with_2fa.name) expect(member(0)).to include(user_with_2fa.name)
expect(members_list.size).to eq(1) expect(all_rows.size).to eq(1)
expect(page).to have_css('.member-filter-2fa-dropdown .dropdown-toggle-text', text: 'Enabled') expect(page).to have_css(two_factor_auth_dropdown_toggle_selector, text: 'Enabled')
end end
it 'shows only non 2FA members' do it 'shows only non 2FA members' do
visit_members_list(group, two_factor: 'disabled') visit_members_list(group, two_factor: 'disabled')
expect(member(0)).to include(user.name) expect(member(0)).to include(user.name)
expect(members_list.size).to eq(1) expect(all_rows.size).to eq(1)
expect(page).to have_css('.member-filter-2fa-dropdown .dropdown-toggle-text', text: 'Disabled') expect(page).to have_css(two_factor_auth_dropdown_toggle_selector, text: 'Disabled')
end end
it 'shows inherited members by default' do it 'shows inherited members by default' do
...@@ -49,35 +52,31 @@ RSpec.describe 'Groups > Members > Filter members' do ...@@ -49,35 +52,31 @@ RSpec.describe 'Groups > Members > Filter members' do
expect(member(0)).to include(user.name) expect(member(0)).to include(user.name)
expect(member(1)).to include(user_with_2fa.name) expect(member(1)).to include(user_with_2fa.name)
expect(member(2)).to include(nested_group_user.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 end
it 'shows only group members' do it 'shows only group members' do
visit_members_list(nested_group, with_inherited_permissions: 'exclude') visit_members_list(nested_group, with_inherited_permissions: 'exclude')
expect(member(0)).to include(nested_group_user.name) expect(member(0)).to include(nested_group_user.name)
expect(members_list.size).to eq(1) expect(all_rows.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(page).to have_css(active_inherited_members_filter_selector, text: 'Show only direct members', visible: false)
end end
it 'shows only inherited members' do it 'shows only inherited members' do
visit_members_list(nested_group, with_inherited_permissions: 'only') visit_members_list(nested_group, with_inherited_permissions: 'only')
expect(member(0)).to include(user.name) expect(member(0)).to include(user.name)
expect(member(1)).to include(user_with_2fa.name) expect(member(1)).to include(user_with_2fa.name)
expect(members_list.size).to eq(2) expect(all_rows.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(page).to have_css(active_inherited_members_filter_selector, text: 'Show only inherited members', visible: false)
end end
def visit_members_list(group, options = {}) def visit_members_list(group, options = {})
visit group_group_members_path(group.to_param, options) visit group_group_members_path(group.to_param, options)
end end
def members_list
page.all('ul.content-list > li')
end
def member(number) def member(number)
members_list[number].text all_rows[number].text
end end
end end
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Groups > Members > Leave group' do RSpec.describe 'Groups > Members > Leave group' do
include Spec::Support::Helpers::Features::MembersHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
let(:other_user) { create(:user) } let(:other_user) { create(:user) }
let(:group) { create(:group) } let(:group) { create(:group) }
before do before do
stub_feature_flags(vue_group_members_list: false) sign_in(user)
gitlab_sign_in(user)
end end
it 'guest leaves the group' do it 'guest leaves the group' do
...@@ -61,7 +61,7 @@ RSpec.describe 'Groups > Members > Leave group' do ...@@ -61,7 +61,7 @@ RSpec.describe 'Groups > Members > Leave group' do
expect(group.users).not_to include(user) expect(group.users).not_to include(user)
end 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) group.add_owner(user)
visit group_path(group) visit group_path(group)
...@@ -70,7 +70,7 @@ RSpec.describe 'Groups > Members > Leave group' do ...@@ -70,7 +70,7 @@ RSpec.describe 'Groups > Members > Leave group' do
visit group_group_members_path(group) 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 end
it 'owner can not leave the group by url param if they are the last owner', :js do it 'owner can not leave the group by url param if they are the last owner', :js do
......
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Groups > Members > List members' do RSpec.describe 'Groups > Members > List members', :js do
include Select2Helper include Spec::Support::Helpers::Features::MembersHelpers
include Spec::Support::Helpers::Features::ListRowsHelpers
let(:user1) { create(:user, name: 'John Doe') } let(:user1) { create(:user, name: 'John Doe') }
let(:user2) { create(:user, name: 'Mary Jane') } let(:user2) { create(:user, name: 'Mary Jane') }
...@@ -12,8 +11,6 @@ RSpec.describe 'Groups > Members > List members' do ...@@ -12,8 +11,6 @@ RSpec.describe 'Groups > Members > List members' do
let(:nested_group) { create(:group, parent: group) } let(:nested_group) { create(:group, parent: group) }
before do before do
stub_feature_flags(vue_group_members_list: false)
sign_in(user1) sign_in(user1)
end end
...@@ -42,10 +39,12 @@ RSpec.describe 'Groups > Members > List members' do ...@@ -42,10 +39,12 @@ RSpec.describe 'Groups > Members > List members' do
group.add_developer(user2) group.add_developer(user2)
end 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 expect(first_row).to have_selector('gl-emoji[data-name="smirk"]')
let(:user_with_status) { user2 }
end end
end end
end end
...@@ -4,13 +4,11 @@ require 'spec_helper' ...@@ -4,13 +4,11 @@ require 'spec_helper'
RSpec.describe 'Groups > Members > Manage groups', :js do RSpec.describe 'Groups > Members > Manage groups', :js do
include Select2Helper include Select2Helper
include Spec::Support::Helpers::Features::ListRowsHelpers include Spec::Support::Helpers::Features::MembersHelpers
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
before do before do
stub_feature_flags(vue_group_members_list: false)
sign_in(user) sign_in(user)
end end
...@@ -51,7 +49,6 @@ RSpec.describe 'Groups > Members > Manage groups', :js do ...@@ -51,7 +49,6 @@ RSpec.describe 'Groups > Members > Manage groups', :js do
end end
before do before do
travel_to Time.now.utc.beginning_of_day
group_link.update!(additional_link_attrs) group_link.update!(additional_link_attrs)
shared_group.add_owner(user) shared_group.add_owner(user)
...@@ -63,8 +60,12 @@ RSpec.describe 'Groups > Members > Manage groups', :js do ...@@ -63,8 +60,12 @@ RSpec.describe 'Groups > Members > Manage groups', :js do
expect(page).to have_content(shared_with_group.name) expect(page).to have_content(shared_with_group.name)
accept_confirm do page.within(first_row) do
find(:css, '#tab-groups li', text: shared_with_group.name).find(:css, 'a.btn-danger').click click_button 'Remove group'
end
page.within('[role="dialog"]') do
click_button('Remove group')
end end
expect(page).not_to have_content(shared_with_group.name) expect(page).not_to have_content(shared_with_group.name)
...@@ -75,7 +76,7 @@ RSpec.describe 'Groups > Members > Manage groups', :js do ...@@ -75,7 +76,7 @@ RSpec.describe 'Groups > Members > Manage groups', :js do
page.within(first_row) do page.within(first_row) do
click_button('Developer') click_button('Developer')
click_link('Maintainer') click_button('Maintainer')
wait_for_requests wait_for_requests
...@@ -86,33 +87,30 @@ RSpec.describe 'Groups > Members > Manage groups', :js do ...@@ -86,33 +87,30 @@ RSpec.describe 'Groups > Members > Manage groups', :js do
it 'updates expiry date' do it 'updates expiry date' do
click_groups_tab click_groups_tab
expires_at_field = "member_expires_at_#{shared_with_group.id}" page.within first_row do
fill_in "member_expires_at_#{shared_with_group.id}", with: 3.days.from_now.to_date 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(/in \d days/)
expect(page).to have_content('Expires in 3 days')
end end
end end
context 'when expiry date is set' do 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 it 'clears expiry date' do
click_groups_tab click_groups_tab
page.within(find('li.group_member')) do page.within first_row do
expect(page).to have_content('Expires in 3 days') expect(page).to have_content(/in \d days/)
page.within(find('.js-edit-member-form')) do find('[data-testid="clear-button"]').click
find('.js-clear-input').click
end
wait_for_requests wait_for_requests
expect(page).not_to have_content('Expires in') expect(page).to have_content('No expiration set')
end end
end end
end end
...@@ -128,6 +126,7 @@ RSpec.describe 'Groups > Members > Manage groups', :js do ...@@ -128,6 +126,7 @@ RSpec.describe 'Groups > Members > Manage groups', :js do
end end
def click_groups_tab def click_groups_tab
expect(page).to have_link 'Groups'
click_link "Groups" click_link "Groups"
end end
end end
...@@ -4,15 +4,13 @@ require 'spec_helper' ...@@ -4,15 +4,13 @@ require 'spec_helper'
RSpec.describe 'Groups > Members > Manage members' do RSpec.describe 'Groups > Members > Manage members' do
include Select2Helper include Select2Helper
include Spec::Support::Helpers::Features::ListRowsHelpers include Spec::Support::Helpers::Features::MembersHelpers
let(:user1) { create(:user, name: 'John Doe') } let(:user1) { create(:user, name: 'John Doe') }
let(:user2) { create(:user, name: 'Mary Jane') } let(:user2) { create(:user, name: 'Mary Jane') }
let(:group) { create(:group) } let(:group) { create(:group) }
before do before do
stub_feature_flags(vue_group_members_list: false)
sign_in(user1) sign_in(user1)
end end
...@@ -24,7 +22,7 @@ RSpec.describe 'Groups > Members > Manage members' do ...@@ -24,7 +22,7 @@ RSpec.describe 'Groups > Members > Manage members' do
page.within(second_row) do page.within(second_row) do
click_button('Developer') click_button('Developer')
click_link('Owner') click_button('Owner')
expect(page).to have_button('Owner') expect(page).to have_button('Owner')
end end
...@@ -71,11 +69,14 @@ RSpec.describe 'Groups > Members > Manage members' do ...@@ -71,11 +69,14 @@ RSpec.describe 'Groups > Members > Manage members' do
visit group_group_members_path(group) visit group_group_members_path(group)
# Open modal # Open modal
find(:css, '.project-members-page li', text: user2.name).find(:css, 'button.btn-danger').click page.within(second_row) do
click_button 'Remove member'
expect(page).to have_unchecked_field 'Also unassign this user from related issues and merge requests' 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 wait_for_requests
...@@ -103,16 +104,17 @@ RSpec.describe 'Groups > Members > Manage members' do ...@@ -103,16 +104,17 @@ RSpec.describe 'Groups > Members > Manage members' do
add_user('test@example.com', 'Reporter') 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('test@example.com')
expect(page).to have_content('Invited') expect(page).to have_content('Invited')
expect(page).to have_button('Reporter') expect(page).to have_button('Reporter')
end end
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_guest(user1)
group.add_developer(user2) group.add_developer(user2)
...@@ -126,7 +128,7 @@ RSpec.describe 'Groups > Members > Manage members' do ...@@ -126,7 +128,7 @@ RSpec.describe 'Groups > Members > Manage members' do
expect(page).not_to have_button 'Developer' expect(page).not_to have_button 'Developer'
# Can not remove user2 # 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
end end
......
...@@ -4,17 +4,13 @@ require 'spec_helper' ...@@ -4,17 +4,13 @@ require 'spec_helper'
RSpec.describe 'Groups > Members > Owner adds member with expiration date', :js do RSpec.describe 'Groups > Members > Owner adds member with expiration date', :js do
include Select2Helper include Select2Helper
include ActiveSupport::Testing::TimeHelpers include Spec::Support::Helpers::Features::MembersHelpers
let_it_be(:user1) { create(:user, name: 'John Doe') } let_it_be(:user1) { create(:user, name: 'John Doe') }
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let(:new_member) { create(:user, name: 'Mary Jane') } let(:new_member) { create(:user, name: 'Mary Jane') }
before do before do
stub_feature_flags(vue_group_members_list: false)
travel_to Time.now.utc.beginning_of_day
group.add_owner(user1) group.add_owner(user1)
sign_in(user1) sign_in(user1)
end end
...@@ -22,17 +18,17 @@ RSpec.describe 'Groups > Members > Owner adds member with expiration date', :js ...@@ -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 it 'expiration date is displayed in the members list' do
visit group_group_members_path(group) 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) 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 find_field('expires_at').native.send_keys :enter
click_on 'Invite' click_on 'Invite'
end end
page.within "#group_member_#{group_member_id}" do page.within second_row do
expect(page).to have_content('Expires in 3 days') expect(page).to have_content(/in \d days/)
end end
end end
...@@ -40,32 +36,28 @@ RSpec.describe 'Groups > Members > Owner adds member with expiration date', :js ...@@ -40,32 +36,28 @@ RSpec.describe 'Groups > Members > Owner adds member with expiration date', :js
group.add_developer(new_member) group.add_developer(new_member)
visit group_group_members_path(group) visit group_group_members_path(group)
page.within "#group_member_#{group_member_id}" do page.within second_row do
fill_in 'Expiration date', with: 3.days.from_now.to_date fill_in 'Expiration date', with: 5.days.from_now.to_date
find_field('Expiration date').native.send_keys :enter find_field('Expiration date').native.send_keys :enter
wait_for_requests wait_for_requests
expect(page).to have_content('Expires in 3 days') expect(page).to have_content(/in \d days/)
end end
end end
it 'clears expiration date' do 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) visit group_group_members_path(group)
page.within "#group_member_#{group_member_id}" do page.within second_row do
expect(page).to have_content('Expires in 3 days') expect(page).to have_content(/in \d days/)
find('.js-clear-input').click find('[data-testid="clear-button"]').click
wait_for_requests wait_for_requests
expect(page).not_to have_content('Expires in') expect(page).to have_content('No expiration set')
end end
end end
def group_member_id
group.members.find_by(user_id: new_member).id
end
end end
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Groups > Members > Maintainer manages access requests' do 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 it_behaves_like 'Maintainer manages access requests' do
let(:has_tabs) { true } let(:has_tabs) { true }
let(:entity) { create(:group, :public) } let(:entity) { create(:group, :public) }
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
require 'spec_helper' 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(:user) { create :user }
let(:member) { create :user } let(:member) { create :user }
...@@ -14,8 +16,6 @@ RSpec.describe 'Search group member' do ...@@ -14,8 +16,6 @@ RSpec.describe 'Search group member' do
end end
before do before do
stub_feature_flags(vue_group_members_list: false)
sign_in(user) sign_in(user)
visit group_group_members_path(guest_group) visit group_group_members_path(guest_group)
end end
...@@ -23,11 +23,10 @@ RSpec.describe 'Search group member' do ...@@ -23,11 +23,10 @@ RSpec.describe 'Search group member' do
it 'renders member users' do it 'renders member users' do
page.within '[data-testid="user-search-form"]' do page.within '[data-testid="user-search-form"]' do
fill_in 'search', with: member.name fill_in 'search', with: member.name
find('.user-search-btn').click find('[data-testid="user-search-submit"]').click
end end
group_members_list = find('[data-qa-selector="members_list"]') expect(members_table).to have_content(member.name)
expect(group_members_list).to have_content(member.name) expect(members_table).not_to have_content(user.name)
expect(group_members_list).not_to have_content(user.name)
end end
end end
...@@ -2,14 +2,16 @@ ...@@ -2,14 +2,16 @@
require 'spec_helper' 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(:owner) { create(:user, name: 'John Doe') }
let(:developer) { create(:user, name: 'Mary Jane', last_sign_in_at: 5.days.ago) } let(:developer) { create(:user, name: 'Mary Jane', last_sign_in_at: 5.days.ago) }
let(:group) { create(:group) } let(:group) { create(:group) }
before do dropdown_toggle_selector = '[data-testid="user-sort-dropdown"] [data-testid="dropdown-toggle"]'
stub_feature_flags(vue_group_members_list: false)
before do
create(:group_member, :owner, user: owner, group: group, created_at: 5.days.ago) 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) create(:group_member, :developer, user: developer, group: group, created_at: 3.days.ago)
...@@ -19,84 +21,76 @@ RSpec.describe 'Groups > Members > Sort members' do ...@@ -19,84 +21,76 @@ RSpec.describe 'Groups > Members > Sort members' do
it 'sorts alphabetically by default' do it 'sorts alphabetically by default' do
visit_members_list(sort: nil) visit_members_list(sort: nil)
expect(first_member).to include(owner.name) expect(first_row.text).to include(owner.name)
expect(second_member).to include(developer.name) expect(second_row.text).to include(developer.name)
expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Name, ascending') expect(page).to have_css(dropdown_toggle_selector, text: 'Name, ascending')
end end
it 'sorts by access level ascending' do it 'sorts by access level ascending' do
visit_members_list(sort: :access_level_asc) visit_members_list(sort: :access_level_asc)
expect(first_member).to include(developer.name) expect(first_row.text).to include(developer.name)
expect(second_member).to include(owner.name) expect(second_row.text).to include(owner.name)
expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Access level, ascending') expect(page).to have_css(dropdown_toggle_selector, text: 'Access level, ascending')
end end
it 'sorts by access level descending' do it 'sorts by access level descending' do
visit_members_list(sort: :access_level_desc) visit_members_list(sort: :access_level_desc)
expect(first_member).to include(owner.name) expect(first_row.text).to include(owner.name)
expect(second_member).to include(developer.name) expect(second_row.text).to include(developer.name)
expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Access level, descending') expect(page).to have_css(dropdown_toggle_selector, text: 'Access level, descending')
end end
it 'sorts by last joined' do it 'sorts by last joined' do
visit_members_list(sort: :last_joined) visit_members_list(sort: :last_joined)
expect(first_member).to include(developer.name) expect(first_row.text).to include(developer.name)
expect(second_member).to include(owner.name) expect(second_row.text).to include(owner.name)
expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Last joined') expect(page).to have_css(dropdown_toggle_selector, text: 'Last joined')
end end
it 'sorts by oldest joined' do it 'sorts by oldest joined' do
visit_members_list(sort: :oldest_joined) visit_members_list(sort: :oldest_joined)
expect(first_member).to include(owner.name) expect(first_row.text).to include(owner.name)
expect(second_member).to include(developer.name) expect(second_row.text).to include(developer.name)
expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Oldest joined') expect(page).to have_css(dropdown_toggle_selector, text: 'Oldest joined')
end end
it 'sorts by name ascending' do it 'sorts by name ascending' do
visit_members_list(sort: :name_asc) visit_members_list(sort: :name_asc)
expect(first_member).to include(owner.name) expect(first_row.text).to include(owner.name)
expect(second_member).to include(developer.name) expect(second_row.text).to include(developer.name)
expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Name, ascending') expect(page).to have_css(dropdown_toggle_selector, text: 'Name, ascending')
end end
it 'sorts by name descending' do it 'sorts by name descending' do
visit_members_list(sort: :name_desc) visit_members_list(sort: :name_desc)
expect(first_member).to include(developer.name) expect(first_row.text).to include(developer.name)
expect(second_member).to include(owner.name) expect(second_row.text).to include(owner.name)
expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Name, descending') expect(page).to have_css(dropdown_toggle_selector, text: 'Name, descending')
end end
it 'sorts by recent sign in', :clean_gitlab_redis_shared_state do it 'sorts by recent sign in', :clean_gitlab_redis_shared_state do
visit_members_list(sort: :recent_sign_in) visit_members_list(sort: :recent_sign_in)
expect(first_member).to include(owner.name) expect(first_row.text).to include(owner.name)
expect(second_member).to include(developer.name) expect(second_row.text).to include(developer.name)
expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Recent sign in') expect(page).to have_css(dropdown_toggle_selector, text: 'Recent sign in')
end end
it 'sorts by oldest sign in', :clean_gitlab_redis_shared_state do it 'sorts by oldest sign in', :clean_gitlab_redis_shared_state do
visit_members_list(sort: :oldest_sign_in) visit_members_list(sort: :oldest_sign_in)
expect(first_member).to include(developer.name) expect(first_row.text).to include(developer.name)
expect(second_member).to include(owner.name) expect(second_row.text).to include(owner.name)
expect(page).to have_css('.qa-user-sort-dropdown .dropdown-toggle-text', text: 'Oldest sign in') expect(page).to have_css(dropdown_toggle_selector, text: 'Oldest sign in')
end end
def visit_members_list(sort:) def visit_members_list(sort:)
visit group_group_members_path(group.to_param, sort: sort) visit group_group_members_path(group.to_param, sort: sort)
end 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 end
# frozen_string_literal: true
module Spec
module Support
module Helpers
module Features
module MembersHelpers
def members_table
page.find('[data-testid="members-table"]')
end
def all_rows
page.within(members_table) do
page.all('tbody > tr')
end
end
def first_row
all_rows[0]
end
def second_row
all_rows[1]
end
def invite_users_form
page.find('[data-testid="invite-users-form"]')
end
end
end
end
end
end
# frozen_string_literal: true # frozen_string_literal: true
RSpec.shared_examples 'Maintainer manages access requests' do RSpec.shared_examples 'Maintainer manages access requests' do
include Spec::Support::Helpers::Features::MembersHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
let(:maintainer) { create(:user) } let(:maintainer) { create(:user) }
...@@ -26,7 +28,7 @@ RSpec.shared_examples 'Maintainer manages access requests' do ...@@ -26,7 +28,7 @@ RSpec.shared_examples 'Maintainer manages access requests' do
expect_no_visible_access_request(entity, user) expect_no_visible_access_request(entity, user)
page.within('[data-qa-selector="members_list"]') do page.within(members_table) do
expect(page).to have_content user.name expect(page).to have_content user.name
end end
end end
...@@ -35,7 +37,7 @@ RSpec.shared_examples 'Maintainer manages access requests' do ...@@ -35,7 +37,7 @@ RSpec.shared_examples 'Maintainer manages access requests' do
expect_visible_access_request(entity, user) expect_visible_access_request(entity, user)
# Open modal # Open modal
click_on 'Deny access request' click_on 'Deny access'
expect(page).not_to have_field "Also unassign this user from related issues and merge requests" expect(page).not_to have_field "Also unassign this user from related issues and merge requests"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment