diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /spec/features/admin | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.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_mode/login_spec.rb | 10 | ||||
-rw-r--r-- | spec/features/admin/admin_settings_spec.rb | 37 | ||||
-rw-r--r-- | spec/features/admin/admin_users_spec.rb | 97 | ||||
-rw-r--r-- | spec/features/admin/admin_uses_repository_checks_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/admin/clusters/eks_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/admin/dashboard_spec.rb | 6 |
7 files changed, 142 insertions, 14 deletions
diff --git a/spec/features/admin/admin_groups_spec.rb b/spec/features/admin/admin_groups_spec.rb index f5c5a73c042..653a45a4bb8 100644 --- a/spec/features/admin/admin_groups_spec.rb +++ b/spec/features/admin/admin_groups_spec.rb @@ -194,7 +194,7 @@ RSpec.describe 'Admin Groups' do expect(page).to have_content('Developer') end - accept_confirm { find(:css, 'li', text: current_user.name).find(:css, 'a.btn-remove').click } + accept_confirm { find(:css, 'li', text: current_user.name).find(:css, 'a.btn-danger').click } visit group_group_members_path(group) diff --git a/spec/features/admin/admin_mode/login_spec.rb b/spec/features/admin/admin_mode/login_spec.rb index 12046518aac..7cbba9ec674 100644 --- a/spec/features/admin/admin_mode/login_spec.rb +++ b/spec/features/admin/admin_mode/login_spec.rb @@ -48,7 +48,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc it 'allows login with valid code' do # Cannot reuse the TOTP - Timecop.travel(30.seconds.from_now) do + travel_to(30.seconds.from_now) do enter_code(user.current_otp) expect(current_path).to eq admin_root_path @@ -58,7 +58,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc it 'blocks login with invalid code' do # Cannot reuse the TOTP - Timecop.travel(30.seconds.from_now) do + travel_to(30.seconds.from_now) do enter_code('foo') expect(page).to have_content('Invalid two-factor code') @@ -67,7 +67,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc it 'allows login with invalid code, then valid code' do # Cannot reuse the TOTP - Timecop.travel(30.seconds.from_now) do + travel_to(30.seconds.from_now) do enter_code('foo') expect(page).to have_content('Invalid two-factor code') @@ -163,7 +163,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc expect(page).to have_content('Two-Factor Authentication') # Cannot reuse the TOTP - Timecop.travel(30.seconds.from_now) do + travel_to(30.seconds.from_now) do enter_code(user.current_otp) expect(current_path).to eq admin_root_path @@ -215,7 +215,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc expect(page).to have_content('Two-Factor Authentication') # Cannot reuse the TOTP - Timecop.travel(30.seconds.from_now) do + travel_to(30.seconds.from_now) do enter_code(user.current_otp) expect(current_path).to eq admin_root_path diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index 38f0b813183..528dfad606e 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -130,6 +130,38 @@ RSpec.describe 'Admin updates settings', :clean_gitlab_redis_shared_state, :do_n expect(user_internal_regex['placeholder']).to eq 'Regex pattern' end + context 'Change Sign-up restrictions' do + context 'Require Admin approval for new signup setting' do + context 'when feature is enabled' do + before do + stub_feature_flags(admin_approval_for_new_user_signups: true) + end + + it 'changes the setting' do + page.within('.as-signup') do + check 'Require admin approval for new sign-ups' + click_button 'Save changes' + end + + expect(current_settings.require_admin_approval_after_user_signup).to be_truthy + expect(page).to have_content "Application settings saved successfully" + end + end + + context 'when feature is disabled' do + before do + stub_feature_flags(admin_approval_for_new_user_signups: false) + end + + it 'does not show the the setting' do + page.within('.as-signup') do + expect(page).not_to have_selector('.application_setting_require_admin_approval_after_user_signup') + end + end + end + end + end + it 'Change Sign-in restrictions' do page.within('.as-signin') do fill_in 'Home page URL', with: 'https://about.gitlab.com/' @@ -497,18 +529,23 @@ RSpec.describe 'Admin updates settings', :clean_gitlab_redis_shared_state, :do_n end it 'Change Help page' do + stub_feature_flags(help_page_documentation_redirect: true) + new_support_url = 'http://example.com/help' + 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 'Support page URL', with: new_support_url + fill_in 'Documentation pages URL', with: new_documentation_url click_button 'Save changes' end expect(current_settings.help_page_text).to eq "Example text" expect(current_settings.help_page_hide_commercial_content).to be_truthy expect(current_settings.help_page_support_url).to eq new_support_url + expect(current_settings.help_page_documentation_base_url).to eq new_documentation_url expect(page).to have_content "Application settings saved successfully" end diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb index a37210d2acc..e06e2d14f3c 100644 --- a/spec/features/admin/admin_users_spec.rb +++ b/spec/features/admin/admin_users_spec.rb @@ -31,6 +31,7 @@ RSpec.describe "Admin::Users" do expect(page).to have_content(current_user.last_activity_on.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_button('Block') expect(page).to have_button('Deactivate') expect(page).to have_button('Delete user') @@ -48,6 +49,56 @@ RSpec.describe "Admin::Users" do end 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 + + 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 + + context '`Pending approval` tab' do + context 'feature is enabled' do + before do + stub_feature_flags(admin_approval_for_new_user_signups: true) + 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 + + context 'feature is disabled' do + before do + stub_feature_flags(admin_approval_for_new_user_signups: false) + visit admin_users_path + end + + it 'does not show the `Pending approval` tab' do + expect(page).not_to have_link('Pending approval', href: admin_users_path(filter: 'blocked_pending_approval')) + end + end + end + end + describe 'search and sort' do before do create(:user, name: 'Foo Bar', last_activity_on: 3.days.ago) @@ -146,6 +197,27 @@ RSpec.describe "Admin::Users" do expect(page).to have_content(user.email) end end + + describe 'Pending approval filter' do + it 'counts users who are pending approval' do + create_list(:user, 2, :blocked_pending_approval) + + visit admin_users_path + + page.within('.filter-blocked-pending-approval small') do + expect(page).to have_content('2') + end + end + + it 'filters by users who are pending approval' do + user = create(:user, :blocked_pending_approval) + + visit admin_users_path + click_link 'Pending approval' + + expect(page).to have_content(user.email) + end + end end describe "GET /admin/users/new" do @@ -287,6 +359,23 @@ RSpec.describe "Admin::Users" do expect(page).to have_button('Delete user and contributions') end + context 'user pending approval' do + it 'shows user info' do + user = create(:user, :blocked_pending_approval) + + 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_button('Block user') + expect(page).to have_button('Delete user') + expect(page).to have_button('Delete user and contributions') + end + end + describe 'Impersonation' do let(:another_user) { create(:user) } @@ -606,7 +695,7 @@ RSpec.describe "Admin::Users" do end end - describe 'show user keys' do + describe 'show user keys', :js do let!(:key1) do create(:key, user: user, title: "ssh-rsa Key1", key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4FIEBXGi4bPU8kzxMefudPIJ08/gNprdNTaO9BR/ndy3+58s2HCTw2xCHcsuBmq+TsAqgEidVq4skpqoTMB+Uot5Uzp9z4764rc48dZiI661izoREoKnuRQSsRqUTHg5wrLzwxlQbl1MVfRWQpqiz/5KjBC7yLEb9AbusjnWBk8wvC1bQPQ1uLAauEA7d836tgaIsym9BrLsMVnR4P1boWD3Xp1B1T/ImJwAGHvRmP/ycIqmKdSpMdJXwxcb40efWVj0Ibbe7ii9eeoLdHACqevUZi6fwfbymdow+FeqlkPoHyGg3Cu4vD/D8+8cRc7mE/zGCWcQ15Var83Tczour Key1") end @@ -629,7 +718,11 @@ RSpec.describe "Admin::Users" do expect(page).to have_content(key2.title) expect(page).to have_content(key2.key) - click_link 'Remove' + click_button 'Delete' + + page.within('.modal') do + page.click_button('Delete') + end expect(page).not_to have_content(key2.title) end diff --git a/spec/features/admin/admin_uses_repository_checks_spec.rb b/spec/features/admin/admin_uses_repository_checks_spec.rb index b8851c28531..44642983a36 100644 --- a/spec/features/admin/admin_uses_repository_checks_spec.rb +++ b/spec/features/admin/admin_uses_repository_checks_spec.rb @@ -46,7 +46,7 @@ RSpec.describe 'Admin uses repository checks', :request_store, :clean_gitlab_red ) visit_admin_project_page(project) - page.within('.alert') do + page.within('.gl-alert') do expect(page.text).to match(/Last repository check \(just now\) failed/) end end diff --git a/spec/features/admin/clusters/eks_spec.rb b/spec/features/admin/clusters/eks_spec.rb index ef49aebc7c5..ad7122bf182 100644 --- a/spec/features/admin/clusters/eks_spec.rb +++ b/spec/features/admin/clusters/eks_spec.rb @@ -13,7 +13,7 @@ RSpec.describe 'Instance-level AWS EKS Cluster', :js do before do visit admin_clusters_path - click_link 'Add Kubernetes cluster' + click_link 'Integrate with a cluster certificate' end context 'when user creates a cluster on AWS EKS' do diff --git a/spec/features/admin/dashboard_spec.rb b/spec/features/admin/dashboard_spec.rb index 4ffa5e3be0b..acb8fb54e11 100644 --- a/spec/features/admin/dashboard_spec.rb +++ b/spec/features/admin/dashboard_spec.rb @@ -28,11 +28,9 @@ RSpec.describe 'admin visits dashboard' do describe 'Users statistic' do let_it_be(:users_statistics) { create(:users_statistics) } + let_it_be(:users_count_label) { Gitlab.ee? ? 'Billable users 71' : 'Active users 71' } it 'shows correct amounts of users', :aggregate_failures do - expected_active_users_text = Gitlab.ee? ? 'Active users (Billable users) 71' : 'Active users 71' - - sign_in(create(:admin)) visit admin_dashboard_stats_path expect(page).to have_content('Users without a Group and Project 23') @@ -42,9 +40,9 @@ RSpec.describe 'admin visits dashboard' do expect(page).to have_content('Users with highest role Maintainer 6') expect(page).to have_content('Users with highest role Owner 5') expect(page).to have_content('Bots 2') - expect(page).to have_content(expected_active_users_text) expect(page).to have_content('Blocked users 7') expect(page).to have_content('Total users 78') + expect(page).to have_content(users_count_label) end end end |