Commit 987e3523 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'enable_invite_a_group_modal_tests' into 'master'

Enable the invite a group modal rspec tests [RUN ALL RSPEC]

See merge request gitlab-org/gitlab!60177
parents c6fc46d7 612f8fcc
......@@ -51,7 +51,6 @@ RSpec.describe 'Groups > Members > List members' do
before do
stub_licensed_features(group_saml: true)
stub_feature_flags(invite_members_group_modal: false)
allow(Gitlab::Session).to receive(:current).and_return(session)
create(:identity, saml_provider: saml_provider, user: user1)
......@@ -68,12 +67,45 @@ RSpec.describe 'Groups > Members > List members' do
wait_for_requests
find('.select2-container').click
click_on 'Invite members'
expect(page).to have_content(user1.name)
expect(page).to have_content(user2.name)
expect(page).not_to have_content(user3.name)
expect(page).not_to have_content(user4.name)
page.within '#invite-members-modal' do
[user1, user2].each do |user_with_saml|
fill_in 'Select members or type email addresses', with: user_with_saml.name
wait_for_requests
expect(page).to have_content(user_with_saml.name)
end
[user3, user4].each do |user_without_saml|
fill_in 'Select members or type email addresses', with: user_without_saml.name
wait_for_requests
expect(page).not_to have_content(user_without_saml.name)
end
end
end
context 'when the :invite_members_group_modal feature flag is disabled' do
before do
stub_feature_flags(invite_members_group_modal: false)
end
it 'returns only users with SAML in autocomplete', :js do
create(:identity, saml_provider: saml_provider, user: user2)
create(:identity, user: user3)
visit group_group_members_path(group)
wait_for_requests
find('.select2-container').click
expect(page).to have_content(user1.name)
expect(page).to have_content(user2.name)
expect(page).not_to have_content(user3.name)
expect(page).not_to have_content(user4.name)
end
end
end
end
......@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec.describe 'Groups > Members > Manage groups', :js do
include Select2Helper
include Spec::Support::Helpers::Features::MembersHelpers
include Spec::Support::Helpers::Features::InviteMembersModalHelper
let_it_be(:user) { create(:user) }
......@@ -13,17 +14,21 @@ RSpec.describe 'Groups > Members > Manage groups', :js do
end
context 'with invite_members_group_modal disabled' do
before do
stub_feature_flags(invite_members_group_modal: false)
end
context 'when group link does not exist' do
let_it_be(:group) { create(:group) }
let_it_be(:group_to_add) { create(:group) }
before do
stub_feature_flags(invite_members_group_modal: false)
group.add_owner(user)
group_to_add.add_owner(user)
visit group_group_members_path(group)
end
it 'add group to group' do
it 'can share group with group' do
add_group(group_to_add.id, 'Reporter')
click_groups_tab
......@@ -44,7 +49,7 @@ RSpec.describe 'Groups > Members > Manage groups', :js do
group_to_add.add_owner(user)
visit group_group_members_path(group)
invite_group(group_to_add.name, 'Reporter')
invite_group(group_to_add.name, role: 'Reporter')
click_groups_tab
......@@ -147,21 +152,6 @@ RSpec.describe 'Groups > Members > Manage groups', :js do
end
end
def invite_group(name, role)
click_on 'Invite a group'
click_on 'Select a group'
wait_for_requests
click_button name
click_button 'Guest'
wait_for_requests
click_button role
click_button 'Invite'
page.refresh
end
def click_groups_tab
expect(page).to have_link 'Groups'
click_link "Groups"
......
......@@ -6,6 +6,7 @@ RSpec.describe 'Project > Members > Invite group', :js do
include Select2Helper
include ActionView::Helpers::DateHelper
include Spec::Support::Helpers::Features::MembersHelpers
include Spec::Support::Helpers::Features::InviteMembersModalHelper
let(:maintainer) { create(:user) }
......@@ -88,12 +89,7 @@ RSpec.describe 'Project > Members > Invite group', :js do
expect(page).not_to have_link 'Groups'
click_on 'Invite a group'
click_on 'Select a group'
wait_for_requests
click_button group_to_share_with.name
click_button 'Invite'
invite_group(group_to_share_with.name)
visit project_project_members_path(project)
......@@ -172,14 +168,7 @@ RSpec.describe 'Project > Members > Invite group', :js do
visit project_project_members_path(project)
click_on 'Invite a group'
click_on 'Select a group'
wait_for_requests
click_button group.name
fill_in 'YYYY-MM-DD', with: 5.days.from_now.strftime('%Y-%m-%d')
click_button 'Invite'
page.refresh
invite_group(group.name, role: 'Guest', expires_at: 5.days.from_now)
end
it 'the group link shows the expiration time with a warning class' do
......
......@@ -13,20 +13,36 @@ module Spec
wait_for_requests
click_button name
fill_in 'YYYY-MM-DD', with: expires_at.try(:strftime, '%Y-%m-%d')
unless role == 'Guest'
click_button 'Guest'
wait_for_requests
click_button role
end
choose_options(role, expires_at)
click_button 'Invite'
page.refresh
end
end
def invite_group(name, role: 'Guest', expires_at: nil)
click_on 'Invite a group'
click_on 'Select a group'
wait_for_requests
click_button name
choose_options(role, expires_at)
click_button 'Invite'
page.refresh
end
def choose_options(role, expires_at)
unless role == 'Guest'
click_button 'Guest'
wait_for_requests
click_button role
end
fill_in 'YYYY-MM-DD', with: expires_at.try(:strftime, '%Y-%m-%d')
end
end
end
end
......
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