summaryrefslogtreecommitdiff
path: root/spec/features/admin
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /spec/features/admin
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
downloadgitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/features/admin')
-rw-r--r--spec/features/admin/admin_appearance_spec.rb2
-rw-r--r--spec/features/admin/admin_dev_ops_report_spec.rb2
-rw-r--r--spec/features/admin/admin_groups_spec.rb13
-rw-r--r--spec/features/admin/admin_mode/workers_spec.rb5
-rw-r--r--spec/features/admin/admin_projects_spec.rb11
-rw-r--r--spec/features/admin/admin_runners_spec.rb274
-rw-r--r--spec/features/admin/admin_sees_background_migrations_spec.rb13
-rw-r--r--spec/features/admin/admin_settings_spec.rb113
-rw-r--r--spec/features/admin/admin_users_impersonation_tokens_spec.rb4
-rw-r--r--spec/features/admin/services/admin_visits_service_templates_spec.rb14
-rw-r--r--spec/features/admin/users/user_spec.rb78
-rw-r--r--spec/features/admin/users/users_spec.rb18
12 files changed, 322 insertions, 225 deletions
diff --git a/spec/features/admin/admin_appearance_spec.rb b/spec/features/admin/admin_appearance_spec.rb
index 5596ad7bf21..b96762ec6ad 100644
--- a/spec/features/admin/admin_appearance_spec.rb
+++ b/spec/features/admin/admin_appearance_spec.rb
@@ -90,7 +90,7 @@ RSpec.describe 'Admin Appearance' do
sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin)
visit new_project_path
- find('[data-qa-selector="blank_project_link"]').click
+ find('[data-qa-panel-name="blank_project"]').click
expect_custom_new_project_appearance(appearance)
end
diff --git a/spec/features/admin/admin_dev_ops_report_spec.rb b/spec/features/admin/admin_dev_ops_report_spec.rb
index 33f984af807..8f1960b681c 100644
--- a/spec/features/admin/admin_dev_ops_report_spec.rb
+++ b/spec/features/admin/admin_dev_ops_report_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe 'DevOps Report page', :js do
it 'shows empty state' do
visit admin_dev_ops_report_path
- expect(page).to have_selector(".js-empty-state")
+ expect(page).to have_text('Service ping is off')
end
it 'hides the intro callout' do
diff --git a/spec/features/admin/admin_groups_spec.rb b/spec/features/admin/admin_groups_spec.rb
index f9673a8aa2f..7d7b2baf941 100644
--- a/spec/features/admin/admin_groups_spec.rb
+++ b/spec/features/admin/admin_groups_spec.rb
@@ -132,6 +132,19 @@ RSpec.describe 'Admin Groups' do
expect(page).to have_text(note_text)
end
+
+ context 'when group has open access requests' do
+ let!(:access_request) { create(:group_member, :access_request, group: group) }
+
+ it 'shows access requests with link to manage access' do
+ visit admin_group_path(group)
+
+ page.within '[data-testid="access-requests"]' do
+ expect(page).to have_content access_request.user.name
+ expect(page).to have_link 'Manage access', href: group_group_members_path(group, tab: 'access_requests')
+ end
+ end
+ end
end
describe 'group edit' do
diff --git a/spec/features/admin/admin_mode/workers_spec.rb b/spec/features/admin/admin_mode/workers_spec.rb
index fbbcf19063b..0caa883fb5b 100644
--- a/spec/features/admin/admin_mode/workers_spec.rb
+++ b/spec/features/admin/admin_mode/workers_spec.rb
@@ -4,6 +4,8 @@ require 'spec_helper'
# Test an operation that triggers background jobs requiring administrative rights
RSpec.describe 'Admin mode for workers', :request_store do
+ include Spec::Support::Helpers::Features::AdminUsersHelpers
+
let(:user) { create(:user) }
let(:user_to_delete) { create(:user) }
@@ -37,7 +39,8 @@ RSpec.describe 'Admin mode for workers', :request_store do
it 'can delete user', :js do
visit admin_user_path(user_to_delete)
- click_button 'Delete user'
+
+ click_action_in_user_dropdown(user_to_delete.id, 'Delete user')
page.within '.modal-dialog' do
find("input[name='username']").send_keys(user_to_delete.name)
diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb
index cbbe9aa3b8b..15def00f354 100644
--- a/spec/features/admin/admin_projects_spec.rb
+++ b/spec/features/admin/admin_projects_spec.rb
@@ -52,6 +52,8 @@ RSpec.describe "Admin::Projects" do
end
describe "GET /admin/projects/:namespace_id/:id" do
+ let!(:access_request) { create(:project_member, :access_request, project: project) }
+
before do
expect(project).to be_persisted
@@ -67,6 +69,15 @@ RSpec.describe "Admin::Projects" do
expect(page).to have_content(project.creator.name)
expect(page).to have_content(project.id)
end
+
+ context 'when project has open access requests' do
+ it 'shows access requests with link to manage access' do
+ page.within '[data-testid="access-requests"]' do
+ expect(page).to have_content access_request.user.name
+ expect(page).to have_link 'Manage access', href: project_project_members_path(project, tab: 'access_requests')
+ end
+ end
+ end
end
describe 'transfer project' do
diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb
index d7a267fec69..54c07985a21 100644
--- a/spec/features/admin/admin_runners_spec.rb
+++ b/spec/features/admin/admin_runners_spec.rb
@@ -4,8 +4,6 @@ require 'spec_helper'
RSpec.describe "Admin Runners" do
include StubENV
- include FilteredSearchHelpers
- include SortingHelper
before do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
@@ -14,31 +12,68 @@ RSpec.describe "Admin Runners" do
gitlab_enable_admin_mode_sign_in(admin)
end
- describe "Runners page" do
- let(:pipeline) { create(:ci_pipeline) }
-
- before do
- stub_feature_flags(runner_list_view_vue_ui: false)
- end
+ describe "Runners page", :js do
+ let_it_be(:user) { create(:user) }
+ let_it_be(:group) { create(:group) }
+ let_it_be(:namespace) { create(:namespace) }
+ let_it_be(:project) { create(:project, namespace: namespace, creator: user) }
context "when there are runners" do
it 'has all necessary texts' do
- runner = create(:ci_runner, contacted_at: Time.now)
- create(:ci_build, pipeline: pipeline, runner_id: runner.id)
+ create(:ci_runner, :instance, contacted_at: Time.now)
+
visit admin_runners_path
expect(page).to have_text "Set up a shared runner manually"
expect(page).to have_text "Runners currently online: 1"
end
- describe 'search', :js do
+ it 'with an instance runner shows an instance badge and no project count' do
+ runner = create(:ci_runner, :instance)
+
+ visit admin_runners_path
+
+ within "[data-testid='runner-row-#{runner.id}']" do
+ expect(page).to have_selector '.badge', text: 'shared'
+ expect(page).to have_text 'n/a'
+ end
+ end
+
+ it 'with a group runner shows a group badge and no project count' do
+ runner = create(:ci_runner, :group, groups: [group])
+
+ visit admin_runners_path
+
+ within "[data-testid='runner-row-#{runner.id}']" do
+ expect(page).to have_selector '.badge', text: 'group'
+ expect(page).to have_text 'n/a'
+ end
+ end
+
+ it 'with a project runner shows a project badge and project count' do
+ runner = create(:ci_runner, :project, projects: [project])
+
+ visit admin_runners_path
+
+ within "[data-testid='runner-row-#{runner.id}']" do
+ expect(page).to have_selector '.badge', text: 'specific'
+ expect(page).to have_text '1'
+ end
+ end
+
+ describe 'search' do
before do
- create(:ci_runner, description: 'runner-foo')
- create(:ci_runner, description: 'runner-bar')
+ create(:ci_runner, :instance, description: 'runner-foo')
+ create(:ci_runner, :instance, description: 'runner-bar')
visit admin_runners_path
end
+ it 'shows runners' do
+ expect(page).to have_content("runner-foo")
+ expect(page).to have_content("runner-bar")
+ end
+
it 'shows correct runner when description matches' do
input_filtered_search_keys('runner-foo')
@@ -53,28 +88,29 @@ RSpec.describe "Admin Runners" do
end
end
- describe 'filter by status', :js do
+ describe 'filter by status' do
it 'shows correct runner when status matches' do
- create(:ci_runner, description: 'runner-active', active: true)
- create(:ci_runner, description: 'runner-paused', active: false)
+ create(:ci_runner, :instance, description: 'runner-active', active: true)
+ create(:ci_runner, :instance, description: 'runner-paused', active: false)
visit admin_runners_path
expect(page).to have_content 'runner-active'
expect(page).to have_content 'runner-paused'
- input_filtered_search_keys('status:=active')
+ input_filtered_search_filter_is_only('Status', 'Active')
+
expect(page).to have_content 'runner-active'
expect(page).not_to have_content 'runner-paused'
end
it 'shows no runner when status does not match' do
- create(:ci_runner, :online, description: 'runner-active', active: true)
- create(:ci_runner, :online, description: 'runner-paused', active: false)
+ create(:ci_runner, :instance, description: 'runner-active', active: true)
+ create(:ci_runner, :instance, description: 'runner-paused', active: false)
visit admin_runners_path
- input_filtered_search_keys('status:=offline')
+ input_filtered_search_filter_is_only('Status', 'Online')
expect(page).not_to have_content 'runner-active'
expect(page).not_to have_content 'runner-paused'
@@ -83,46 +119,48 @@ RSpec.describe "Admin Runners" do
end
it 'shows correct runner when status is selected and search term is entered' do
- create(:ci_runner, description: 'runner-a-1', active: true)
- create(:ci_runner, description: 'runner-a-2', active: false)
- create(:ci_runner, description: 'runner-b-1', active: true)
+ create(:ci_runner, :instance, description: 'runner-a-1', active: true)
+ create(:ci_runner, :instance, description: 'runner-a-2', active: false)
+ create(:ci_runner, :instance, description: 'runner-b-1', active: true)
visit admin_runners_path
- input_filtered_search_keys('status:=active')
+ input_filtered_search_filter_is_only('Status', 'Active')
+
expect(page).to have_content 'runner-a-1'
expect(page).to have_content 'runner-b-1'
expect(page).not_to have_content 'runner-a-2'
- input_filtered_search_keys('status:=active runner-a')
+ input_filtered_search_keys('runner-a')
+
expect(page).to have_content 'runner-a-1'
expect(page).not_to have_content 'runner-b-1'
expect(page).not_to have_content 'runner-a-2'
end
end
- describe 'filter by type', :js do
- it 'shows correct runner when type matches' do
- create :ci_runner, :project, description: 'runner-project'
- create :ci_runner, :group, description: 'runner-group'
+ describe 'filter by type' do
+ before do
+ create(:ci_runner, :project, description: 'runner-project', projects: [project])
+ create(:ci_runner, :group, description: 'runner-group', groups: [group])
+ end
+ it 'shows correct runner when type matches' do
visit admin_runners_path
expect(page).to have_content 'runner-project'
expect(page).to have_content 'runner-group'
- input_filtered_search_keys('type:=project_type')
+ input_filtered_search_filter_is_only('Type', 'project')
+
expect(page).to have_content 'runner-project'
expect(page).not_to have_content 'runner-group'
end
it 'shows no runner when type does not match' do
- create :ci_runner, :project, description: 'runner-project'
- create :ci_runner, :group, description: 'runner-group'
-
visit admin_runners_path
- input_filtered_search_keys('type:=instance_type')
+ input_filtered_search_filter_is_only('Type', 'instance')
expect(page).not_to have_content 'runner-project'
expect(page).not_to have_content 'runner-group'
@@ -131,95 +169,93 @@ RSpec.describe "Admin Runners" do
end
it 'shows correct runner when type is selected and search term is entered' do
- create :ci_runner, :project, description: 'runner-a-1'
- create :ci_runner, :instance, description: 'runner-a-2'
- create :ci_runner, :project, description: 'runner-b-1'
+ create(:ci_runner, :project, description: 'runner-2-project', projects: [project])
visit admin_runners_path
- input_filtered_search_keys('type:=project_type')
- expect(page).to have_content 'runner-a-1'
- expect(page).to have_content 'runner-b-1'
- expect(page).not_to have_content 'runner-a-2'
+ input_filtered_search_filter_is_only('Type', 'project')
- input_filtered_search_keys('type:=project_type runner-a')
- expect(page).to have_content 'runner-a-1'
- expect(page).not_to have_content 'runner-b-1'
- expect(page).not_to have_content 'runner-a-2'
+ expect(page).to have_content 'runner-project'
+ expect(page).to have_content 'runner-2-project'
+ expect(page).not_to have_content 'runner-group'
+
+ input_filtered_search_keys('runner-project')
+
+ expect(page).to have_content 'runner-project'
+ expect(page).not_to have_content 'runner-2-project'
+ expect(page).not_to have_content 'runner-group'
end
end
- describe 'filter by tag', :js do
- it 'shows correct runner when tag matches' do
- create :ci_runner, description: 'runner-blue', tag_list: ['blue']
- create :ci_runner, description: 'runner-red', tag_list: ['red']
+ describe 'filter by tag' do
+ before do
+ create(:ci_runner, :instance, description: 'runner-blue', tag_list: ['blue'])
+ create(:ci_runner, :instance, description: 'runner-red', tag_list: ['red'])
+ end
+ it 'shows correct runner when tag matches' do
visit admin_runners_path
expect(page).to have_content 'runner-blue'
expect(page).to have_content 'runner-red'
- input_filtered_search_keys('tag:=blue')
+ input_filtered_search_filter_is_only('Tags', 'blue')
expect(page).to have_content 'runner-blue'
expect(page).not_to have_content 'runner-red'
end
it 'shows no runner when tag does not match' do
- create :ci_runner, description: 'runner-blue', tag_list: ['blue']
- create :ci_runner, description: 'runner-red', tag_list: ['blue']
-
visit admin_runners_path
- input_filtered_search_keys('tag:=red')
+ input_filtered_search_filter_is_only('Tags', 'green')
expect(page).not_to have_content 'runner-blue'
- expect(page).not_to have_content 'runner-blue'
expect(page).to have_text 'No runners found'
end
it 'shows correct runner when tag is selected and search term is entered' do
- create :ci_runner, description: 'runner-a-1', tag_list: ['blue']
- create :ci_runner, description: 'runner-a-2', tag_list: ['red']
- create :ci_runner, description: 'runner-b-1', tag_list: ['blue']
+ create(:ci_runner, :instance, description: 'runner-2-blue', tag_list: ['blue'])
visit admin_runners_path
- input_filtered_search_keys('tag:=blue')
+ input_filtered_search_filter_is_only('Tags', 'blue')
- expect(page).to have_content 'runner-a-1'
- expect(page).to have_content 'runner-b-1'
- expect(page).not_to have_content 'runner-a-2'
+ expect(page).to have_content 'runner-blue'
+ expect(page).to have_content 'runner-2-blue'
+ expect(page).not_to have_content 'runner-red'
- input_filtered_search_keys('tag:=blue runner-a')
+ input_filtered_search_keys('runner-2-blue')
- expect(page).to have_content 'runner-a-1'
- expect(page).not_to have_content 'runner-b-1'
- expect(page).not_to have_content 'runner-a-2'
+ expect(page).to have_content 'runner-2-blue'
+ expect(page).not_to have_content 'runner-blue'
+ expect(page).not_to have_content 'runner-red'
end
end
- it 'sorts by last contact date', :js do
- create(:ci_runner, description: 'runner-1', created_at: '2018-07-12 15:37', contacted_at: '2018-07-12 15:37')
- create(:ci_runner, description: 'runner-2', created_at: '2018-07-12 16:37', contacted_at: '2018-07-12 16:37')
+ it 'sorts by last contact date' do
+ create(:ci_runner, :instance, description: 'runner-1', created_at: '2018-07-12 15:37', contacted_at: '2018-07-12 15:37')
+ create(:ci_runner, :instance, description: 'runner-2', created_at: '2018-07-12 16:37', contacted_at: '2018-07-12 16:37')
visit admin_runners_path
- within '[data-testid="runners-table"] .gl-responsive-table-row:nth-child(2)' do
+ within '[data-testid="runner-list"] tbody tr:nth-child(1)' do
expect(page).to have_content 'runner-2'
end
- within '[data-testid="runners-table"] .gl-responsive-table-row:nth-child(3)' do
+ within '[data-testid="runner-list"] tbody tr:nth-child(2)' do
expect(page).to have_content 'runner-1'
end
- sorting_by 'Last Contact'
+ click_on 'Created date' # Open "sort by" dropdown
+ click_on 'Last contact'
+ click_on 'Sort direction: Descending'
- within '[data-testid="runners-table"] .gl-responsive-table-row:nth-child(2)' do
+ within '[data-testid="runner-list"] tbody tr:nth-child(1)' do
expect(page).to have_content 'runner-1'
end
- within '[data-testid="runners-table"] .gl-responsive-table-row:nth-child(3)' do
+ within '[data-testid="runner-list"] tbody tr:nth-child(2)' do
expect(page).to have_content 'runner-2'
end
end
@@ -237,47 +273,6 @@ RSpec.describe "Admin Runners" do
end
end
- context 'group runner' do
- let(:group) { create(:group) }
- let!(:runner) { create(:ci_runner, :group, groups: [group]) }
-
- it 'shows the label and does not show the project count' do
- visit admin_runners_path
-
- within "[data-testid='runner-row-#{runner.id}']" do
- expect(page).to have_selector '.badge', text: 'group'
- expect(page).to have_text 'n/a'
- end
- end
- end
-
- context 'shared runner' do
- it 'shows the label and does not show the project count' do
- runner = create(:ci_runner, :instance)
-
- visit admin_runners_path
-
- within "[data-testid='runner-row-#{runner.id}']" do
- expect(page).to have_selector '.badge', text: 'shared'
- expect(page).to have_text 'n/a'
- end
- end
- end
-
- context 'specific runner' do
- it 'shows the label and the project count' do
- project = create(:project)
- runner = create(:ci_runner, :project, projects: [project])
-
- visit admin_runners_path
-
- 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 }
@@ -286,17 +281,23 @@ RSpec.describe "Admin Runners" do
end
it 'has a registration token' do
- expect(page.find('[data-testid="registration_token"]')).to have_content(token)
+ click_on 'Click to reveal'
+ 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 }
+ let(:page_token) { find('[data-testid="registration-token"]').text }
before do
click_button 'Reset registration token'
+
+ page.accept_alert
+
+ wait_for_requests
end
it 'changes registration token' do
+ click_on 'Click to reveal'
expect(page_token).not_to eq token
end
end
@@ -409,4 +410,43 @@ RSpec.describe "Admin Runners" do
end
end
end
+
+ private
+
+ def search_bar_selector
+ '[data-testid="runners-filtered-search"]'
+ end
+
+ # The filters must be clicked first to be able to receive events
+ # See: https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1493
+ def focus_filtered_search
+ page.within(search_bar_selector) do
+ page.find('.gl-filtered-search-term-token').click
+ end
+ end
+
+ def input_filtered_search_keys(search_term)
+ focus_filtered_search
+
+ page.within(search_bar_selector) do
+ page.find('input').send_keys(search_term)
+ click_on 'Search'
+ end
+ end
+
+ def input_filtered_search_filter_is_only(filter, value)
+ focus_filtered_search
+
+ page.within(search_bar_selector) do
+ click_on filter
+
+ # For OPERATOR_IS_ONLY, clicking the filter
+ # immediately preselects "=" operator
+
+ page.find('input').send_keys(value)
+ page.find('input').send_keys(:enter)
+
+ click_on 'Search'
+ end
+ end
end
diff --git a/spec/features/admin/admin_sees_background_migrations_spec.rb b/spec/features/admin/admin_sees_background_migrations_spec.rb
index d848a8352bc..11823195310 100644
--- a/spec/features/admin/admin_sees_background_migrations_spec.rb
+++ b/spec/features/admin/admin_sees_background_migrations_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe "Admin > Admin sees background migrations" do
end
end
- it 'can view queued migrations' do
+ it 'can view queued migrations and pause and resume them' do
visit admin_background_migrations_path
within '#content-body' do
@@ -40,7 +40,16 @@ RSpec.describe "Admin > Admin sees background migrations" do
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)
+ expect(page).not_to have_content('Paused')
+ expect(page).to have_content('Active')
+
+ click_button('Pause')
+ expect(page).not_to have_content('Active')
+ expect(page).to have_content('Paused')
+
+ click_button('Resume')
+ expect(page).not_to have_content('Paused')
+ expect(page).to have_content('Active')
end
end
diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb
index c289c18126d..9efb31ef4c1 100644
--- a/spec/features/admin/admin_settings_spec.rb
+++ b/spec/features/admin/admin_settings_spec.rb
@@ -269,77 +269,43 @@ RSpec.describe 'Admin updates settings' do
end
context 'Integrations page' do
+ let(:mailgun_events_receiver_enabled) { true }
+
before do
+ stub_feature_flags(mailgun_events_receiver: mailgun_events_receiver_enabled)
visit general_admin_application_settings_path
end
it 'enable hiding third party offers' do
page.within('.as-third-party-offers') do
- check 'Do not display offers from third parties within GitLab'
+ check 'Do not display offers from third parties'
click_button 'Save changes'
end
expect(page).to have_content "Application settings saved successfully"
expect(current_settings.hide_third_party_offers).to be true
end
- end
-
- context 'when Service Templates are enabled' do
- before do
- stub_feature_flags(disable_service_templates: false)
- visit general_admin_application_settings_path
- end
-
- it 'shows Service Templates link' do
- expect(page).to have_link('Service Templates')
- end
-
- context 'when the Slack Notifications Service template is active' do
- before do
- create(:service, :template, type: 'SlackService', active: true)
-
- visit general_admin_application_settings_path
- end
- it 'change Slack Notifications Service template settings', :js do
- first(:link, 'Service Templates').click
- click_link 'Slack notifications'
- fill_in 'Webhook', with: 'http://localhost'
- fill_in 'Username', with: 'test_user'
- fill_in 'service[push_channel]', with: '#test_channel'
- page.check('Notify only broken pipelines')
- page.select 'All branches', from: 'Branches to be notified'
- page.select 'Match any of the labels', from: 'Labels to be notified behavior'
-
- check_all_events
- click_button 'Save changes'
+ context 'when mailgun_events_receiver feature flag is enabled' do
+ it 'enabling Mailgun events', :aggregate_failures do
+ page.within('.as-mailgun') do
+ check 'Enable Mailgun event receiver'
+ fill_in 'Mailgun HTTP webhook signing key', with: 'MAILGUN_SIGNING_KEY'
+ click_button 'Save changes'
+ end
expect(page).to have_content 'Application settings saved successfully'
-
- click_link 'Slack notifications'
-
- expect(page.all('input[type=checkbox]')).to all(be_checked)
- expect(find_field('Webhook').value).to eq 'http://localhost'
- expect(find_field('Username').value).to eq 'test_user'
- expect(find('[name="service[push_channel]"]').value).to eq '#test_channel'
- end
-
- it 'defaults Deployment events to false for chat notification template settings', :js do
- first(:link, 'Service Templates').click
- click_link 'Slack notifications'
-
- expect(find_field('Deployment')).not_to be_checked
+ expect(current_settings.mailgun_events_enabled).to be true
+ expect(current_settings.mailgun_signing_key).to eq 'MAILGUN_SIGNING_KEY'
end
end
- end
- context 'When Service templates are disabled' do
- before do
- stub_feature_flags(disable_service_templates: true)
- end
+ context 'when mailgun_events_receiver feature flag is disabled' do
+ let(:mailgun_events_receiver_enabled) { false }
- it 'does not show Service Templates link' do
- expect(page).not_to have_link('Service Templates')
+ it 'does not have mailgun' do
+ expect(page).not_to have_selector('.as-mailgun')
+ end
end
end
@@ -370,6 +336,43 @@ RSpec.describe 'Admin updates settings' do
expect(page).to have_content "Application settings saved successfully"
end
+ context 'Runner Registration' do
+ context 'when feature is enabled' do
+ before do
+ stub_feature_flags(runner_registration_control: true)
+ end
+
+ it 'allows admins to control who has access to register runners' do
+ visit ci_cd_admin_application_settings_path
+
+ expect(current_settings.valid_runner_registrars).to eq(ApplicationSetting::VALID_RUNNER_REGISTRAR_TYPES)
+
+ page.within('.as-runner') do
+ find_all('.form-check-input').each(&:click)
+
+ click_button 'Save changes'
+ end
+
+ expect(current_settings.valid_runner_registrars).to eq([])
+ expect(page).to have_content "Application settings saved successfully"
+ end
+ end
+
+ context 'when feature is disabled' do
+ before do
+ stub_feature_flags(runner_registration_control: false)
+ end
+
+ it 'does not allow admins to control who has access to register runners' do
+ visit ci_cd_admin_application_settings_path
+
+ expect(current_settings.valid_runner_registrars).to eq(ApplicationSetting::VALID_RUNNER_REGISTRAR_TYPES)
+
+ expect(page).not_to have_css('.as-runner')
+ end
+ end
+ end
+
context 'Container Registry' do
let(:feature_flag_enabled) { true }
let(:client_support) { true }
@@ -530,7 +533,7 @@ RSpec.describe 'Admin updates settings' do
wait_for_requests
- expect(page).to have_selector '.js-usage-ping-payload'
+ expect(page).to have_selector '.js-service-ping-payload'
expect(page).to have_button 'Hide payload'
expect(page).to have_content expected_payload_content
end
@@ -581,8 +584,8 @@ RSpec.describe 'Admin updates settings' do
new_documentation_url = 'https://docs.gitlab.com'
page.within('.as-help-page') do
- fill_in 'Help page text', with: 'Example text'
- check 'Hide marketing-related entries from help'
+ fill_in 'Additional text to show on the Help page', with: 'Example text'
+ check 'Hide marketing-related entries from the Help page.'
fill_in 'Support page URL', with: new_support_url
fill_in 'Documentation pages URL', with: new_documentation_url
click_button 'Save changes'
diff --git a/spec/features/admin/admin_users_impersonation_tokens_spec.rb b/spec/features/admin/admin_users_impersonation_tokens_spec.rb
index dc528dd92d4..ee64e71f176 100644
--- a/spec/features/admin/admin_users_impersonation_tokens_spec.rb
+++ b/spec/features/admin/admin_users_impersonation_tokens_spec.rb
@@ -28,10 +28,10 @@ RSpec.describe 'Admin > Users > Impersonation Tokens', :js do
name = 'Hello World'
visit admin_user_impersonation_tokens_path(user_id: user.username)
- fill_in "Name", with: name
+ fill_in "Token name", with: name
# Set date to 1st of next month
- find_field("Expires at").click
+ find_field("Expiration date").click
find(".pika-next").click
click_on "1"
diff --git a/spec/features/admin/services/admin_visits_service_templates_spec.rb b/spec/features/admin/services/admin_visits_service_templates_spec.rb
index 9d011b97f63..d367867ebb5 100644
--- a/spec/features/admin/services/admin_visits_service_templates_spec.rb
+++ b/spec/features/admin/services/admin_visits_service_templates_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe 'Admin visits service templates' do
let(:admin) { create(:user, :admin) }
- let(:slack_service) { Integration.for_template.find { |s| s.type == 'SlackService' } }
+ let(:slack_integration) { Integration.for_template.find { |s| s.type == 'SlackService' } }
before do
sign_in(admin)
@@ -23,7 +23,7 @@ RSpec.describe 'Admin visits service templates' do
context 'with an active service template' do
before do
- create(:slack_service, :template, active: true)
+ create(:integrations_slack, :template, active: true)
visit(admin_application_settings_services_path)
end
@@ -33,20 +33,20 @@ RSpec.describe 'Admin visits service templates' do
context 'without instance-level integration' do
it 'shows a link to service template' do
- expect(page).to have_link('Slack', href: edit_admin_application_settings_service_path(slack_service.id))
- expect(page).not_to have_link('Slack', href: edit_admin_application_settings_integration_path(slack_service))
+ expect(page).to have_link('Slack', href: edit_admin_application_settings_service_path(slack_integration.id))
+ expect(page).not_to have_link('Slack', href: edit_admin_application_settings_integration_path(slack_integration))
end
end
context 'with instance-level integration' do
before do
- create(:slack_service, instance: true, project: nil)
+ create(:integrations_slack, instance: true, project: nil)
visit(admin_application_settings_services_path)
end
it 'shows a link to instance-level integration' do
- expect(page).not_to have_link('Slack', href: edit_admin_application_settings_service_path(slack_service.id))
- expect(page).to have_link('Slack', href: edit_admin_application_settings_integration_path(slack_service))
+ expect(page).not_to have_link('Slack', href: edit_admin_application_settings_service_path(slack_integration.id))
+ expect(page).to have_link('Slack', href: edit_admin_application_settings_integration_path(slack_integration))
end
end
end
diff --git a/spec/features/admin/users/user_spec.rb b/spec/features/admin/users/user_spec.rb
index 3599658ee56..e6eb76b13eb 100644
--- a/spec/features/admin/users/user_spec.rb
+++ b/spec/features/admin/users/user_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe 'Admin::Users::User' do
+ include Spec::Support::Helpers::Features::AdminUsersHelpers
+
let_it_be(:user) { create(:omniauth_user, provider: 'twitter', extern_uid: '123456') }
let_it_be(:current_user) { create(:admin) }
@@ -12,15 +14,18 @@ RSpec.describe 'Admin::Users::User' do
end
describe 'GET /admin/users/:id' do
- it 'has user info', :aggregate_failures do
+ it 'has user info', :js, :aggregate_failures do
visit admin_user_path(user)
expect(page).to have_content(user.email)
expect(page).to have_content(user.name)
expect(page).to have_content("ID: #{user.id}")
expect(page).to have_content("Namespace ID: #{user.namespace_id}")
- expect(page).to have_button('Deactivate user')
- expect(page).to have_button('Block user')
+
+ 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
@@ -29,9 +34,7 @@ RSpec.describe 'Admin::Users::User' do
it 'shows confirmation and allows blocking and unblocking', :js do
visit admin_user_path(user)
- find('button', text: 'Block user').click
-
- wait_for_requests
+ click_action_in_user_dropdown(user.id, 'Block')
expect(page).to have_content('Block user')
expect(page).to have_content('You can always unblock their account, their data will remain intact.')
@@ -41,21 +44,18 @@ RSpec.describe 'Admin::Users::User' do
wait_for_requests
expect(page).to have_content('Successfully blocked')
- expect(page).to have_content('This user is blocked')
-
- find('button', text: 'Unblock user').click
- wait_for_requests
+ click_action_in_user_dropdown(user.id, 'Unblock')
expect(page).to have_content('Unblock user')
expect(page).to have_content('You can always block their account again if needed.')
find('.modal-footer button', text: 'Unblock').click
- wait_for_requests
-
expect(page).to have_content('Successfully unblocked')
- expect(page).to have_content('Block this user')
+
+ click_user_dropdown_toggle(user.id)
+ expect(page).to have_content('Block')
end
end
@@ -63,9 +63,7 @@ RSpec.describe 'Admin::Users::User' do
it 'shows confirmation and allows deactivating/re-activating', :js do
visit admin_user_path(user)
- find('button', text: 'Deactivate user').click
-
- wait_for_requests
+ click_action_in_user_dropdown(user.id, 'Deactivate')
expect(page).to have_content('Deactivate user')
expect(page).to have_content('You can always re-activate their account, their data will remain intact.')
@@ -75,11 +73,8 @@ RSpec.describe 'Admin::Users::User' do
wait_for_requests
expect(page).to have_content('Successfully deactivated')
- expect(page).to have_content('Reactivate this user')
-
- find('button', text: 'Activate user').click
- wait_for_requests
+ click_action_in_user_dropdown(user.id, 'Activate')
expect(page).to have_content('Activate user')
expect(page).to have_content('You can always deactivate their account again if needed.')
@@ -89,7 +84,9 @@ RSpec.describe 'Admin::Users::User' do
wait_for_requests
expect(page).to have_content('Successfully activated')
- expect(page).to have_content('Deactivate this user')
+
+ click_user_dropdown_toggle(user.id)
+ expect(page).to have_content('Deactivate')
end
end
@@ -367,8 +364,43 @@ RSpec.describe 'Admin::Users::User' do
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')
+
+ click_user_dropdown_toggle(user.id)
+
+ expect(page).to have_button('Approve')
+ expect(page).to have_button('Reject')
+ end
+ end
+ end
+
+ context 'when user has an unconfirmed email', :js do
+ let(:unconfirmed_user) { create(:user, :unconfirmed) }
+
+ where(:path_helper) do
+ [
+ [-> (user) { admin_user_path(user) }],
+ [-> (user) { projects_admin_user_path(user) }],
+ [-> (user) { keys_admin_user_path(user) }],
+ [-> (user) { admin_user_identities_path(user) }],
+ [-> (user) { admin_user_impersonation_tokens_path(user) }]
+ ]
+ end
+
+ with_them do
+ it "allows an admin to force confirmation of the user's email", :aggregate_failures do
+ visit path_helper.call(unconfirmed_user)
+
+ click_button 'Confirm user'
+
+ page.within('[role="dialog"]') do
+ expect(page).to have_content("Confirm user #{unconfirmed_user.name}?")
+ expect(page).to have_content('This user has an unconfirmed email address. You may force a confirmation.')
+
+ click_button 'Confirm user'
+ end
+
+ expect(page).to have_content('Successfully confirmed')
+ expect(page).not_to have_button('Confirm user')
end
end
end
diff --git a/spec/features/admin/users/users_spec.rb b/spec/features/admin/users/users_spec.rb
index 187fa6fc2a4..119b01ff552 100644
--- a/spec/features/admin/users/users_spec.rb
+++ b/spec/features/admin/users/users_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe 'Admin::Users' do
+ include Spec::Support::Helpers::Features::AdminUsersHelpers
+
let_it_be(:user, reload: true) { create(:omniauth_user, provider: 'twitter', extern_uid: '123456') }
let_it_be(:current_user) { create(:admin) }
@@ -572,12 +574,6 @@ RSpec.describe 'Admin::Users' do
end
end
- def click_user_dropdown_toggle(user_id)
- page.within("[data-testid='user-actions-#{user_id}']") do
- find("[data-testid='dropdown-toggle']").click
- end
- end
-
def first_row
page.all('[role="row"]')[1]
end
@@ -592,14 +588,4 @@ RSpec.describe 'Admin::Users' do
click_link option
end
end
-
- def click_action_in_user_dropdown(user_id, action)
- click_user_dropdown_toggle(user_id)
-
- within find("[data-testid='user-actions-#{user_id}']") do
- find('li button', text: action).click
- end
-
- wait_for_requests
- end
end