diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/features/admin | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/features/admin')
-rw-r--r-- | spec/features/admin/admin_abuse_reports_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/admin/admin_appearance_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/admin/admin_groups_spec.rb | 45 | ||||
-rw-r--r-- | spec/features/admin/admin_labels_spec.rb | 6 | ||||
-rw-r--r-- | spec/features/admin/admin_mode/login_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/admin/admin_mode/logout_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/admin/admin_mode_spec.rb | 8 | ||||
-rw-r--r-- | spec/features/admin/admin_runners_spec.rb | 30 | ||||
-rw-r--r-- | spec/features/admin/admin_search_settings_spec.rb | 6 | ||||
-rw-r--r-- | spec/features/admin/admin_sees_project_statistics_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/admin/admin_sees_projects_statistics_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/admin/admin_settings_spec.rb | 18 | ||||
-rw-r--r-- | spec/features/admin/admin_users_impersonation_tokens_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/admin/services/admin_activates_prometheus_spec.rb | 24 | ||||
-rw-r--r-- | spec/features/admin/services/admin_visits_service_templates_spec.rb | 44 |
15 files changed, 130 insertions, 65 deletions
diff --git a/spec/features/admin/admin_abuse_reports_spec.rb b/spec/features/admin/admin_abuse_reports_spec.rb index 192182adddc..3a02ce89aa9 100644 --- a/spec/features/admin/admin_abuse_reports_spec.rb +++ b/spec/features/admin/admin_abuse_reports_spec.rb @@ -56,7 +56,7 @@ RSpec.describe "Admin::AbuseReports", :js do describe 'filtering by user' do let!(:user2) { create(:user) } - let!(:abuse_report) { create(:abuse_report, user: user) } + let!(:abuse_report) { create(:abuse_report, user: user) } let!(:abuse_report_2) { create(:abuse_report, user: user2) } it 'shows only single user report' do diff --git a/spec/features/admin/admin_appearance_spec.rb b/spec/features/admin/admin_appearance_spec.rb index cd136af8d69..61e7efbc56c 100644 --- a/spec/features/admin/admin_appearance_spec.rb +++ b/spec/features/admin/admin_appearance_spec.rb @@ -66,7 +66,7 @@ RSpec.describe 'Admin Appearance' do context 'when system header and footer messages are not empty' do before do - appearance.update(header_message: 'Foo', footer_message: 'Bar') + appearance.update!(header_message: 'Foo', footer_message: 'Bar') end it 'shows custom system header and footer fields' do diff --git a/spec/features/admin/admin_groups_spec.rb b/spec/features/admin/admin_groups_spec.rb index bbdf2f7f4a9..e7634f4e020 100644 --- a/spec/features/admin/admin_groups_spec.rb +++ b/spec/features/admin/admin_groups_spec.rb @@ -35,6 +35,7 @@ RSpec.describe 'Admin Groups' do expect(page).to have_field('group_path') expect(page).to have_field('group_visibility_level_0') expect(page).to have_field('description') + expect(page).to have_field('group_admin_note_attributes_note') end end @@ -47,10 +48,12 @@ RSpec.describe 'Admin Groups' do path_component = 'gitlab' group_name = 'GitLab group name' group_description = 'Description of group for GitLab' + group_admin_note = 'A note about this group by an admin' fill_in 'group_path', with: path_component fill_in 'group_name', with: group_name fill_in 'group_description', with: group_description + fill_in 'group_admin_note_attributes_note', with: group_admin_note click_button "Create group" expect(current_path).to eq admin_group_path(Group.find_by(path: path_component)) @@ -61,6 +64,8 @@ RSpec.describe 'Admin Groups' do expect(li_texts).to match group_name expect(li_texts).to match path_component expect(li_texts).to match group_description + p_texts = content.all('p').collect(&:text).join('/n') + expect(p_texts).to match group_admin_note end it 'shows the visibility level radio populated with the default value' do @@ -116,6 +121,16 @@ RSpec.describe 'Admin Groups' do expect(page).to have_link(group.name, href: group_path(group)) end + + it 'has a note if one is available' do + group = create(:group, :private) + note_text = 'A group administrator note' + group.update!(admin_note_attributes: { note: note_text }) + + visit admin_group_path(group) + + expect(page).to have_text(note_text) + end end describe 'group edit' do @@ -145,6 +160,36 @@ RSpec.describe 'Admin Groups' do expect(name_field.value).to eq original_name end + + it 'adding an admin note to group without one' do + group = create(:group, :private) + expect(group.admin_note).to be_nil + + visit admin_group_edit_path(group) + admin_note_text = 'A note by an administrator' + + fill_in 'group_admin_note_attributes_note', with: admin_note_text + click_button 'Save changes' + + expect(page).to have_content(admin_note_text) + end + + it 'editing an existing group admin note' do + admin_note_text = 'A note by an administrator' + new_admin_note_text = 'A new note by an administrator' + group = create(:group, :private) + group.create_admin_note(note: admin_note_text) + + visit admin_group_edit_path(group) + + admin_note_field = find('#group_admin_note_attributes_note') + expect(admin_note_field.value).to eq(admin_note_text) + + fill_in 'group_admin_note_attributes_note', with: new_admin_note_text + click_button 'Save changes' + + expect(page).to have_content(new_admin_note_text) + end end describe 'add user into a group', :js do diff --git a/spec/features/admin/admin_labels_spec.rb b/spec/features/admin/admin_labels_spec.rb index 815a73b1450..43fb1f31a0f 100644 --- a/spec/features/admin/admin_labels_spec.rb +++ b/spec/features/admin/admin_labels_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' RSpec.describe 'admin issues labels' do - let!(:bug_label) { Label.create(title: 'bug', template: true) } - let!(:feature_label) { Label.create(title: 'feature', template: true) } + let!(:bug_label) { Label.create!(title: 'bug', template: true) } + let!(:feature_label) { Label.create!(title: 'feature', template: true) } before do admin = create(:admin) @@ -36,7 +36,7 @@ RSpec.describe 'admin issues labels' do it 'deletes all labels', :js do page.within '.labels' do - page.all('.remove-row').each do |remove| + page.all('.js-remove-row').each do |remove| accept_confirm { remove.click } wait_for_requests end diff --git a/spec/features/admin/admin_mode/login_spec.rb b/spec/features/admin/admin_mode/login_spec.rb index f1dee075925..5b2dfdb2941 100644 --- a/spec/features/admin/admin_mode/login_spec.rb +++ b/spec/features/admin/admin_mode/login_spec.rb @@ -86,7 +86,7 @@ RSpec.describe 'Admin Mode Login' do expect(codes.size).to eq 10 # Ensure the generated codes get saved - user.save + user.save! end context 'with valid code' do diff --git a/spec/features/admin/admin_mode/logout_spec.rb b/spec/features/admin/admin_mode/logout_spec.rb index b7fa59bbfb7..8cfac5d8b99 100644 --- a/spec/features/admin/admin_mode/logout_spec.rb +++ b/spec/features/admin/admin_mode/logout_spec.rb @@ -9,6 +9,8 @@ RSpec.describe 'Admin Mode Logout', :js do let(:user) { create(:admin) } before do + stub_feature_flags(combined_menu: false) + gitlab_sign_in(user) gitlab_enable_admin_mode_sign_in(user) visit admin_root_path diff --git a/spec/features/admin/admin_mode_spec.rb b/spec/features/admin/admin_mode_spec.rb index 8169b3a20db..633de20c82d 100644 --- a/spec/features/admin/admin_mode_spec.rb +++ b/spec/features/admin/admin_mode_spec.rb @@ -9,10 +9,12 @@ RSpec.describe 'Admin mode' do let(:admin) { create(:admin) } before do + stub_feature_flags(combined_menu: false) + stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') end - context 'feature flag :user_mode_in_session is enabled', :request_store do + context 'application setting :admin_mode is enabled', :request_store do before do sign_in(admin) end @@ -155,9 +157,9 @@ RSpec.describe 'Admin mode' do end end - context 'feature flag :user_mode_in_session is disabled' do + context 'application setting :admin_mode is disabled' do before do - stub_feature_flags(user_mode_in_session: false) + stub_application_setting(admin_mode: false) sign_in(admin) end diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb index 4f135b81bdf..4e0dcbdf075 100644 --- a/spec/features/admin/admin_runners_spec.rb +++ b/spec/features/admin/admin_runners_spec.rb @@ -201,21 +201,21 @@ RSpec.describe "Admin Runners" do visit admin_runners_path - within '.runners-content .gl-responsive-table-row:nth-child(2)' do + within '[data-testid="runners-table"] .gl-responsive-table-row:nth-child(2)' do expect(page).to have_content 'runner-2' end - within '.runners-content .gl-responsive-table-row:nth-child(3)' do + within '[data-testid="runners-table"] .gl-responsive-table-row:nth-child(3)' do expect(page).to have_content 'runner-1' end sorting_by 'Last Contact' - within '.runners-content .gl-responsive-table-row:nth-child(2)' do + within '[data-testid="runners-table"] .gl-responsive-table-row:nth-child(2)' do expect(page).to have_content 'runner-1' end - within '.runners-content .gl-responsive-table-row:nth-child(3)' do + within '[data-testid="runners-table"] .gl-responsive-table-row:nth-child(3)' do expect(page).to have_content 'runner-2' end end @@ -285,8 +285,16 @@ RSpec.describe "Admin Runners" do end describe 'runner page breadcrumbs' do - it 'contains the current runner’s short sha' do - expect(page.find('h2')).to have_content(runner.short_sha) + it 'contains the current runner token' do + page.within '[data-testid="breadcrumb-links"]' do + expect(page.find('h2')).to have_content(runner.short_sha) + end + end + end + + describe 'runner page title', :js do + it 'contains the runner id' do + expect(find('.page-title')).to have_content("Runner ##{runner.id}") end end @@ -313,11 +321,11 @@ RSpec.describe "Admin Runners" do describe 'enable/create' do shared_examples 'assignable runner' do it 'enables a runner for a project' do - within '.unassigned-projects' do + within '[data-testid="unassigned-projects"]' do click_on 'Enable' end - assigned_project = page.find('.assigned-projects') + assigned_project = page.find('[data-testid="assigned-projects"]') expect(assigned_project).to have_content(@project2.path) end @@ -347,7 +355,7 @@ RSpec.describe "Admin Runners" do let(:runner) { create(:ci_runner, :instance) } before do - @project1.destroy + @project1.destroy! visit admin_runner_path(runner) end @@ -363,11 +371,11 @@ RSpec.describe "Admin Runners" do end it 'enables specific runner for project' do - within '.assigned-projects' do + within '[data-testid="assigned-projects"]' do click_on 'Disable' end - new_runner_project = page.find('.unassigned-projects') + new_runner_project = page.find('[data-testid="unassigned-projects"]') expect(new_runner_project).to have_content(@project1.path) end diff --git a/spec/features/admin/admin_search_settings_spec.rb b/spec/features/admin/admin_search_settings_spec.rb index a78d17a6651..cd61a1db6f3 100644 --- a/spec/features/admin/admin_search_settings_spec.rb +++ b/spec/features/admin/admin_search_settings_spec.rb @@ -20,8 +20,10 @@ RSpec.describe 'Admin searches application settings', :js do end context 'in ci/cd settings page' do - let(:visit_path) { ci_cd_admin_application_settings_path } + before do + visit(ci_cd_admin_application_settings_path) + end - it_behaves_like 'can search settings with feature flag check', 'Variables', 'Package Registry' + it_behaves_like 'can search settings', 'Variables', 'Package Registry' end end diff --git a/spec/features/admin/admin_sees_project_statistics_spec.rb b/spec/features/admin/admin_sees_project_statistics_spec.rb index be781730924..3433cc01b8e 100644 --- a/spec/features/admin/admin_sees_project_statistics_spec.rb +++ b/spec/features/admin/admin_sees_project_statistics_spec.rb @@ -21,7 +21,7 @@ RSpec.describe "Admin > Admin sees project statistics" do end context 'when project has no statistics' do - let(:project) { create(:project, :repository) { |project| project.statistics.destroy } } + let(:project) { create(:project, :repository) { |project| project.statistics.destroy! } } it "shows 'Storage: Unknown'" do expect(page).to have_content("Storage: Unknown") diff --git a/spec/features/admin/admin_sees_projects_statistics_spec.rb b/spec/features/admin/admin_sees_projects_statistics_spec.rb index 2e96814d1e9..d340eb47f34 100644 --- a/spec/features/admin/admin_sees_projects_statistics_spec.rb +++ b/spec/features/admin/admin_sees_projects_statistics_spec.rb @@ -7,7 +7,7 @@ RSpec.describe "Admin > Admin sees projects statistics" do before do create(:project, :repository) - create(:project, :repository) { |project| project.statistics.destroy } + create(:project, :repository) { |project| project.statistics.destroy! } sign_in(current_user) gitlab_enable_admin_mode_sign_in(current_user) diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index 249621f5835..9a2e2eb2f6f 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -9,7 +9,7 @@ RSpec.describe 'Admin updates settings' do let(:admin) { create(:admin) } - context 'feature flag :user_mode_in_session is enabled', :request_store do + context 'application setting :admin_mode is enabled', :request_store do before do stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') sign_in(admin) @@ -129,7 +129,7 @@ RSpec.describe 'Admin updates settings' do context 'Change Sign-up restrictions' do context 'Require Admin approval for new signup setting' do - it 'changes the setting' do + it 'changes the setting', :js do page.within('.as-signup') do check 'Require admin approval for new sign-ups' click_button 'Save changes' @@ -249,6 +249,14 @@ RSpec.describe 'Admin updates settings' do expect(page).to have_content "Application settings saved successfully" expect(current_settings.hide_third_party_offers).to be true end + 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 @@ -588,7 +596,7 @@ RSpec.describe 'Admin updates settings' do context 'Nav bar' do it 'shows default help links in nav' do - default_support_url = 'https://about.gitlab.com/getting-help/' + default_support_url = "https://#{ApplicationHelper.promo_host}/getting-help/" visit root_dashboard_path @@ -615,9 +623,9 @@ RSpec.describe 'Admin updates settings' do end end - context 'feature flag :user_mode_in_session is disabled' do + context 'application setting :admin_mode is disabled' do before do - stub_feature_flags(user_mode_in_session: false) + stub_application_setting(admin_mode: false) stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') diff --git a/spec/features/admin/admin_users_impersonation_tokens_spec.rb b/spec/features/admin/admin_users_impersonation_tokens_spec.rb index cae190e76b0..dc528dd92d4 100644 --- a/spec/features/admin/admin_users_impersonation_tokens_spec.rb +++ b/spec/features/admin/admin_users_impersonation_tokens_spec.rb @@ -75,7 +75,7 @@ RSpec.describe 'Admin > Users > Impersonation Tokens', :js do end it "removes expired tokens from 'active' section" do - impersonation_token.update(expires_at: 5.days.ago) + impersonation_token.update!(expires_at: 5.days.ago) visit admin_user_impersonation_tokens_path(user_id: user.username) diff --git a/spec/features/admin/services/admin_activates_prometheus_spec.rb b/spec/features/admin/services/admin_activates_prometheus_spec.rb deleted file mode 100644 index a225de365c8..00000000000 --- a/spec/features/admin/services/admin_activates_prometheus_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Admin activates Prometheus', :js do - let(:admin) { create(:user, :admin) } - - before do - sign_in(admin) - gitlab_enable_admin_mode_sign_in(admin) - - visit(admin_application_settings_services_path) - - click_link('Prometheus') - end - - it 'activates service' do - check('Active') - fill_in('API URL', with: 'http://prometheus.example.com') - click_button('Save changes') - - expect(page).to have_content('Application settings saved successfully') - end -end 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 563bca8b32f..1fd8c8316e3 100644 --- a/spec/features/admin/services/admin_visits_service_templates_spec.rb +++ b/spec/features/admin/services/admin_visits_service_templates_spec.rb @@ -9,23 +9,45 @@ RSpec.describe 'Admin visits service templates' do before do sign_in(admin) gitlab_enable_admin_mode_sign_in(admin) - - visit(admin_application_settings_services_path) end - 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)) + context 'without an active service template' do + before do + visit(admin_application_settings_services_path) + end + + it 'does not show service template content' do + expect(page).not_to have_content('Service template allows you to set default values for integrations') end end - context 'with instance-level integration' do - let_it_be(:slack_instance_integration) { create(:slack_service, instance: true, project: nil) } + context 'with an active service template' do + before do + create(:slack_service, :template, active: true) + visit(admin_application_settings_services_path) + end + + it 'shows service template content' do + expect(page).to have_content('Service template allows you to set default values for integrations') + end + + 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)) + end + end + + context 'with instance-level integration' do + before do + create(:slack_service, 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)) + 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)) + end end end end |