diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/features/admin | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/features/admin')
-rw-r--r-- | spec/features/admin/admin_groups_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/admin/admin_projects_spec.rb | 4 | ||||
-rw-r--r-- | spec/features/admin/admin_requests_profiles_spec.rb | 136 | ||||
-rw-r--r-- | spec/features/admin/admin_runners_spec.rb | 59 | ||||
-rw-r--r-- | spec/features/admin/admin_sees_background_migrations_spec.rb | 142 | ||||
-rw-r--r-- | spec/features/admin/admin_settings_spec.rb | 55 | ||||
-rw-r--r-- | spec/features/admin/clusters/eks_spec.rb | 32 | ||||
-rw-r--r-- | spec/features/admin/users/users_spec.rb | 2 |
8 files changed, 211 insertions, 221 deletions
diff --git a/spec/features/admin/admin_groups_spec.rb b/spec/features/admin/admin_groups_spec.rb index 3b3289a8487..90dde7340d5 100644 --- a/spec/features/admin/admin_groups_spec.rb +++ b/spec/features/admin/admin_groups_spec.rb @@ -212,7 +212,7 @@ RSpec.describe 'Admin Groups' do it do visit admin_group_path(group) - select2(user_selector, from: '#user_ids', multiple: true) + select2(user_selector, from: '#user_id', multiple: true) page.within '#new_project_member' do select2(Gitlab::Access::REPORTER, from: '#access_level') end diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb index b0737377de0..2166edf65ff 100644 --- a/spec/features/admin/admin_projects_spec.rb +++ b/spec/features/admin/admin_projects_spec.rb @@ -8,7 +8,7 @@ RSpec.describe "Admin::Projects" do include Spec::Support::Helpers::ModalHelpers let(:user) { create :user } - let(:project) { create(:project) } + let(:project) { create(:project, :with_namespace_settings) } let(:current_user) { create(:admin) } before do @@ -82,7 +82,7 @@ RSpec.describe "Admin::Projects" do describe 'transfer project' do # The gitlab-shell transfer will fail for a project without a repository - let(:project) { create(:project, :repository) } + let(:project) { create(:project, :repository, :with_namespace_settings) } before do create(:group, name: 'Web') diff --git a/spec/features/admin/admin_requests_profiles_spec.rb b/spec/features/admin/admin_requests_profiles_spec.rb deleted file mode 100644 index e92528d431d..00000000000 --- a/spec/features/admin/admin_requests_profiles_spec.rb +++ /dev/null @@ -1,136 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Admin::RequestsProfilesController' do - let(:tmpdir) { Dir.mktmpdir('profiler-test') } - - before do - stub_const('Gitlab::RequestProfiler::PROFILES_DIR', tmpdir) - admin = create(:admin) - sign_in(admin) - gitlab_enable_admin_mode_sign_in(admin) - end - - after do - FileUtils.rm_rf(tmpdir) - end - - describe 'GET /admin/requests_profiles' do - it 'shows the current profile token' do - allow(Rails).to receive(:cache).and_return(ActiveSupport::Cache::MemoryStore.new) - - visit admin_requests_profiles_path - - expect(page).to have_content("X-Profile-Token: #{Gitlab::RequestProfiler.profile_token}") - end - - context 'when having multiple profiles' do - let(:time1) { 1.hour.ago } - let(:time2) { 2.hours.ago } - - let(:profiles) do - [ - { - request_path: '/gitlab-org/gitlab-foss', - name: "|gitlab-org|gitlab-foss_#{time1.to_i}_execution.html", - created: time1, - profile_mode: 'Execution' - }, - { - request_path: '/gitlab-org/gitlab-foss', - name: "|gitlab-org|gitlab-foss_#{time2.to_i}_execution.html", - created: time2, - profile_mode: 'Execution' - }, - { - request_path: '/gitlab-org/gitlab-foss', - name: "|gitlab-org|gitlab-foss_#{time1.to_i}_memory.html", - created: time1, - profile_mode: 'Memory' - }, - { - request_path: '/gitlab-org/gitlab-foss', - name: "|gitlab-org|gitlab-foss_#{time2.to_i}_memory.html", - created: time2, - profile_mode: 'Memory' - }, - { - request_path: '/gitlab-org/infrastructure', - name: "|gitlab-org|infrastructure_#{time1.to_i}_execution.html", - created: time1, - profile_mode: 'Execution' - }, - { - request_path: '/gitlab-org/infrastructure', - name: "|gitlab-org|infrastructure_#{time2.to_i}_memory.html", - created: time2, - profile_mode: 'Memory' - }, - { - request_path: '/gitlab-org/infrastructure', - name: "|gitlab-org|infrastructure_#{time2.to_i}.html", - created: time2, - profile_mode: 'Unknown' - } - ] - end - - before do - profiles.each do |profile| - FileUtils.touch(File.join(Gitlab::RequestProfiler::PROFILES_DIR, profile[:name])) - end - end - - it 'lists all available profiles' do - visit admin_requests_profiles_path - - profiles.each do |profile| - within('.card', text: profile[:request_path]) do - expect(page).to have_selector( - "a[href='#{admin_requests_profile_path(profile[:name])}']", - text: "#{profile[:created].to_s(:long)} #{profile[:profile_mode]}") - end - end - end - end - end - - describe 'GET /admin/requests_profiles/:profile' do - context 'when a profile exists' do - before do - File.write("#{Gitlab::RequestProfiler::PROFILES_DIR}/#{profile}", content) - end - - context 'when is valid call stack profile' do - let(:content) { 'This is a call stack request profile' } - let(:profile) { "|gitlab-org|gitlab-ce_#{Time.now.to_i}_execution.html" } - - it 'displays the content' do - visit admin_requests_profile_path(profile) - - expect(page).to have_content(content) - end - end - - context 'when is valid memory profile' do - let(:content) { 'This is a memory request profile' } - let(:profile) { "|gitlab-org|gitlab-ce_#{Time.now.to_i}_memory.txt" } - - it 'displays the content' do - visit admin_requests_profile_path(profile) - - expect(page).to have_content(content) - end - end - end - - context 'when a profile does not exist' do - it 'shows an error message' do - visit admin_requests_profile_path('|non|existent_12345.html') - - expect(page).to have_content('Profile not found') - end - end - end -end diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb index 7fe49c2571c..e1a1e2bbb2d 100644 --- a/spec/features/admin/admin_runners_spec.rb +++ b/spec/features/admin/admin_runners_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe "Admin Runners" do include Spec::Support::Helpers::Features::RunnersHelpers + include Spec::Support::Helpers::ModalHelpers let_it_be(:admin) { create(:admin) } @@ -429,12 +430,6 @@ RSpec.describe "Admin Runners" do end context "when visiting outdated URLs" do - it 'updates NOT_CONNECTED runner status to NEVER_CONNECTED' do - visit admin_runners_path('status[]': 'NOT_CONNECTED') - - expect(page).to have_current_path(admin_runners_path('status[]': 'NEVER_CONTACTED') ) - end - it 'updates ACTIVE runner status to paused=false' do visit admin_runners_path('status[]': 'ACTIVE') @@ -467,7 +462,7 @@ RSpec.describe "Admin Runners" do describe 'runner show page breadcrumbs' do it 'contains the current runner id and token' do page.within '[data-testid="breadcrumb-links"]' do - expect(page.find('h2')).to have_link("##{runner.id} (#{runner.short_sha})") + expect(page.find('[data-testid="breadcrumb-current-link"]')).to have_link("##{runner.id} (#{runner.short_sha})") end end end @@ -483,10 +478,28 @@ RSpec.describe "Admin Runners" do expect(page).to have_content 'Tags tag1' end end + + describe 'when a runner is deleted' do + before do + click_on 'Delete runner' + + within_modal do + click_on 'Delete runner' + end + end + + it 'deletes runner' do + expect(page.find('[data-testid="alert-success"]')).to have_content('deleted') + end + + it 'redirects to runner list' do + expect(current_url).to match(admin_runners_path) + end + end end describe "Runner edit page" do - let(:runner) { create(:ci_runner) } + let(:runner) { create(:ci_runner, :project) } before do @project1 = create(:project) @@ -500,14 +513,29 @@ RSpec.describe "Admin Runners" do it 'contains the current runner id and token' do page.within '[data-testid="breadcrumb-links"]' do expect(page).to have_link("##{runner.id} (#{runner.short_sha})") - expect(page.find('h2')).to have_content("Edit") + expect(page.find('[data-testid="breadcrumb-current-link"]')).to have_content("Edit") end end end describe 'runner header', :js do it 'contains the runner status, type and id' do - expect(page).to have_content("never contacted shared Runner ##{runner.id} created") + expect(page).to have_content("never contacted specific Runner ##{runner.id} created") + end + end + + describe 'when a runner is updated', :js do + before do + click_on _('Save changes') + wait_for_requests + end + + it 'show success alert' do + expect(page.find('[data-testid="alert-success"]')).to have_content('saved') + end + + it 'redirects to runner page' do + expect(current_url).to match(admin_runner_path(runner)) end end @@ -564,17 +592,6 @@ RSpec.describe "Admin Runners" do it_behaves_like 'assignable runner' end - - context 'with shared runner' do - let(:runner) { create(:ci_runner, :instance) } - - before do - @project1.destroy! - visit edit_admin_runner_path(runner) - end - - it_behaves_like 'assignable runner' - end end describe 'disable/destroy' do diff --git a/spec/features/admin/admin_sees_background_migrations_spec.rb b/spec/features/admin/admin_sees_background_migrations_spec.rb index 432721d63ad..8edddcf9a9b 100644 --- a/spec/features/admin/admin_sees_background_migrations_spec.rb +++ b/spec/features/admin/admin_sees_background_migrations_spec.rb @@ -31,6 +31,52 @@ RSpec.describe "Admin > Admin sees background migrations" do end end + it 'can click on a specific migration' do + visit admin_background_migrations_path + + within '#content-body' do + tab = find_link active_migration.job_class_name + tab.click + + expect(page).to have_current_path admin_background_migration_path(active_migration) + end + end + + it 'can view failed jobs' do + visit admin_background_migration_path(failed_migration) + + within '#content-body' do + expect(page).to have_content('Failed jobs') + expect(page).to have_content('Id') + expect(page).to have_content('Started at') + expect(page).to have_content('Finished at') + expect(page).to have_content('Batch size') + end + end + + it 'can click on a specific job' do + job = create(:batched_background_migration_job, :failed, batched_migration: failed_migration) + + visit admin_background_migration_path(failed_migration) + + within '#content-body' do + tab = find_link job.id + tab.click + + expect(page).to have_current_path admin_background_migration_batched_job_path(id: job.id, background_migration_id: failed_migration.id) + end + end + + context 'when there are no failed jobs' do + it 'dos not display failed jobs' do + visit admin_background_migration_path(active_migration) + + within '#content-body' do + expect(page).not_to have_content('Failed jobs') + end + end + end + it 'can view queued migrations and pause and resume them' do visit admin_background_migrations_path @@ -66,6 +112,17 @@ RSpec.describe "Admin > Admin sees background migrations" do end end + it 'can fire an action with a database param' do + visit admin_background_migrations_path(database: 'main') + + within '#content-body' do + tab = find_link 'Failed' + tab.click + + expect(page).to have_selector("[method='post'][action='/admin/background_migrations/#{failed_migration.id}/retry?database=main']") + end + end + it 'can view and retry them' do visit admin_background_migrations_path @@ -109,4 +166,89 @@ RSpec.describe "Admin > Admin sees background migrations" do expect(page).to have_content(finished_migration.status_name.to_s) end end + + it 'can change tabs and retain database param' do + skip_if_multiple_databases_not_setup + + visit admin_background_migrations_path(database: 'ci') + + within '#content-body' do + tab = find_link 'Finished' + expect(tab[:class]).not_to include('gl-tab-nav-item-active') + + tab.click + + expect(page).to have_current_path(admin_background_migrations_path(tab: 'finished', database: 'ci')) + expect(tab[:class]).to include('gl-tab-nav-item-active') + end + end + + it 'can view documentation from Learn more link' do + visit admin_background_migrations_path + + within '#content-body' do + expect(page).to have_link('Learn more', href: help_page_path('development/database/batched_background_migrations')) + end + end + + describe 'selected database toggle', :js do + context 'when multi database is not enabled' do + before do + skip_if_multiple_databases_are_setup + + allow(Gitlab::Database).to receive(:db_config_names).and_return(['main']) + end + + it 'does not render the database listbox' do + visit admin_background_migrations_path + + expect(page).not_to have_selector('[data-testid="database-listbox"]') + end + end + + context 'when multi database is enabled' do + before do + skip_if_multiple_databases_not_setup + + allow(Gitlab::Database).to receive(:db_config_names).and_return(%w[main ci]) + end + + it 'does render the database listbox' do + visit admin_background_migrations_path + + expect(page).to have_selector('[data-testid="database-listbox"]') + end + + it 'defaults to main when no parameter is passed' do + visit admin_background_migrations_path + + listbox = page.find('[data-testid="database-listbox"]') + + expect(listbox).to have_text('main') + end + + it 'shows correct database when a parameter is passed' do + visit admin_background_migrations_path(database: 'ci') + + listbox = page.find('[data-testid="database-listbox"]') + + expect(listbox).to have_text('ci') + end + + it 'updates the path to correct database when clicking on listbox option' do + visit admin_background_migrations_path + + listbox = page.find('[data-testid="database-listbox"]') + expect(listbox).to have_text('main') + + listbox.find('button').click + listbox.find('li', text: 'ci').click + wait_for_requests + + expect(page).to have_current_path(admin_background_migrations_path(database: 'ci')) + listbox = page.find('[data-testid="database-listbox"]') + expect(listbox).to have_text('ci') + end + end + end end diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index 4cdc3df978d..79b3f049047 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -71,7 +71,7 @@ RSpec.describe 'Admin updates settings' do it 'change Visibility and Access Controls' do page.within('.as-visibility-access') do - uncheck 'Project export enabled' + uncheck 'Enabled' click_button 'Save changes' end @@ -111,6 +111,16 @@ RSpec.describe 'Admin updates settings' do expect(page).to have_content "Application settings saved successfully" end + it 'change Maximum export size' do + page.within('.as-account-limit') do + fill_in 'Maximum export size (MB)', with: 25 + click_button 'Save changes' + end + + expect(current_settings.max_export_size).to eq 25 + expect(page).to have_content "Application settings saved successfully" + end + it 'change Maximum import size' do page.within('.as-account-limit') do fill_in 'Maximum import size (MB)', with: 15 @@ -370,7 +380,7 @@ RSpec.describe 'Admin updates settings' do 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) + find_all('input[type="checkbox"]').each(&:click) click_button 'Save changes' end @@ -396,7 +406,6 @@ RSpec.describe 'Admin updates settings' do end context 'Container Registry' do - let(:feature_flag_enabled) { true } let(:client_support) { true } let(:settings_titles) do { @@ -409,18 +418,9 @@ RSpec.describe 'Admin updates settings' do before do stub_container_registry_config(enabled: true) - stub_feature_flags(container_registry_expiration_policies_throttling: feature_flag_enabled) allow(ContainerRegistry::Client).to receive(:supports_tag_delete?).and_return(client_support) end - shared_examples 'not having container registry setting' do |registry_setting| - it "lacks the container setting #{registry_setting}" do - visit ci_cd_admin_application_settings_path - - expect(page).not_to have_content(settings_titles[registry_setting]) - end - end - %i[container_registry_delete_tags_service_timeout container_registry_expiration_policies_worker_capacity container_registry_cleanup_tags_service_max_list_size].each do |setting| context "for container registry setting #{setting}" do it 'changes the setting' do @@ -434,12 +434,6 @@ RSpec.describe 'Admin updates settings' do expect(current_settings.public_send(setting)).to eq(400) expect(page).to have_content "Application settings saved successfully" end - - context 'with feature flag disabled' do - let(:feature_flag_enabled) { false } - - it_behaves_like 'not having container registry setting', setting - end end end @@ -457,12 +451,6 @@ RSpec.describe 'Admin updates settings' do expect(current_settings.container_registry_expiration_policies_caching).to eq(!old_value) expect(page).to have_content "Application settings saved successfully" end - - context 'with feature flag disabled' do - let(:feature_flag_enabled) { false } - - it_behaves_like 'not having container registry setting', :container_registry_expiration_policies_caching - end end end end @@ -665,7 +653,7 @@ RSpec.describe 'Admin updates settings' do visit network_admin_application_settings_path page.within('.as-issue-limits') do - fill_in 'Max requests per minute per user', with: 0 + fill_in 'Maximum number of requests per minute', with: 0 click_button 'Save changes' end @@ -673,6 +661,18 @@ RSpec.describe 'Admin updates settings' do expect(current_settings.issues_create_limit).to eq(0) end + it 'changes Pipelines rate limits settings' do + visit network_admin_application_settings_path + + page.within('.as-pipeline-limits') do + fill_in 'Maximum number of requests per minute', with: 10 + click_button 'Save changes' + end + + expect(page).to have_content "Application settings saved successfully" + expect(current_settings.pipeline_limit_per_project_user_sha).to eq(10) + end + it 'changes Users API rate limits settings' do visit network_admin_application_settings_path @@ -856,10 +856,9 @@ RSpec.describe 'Admin updates settings' do stub_database_flavor_check end - context 'when service data cached', :clean_gitlab_redis_cache do + context 'when service data cached', :use_clean_rails_memory_store_caching do before do - allow(Rails.cache).to receive(:exist?).with('usage_data').and_return(true) - + visit usage_data_admin_application_settings_path visit service_usage_data_admin_application_settings_path end diff --git a/spec/features/admin/clusters/eks_spec.rb b/spec/features/admin/clusters/eks_spec.rb deleted file mode 100644 index 4667f9c20a1..00000000000 --- a/spec/features/admin/clusters/eks_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Instance-level AWS EKS Cluster', :js do - let(:user) { create(:admin) } - - before do - sign_in(user) - gitlab_enable_admin_mode_sign_in(user) - stub_application_setting(eks_integration_enabled: true) - end - - context 'when user does not have a cluster and visits group clusters page' do - before do - visit admin_clusters_path - - click_button(class: 'dropdown-toggle-split') - click_link 'Create a cluster (deprecated)' - end - - context 'when user creates a cluster on AWS EKS' do - before do - click_link 'Amazon EKS' - end - - it 'user sees a form to create an EKS cluster' do - expect(page).to have_content('Authenticate with Amazon Web Services') - end - end - end -end diff --git a/spec/features/admin/users/users_spec.rb b/spec/features/admin/users/users_spec.rb index 4d9a7f31911..a05e1531949 100644 --- a/spec/features/admin/users/users_spec.rb +++ b/spec/features/admin/users/users_spec.rb @@ -548,7 +548,7 @@ RSpec.describe 'Admin::Users' do end def check_breadcrumb(content) - expect(find('.breadcrumbs-sub-title')).to have_content(content) + expect(find('[data-testid="breadcrumb-current-link"]')).to have_content(content) end end |