2020-09-30 17:10:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
RSpec.describe 'Monitor dropdown sidebar', :aggregate_failures do
|
2020-11-27 07:09:14 -05:00
|
|
|
let_it_be_with_reload(:project) { create(:project, :internal, :repository) }
|
2021-04-30 11:09:50 -04:00
|
|
|
|
2020-09-30 17:10:09 -04:00
|
|
|
let(:user) { create(:user) }
|
2020-11-27 07:09:14 -05:00
|
|
|
let(:access_level) { ProjectFeature::PUBLIC }
|
|
|
|
let(:role) { nil }
|
2020-09-30 17:10:09 -04:00
|
|
|
|
|
|
|
before do
|
2020-11-27 07:09:14 -05:00
|
|
|
project.add_role(user, role) if role
|
|
|
|
project.project_feature.update_attribute(:operations_access_level, access_level)
|
|
|
|
|
2020-09-30 17:10:09 -04:00
|
|
|
sign_in(user)
|
|
|
|
visit project_issues_path(project)
|
|
|
|
end
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
shared_examples 'shows Monitor menu based on the access level' do
|
2020-11-27 07:09:14 -05:00
|
|
|
context 'when operations project feature is PRIVATE' do
|
|
|
|
let(:access_level) { ProjectFeature::PRIVATE }
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it 'shows the `Monitor` menu' do
|
|
|
|
expect(page).to have_selector('a.shortcuts-monitor', text: 'Monitor')
|
2020-11-27 07:09:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when operations project feature is DISABLED' do
|
|
|
|
let(:access_level) { ProjectFeature::DISABLED }
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it 'does not show the `Monitor` menu' do
|
|
|
|
expect(page).not_to have_selector('a.shortcuts-monitor')
|
2020-11-27 07:09:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'user is not a member' do
|
2021-05-18 11:10:46 -04:00
|
|
|
it 'has the correct `Monitor` menu items', :aggregate_failures do
|
|
|
|
expect(page).to have_selector('a.shortcuts-monitor', text: 'Monitor')
|
2021-04-30 11:09:50 -04:00
|
|
|
expect(page).to have_link('Incidents', href: project_incidents_path(project))
|
|
|
|
expect(page).to have_link('Environments', href: project_environments_path(project))
|
|
|
|
|
|
|
|
expect(page).not_to have_link('Metrics', href: project_metrics_dashboard_path(project))
|
|
|
|
expect(page).not_to have_link('Alerts', href: project_alert_management_index_path(project))
|
|
|
|
expect(page).not_to have_link('Error Tracking', href: project_error_tracking_index_path(project))
|
|
|
|
expect(page).not_to have_link('Product Analytics', href: project_product_analytics_path(project))
|
|
|
|
expect(page).not_to have_link('Serverless', href: project_serverless_functions_path(project))
|
|
|
|
expect(page).not_to have_link('Logs', href: project_logs_path(project))
|
|
|
|
expect(page).not_to have_link('Kubernetes', href: project_clusters_path(project))
|
2020-11-27 07:09:14 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when operations project feature is PRIVATE' do
|
|
|
|
let(:access_level) { ProjectFeature::PRIVATE }
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it 'does not show the `Monitor` menu' do
|
|
|
|
expect(page).not_to have_selector('a.shortcuts-monitor')
|
2020-11-27 07:09:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when operations project feature is DISABLED' do
|
|
|
|
let(:access_level) { ProjectFeature::DISABLED }
|
|
|
|
|
|
|
|
it 'does not show the `Operations` menu' do
|
2021-05-18 11:10:46 -04:00
|
|
|
expect(page).not_to have_selector('a.shortcuts-monitor')
|
2020-11-27 07:09:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-09-30 17:10:09 -04:00
|
|
|
context 'user has guest role' do
|
|
|
|
let(:role) { :guest }
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it 'has the correct `Monitor` menu items' do
|
|
|
|
expect(page).to have_selector('a.shortcuts-monitor', text: 'Monitor')
|
2021-04-30 11:09:50 -04:00
|
|
|
expect(page).to have_link('Incidents', href: project_incidents_path(project))
|
|
|
|
expect(page).to have_link('Environments', href: project_environments_path(project))
|
|
|
|
|
|
|
|
expect(page).not_to have_link('Metrics', href: project_metrics_dashboard_path(project))
|
|
|
|
expect(page).not_to have_link('Alerts', href: project_alert_management_index_path(project))
|
|
|
|
expect(page).not_to have_link('Error Tracking', href: project_error_tracking_index_path(project))
|
|
|
|
expect(page).not_to have_link('Product Analytics', href: project_product_analytics_path(project))
|
|
|
|
expect(page).not_to have_link('Serverless', href: project_serverless_functions_path(project))
|
|
|
|
expect(page).not_to have_link('Logs', href: project_logs_path(project))
|
|
|
|
expect(page).not_to have_link('Kubernetes', href: project_clusters_path(project))
|
2020-09-30 17:10:09 -04:00
|
|
|
end
|
2020-11-27 07:09:14 -05:00
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it_behaves_like 'shows Monitor menu based on the access level'
|
2020-09-30 17:10:09 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'user has reporter role' do
|
|
|
|
let(:role) { :reporter }
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it 'has the correct `Monitor` menu items' do
|
2021-04-30 11:09:50 -04:00
|
|
|
expect(page).to have_link('Metrics', href: project_metrics_dashboard_path(project))
|
|
|
|
expect(page).to have_link('Incidents', href: project_incidents_path(project))
|
|
|
|
expect(page).to have_link('Environments', href: project_environments_path(project))
|
|
|
|
expect(page).to have_link('Error Tracking', href: project_error_tracking_index_path(project))
|
|
|
|
expect(page).to have_link('Product Analytics', href: project_product_analytics_path(project))
|
|
|
|
|
|
|
|
expect(page).not_to have_link('Alerts', href: project_alert_management_index_path(project))
|
|
|
|
expect(page).not_to have_link('Serverless', href: project_serverless_functions_path(project))
|
|
|
|
expect(page).not_to have_link('Logs', href: project_logs_path(project))
|
|
|
|
expect(page).not_to have_link('Kubernetes', href: project_clusters_path(project))
|
2020-09-30 17:10:09 -04:00
|
|
|
end
|
2020-11-27 07:09:14 -05:00
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it_behaves_like 'shows Monitor menu based on the access level'
|
2020-09-30 17:10:09 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'user has developer role' do
|
|
|
|
let(:role) { :developer }
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it 'has the correct `Monitor` menu items' do
|
2021-04-30 11:09:50 -04:00
|
|
|
expect(page).to have_link('Metrics', href: project_metrics_dashboard_path(project))
|
|
|
|
expect(page).to have_link('Alerts', href: project_alert_management_index_path(project))
|
|
|
|
expect(page).to have_link('Incidents', href: project_incidents_path(project))
|
|
|
|
expect(page).to have_link('Environments', href: project_environments_path(project))
|
|
|
|
expect(page).to have_link('Error Tracking', href: project_error_tracking_index_path(project))
|
|
|
|
expect(page).to have_link('Product Analytics', href: project_product_analytics_path(project))
|
|
|
|
expect(page).to have_link('Logs', href: project_logs_path(project))
|
2022-01-27 19:14:06 -05:00
|
|
|
expect(page).to have_link('Serverless', href: project_serverless_functions_path(project))
|
|
|
|
expect(page).to have_link('Kubernetes', href: project_clusters_path(project))
|
2020-09-30 17:10:09 -04:00
|
|
|
end
|
2020-11-27 07:09:14 -05:00
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it_behaves_like 'shows Monitor menu based on the access level'
|
2020-09-30 17:10:09 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'user has maintainer role' do
|
|
|
|
let(:role) { :maintainer }
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it 'has the correct `Monitor` menu items' do
|
2021-04-30 11:09:50 -04:00
|
|
|
expect(page).to have_link('Metrics', href: project_metrics_dashboard_path(project))
|
|
|
|
expect(page).to have_link('Alerts', href: project_alert_management_index_path(project))
|
|
|
|
expect(page).to have_link('Incidents', href: project_incidents_path(project))
|
|
|
|
expect(page).to have_link('Environments', href: project_environments_path(project))
|
|
|
|
expect(page).to have_link('Error Tracking', href: project_error_tracking_index_path(project))
|
|
|
|
expect(page).to have_link('Product Analytics', href: project_product_analytics_path(project))
|
|
|
|
expect(page).to have_link('Serverless', href: project_serverless_functions_path(project))
|
|
|
|
expect(page).to have_link('Logs', href: project_logs_path(project))
|
|
|
|
expect(page).to have_link('Kubernetes', href: project_clusters_path(project))
|
2020-09-30 17:10:09 -04:00
|
|
|
end
|
2020-11-27 07:09:14 -05:00
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it_behaves_like 'shows Monitor menu based on the access level'
|
2020-09-30 17:10:09 -04:00
|
|
|
end
|
|
|
|
end
|