summaryrefslogtreecommitdiff
path: root/spec/features/admin
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/admin')
-rw-r--r--spec/features/admin/admin_deploy_keys_spec.rb125
-rw-r--r--spec/features/admin/admin_labels_spec.rb24
-rw-r--r--spec/features/admin/admin_runners_spec.rb146
-rw-r--r--spec/features/admin/admin_settings_spec.rb3
-rw-r--r--spec/features/admin/admin_users_spec.rb29
-rw-r--r--spec/features/admin/integrations/user_activates_mattermost_slash_command_spec.rb15
-rw-r--r--spec/features/admin/users/user_spec.rb20
-rw-r--r--spec/features/admin/users/users_spec.rb4
8 files changed, 231 insertions, 135 deletions
diff --git a/spec/features/admin/admin_deploy_keys_spec.rb b/spec/features/admin/admin_deploy_keys_spec.rb
index 9b74aa2ac5a..88b8fcd8d5e 100644
--- a/spec/features/admin/admin_deploy_keys_spec.rb
+++ b/spec/features/admin/admin_deploy_keys_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe 'admin deploy keys' do
+RSpec.describe 'admin deploy keys', :js do
include Spec::Support::Helpers::ModalHelpers
let_it_be(:admin) { create(:admin) }
@@ -15,112 +15,81 @@ RSpec.describe 'admin deploy keys' do
gitlab_enable_admin_mode_sign_in(admin)
end
- shared_examples 'renders deploy keys correctly' do
- it 'show all public deploy keys' do
- visit admin_deploy_keys_path
+ it 'show all public deploy keys' do
+ visit admin_deploy_keys_path
- page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
- expect(page).to have_content(deploy_key.title)
- expect(page).to have_content(another_deploy_key.title)
- end
+ page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
+ expect(page).to have_content(deploy_key.title)
+ expect(page).to have_content(another_deploy_key.title)
end
+ end
- it 'shows all the projects the deploy key has write access' do
- write_key = create(:deploy_keys_project, :write_access, deploy_key: deploy_key)
+ it 'shows all the projects the deploy key has write access' do
+ write_key = create(:deploy_keys_project, :write_access, deploy_key: deploy_key)
- visit admin_deploy_keys_path
+ visit admin_deploy_keys_path
- page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
- expect(page).to have_content(write_key.project.full_name)
- end
+ page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
+ expect(page).to have_content(write_key.project.full_name)
end
+ end
- describe 'create a new deploy key' do
- let(:new_ssh_key) { attributes_for(:key)[:key] }
-
- before do
- visit admin_deploy_keys_path
- click_link 'New deploy key'
- end
-
- it 'creates a new deploy key' do
- fill_in 'deploy_key_title', with: 'laptop'
- fill_in 'deploy_key_key', with: new_ssh_key
- click_button 'Create'
-
- expect(current_path).to eq admin_deploy_keys_path
+ describe 'create a new deploy key' do
+ let(:new_ssh_key) { attributes_for(:key)[:key] }
- page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
- expect(page).to have_content('laptop')
- end
- end
+ before do
+ visit admin_deploy_keys_path
+ click_link 'New deploy key'
end
- describe 'update an existing deploy key' do
- before do
- visit admin_deploy_keys_path
- page.within('tr', text: deploy_key.title) do
- click_link(_('Edit deploy key'))
- end
- end
+ it 'creates a new deploy key' do
+ fill_in 'deploy_key_title', with: 'laptop'
+ fill_in 'deploy_key_key', with: new_ssh_key
+ click_button 'Create'
- it 'updates an existing deploy key' do
- fill_in 'deploy_key_title', with: 'new-title'
- click_button 'Save changes'
+ expect(current_path).to eq admin_deploy_keys_path
- expect(current_path).to eq admin_deploy_keys_path
-
- page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
- expect(page).to have_content('new-title')
- end
+ page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
+ expect(page).to have_content('laptop')
end
end
end
- context 'when `admin_deploy_keys_vue` feature flag is enabled', :js do
- it_behaves_like 'renders deploy keys correctly'
-
- describe 'remove an existing deploy key' do
- before do
- visit admin_deploy_keys_path
+ describe 'update an existing deploy key' do
+ before do
+ visit admin_deploy_keys_path
+ page.within('tr', text: deploy_key.title) do
+ click_link(_('Edit deploy key'))
end
+ end
- it 'removes an existing deploy key' do
- accept_gl_confirm('Are you sure you want to delete this deploy key?', button_text: 'Delete') do
- page.within('tr', text: deploy_key.title) do
- click_button _('Delete deploy key')
- end
- end
+ it 'updates an existing deploy key' do
+ fill_in 'deploy_key_title', with: 'new-title'
+ click_button 'Save changes'
- expect(current_path).to eq admin_deploy_keys_path
- page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
- expect(page).not_to have_content(deploy_key.title)
- end
+ expect(current_path).to eq admin_deploy_keys_path
+
+ page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
+ expect(page).to have_content('new-title')
end
end
end
- context 'when `admin_deploy_keys_vue` feature flag is disabled' do
+ describe 'remove an existing deploy key' do
before do
- stub_feature_flags(admin_deploy_keys_vue: false)
+ visit admin_deploy_keys_path
end
- it_behaves_like 'renders deploy keys correctly'
-
- describe 'remove an existing deploy key' do
- before do
- visit admin_deploy_keys_path
- end
-
- it 'removes an existing deploy key' do
+ it 'removes an existing deploy key' do
+ accept_gl_confirm('Are you sure you want to delete this deploy key?', button_text: 'Delete') do
page.within('tr', text: deploy_key.title) do
- click_link _('Remove deploy key')
+ click_button _('Delete deploy key')
end
+ end
- expect(current_path).to eq admin_deploy_keys_path
- page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
- expect(page).not_to have_content(deploy_key.title)
- end
+ expect(current_path).to eq admin_deploy_keys_path
+ page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
+ expect(page).not_to have_content(deploy_key.title)
end
end
end
diff --git a/spec/features/admin/admin_labels_spec.rb b/spec/features/admin/admin_labels_spec.rb
index 86d60b5d483..ba0870a53ae 100644
--- a/spec/features/admin/admin_labels_spec.rb
+++ b/spec/features/admin/admin_labels_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe 'admin issues labels' do
+ include Spec::Support::Helpers::ModalHelpers
+
let!(:bug_label) { Label.create!(title: 'bug', template: true) }
let!(:feature_label) { Label.create!(title: 'feature', template: true) }
@@ -59,7 +61,7 @@ RSpec.describe 'admin issues labels' do
it 'creates new label' do
fill_in 'Title', with: 'support'
fill_in 'Background color', with: '#F95610'
- click_button 'Save'
+ click_button 'Create label'
page.within '.manage-labels-list' do
expect(page).to have_content('support')
@@ -69,7 +71,7 @@ RSpec.describe 'admin issues labels' do
it 'does not creates label with invalid color' do
fill_in 'Title', with: 'support'
fill_in 'Background color', with: '#12'
- click_button 'Save'
+ click_button 'Create label'
page.within '.label-form' do
expect(page).to have_content('Color must be a valid color code')
@@ -79,7 +81,7 @@ RSpec.describe 'admin issues labels' do
it 'does not creates label if label already exists' do
fill_in 'Title', with: 'bug'
fill_in 'Background color', with: '#F95610'
- click_button 'Save'
+ click_button 'Create label'
page.within '.label-form' do
expect(page).to have_content 'Title has already been taken'
@@ -93,11 +95,25 @@ RSpec.describe 'admin issues labels' do
fill_in 'Title', with: 'fix'
fill_in 'Background color', with: '#F15610'
- click_button 'Save'
+ click_button 'Save changes'
page.within '.manage-labels-list' do
expect(page).to have_content('fix')
end
end
+
+ it 'allows user to delete label', :js do
+ visit edit_admin_label_path(bug_label)
+
+ click_button 'Delete'
+
+ within_modal do
+ expect(page).to have_content("#{bug_label.title} will be permanently deleted. This cannot be undone.")
+
+ click_link 'Delete label'
+ end
+
+ expect(page).to have_content('Label was removed')
+ end
end
end
diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb
index cc2d36221dc..ceb91b86876 100644
--- a/spec/features/admin/admin_runners_spec.rb
+++ b/spec/features/admin/admin_runners_spec.rb
@@ -21,12 +21,16 @@ RSpec.describe "Admin Runners" do
context "when there are runners" do
it 'has all necessary texts' do
- create(:ci_runner, :instance, contacted_at: Time.now)
+ create(:ci_runner, :instance, created_at: 1.year.ago, contacted_at: Time.now)
+ create(:ci_runner, :instance, created_at: 1.year.ago, contacted_at: 1.week.ago)
+ create(:ci_runner, :instance, created_at: 1.year.ago, contacted_at: 1.year.ago)
visit admin_runners_path
expect(page).to have_text "Register an instance runner"
- expect(page).to have_text "Online Runners 1"
+ expect(page).to have_text "Online runners 1"
+ expect(page).to have_text "Offline runners 2"
+ expect(page).to have_text "Stale runners 1"
end
it 'with an instance runner shows an instance badge' do
@@ -131,6 +135,9 @@ RSpec.describe "Admin Runners" do
it 'shows correct runner when description matches' do
input_filtered_search_keys('runner-foo')
+ expect(page).to have_link('All 1')
+ expect(page).to have_link('Instance 1')
+
expect(page).to have_content("runner-foo")
expect(page).not_to have_content("runner-bar")
end
@@ -138,71 +145,78 @@ RSpec.describe "Admin Runners" do
it 'shows no runner when description does not match' do
input_filtered_search_keys('runner-baz')
+ expect(page).to have_link('All 0')
+ expect(page).to have_link('Instance 0')
+
expect(page).to have_text 'No runners found'
end
end
describe 'filter by status' do
- it 'shows correct runner when status matches' do
- create(:ci_runner, :instance, description: 'runner-active', active: true)
- create(:ci_runner, :instance, description: 'runner-paused', active: false)
+ let!(:never_contacted) { create(:ci_runner, :instance, description: 'runner-never-contacted', contacted_at: nil) }
+
+ before do
+ create(:ci_runner, :instance, description: 'runner-1', contacted_at: Time.now)
+ create(:ci_runner, :instance, description: 'runner-2', contacted_at: Time.now)
+ create(:ci_runner, :instance, description: 'runner-paused', active: false, contacted_at: Time.now)
visit admin_runners_path
+ end
- expect(page).to have_content 'runner-active'
+ it 'shows all runners' do
+ expect(page).to have_content 'runner-1'
+ expect(page).to have_content 'runner-2'
expect(page).to have_content 'runner-paused'
+ expect(page).to have_content 'runner-never-contacted'
+ expect(page).to have_link('All 4')
+ end
+
+ it 'shows correct runner when status matches' do
input_filtered_search_filter_is_only('Status', 'Active')
- expect(page).to have_content 'runner-active'
+ expect(page).to have_link('All 3')
+
+ expect(page).to have_content 'runner-1'
+ expect(page).to have_content 'runner-2'
+ expect(page).to have_content 'runner-never-contacted'
expect(page).not_to have_content 'runner-paused'
end
it 'shows no runner when status does not match' do
- create(:ci_runner, :instance, description: 'runner-active', active: true)
- create(:ci_runner, :instance, description: 'runner-paused', active: false)
+ input_filtered_search_filter_is_only('Status', 'Stale')
- visit admin_runners_path
-
- input_filtered_search_filter_is_only('Status', 'Online')
-
- expect(page).not_to have_content 'runner-active'
- expect(page).not_to have_content 'runner-paused'
+ expect(page).to have_link('All 0')
expect(page).to have_text 'No runners found'
end
it 'shows correct runner when status is selected and search term is entered' do
- 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_filter_is_only('Status', 'Active')
+ input_filtered_search_keys('runner-1')
- 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('runner-a')
+ expect(page).to have_link('All 1')
- 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-1'
+ expect(page).not_to have_content 'runner-2'
+ expect(page).not_to have_content 'runner-never-contacted'
+ expect(page).not_to have_content 'runner-paused'
end
- it 'shows correct runner when type is selected and search term is entered' do
- create(:ci_runner, :instance, description: 'runner-connected', contacted_at: Time.now)
- create(:ci_runner, :instance, description: 'runner-not-connected', contacted_at: nil)
+ it 'shows correct runner when status filter is entered' do
+ # use the string "Never" to avoid using space and trigger an early selection
+ input_filtered_search_filter_is_only('Status', 'Never')
- visit admin_runners_path
+ expect(page).to have_link('All 1')
- # use the string "Not" to avoid using space and trigger an early selection
- input_filtered_search_filter_is_only('Status', 'Not')
+ expect(page).not_to have_content 'runner-1'
+ expect(page).not_to have_content 'runner-2'
+ expect(page).not_to have_content 'runner-paused'
+ expect(page).to have_content 'runner-never-contacted'
- expect(page).not_to have_content 'runner-connected'
- expect(page).to have_content 'runner-not-connected'
+ within "[data-testid='runner-row-#{never_contacted.id}']" do
+ expect(page).to have_selector '.badge', text: 'never contacted'
+ end
end
end
@@ -215,6 +229,10 @@ RSpec.describe "Admin Runners" do
it '"All" tab is selected by default' do
visit admin_runners_path
+ expect(page).to have_link('All 2')
+ expect(page).to have_link('Group 1')
+ expect(page).to have_link('Project 1')
+
page.within('[data-testid="runner-type-tabs"]') do
expect(page).to have_link('All', class: 'active')
end
@@ -373,9 +391,28 @@ RSpec.describe "Admin Runners" do
it 'has all necessary texts including no runner message' do
expect(page).to have_text "Register an instance runner"
- expect(page).to have_text "Online Runners 0"
+
+ expect(page).to have_text "Online runners 0"
+ expect(page).to have_text "Offline runners 0"
+ expect(page).to have_text "Stale runners 0"
+
expect(page).to have_text 'No runners found'
end
+
+ it 'shows tabs with total counts equal to 0' do
+ expect(page).to have_link('All 0')
+ expect(page).to have_link('Instance 0')
+ expect(page).to have_link('Group 0')
+ expect(page).to have_link('Project 0')
+ end
+ 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
end
describe 'runners registration' do
@@ -422,7 +459,9 @@ RSpec.describe "Admin Runners" do
before do
click_on 'Reset registration token'
- page.accept_alert
+ within_modal do
+ click_button('OK', match: :first)
+ end
wait_for_requests
end
@@ -437,26 +476,29 @@ RSpec.describe "Admin Runners" do
end
end
- describe "Runner show page" do
+ describe "Runner edit page" do
let(:runner) { create(:ci_runner) }
before do
@project1 = create(:project)
@project2 = create(:project)
- visit admin_runner_path(runner)
+ visit edit_admin_runner_path(runner)
+
+ wait_for_requests
end
describe 'runner page breadcrumbs' do
- it 'contains the current runner token' do
+ it 'contains the current runner id and token' do
page.within '[data-testid="breadcrumb-links"]' do
- expect(page.find('h2')).to have_content(runner.short_sha)
+ expect(page).to have_link("##{runner.id} (#{runner.short_sha})")
+ expect(page.find('h2')).to have_content("Edit")
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}")
+ 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")
end
end
@@ -498,7 +540,7 @@ RSpec.describe "Admin Runners" do
let(:runner) { create(:ci_runner, :project, projects: [@project1]) }
before do
- visit admin_runner_path(runner)
+ visit edit_admin_runner_path(runner)
end
it_behaves_like 'assignable runner'
@@ -508,7 +550,7 @@ RSpec.describe "Admin Runners" do
let(:runner) { create(:ci_runner, :project, projects: [@project1], locked: true) }
before do
- visit admin_runner_path(runner)
+ visit edit_admin_runner_path(runner)
end
it_behaves_like 'assignable runner'
@@ -519,7 +561,7 @@ RSpec.describe "Admin Runners" do
before do
@project1.destroy!
- visit admin_runner_path(runner)
+ visit edit_admin_runner_path(runner)
end
it_behaves_like 'assignable runner'
@@ -530,7 +572,7 @@ RSpec.describe "Admin Runners" do
let(:runner) { create(:ci_runner, :project, projects: [@project1]) }
before do
- visit admin_runner_path(runner)
+ visit edit_admin_runner_path(runner)
end
it 'removed specific runner from project' do
@@ -567,6 +609,8 @@ RSpec.describe "Admin Runners" do
page.find('input').send_keys(search_term)
click_on 'Search'
end
+
+ wait_for_requests
end
def input_filtered_search_filter_is_only(filter, value)
@@ -583,5 +627,7 @@ RSpec.describe "Admin Runners" do
click_on 'Search'
end
+
+ wait_for_requests
end
end
diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb
index 29323c604ef..e136ab41966 100644
--- a/spec/features/admin/admin_settings_spec.rb
+++ b/spec/features/admin/admin_settings_spec.rb
@@ -275,7 +275,7 @@ RSpec.describe 'Admin updates settings' do
it 'enable hiding third party offers' do
page.within('.as-third-party-offers') do
- check 'Do not display offers from third parties'
+ check 'Do not display content for customer experience improvement and offers from third parties'
click_button 'Save changes'
end
@@ -530,6 +530,7 @@ RSpec.describe 'Admin updates settings' do
it 'loads usage ping payload on click', :js do
stub_usage_data_connections
+ stub_database_flavor_check
page.within('#js-usage-settings') do
expected_payload_content = /(?=.*"uuid")(?=.*"hostname")/m
diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb
index 2b627707ff2..95e3f5c70e5 100644
--- a/spec/features/admin/admin_users_spec.rb
+++ b/spec/features/admin/admin_users_spec.rb
@@ -57,4 +57,33 @@ RSpec.describe "Admin::Users" do
expect(page).to have_content("#{Time.now.strftime('%b %Y')} 3 0")
end
end
+
+ describe 'prompt user about registration features' do
+ let(:message) { s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|send emails to users') } }
+
+ it 'does not render registration features CTA when service ping is enabled' do
+ stub_application_setting(usage_ping_enabled: true)
+
+ visit admin_users_path
+
+ expect(page).not_to have_content(message)
+ end
+
+ context 'with no license and service ping disabled' do
+ before do
+ stub_application_setting(usage_ping_enabled: false)
+
+ if Gitlab.ee?
+ allow(License).to receive(:current).and_return(nil)
+ end
+ end
+
+ it 'renders registration features CTA' do
+ visit admin_users_path
+
+ expect(page).to have_content(message)
+ expect(page).to have_link(s_('RegistrationFeatures|Registration Features Program'))
+ end
+ end
+ end
end
diff --git a/spec/features/admin/integrations/user_activates_mattermost_slash_command_spec.rb b/spec/features/admin/integrations/user_activates_mattermost_slash_command_spec.rb
index 22a27b33671..793a5bced00 100644
--- a/spec/features/admin/integrations/user_activates_mattermost_slash_command_spec.rb
+++ b/spec/features/admin/integrations/user_activates_mattermost_slash_command_spec.rb
@@ -19,4 +19,19 @@ RSpec.describe 'User activates the instance-level Mattermost Slash Command integ
expect(page).to have_link('Settings', href: edit_path)
expect(page).to have_link('Projects using custom settings', href: overrides_path)
end
+
+ it 'does not render integration form element' do
+ expect(page).not_to have_selector('[data-testid="integration-form"]')
+ end
+
+ context 'when `vue_integration_form` feature flag is disabled' do
+ before do
+ stub_feature_flags(vue_integration_form: false)
+ visit_instance_integration('Mattermost slash commands')
+ end
+
+ it 'renders integration form element' do
+ expect(page).to have_selector('[data-testid="integration-form"]')
+ end
+ end
end
diff --git a/spec/features/admin/users/user_spec.rb b/spec/features/admin/users/user_spec.rb
index ae940fecabe..0d053329627 100644
--- a/spec/features/admin/users/user_spec.rb
+++ b/spec/features/admin/users/user_spec.rb
@@ -125,6 +125,26 @@ RSpec.describe 'Admin::Users::User' do
end
end
+ context 'when a user is locked', time_travel_to: '2020-02-02 10:30:45 -0700' do
+ let_it_be(:locked_user) { create(:user, locked_at: DateTime.parse('2020-02-02 10:30:00 -0700')) }
+
+ before do
+ visit admin_user_path(locked_user)
+ end
+
+ it "displays `(Locked)` next to user's name" do
+ expect(page).to have_content("#{locked_user.name} (Locked)")
+ end
+
+ it 'allows a user to be unlocked from the `User administration dropdown', :js do
+ accept_gl_confirm("Unlock user #{locked_user.name}?", button_text: 'Unlock') do
+ click_action_in_user_dropdown(locked_user.id, 'Unlock')
+ end
+
+ expect(page).not_to have_content("#{locked_user.name} (Locked)")
+ end
+ end
+
describe 'Impersonation' do
let_it_be(:another_user) { create(:user) }
diff --git a/spec/features/admin/users/users_spec.rb b/spec/features/admin/users/users_spec.rb
index fa943245fcb..473f51370b3 100644
--- a/spec/features/admin/users/users_spec.rb
+++ b/spec/features/admin/users/users_spec.rb
@@ -462,9 +462,9 @@ RSpec.describe 'Admin::Users' do
visit projects_admin_user_path(user)
end
- it 'lists group projects' do
+ it 'lists groups' do
within(:css, '.gl-mb-3 + .card') do
- expect(page).to have_content 'Group projects'
+ expect(page).to have_content 'Groups'
expect(page).to have_link group.name, href: admin_group_path(group)
end
end