Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/admin')
-rw-r--r--spec/features/admin/admin_appearance_spec.rb20
-rw-r--r--spec/features/admin/admin_hooks_spec.rb18
-rw-r--r--spec/features/admin/admin_mode/logout_spec.rb31
-rw-r--r--spec/features/admin/admin_mode_spec.rb77
-rw-r--r--spec/features/admin/admin_runners_spec.rb58
-rw-r--r--spec/features/admin/admin_search_settings_spec.rb2
-rw-r--r--spec/features/admin/admin_sees_background_migrations_spec.rb84
-rw-r--r--spec/features/admin/admin_settings_spec.rb46
-rw-r--r--spec/features/admin/clusters/applications_spec.rb22
-rw-r--r--spec/features/admin/integrations/user_activates_mattermost_slash_command_spec.rb16
-rw-r--r--spec/features/admin/users/user_spec.rb30
-rw-r--r--spec/features/admin/users/users_spec.rb458
12 files changed, 465 insertions, 397 deletions
diff --git a/spec/features/admin/admin_appearance_spec.rb b/spec/features/admin/admin_appearance_spec.rb
index 603e757096f..5596ad7bf21 100644
--- a/spec/features/admin/admin_appearance_spec.rb
+++ b/spec/features/admin/admin_appearance_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe 'Admin Appearance' do
it 'create new appearance' do
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
- visit admin_appearances_path
+ visit admin_application_settings_appearances_path
fill_in 'appearance_title', with: 'MyCompany'
fill_in 'appearance_description', with: 'dev server'
@@ -17,7 +17,7 @@ RSpec.describe 'Admin Appearance' do
fill_in 'appearance_profile_image_guidelines', with: 'Custom profile image guidelines'
click_button 'Update appearance settings'
- expect(current_path).to eq admin_appearances_path
+ expect(current_path).to eq admin_application_settings_appearances_path
expect(page).to have_content 'Appearance'
expect(page).to have_field('appearance_title', with: 'MyCompany')
@@ -31,7 +31,7 @@ RSpec.describe 'Admin Appearance' do
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
- visit admin_appearances_path
+ visit admin_application_settings_appearances_path
click_link "Sign-in page"
expect_custom_sign_in_appearance(appearance)
@@ -41,7 +41,7 @@ RSpec.describe 'Admin Appearance' do
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
- visit admin_appearances_path
+ visit admin_application_settings_appearances_path
click_link "New project page"
expect_custom_new_project_appearance(appearance)
@@ -55,7 +55,7 @@ RSpec.describe 'Admin Appearance' do
context 'when system header and footer messages are empty' do
it 'shows custom system header and footer fields' do
- visit admin_appearances_path
+ visit admin_application_settings_appearances_path
expect(page).to have_field('appearance_header_message', with: '')
expect(page).to have_field('appearance_footer_message', with: '')
@@ -70,7 +70,7 @@ RSpec.describe 'Admin Appearance' do
end
it 'shows custom system header and footer fields' do
- visit admin_appearances_path
+ visit admin_application_settings_appearances_path
expect(page).to have_field('appearance_header_message', with: appearance.header_message)
expect(page).to have_field('appearance_footer_message', with: appearance.footer_message)
@@ -99,7 +99,7 @@ RSpec.describe 'Admin Appearance' do
before do
sign_in(create(:admin))
gitlab_enable_admin_mode_sign_in(admin)
- visit admin_appearances_path
+ visit admin_application_settings_appearances_path
fill_in 'appearance_profile_image_guidelines', with: 'Custom profile image guidelines, please :smile:!'
click_button 'Update appearance settings'
end
@@ -115,7 +115,7 @@ RSpec.describe 'Admin Appearance' do
it 'appearance logo' do
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
- visit admin_appearances_path
+ visit admin_application_settings_appearances_path
attach_file(:appearance_logo, logo_fixture)
click_button 'Update appearance settings'
@@ -128,7 +128,7 @@ RSpec.describe 'Admin Appearance' do
it 'header logos' do
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
- visit admin_appearances_path
+ visit admin_application_settings_appearances_path
attach_file(:appearance_header_logo, logo_fixture)
click_button 'Update appearance settings'
@@ -141,7 +141,7 @@ RSpec.describe 'Admin Appearance' do
it 'Favicon' do
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
- visit admin_appearances_path
+ visit admin_application_settings_appearances_path
attach_file(:appearance_favicon, logo_fixture)
click_button 'Update appearance settings'
diff --git a/spec/features/admin/admin_hooks_spec.rb b/spec/features/admin/admin_hooks_spec.rb
index 3fed402267c..a501efd82ed 100644
--- a/spec/features/admin/admin_hooks_spec.rb
+++ b/spec/features/admin/admin_hooks_spec.rb
@@ -37,24 +37,6 @@ RSpec.describe 'Admin::Hooks' do
expect(page).to have_content('foo.rb')
expect(page).to have_content('bar.clj')
end
-
- context 'deprecation warning' do
- it 'shows warning for plugins directory' do
- allow(Gitlab::FileHook).to receive(:files).and_return(['plugins/foo.rb'])
-
- visit admin_hooks_path
-
- expect(page).to have_content('Plugins directory is deprecated and will be removed in 14.0')
- end
-
- it 'does not show warning for file_hooks directory' do
- allow(Gitlab::FileHook).to receive(:files).and_return(['file_hooks/foo.rb'])
-
- visit admin_hooks_path
-
- expect(page).not_to have_content('Plugins directory is deprecated and will be removed in 14.0')
- end
- end
end
describe 'New Hook' do
diff --git a/spec/features/admin/admin_mode/logout_spec.rb b/spec/features/admin/admin_mode/logout_spec.rb
index 664eb51e58f..efb4baa8164 100644
--- a/spec/features/admin/admin_mode/logout_spec.rb
+++ b/spec/features/admin/admin_mode/logout_spec.rb
@@ -5,28 +5,32 @@ require 'spec_helper'
RSpec.describe 'Admin Mode Logout', :js do
include TermsHelper
include UserLoginHelper
+ include Spec::Support::Helpers::Features::TopNavSpecHelpers
let(:user) { create(:admin) }
shared_examples 'combined_menu: feature flag examples' do
before do
- gitlab_sign_in(user)
+ # TODO: This used to use gitlab_sign_in, instead of sign_in, but that is buggy. See
+ # this issue to look into why: https://gitlab.com/gitlab-org/gitlab/-/issues/331851
+ sign_in(user)
gitlab_enable_admin_mode_sign_in(user)
visit admin_root_path
end
it 'disable removes admin mode and redirects to root page' do
- pending_on_combined_menu_flag
-
gitlab_disable_admin_mode
expect(current_path).to eq root_path
- expect(page).to have_link(href: new_admin_session_path)
+
+ open_top_nav
+
+ within_top_nav do
+ expect(page).to have_link(href: new_admin_session_path)
+ end
end
it 'disable shows flash notice' do
- pending_on_combined_menu_flag
-
gitlab_disable_admin_mode
expect(page).to have_selector('.flash-notice')
@@ -38,17 +42,20 @@ RSpec.describe 'Admin Mode Logout', :js do
end
it 'disable removes admin mode and redirects to root page' do
- pending_on_combined_menu_flag
-
gitlab_disable_admin_mode
expect(current_path).to eq root_path
- expect(page).to have_link(href: new_admin_session_path)
+
+ open_top_nav
+
+ within_top_nav do
+ expect(page).to have_link(href: new_admin_session_path)
+ end
end
end
end
- context 'with combined_menu: feature flag on' do
+ context 'with combined_menu feature flag on' do
let(:needs_rewrite_for_combined_menu_flag_on) { true }
before do
@@ -67,8 +74,4 @@ RSpec.describe 'Admin Mode Logout', :js do
it_behaves_like 'combined_menu: feature flag examples'
end
-
- def pending_on_combined_menu_flag
- pending 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56587' if needs_rewrite_for_combined_menu_flag_on
- end
end
diff --git a/spec/features/admin/admin_mode_spec.rb b/spec/features/admin/admin_mode_spec.rb
index 4df035b13e8..9fd83f4af6d 100644
--- a/spec/features/admin/admin_mode_spec.rb
+++ b/spec/features/admin/admin_mode_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe 'Admin mode' do
include MobileHelpers
+ include Spec::Support::Helpers::Features::TopNavSpecHelpers
include StubENV
let(:admin) { create(:admin) }
@@ -21,6 +22,7 @@ RSpec.describe 'Admin mode' do
context 'when not in admin mode' do
it 'has no leave admin mode button' do
visit new_admin_session_path
+ open_top_nav
page.within('.navbar-sub-nav') do
expect(page).not_to have_link(href: destroy_admin_session_path)
@@ -28,12 +30,11 @@ RSpec.describe 'Admin mode' do
end
it 'can open pages not in admin scope' do
- pending_on_combined_menu_flag
-
visit new_admin_session_path
+ open_top_nav_projects
- page.within('.navbar-sub-nav') do
- find_all('a', text: 'Projects').first.click
+ within_top_nav do
+ click_link('Your projects')
end
expect(page).to have_current_path(dashboard_projects_path)
@@ -78,71 +79,66 @@ RSpec.describe 'Admin mode' do
end
it 'contains link to leave admin mode' do
- pending_on_combined_menu_flag
+ open_top_nav
- page.within('.navbar-sub-nav') do
+ within_top_nav do
expect(page).to have_link(href: destroy_admin_session_path)
end
end
it 'can leave admin mode using main dashboard link', :js do
- pending_on_combined_menu_flag
+ gitlab_disable_admin_mode
- page.within('.navbar-sub-nav') do
- click_on 'Leave Admin Mode'
+ open_top_nav
+ within_top_nav do
expect(page).to have_link(href: new_admin_session_path)
end
end
it 'can leave admin mode using dropdown menu on smaller screens', :js do
- pending_on_combined_menu_flag
+ skip('pending responsive development under :combined_menu feature flag') if Feature.enabled?(:combined_menu, default_enabled: :yaml)
resize_screen_xs
visit root_dashboard_path
- find('.header-more').click
+ find('.header-more').click unless Feature.enabled?(:combined_menu, default_enabled: :yaml)
- page.within '.navbar-sub-nav' do
- click_on 'Leave Admin Mode'
+ gitlab_disable_admin_mode
- find('.header-more').click
+ open_top_nav
+ find('.header-more').click unless Feature.enabled?(:combined_menu, default_enabled: :yaml)
- expect(page).to have_link(href: new_admin_session_path)
- end
+ expect(page).to have_link(href: new_admin_session_path)
end
it 'can open pages not in admin scope' do
- pending_on_combined_menu_flag
-
- page.within('.navbar-sub-nav') do
- find_all('a', text: 'Projects').first.click
+ open_top_nav_projects
- expect(page).to have_current_path(dashboard_projects_path)
+ within_top_nav do
+ click_link('Your projects')
end
+
+ expect(page).to have_current_path(dashboard_projects_path)
end
context 'nav bar' do
it 'shows admin dashboard links on bigger screen' do
- pending_on_combined_menu_flag
-
visit root_dashboard_path
+ open_top_nav
- page.within '.navbar' do
- expect(page).to have_link(text: 'Admin Area', href: admin_root_path, visible: true)
- expect(page).to have_link(text: 'Leave Admin Mode', href: destroy_admin_session_path, visible: true)
- end
+ link_text = Feature.enabled?(:combined_menu, default_enabled: :yaml) ? 'Admin' : 'Admin Area'
+ expect(page).to have_link(text: link_text, href: admin_root_path, visible: true)
+ expect(page).to have_link(text: 'Leave Admin Mode', href: destroy_admin_session_path, visible: true)
end
it 'relocates admin dashboard links to dropdown list on smaller screen', :js do
- pending_on_combined_menu_flag
+ skip('pending responsive development under :combined_menu feature flag') if Feature.enabled?(:combined_menu, default_enabled: :yaml)
resize_screen_xs
visit root_dashboard_path
- page.within '.navbar' do
- expect(page).not_to have_link(text: 'Leave Admin Mode', href: destroy_admin_session_path, visible: true)
- end
+ expect(page).not_to have_link(text: 'Leave Admin Mode', href: destroy_admin_session_path, visible: true)
find('.header-more').click
@@ -159,11 +155,11 @@ RSpec.describe 'Admin mode' do
end
it 'can leave admin mode', :js do
- pending_on_combined_menu_flag
+ gitlab_disable_admin_mode
- page.within('.navbar-sub-nav') do
- click_on 'Leave Admin Mode'
+ open_top_nav
+ within_top_nav do
expect(page).to have_link(href: new_admin_session_path)
end
end
@@ -179,16 +175,15 @@ RSpec.describe 'Admin mode' do
it 'shows no admin mode buttons in navbar' do
visit admin_root_path
+ open_top_nav
- page.within('.navbar-sub-nav') do
- expect(page).not_to have_link(href: new_admin_session_path)
- expect(page).not_to have_link(href: destroy_admin_session_path)
- end
+ expect(page).not_to have_link(href: new_admin_session_path)
+ expect(page).not_to have_link(href: destroy_admin_session_path)
end
end
end
- context 'with combined_menu: feature flag on' do
+ context 'with combined_menu feature flag on', :js do
let(:needs_rewrite_for_combined_menu_flag_on) { true }
before do
@@ -207,8 +202,4 @@ RSpec.describe 'Admin mode' do
it_behaves_like 'combined_menu: feature flag examples'
end
-
- def pending_on_combined_menu_flag
- pending 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56587' if needs_rewrite_for_combined_menu_flag_on
- end
end
diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb
index 4e0dcbdf075..d7a267fec69 100644
--- a/spec/features/admin/admin_runners_spec.rb
+++ b/spec/features/admin/admin_runners_spec.rb
@@ -17,6 +17,10 @@ RSpec.describe "Admin Runners" do
describe "Runners page" do
let(:pipeline) { create(:ci_pipeline) }
+ before do
+ stub_feature_flags(runner_list_view_vue_ui: false)
+ end
+
context "when there are runners" do
it 'has all necessary texts' do
runner = create(:ci_runner, contacted_at: Time.now)
@@ -240,7 +244,7 @@ RSpec.describe "Admin Runners" do
it 'shows the label and does not show the project count' do
visit admin_runners_path
- within "#runner_#{runner.id}" do
+ within "[data-testid='runner-row-#{runner.id}']" do
expect(page).to have_selector '.badge', text: 'group'
expect(page).to have_text 'n/a'
end
@@ -253,7 +257,7 @@ RSpec.describe "Admin Runners" do
visit admin_runners_path
- within "#runner_#{runner.id}" do
+ within "[data-testid='runner-row-#{runner.id}']" do
expect(page).to have_selector '.badge', text: 'shared'
expect(page).to have_text 'n/a'
end
@@ -267,12 +271,36 @@ RSpec.describe "Admin Runners" do
visit admin_runners_path
- within "#runner_#{runner.id}" do
+ within "[data-testid='runner-row-#{runner.id}']" do
expect(page).to have_selector '.badge', text: 'specific'
expect(page).to have_text '1'
end
end
end
+
+ describe 'runners registration token' do
+ let!(:token) { Gitlab::CurrentSettings.runners_registration_token }
+
+ before do
+ visit admin_runners_path
+ end
+
+ it 'has a registration token' do
+ expect(page.find('[data-testid="registration_token"]')).to have_content(token)
+ end
+
+ describe 'reset registration token' do
+ let(:page_token) { find('[data-testid="registration_token"]').text }
+
+ before do
+ click_button 'Reset registration token'
+ end
+
+ it 'changes registration token' do
+ expect(page_token).not_to eq token
+ end
+ end
+ end
end
describe "Runner show page" do
@@ -381,28 +409,4 @@ RSpec.describe "Admin Runners" do
end
end
end
-
- describe 'runners registration token' do
- let!(:token) { Gitlab::CurrentSettings.runners_registration_token }
-
- before do
- visit admin_runners_path
- end
-
- it 'has a registration token' do
- expect(page.find('#registration_token')).to have_content(token)
- end
-
- describe 'reload registration token' do
- let(:page_token) { find('#registration_token').text }
-
- before do
- click_button 'Reset registration token'
- end
-
- it 'changes registration token' do
- expect(page_token).not_to eq token
- end
- end
- end
end
diff --git a/spec/features/admin/admin_search_settings_spec.rb b/spec/features/admin/admin_search_settings_spec.rb
index cd61a1db6f3..989cb7cc787 100644
--- a/spec/features/admin/admin_search_settings_spec.rb
+++ b/spec/features/admin/admin_search_settings_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe 'Admin searches application settings', :js do
context 'in appearances page' do
before do
- visit(admin_appearances_path)
+ visit(admin_application_settings_appearances_path)
end
it_behaves_like 'cannot search settings'
diff --git a/spec/features/admin/admin_sees_background_migrations_spec.rb b/spec/features/admin/admin_sees_background_migrations_spec.rb
new file mode 100644
index 00000000000..d848a8352bc
--- /dev/null
+++ b/spec/features/admin/admin_sees_background_migrations_spec.rb
@@ -0,0 +1,84 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe "Admin > Admin sees background migrations" do
+ let_it_be(:admin) { create(:admin) }
+
+ let_it_be(:active_migration) { create(:batched_background_migration, table_name: 'active', status: :active) }
+ let_it_be(:failed_migration) { create(:batched_background_migration, table_name: 'failed', status: :failed, total_tuple_count: 100) }
+ let_it_be(:finished_migration) { create(:batched_background_migration, table_name: 'finished', status: :finished) }
+
+ before_all do
+ create(:batched_background_migration_job, batched_migration: failed_migration, batch_size: 30, status: :succeeded)
+ end
+
+ before do
+ sign_in(admin)
+ gitlab_enable_admin_mode_sign_in(admin)
+ end
+
+ it 'can navigate to background migrations' do
+ visit admin_root_path
+
+ within '.nav-sidebar' do
+ link = find_link 'Background Migrations'
+
+ link.click
+
+ expect(page).to have_current_path(admin_background_migrations_path)
+ expect(link).to have_ancestor(:css, 'li.active')
+ end
+ end
+
+ it 'can view queued migrations' do
+ visit admin_background_migrations_path
+
+ within '#content-body' do
+ expect(page).to have_selector('tbody tr', count: 1)
+
+ expect(page).to have_content(active_migration.job_class_name)
+ expect(page).to have_content(active_migration.table_name)
+ expect(page).to have_content('0.00%')
+ expect(page).to have_content(active_migration.status.humanize)
+ end
+ end
+
+ it 'can view failed migrations' do
+ visit admin_background_migrations_path
+
+ within '#content-body' do
+ tab = find_link 'Failed'
+ tab.click
+
+ expect(page).to have_current_path(admin_background_migrations_path(tab: 'failed'))
+ expect(tab[:class]).to include('gl-tab-nav-item-active', 'gl-tab-nav-item-active-indigo')
+
+ expect(page).to have_selector('tbody tr', count: 1)
+
+ expect(page).to have_content(failed_migration.job_class_name)
+ expect(page).to have_content(failed_migration.table_name)
+ expect(page).to have_content('30.00%')
+ expect(page).to have_content(failed_migration.status.humanize)
+ end
+ end
+
+ it 'can view finished migrations' do
+ visit admin_background_migrations_path
+
+ within '#content-body' do
+ tab = find_link 'Finished'
+ tab.click
+
+ expect(page).to have_current_path(admin_background_migrations_path(tab: 'finished'))
+ expect(tab[:class]).to include('gl-tab-nav-item-active', 'gl-tab-nav-item-active-indigo')
+
+ expect(page).to have_selector('tbody tr', count: 1)
+
+ expect(page).to have_content(finished_migration.job_class_name)
+ expect(page).to have_content(finished_migration.table_name)
+ expect(page).to have_content('100.00%')
+ expect(page).to have_content(finished_migration.status.humanize)
+ end
+ end
+end
diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb
index 0a7113a5559..c289c18126d 100644
--- a/spec/features/admin/admin_settings_spec.rb
+++ b/spec/features/admin/admin_settings_spec.rb
@@ -8,9 +8,11 @@ RSpec.describe 'Admin updates settings' do
include UsageDataHelpers
let(:admin) { create(:admin) }
+ let(:dot_com?) { false }
context 'application setting :admin_mode is enabled', :request_store do
before do
+ allow(Gitlab).to receive(:com?).and_return(dot_com?)
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
@@ -127,6 +129,37 @@ RSpec.describe 'Admin updates settings' do
expect(user_internal_regex['placeholder']).to eq 'Regex pattern'
end
+ context 'Dormant users' do
+ context 'when Gitlab.com' do
+ let(:dot_com?) { true }
+
+ it 'does not expose the setting' do
+ expect(page).to have_no_selector('#application_setting_deactivate_dormant_users')
+ end
+ end
+
+ context 'when not Gitlab.com' do
+ let(:dot_com?) { false }
+
+ it 'change Dormant users' do
+ expect(page).to have_unchecked_field('Deactivate dormant users after 90 days of inactivity')
+ expect(current_settings.deactivate_dormant_users).to be_falsey
+
+ page.within('.as-account-limit') do
+ check 'application_setting_deactivate_dormant_users'
+ click_button 'Save changes'
+ end
+
+ expect(page).to have_content "Application settings saved successfully"
+
+ page.refresh
+
+ expect(current_settings.deactivate_dormant_users).to be_truthy
+ expect(page).to have_checked_field('Deactivate dormant users after 90 days of inactivity')
+ end
+ end
+ end
+
context 'Change Sign-up restrictions' do
context 'Require Admin approval for new signup setting' do
it 'changes the setting', :js do
@@ -315,19 +348,6 @@ RSpec.describe 'Admin updates settings' do
visit integrations_admin_application_settings_path
end
- it 'allows user to dismiss deprecation notice' do
- expect(page).to have_content('Some settings have moved')
-
- click_button 'Dismiss'
- wait_for_requests
-
- expect(page).not_to have_content('Some settings have moved')
-
- visit integrations_admin_application_settings_path
-
- expect(page).not_to have_content('Some settings have moved')
- end
-
it 'shows integrations table' do
expect(page).to have_selector '[data-testid="inactive-integrations-table"]'
end
diff --git a/spec/features/admin/clusters/applications_spec.rb b/spec/features/admin/clusters/applications_spec.rb
deleted file mode 100644
index e083e4fee4c..00000000000
--- a/spec/features/admin/clusters/applications_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require_relative '../../../../spec/features/clusters/installing_applications_shared_examples'
-
-RSpec.describe 'Instance-level Cluster Applications', :js do
- include GoogleApi::CloudPlatformHelpers
-
- let(:user) { create(:admin) }
-
- before do
- sign_in(user)
- gitlab_enable_admin_mode_sign_in(user)
- end
-
- describe 'Installing applications' do
- include_examples "installing applications on a cluster" do
- let(:cluster_path) { admin_cluster_path(cluster) }
- let(:cluster_factory_args) { [:instance] }
- end
- end
-end
diff --git a/spec/features/admin/integrations/user_activates_mattermost_slash_command_spec.rb b/spec/features/admin/integrations/user_activates_mattermost_slash_command_spec.rb
new file mode 100644
index 00000000000..6f091d37995
--- /dev/null
+++ b/spec/features/admin/integrations/user_activates_mattermost_slash_command_spec.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'User activates the instance-level Mattermost Slash Command integration', :js do
+ include_context 'instance integration activation'
+
+ before do
+ stub_mattermost_setting(enabled: true)
+ visit_instance_integration('Mattermost slash commands')
+ end
+
+ let(:edit_path) { edit_admin_application_settings_integration_path(:mattermost_slash_commands) }
+
+ include_examples 'user activates the Mattermost Slash Command integration'
+end
diff --git a/spec/features/admin/users/user_spec.rb b/spec/features/admin/users/user_spec.rb
index 01341398135..3599658ee56 100644
--- a/spec/features/admin/users/user_spec.rb
+++ b/spec/features/admin/users/user_spec.rb
@@ -356,27 +356,19 @@ RSpec.describe 'Admin::Users::User' do
end
end
- [true, false].each do |vue_admin_users|
- context "with vue_admin_users feature flag set to #{vue_admin_users}", js: vue_admin_users do
- before do
- stub_feature_flags(vue_admin_users: vue_admin_users)
- end
-
- describe 'GET /admin/users' do
- context 'user pending approval' do
- it 'shows user info', :aggregate_failures do
- user = create(:user, :blocked_pending_approval)
+ describe 'GET /admin/users', :js do
+ context 'user pending approval' do
+ it 'shows user info', :aggregate_failures do
+ user = create(:user, :blocked_pending_approval)
- visit admin_users_path
- click_link 'Pending approval'
- click_link user.name
+ visit admin_users_path
+ click_link 'Pending approval'
+ click_link user.name
- expect(page).to have_content(user.name)
- expect(page).to have_content('Pending approval')
- expect(page).to have_link('Approve user')
- expect(page).to have_link('Reject request')
- end
- end
+ expect(page).to have_content(user.name)
+ expect(page).to have_content('Pending approval')
+ expect(page).to have_link('Approve user')
+ expect(page).to have_link('Reject request')
end
end
end
diff --git a/spec/features/admin/users/users_spec.rb b/spec/features/admin/users/users_spec.rb
index d3931373ee3..187fa6fc2a4 100644
--- a/spec/features/admin/users/users_spec.rb
+++ b/spec/features/admin/users/users_spec.rb
@@ -11,294 +11,318 @@ RSpec.describe 'Admin::Users' do
gitlab_enable_admin_mode_sign_in(current_user)
end
- [true, false].each do |vue_admin_users|
- context "with vue_admin_users feature flag set to #{vue_admin_users}", js: vue_admin_users do
- before do
- stub_feature_flags(vue_admin_users: vue_admin_users)
- end
+ describe 'GET /admin/users', :js do
+ before do
+ visit admin_users_path
+ end
- describe 'GET /admin/users' do
- before do
- visit admin_users_path
- end
+ it "is ok" do
+ expect(current_path).to eq(admin_users_path)
+ end
- it "is ok" do
- expect(current_path).to eq(admin_users_path)
- end
+ it "has users list" do
+ current_user.reload
- it "has users list" do
- current_user.reload
+ expect(page).to have_content(current_user.email)
+ expect(page).to have_content(current_user.name)
+ expect(page).to have_content(current_user.created_at.strftime('%e %b, %Y'))
+ expect(page).to have_content(user.email)
+ expect(page).to have_content(user.name)
+ expect(page).to have_content('Projects')
- expect(page).to have_content(current_user.email)
- expect(page).to have_content(current_user.name)
- expect(page).to have_content(current_user.created_at.strftime('%e %b, %Y'))
- expect(page).to have_content(user.email)
- expect(page).to have_content(user.name)
- expect(page).to have_content('Projects')
+ click_user_dropdown_toggle(user.id)
- click_user_dropdown_toggle(user.id)
+ expect(page).to have_button('Block')
+ expect(page).to have_button('Deactivate')
+ expect(page).to have_button('Delete user')
+ expect(page).to have_button('Delete user and contributions')
+ end
- expect(page).to have_button('Block')
- expect(page).to have_button('Deactivate')
- expect(page).to have_button('Delete user')
- expect(page).to have_button('Delete user and contributions')
- end
+ it 'clicking edit user takes us to edit page', :aggregate_failures do
+ page.within("[data-testid='user-actions-#{user.id}']") do
+ click_link 'Edit'
+ end
- it 'clicking edit user takes us to edit page', :aggregate_failures do
- page.within("[data-testid='user-actions-#{user.id}']") do
- click_link 'Edit'
- end
+ expect(page).to have_content('Name')
+ expect(page).to have_content('Password')
+ end
- expect(page).to have_content('Name')
- expect(page).to have_content('Password')
- end
+ describe 'view extra user information' do
+ it 'shows the user popover on hover', :js, quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/11290' do
+ expect(page).not_to have_selector('#__BV_popover_1__')
- describe 'view extra user information' do
- it 'shows the user popover on hover', :js, quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/11290' do
- expect(page).not_to have_selector('#__BV_popover_1__')
+ first_user_link = page.first('.js-user-link')
+ first_user_link.hover
- first_user_link = page.first('.js-user-link')
- first_user_link.hover
+ expect(page).to have_selector('#__BV_popover_1__')
+ end
+ end
- expect(page).to have_selector('#__BV_popover_1__')
- end
- end
+ context 'user project count' do
+ before do
+ project = create(:project)
+ project.add_maintainer(current_user)
+ end
- context 'user project count' do
- before do
- project = create(:project)
- project.add_maintainer(current_user)
- end
+ it 'displays count of users projects' do
+ visit admin_users_path
- it 'displays count of users projects' do
- visit admin_users_path
+ expect(page.find("[data-testid='user-project-count-#{current_user.id}']").text).to eq("1")
+ end
+ end
+
+ describe 'tabs' do
+ it 'has multiple tabs to filter users' do
+ expect(page).to have_link('Active', href: admin_users_path)
+ expect(page).to have_link('Admins', href: admin_users_path(filter: 'admins'))
+ expect(page).to have_link('2FA Enabled', href: admin_users_path(filter: 'two_factor_enabled'))
+ expect(page).to have_link('2FA Disabled', href: admin_users_path(filter: 'two_factor_disabled'))
+ expect(page).to have_link('External', href: admin_users_path(filter: 'external'))
+ expect(page).to have_link('Blocked', href: admin_users_path(filter: 'blocked'))
+ expect(page).to have_link('Deactivated', href: admin_users_path(filter: 'deactivated'))
+ expect(page).to have_link('Without projects', href: admin_users_path(filter: 'wop'))
+ end
- expect(page.find("[data-testid='user-project-count-#{current_user.id}']").text).to eq("1")
- end
+ context '`Pending approval` tab' do
+ before do
+ visit admin_users_path
end
- describe 'tabs' do
- it 'has multiple tabs to filter users' do
- expect(page).to have_link('Active', href: admin_users_path)
- expect(page).to have_link('Admins', href: admin_users_path(filter: 'admins'))
- expect(page).to have_link('2FA Enabled', href: admin_users_path(filter: 'two_factor_enabled'))
- expect(page).to have_link('2FA Disabled', href: admin_users_path(filter: 'two_factor_disabled'))
- expect(page).to have_link('External', href: admin_users_path(filter: 'external'))
- expect(page).to have_link('Blocked', href: admin_users_path(filter: 'blocked'))
- expect(page).to have_link('Banned', href: admin_users_path(filter: 'banned'))
- expect(page).to have_link('Deactivated', href: admin_users_path(filter: 'deactivated'))
- expect(page).to have_link('Without projects', href: admin_users_path(filter: 'wop'))
- end
-
- context '`Pending approval` tab' do
- before do
- visit admin_users_path
- end
-
- it 'shows the `Pending approval` tab' do
- expect(page).to have_link('Pending approval', href: admin_users_path(filter: 'blocked_pending_approval'))
- end
- end
+ it 'shows the `Pending approval` tab' do
+ expect(page).to have_link('Pending approval', href: admin_users_path(filter: 'blocked_pending_approval'))
end
+ end
+ end
- describe 'search and sort' do
- before_all do
- create(:user, name: 'Foo Bar', last_activity_on: 3.days.ago)
- create(:user, name: 'Foo Baz', last_activity_on: 2.days.ago)
- create(:user, name: 'Dmitriy')
- end
+ describe 'search and sort' do
+ before_all do
+ create(:user, name: 'Foo Bar', last_activity_on: 3.days.ago)
+ create(:user, name: 'Foo Baz', last_activity_on: 2.days.ago)
+ create(:user, name: 'Dmitriy')
+ end
- it 'searches users by name' do
- visit admin_users_path(search_query: 'Foo')
+ it 'searches users by name' do
+ visit admin_users_path(search_query: 'Foo')
- expect(page).to have_content('Foo Bar')
- expect(page).to have_content('Foo Baz')
- expect(page).not_to have_content('Dmitriy')
- end
+ expect(page).to have_content('Foo Bar')
+ expect(page).to have_content('Foo Baz')
+ expect(page).not_to have_content('Dmitriy')
+ end
- it 'sorts users by name' do
- visit admin_users_path
+ it 'sorts users by name' do
+ visit admin_users_path
- sort_by('Name')
+ sort_by('Name')
- expect(first_row.text).to include('Dmitriy')
- expect(second_row.text).to include('Foo Bar')
- end
+ expect(first_row.text).to include('Dmitriy')
+ expect(second_row.text).to include('Foo Bar')
+ end
- it 'sorts search results only' do
- visit admin_users_path(search_query: 'Foo')
+ it 'sorts search results only' do
+ visit admin_users_path(search_query: 'Foo')
- sort_by('Name')
- expect(page).not_to have_content('Dmitriy')
- expect(first_row.text).to include('Foo Bar')
- expect(second_row.text).to include('Foo Baz')
- end
+ sort_by('Name')
+ expect(page).not_to have_content('Dmitriy')
+ expect(first_row.text).to include('Foo Bar')
+ expect(second_row.text).to include('Foo Baz')
+ end
- it 'searches with respect of sorting' do
- visit admin_users_path(sort: 'Name')
+ it 'searches with respect of sorting' do
+ visit admin_users_path(sort: 'Name')
- fill_in :search_query, with: 'Foo'
- click_button('Search users')
+ fill_in :search_query, with: 'Foo'
+ click_button('Search users')
- expect(first_row.text).to include('Foo Bar')
- expect(second_row.text).to include('Foo Baz')
- end
+ expect(first_row.text).to include('Foo Bar')
+ expect(second_row.text).to include('Foo Baz')
+ end
- it 'sorts users by recent last activity' do
- visit admin_users_path(search_query: 'Foo')
+ it 'sorts users by recent last activity' do
+ visit admin_users_path(search_query: 'Foo')
- sort_by('Recent last activity')
+ sort_by('Recent last activity')
- expect(first_row.text).to include('Foo Baz')
- expect(second_row.text).to include('Foo Bar')
- end
+ expect(first_row.text).to include('Foo Baz')
+ expect(second_row.text).to include('Foo Bar')
+ end
- it 'sorts users by oldest last activity' do
- visit admin_users_path(search_query: 'Foo')
+ it 'sorts users by oldest last activity' do
+ visit admin_users_path(search_query: 'Foo')
- sort_by('Oldest last activity')
+ sort_by('Oldest last activity')
- expect(first_row.text).to include('Foo Bar')
- expect(second_row.text).to include('Foo Baz')
- end
+ expect(first_row.text).to include('Foo Bar')
+ expect(second_row.text).to include('Foo Baz')
+ end
+ end
+
+ describe 'Two-factor Authentication filters' do
+ it 'counts users who have enabled 2FA' do
+ create(:user, :two_factor)
+
+ visit admin_users_path
+
+ page.within('.filter-two-factor-enabled small') do
+ expect(page).to have_content('1')
end
+ end
- describe 'Two-factor Authentication filters' do
- it 'counts users who have enabled 2FA' do
- create(:user, :two_factor)
+ it 'filters by users who have enabled 2FA' do
+ user = create(:user, :two_factor)
- visit admin_users_path
+ visit admin_users_path
+ click_link '2FA Enabled'
- page.within('.filter-two-factor-enabled small') do
- expect(page).to have_content('1')
- end
- end
+ expect(page).to have_content(user.email)
+ end
- it 'filters by users who have enabled 2FA' do
- user = create(:user, :two_factor)
+ it 'counts users who have not enabled 2FA' do
+ visit admin_users_path
- visit admin_users_path
- click_link '2FA Enabled'
+ page.within('.filter-two-factor-disabled small') do
+ expect(page).to have_content('2') # Including admin
+ end
+ end
- expect(page).to have_content(user.email)
- end
+ it 'filters by users who have not enabled 2FA' do
+ visit admin_users_path
+ click_link '2FA Disabled'
- it 'counts users who have not enabled 2FA' do
- visit admin_users_path
+ expect(page).to have_content(user.email)
+ end
+ end
- page.within('.filter-two-factor-disabled small') do
- expect(page).to have_content('2') # Including admin
- end
- end
+ describe 'Pending approval filter' do
+ it 'counts users who are pending approval' do
+ create_list(:user, 2, :blocked_pending_approval)
- it 'filters by users who have not enabled 2FA' do
- visit admin_users_path
- click_link '2FA Disabled'
+ visit admin_users_path
- expect(page).to have_content(user.email)
- end
+ page.within('.filter-blocked-pending-approval small') do
+ expect(page).to have_content('2')
end
+ end
- describe 'Pending approval filter' do
- it 'counts users who are pending approval' do
- create_list(:user, 2, :blocked_pending_approval)
+ it 'filters by users who are pending approval' do
+ user = create(:user, :blocked_pending_approval)
- visit admin_users_path
+ visit admin_users_path
+ click_link 'Pending approval'
- page.within('.filter-blocked-pending-approval small') do
- expect(page).to have_content('2')
- end
- end
+ expect(page).to have_content(user.email)
+ end
+ end
- it 'filters by users who are pending approval' do
- user = create(:user, :blocked_pending_approval)
+ context 'when blocking/unblocking a user' do
+ it 'shows confirmation and allows blocking and unblocking', :js do
+ expect(page).to have_content(user.email)
- visit admin_users_path
- click_link 'Pending approval'
+ click_action_in_user_dropdown(user.id, 'Block')
- expect(page).to have_content(user.email)
- end
- end
+ wait_for_requests
- context 'when blocking/unblocking a user' do
- it 'shows confirmation and allows blocking and unblocking', :js do
- expect(page).to have_content(user.email)
+ expect(page).to have_content('Block user')
+ expect(page).to have_content('Blocking user has the following effects')
+ expect(page).to have_content('User will not be able to login')
+ expect(page).to have_content('Owned groups will be left')
- click_action_in_user_dropdown(user.id, 'Block')
+ find('.modal-footer button', text: 'Block').click
- wait_for_requests
+ wait_for_requests
- expect(page).to have_content('Block user')
- expect(page).to have_content('Blocking user has the following effects')
- expect(page).to have_content('User will not be able to login')
- expect(page).to have_content('Owned groups will be left')
+ expect(page).to have_content('Successfully blocked')
+ expect(page).not_to have_content(user.email)
- find('.modal-footer button', text: 'Block').click
+ click_link 'Blocked'
- wait_for_requests
+ wait_for_requests
- expect(page).to have_content('Successfully blocked')
- expect(page).not_to have_content(user.email)
+ expect(page).to have_content(user.email)
- click_link 'Blocked'
+ click_action_in_user_dropdown(user.id, 'Unblock')
- wait_for_requests
+ expect(page).to have_content('Unblock user')
+ expect(page).to have_content('You can always block their account again if needed.')
- expect(page).to have_content(user.email)
+ find('.modal-footer button', text: 'Unblock').click
- click_action_in_user_dropdown(user.id, 'Unblock')
+ wait_for_requests
- expect(page).to have_content('Unblock user')
- expect(page).to have_content('You can always block their account again if needed.')
+ expect(page).to have_content('Successfully unblocked')
+ expect(page).not_to have_content(user.email)
+ end
+ end
- find('.modal-footer button', text: 'Unblock').click
+ context 'when deactivating/re-activating a user' do
+ it 'shows confirmation and allows deactivating and re-activating', :js do
+ expect(page).to have_content(user.email)
- wait_for_requests
+ click_action_in_user_dropdown(user.id, 'Deactivate')
- expect(page).to have_content('Successfully unblocked')
- expect(page).not_to have_content(user.email)
- end
- end
+ expect(page).to have_content('Deactivate user')
+ expect(page).to have_content('Deactivating a user has the following effects')
+ expect(page).to have_content('The user will be logged out')
+ expect(page).to have_content('Personal projects, group and user history will be left intact')
- context 'when deactivating/re-activating a user' do
- it 'shows confirmation and allows deactivating and re-activating', :js do
- expect(page).to have_content(user.email)
+ find('.modal-footer button', text: 'Deactivate').click
- click_action_in_user_dropdown(user.id, 'Deactivate')
+ wait_for_requests
- expect(page).to have_content('Deactivate user')
- expect(page).to have_content('Deactivating a user has the following effects')
- expect(page).to have_content('The user will be logged out')
- expect(page).to have_content('Personal projects, group and user history will be left intact')
+ expect(page).to have_content('Successfully deactivated')
+ expect(page).not_to have_content(user.email)
- find('.modal-footer button', text: 'Deactivate').click
+ click_link 'Deactivated'
- wait_for_requests
+ wait_for_requests
- expect(page).to have_content('Successfully deactivated')
- expect(page).not_to have_content(user.email)
+ expect(page).to have_content(user.email)
- click_link 'Deactivated'
+ click_action_in_user_dropdown(user.id, 'Activate')
- wait_for_requests
+ expect(page).to have_content('Activate user')
+ expect(page).to have_content('You can always deactivate their account again if needed.')
- expect(page).to have_content(user.email)
+ find('.modal-footer button', text: 'Activate').click
- click_action_in_user_dropdown(user.id, 'Activate')
+ wait_for_requests
- expect(page).to have_content('Activate user')
- expect(page).to have_content('You can always deactivate their account again if needed.')
+ expect(page).to have_content('Successfully activated')
+ expect(page).not_to have_content(user.email)
+ end
+ end
- find('.modal-footer button', text: 'Activate').click
+ describe 'internal users' do
+ context 'when showing a `Ghost User`' do
+ let_it_be(:ghost_user) { create(:user, :ghost) }
- wait_for_requests
+ it 'does not render actions dropdown' do
+ expect(page).not_to have_css("[data-testid='user-actions-#{ghost_user.id}'] [data-testid='dropdown-toggle']")
+ end
+ end
+
+ context 'when showing a `Bot User`' do
+ let_it_be(:bot_user) { create(:user, user_type: :alert_bot) }
- expect(page).to have_content('Successfully activated')
- expect(page).not_to have_content(user.email)
- end
+ it 'does not render actions dropdown' do
+ expect(page).not_to have_css("[data-testid='user-actions-#{bot_user.id}'] [data-testid='dropdown-toggle']")
end
end
end
+
+ context 'user group count', :js do
+ before do
+ group = create(:group)
+ group.add_developer(current_user)
+ project = create(:project, group: create(:group))
+ project.add_reporter(current_user)
+ end
+
+ it 'displays count of the users authorized groups' do
+ wait_for_requests
+
+ expect(page.find("[data-testid='user-group-count-#{current_user.id}']").text).to eq("2")
+ end
+ end
end
describe 'GET /admin/users/new' do
@@ -548,32 +572,6 @@ RSpec.describe 'Admin::Users' do
end
end
- # TODO: Move to main GET /admin/users block once feature flag is removed. Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/290737
- context 'with vue_admin_users feature flag enabled', :js do
- before do
- stub_feature_flags(vue_admin_users: true)
- end
-
- describe 'GET /admin/users' do
- context 'user group count', :js do
- before do
- group = create(:group)
- group.add_developer(current_user)
- project = create(:project, group: create(:group))
- project.add_reporter(current_user)
- end
-
- it 'displays count of the users authorized groups' do
- visit admin_users_path
-
- wait_for_requests
-
- expect(page.find("[data-testid='user-group-count-#{current_user.id}']").text).to eq("2")
- end
- end
- end
- end
-
def click_user_dropdown_toggle(user_id)
page.within("[data-testid='user-actions-#{user_id}']") do
find("[data-testid='dropdown-toggle']").click