diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/features/admin | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/features/admin')
-rw-r--r-- | spec/features/admin/admin_cohorts_spec.rb | 33 | ||||
-rw-r--r-- | spec/features/admin/admin_disables_git_access_protocol_spec.rb | 15 | ||||
-rw-r--r-- | spec/features/admin/admin_groups_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/admin/admin_projects_spec.rb | 99 | ||||
-rw-r--r-- | spec/features/admin/admin_search_settings_spec.rb | 27 | ||||
-rw-r--r-- | spec/features/admin/admin_settings_spec.rb | 75 | ||||
-rw-r--r-- | spec/features/admin/admin_users_spec.rb | 70 | ||||
-rw-r--r-- | spec/features/admin/users/user_spec.rb | 4 |
8 files changed, 231 insertions, 94 deletions
diff --git a/spec/features/admin/admin_cohorts_spec.rb b/spec/features/admin/admin_cohorts_spec.rb deleted file mode 100644 index 982a9333275..00000000000 --- a/spec/features/admin/admin_cohorts_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Cohorts page' do - before do - admin = create(:admin) - sign_in(admin) - gitlab_enable_admin_mode_sign_in(admin) - end - - context 'with usage ping enabled' do - it 'shows users count per month' do - stub_application_setting(usage_ping_enabled: true) - - create_list(:user, 2) - - visit admin_cohorts_path - - expect(page).to have_content("#{Time.now.strftime('%b %Y')} 3 0") - end - end - - context 'with usage ping disabled' do - it 'shows empty state', :js do - stub_application_setting(usage_ping_enabled: false) - - visit admin_cohorts_path - - expect(page).to have_selector(".js-empty-state") - end - end -end diff --git a/spec/features/admin/admin_disables_git_access_protocol_spec.rb b/spec/features/admin/admin_disables_git_access_protocol_spec.rb index f7f0592a315..b370b779afe 100644 --- a/spec/features/admin/admin_disables_git_access_protocol_spec.rb +++ b/spec/features/admin/admin_disables_git_access_protocol_spec.rb @@ -37,7 +37,10 @@ RSpec.describe 'Admin disables Git access protocol', :js do it 'shows only the SSH clone information' do resize_screen_xs visit_project - find('.dropdown-toggle').click + + within('.js-mobile-git-clone') do + find('.dropdown-toggle').click + end expect(page).to have_content('Copy SSH clone URL') expect(page).not_to have_content('Copy HTTP clone URL') @@ -66,7 +69,10 @@ RSpec.describe 'Admin disables Git access protocol', :js do it 'shows only the HTTP clone information' do resize_screen_xs visit_project - find('.dropdown-toggle').click + + within('.js-mobile-git-clone') do + find('.dropdown-toggle').click + end expect(page).to have_content('Copy HTTP clone URL') expect(page).not_to have_content('Copy SSH clone URL') @@ -97,7 +103,10 @@ RSpec.describe 'Admin disables Git access protocol', :js do it 'shows both SSH and HTTP clone information' do resize_screen_xs visit_project - find('.dropdown-toggle').click + + within('.js-mobile-git-clone') do + find('.dropdown-toggle').click + end expect(page).to have_content('Copy HTTP clone URL') expect(page).to have_content('Copy SSH clone URL') diff --git a/spec/features/admin/admin_groups_spec.rb b/spec/features/admin/admin_groups_spec.rb index a8e18385bd2..bbdf2f7f4a9 100644 --- a/spec/features/admin/admin_groups_spec.rb +++ b/spec/features/admin/admin_groups_spec.rb @@ -54,7 +54,7 @@ RSpec.describe 'Admin Groups' do click_button "Create group" expect(current_path).to eq admin_group_path(Group.find_by(path: path_component)) - content = page.find('div#content-body') + content = page.find('#content-body') h3_texts = content.all('h3').collect(&:text).join("\n") expect(h3_texts).to match group_name li_texts = content.all('li').collect(&:text).join("\n") diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb index ff4e592234b..aab2e6d7cef 100644 --- a/spec/features/admin/admin_projects_spec.rb +++ b/spec/features/admin/admin_projects_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' RSpec.describe "Admin::Projects" do + include Spec::Support::Helpers::Features::MembersHelpers include Select2Helper let(:user) { create :user } @@ -91,45 +92,97 @@ RSpec.describe "Admin::Projects" do end end - describe 'add admin himself to a project' do - before do - project.add_maintainer(user) - end + context 'when `vue_project_members_list` feature flag is enabled', :js do + describe 'admin adds themselves to the project' do + before do + project.add_maintainer(user) + stub_feature_flags(invite_members_group_modal: false) + end - it 'adds admin a to a project as developer', :js do - visit project_project_members_path(project) + it 'adds admin to the project as developer', :js do + visit project_project_members_path(project) - page.within '.invite-users-form' do - select2(current_user.id, from: '#user_ids', multiple: true) - select 'Developer', from: 'access_level' + page.within '.invite-users-form' do + select2(current_user.id, from: '#user_ids', multiple: true) + select 'Developer', from: 'access_level' + end + + click_button 'Invite' + + expect(find_member_row(current_user)).to have_content('Developer') end + end + + describe 'admin removes themselves from the project' do + before do + project.add_maintainer(user) + project.add_developer(current_user) + end + + it 'removes admin from the project' do + visit project_project_members_path(project) + + expect(find_member_row(current_user)).to have_content('Developer') + + page.within find_member_row(current_user) do + click_button 'Leave' + end - click_button 'Invite' + page.within('[role="dialog"]') do + click_button('Leave') + end - page.within '.content-list' do - expect(page).to have_content(current_user.name) - expect(page).to have_content('Developer') + expect(current_path).to match dashboard_projects_path end end end - describe 'admin remove himself from a project' do + context 'when `vue_project_members_list` feature flag is disabled' do before do - project.add_maintainer(user) - project.add_developer(current_user) + stub_feature_flags(vue_project_members_list: false) end - it 'removes admin from the project' do - visit project_project_members_path(project) + describe 'admin adds themselves to the project' do + before do + project.add_maintainer(user) + stub_feature_flags(invite_members_group_modal: false) + end + + it 'adds admin to the project as developer', :js do + visit project_project_members_path(project) + + page.within '.invite-users-form' do + select2(current_user.id, from: '#user_ids', multiple: true) + select 'Developer', from: 'access_level' + end + + click_button 'Invite' + + page.within '.content-list' do + expect(page).to have_content(current_user.name) + expect(page).to have_content('Developer') + end + end + end - page.within '.content-list' do - expect(page).to have_content(current_user.name) - expect(page).to have_content('Developer') + describe 'admin removes themselves from the project' do + before do + project.add_maintainer(user) + project.add_developer(current_user) end - find(:css, '.content-list li', text: current_user.name).find(:css, 'a.btn-danger').click + it 'removes admin from the project' do + visit project_project_members_path(project) + + page.within '.content-list' do + expect(page).to have_content(current_user.name) + expect(page).to have_content('Developer') + end - expect(page).not_to have_selector(:css, '.content-list') + find(:css, '.content-list li', text: current_user.name).find(:css, 'a.btn-danger').click + + expect(page).not_to have_selector(:css, '.content-list') + end end end end diff --git a/spec/features/admin/admin_search_settings_spec.rb b/spec/features/admin/admin_search_settings_spec.rb new file mode 100644 index 00000000000..a78d17a6651 --- /dev/null +++ b/spec/features/admin/admin_search_settings_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Admin searches application settings', :js do + let_it_be(:admin) { create(:admin) } + let_it_be(:application_settings) { create(:application_setting) } + + before do + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) + end + + context 'in appearances page' do + before do + visit(admin_appearances_path) + end + + it_behaves_like 'cannot search settings' + end + + context 'in ci/cd settings page' do + let(:visit_path) { ci_cd_admin_application_settings_path } + + it_behaves_like 'can search settings with feature flag check', 'Variables', 'Package Registry' + end +end diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index 0c66775c323..52f39f65bd0 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -306,59 +306,70 @@ RSpec.describe 'Admin updates settings' do page.within('.as-ci-cd') do check 'Default to Auto DevOps pipeline for all projects' fill_in 'application_setting_auto_devops_domain', with: 'domain.com' + uncheck 'Keep the latest artifacts for all jobs in the latest successful pipelines' click_button 'Save changes' end expect(current_settings.auto_devops_enabled?).to be true expect(current_settings.auto_devops_domain).to eq('domain.com') + expect(current_settings.keep_latest_artifact).to be false expect(page).to have_content "Application settings saved successfully" end context 'Container Registry' do - context 'delete tags service execution timeout' do - let(:feature_flag_enabled) { true } - let(:client_support) { true } - - 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 + let(:feature_flag_enabled) { true } + let(:client_support) { true } + let(:settings_titles) do + { + container_registry_delete_tags_service_timeout: 'Container Registry delete tags service execution timeout', + container_registry_expiration_policies_worker_capacity: 'Cleanup policy maximum workers running concurrently', + container_registry_cleanup_tags_service_max_list_size: 'Cleanup policy maximum number of tags to be deleted' + } + end + + 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 - RSpec.shared_examples 'not having service timeout settings' do - it 'lacks the timeout settings' do - visit ci_cd_admin_application_settings_path + 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 "Container Registry delete tags service execution timeout" - end + expect(page).not_to have_content(settings_titles[registry_setting]) end + end - context 'with feature flag enabled' do - context 'with client supporting tag delete' do - it 'changes the timeout' do - visit ci_cd_admin_application_settings_path + %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 + context 'with feature flag enabled' do + context 'with client supporting tag delete' do + it 'changes the setting' do + visit ci_cd_admin_application_settings_path - page.within('.as-registry') do - fill_in 'application_setting_container_registry_delete_tags_service_timeout', with: 400 - click_button 'Save changes' - end + page.within('.as-registry') do + fill_in "application_setting_#{setting}", with: 400 + click_button 'Save changes' + end - expect(current_settings.container_registry_delete_tags_service_timeout).to eq(400) - expect(page).to have_content "Application settings saved successfully" + expect(current_settings.public_send(setting)).to eq(400) + expect(page).to have_content "Application settings saved successfully" + end end - end - context 'with client not supporting tag delete' do - let(:client_support) { false } + context 'with client not supporting tag delete' do + let(:client_support) { false } - it_behaves_like 'not having service timeout settings' + it_behaves_like 'not having container registry setting', setting + end end - end - context 'with feature flag disabled' do - let(:feature_flag_enabled) { false } + context 'with feature flag disabled' do + let(:feature_flag_enabled) { false } - it_behaves_like 'not having service timeout settings' + it_behaves_like 'not having container registry setting', setting + end end end end diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb new file mode 100644 index 00000000000..4fc60d17886 --- /dev/null +++ b/spec/features/admin/admin_users_spec.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe "Admin::Users" do + let(:current_user) { create(:admin) } + + before do + sign_in(current_user) + gitlab_enable_admin_mode_sign_in(current_user) + end + + describe 'Tabs', :js do + let(:tabs_selector) { '.js-users-tabs' } + let(:active_tab_selector) { '.nav-link.active' } + + it 'does not add the tab param when the Users tab is selected' do + visit admin_users_path + + within tabs_selector do + click_link 'Users' + end + + expect(page).to have_current_path(admin_users_path) + end + + it 'adds the ?tab=cohorts param when the Cohorts tab is selected' do + visit admin_users_path + + within tabs_selector do + click_link 'Cohorts' + end + + expect(page).to have_current_path(admin_users_path(tab: 'cohorts')) + end + + it 'shows the cohorts tab when the tab param is set' do + visit admin_users_path(tab: 'cohorts') + + within tabs_selector do + expect(page).to have_selector active_tab_selector, text: 'Cohorts' + end + end + end + + describe 'Cohorts tab content' do + context 'with usage ping enabled' do + it 'shows users count per month' do + stub_application_setting(usage_ping_enabled: true) + + create_list(:user, 2) + + visit admin_users_path(tab: 'cohorts') + + expect(page).to have_content("#{Time.now.strftime('%b %Y')} 3 0") + end + end + + context 'with usage ping disabled' do + it 'shows empty state', :js do + stub_application_setting(usage_ping_enabled: false) + + visit admin_users_path(tab: 'cohorts') + + expect(page).to have_selector(".js-empty-state") + expect(page).to have_content("Activate user activity analysis") + end + end + end +end diff --git a/spec/features/admin/users/user_spec.rb b/spec/features/admin/users/user_spec.rb index e7dd50ed514..befa7bd338b 100644 --- a/spec/features/admin/users/user_spec.rb +++ b/spec/features/admin/users/user_spec.rb @@ -171,7 +171,7 @@ RSpec.describe 'Admin::Users::User' do it 'logs in as the user when impersonate is clicked' do subject - expect(page.find(:css, '.header-user .profile-link')['data-user']).to eql(another_user.username) + expect(page.find(:css, '[data-testid="user-profile-link"]')['data-user']).to eql(another_user.username) end it 'sees impersonation log out icon' do @@ -205,7 +205,7 @@ RSpec.describe 'Admin::Users::User' do it 'logs out of impersonated user back to original user' do subject - expect(page.find(:css, '.header-user .profile-link')['data-user']).to eq(current_user.username) + expect(page.find(:css, '[data-testid="user-profile-link"]')['data-user']).to eq(current_user.username) end it 'is redirected back to the impersonated users page in the admin after stopping' do |