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) }
|
2022-09-14 20:14:10 -04:00
|
|
|
let_it_be(:user) { create(:user) }
|
2021-04-30 11:09:50 -04:00
|
|
|
|
2020-11-27 07:09:14 -05:00
|
|
|
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
|
2020-09-30 17:10:09 -04:00
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
shared_examples 'shows Monitor menu based on the access level' do
|
2022-09-14 20:14:10 -04:00
|
|
|
using RSpec::Parameterized::TableSyntax
|
|
|
|
|
|
|
|
let(:enabled) { Featurable::PRIVATE }
|
|
|
|
let(:disabled) { Featurable::DISABLED }
|
|
|
|
|
|
|
|
where(:flag_enabled, :operations_access_level, :monitor_level, :render) do
|
|
|
|
true | ref(:disabled) | ref(:enabled) | true
|
|
|
|
true | ref(:disabled) | ref(:disabled) | false
|
|
|
|
true | ref(:enabled) | ref(:enabled) | true
|
|
|
|
true | ref(:enabled) | ref(:disabled) | false
|
|
|
|
false | ref(:disabled) | ref(:enabled) | false
|
|
|
|
false | ref(:disabled) | ref(:disabled) | false
|
|
|
|
false | ref(:enabled) | ref(:enabled) | true
|
|
|
|
false | ref(:enabled) | ref(:disabled) | true
|
2020-11-27 07:09:14 -05:00
|
|
|
end
|
|
|
|
|
2022-09-14 20:14:10 -04:00
|
|
|
with_them do
|
|
|
|
it 'renders when expected to' do
|
|
|
|
stub_feature_flags(split_operations_visibility_permissions: flag_enabled)
|
|
|
|
project.project_feature.update_attribute(:operations_access_level, operations_access_level)
|
|
|
|
project.project_feature.update_attribute(:monitor_access_level, monitor_level)
|
|
|
|
|
|
|
|
visit project_issues_path(project)
|
2020-11-27 07:09:14 -05:00
|
|
|
|
2022-09-14 20:14:10 -04:00
|
|
|
if render
|
|
|
|
expect(page).to have_selector('a.shortcuts-monitor', text: 'Monitor')
|
|
|
|
else
|
|
|
|
expect(page).not_to have_selector('a.shortcuts-monitor')
|
|
|
|
end
|
2020-11-27 07:09:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-09-14 20:14:10 -04:00
|
|
|
context 'when user is not a member' do
|
|
|
|
let(:access_level) { ProjectFeature::PUBLIC }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.project_feature.update_attribute(:operations_access_level, access_level)
|
|
|
|
project.project_feature.update_attribute(:monitor_access_level, access_level)
|
|
|
|
end
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it 'has the correct `Monitor` menu items', :aggregate_failures do
|
2022-09-14 20:14:10 -04:00
|
|
|
visit project_issues_path(project)
|
2021-05-18 11:10:46 -04:00
|
|
|
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('Kubernetes', href: project_clusters_path(project))
|
2020-11-27 07:09:14 -05:00
|
|
|
end
|
|
|
|
|
2022-09-14 20:14:10 -04:00
|
|
|
context 'with new monitor visiblity flag disabled' do
|
|
|
|
stub_feature_flags(split_operations_visibility_permissions: false)
|
2020-11-27 07:09:14 -05:00
|
|
|
|
2022-09-14 20:14:10 -04:00
|
|
|
context 'when operations project feature is PRIVATE' do
|
|
|
|
let(:access_level) { ProjectFeature::PRIVATE }
|
|
|
|
|
|
|
|
it 'does not show the `Monitor` menu' do
|
|
|
|
expect(page).not_to have_selector('a.shortcuts-monitor')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when operations project feature is DISABLED' do
|
|
|
|
let(:access_level) { ProjectFeature::DISABLED }
|
|
|
|
|
|
|
|
it 'does not show the `Operations` menu' do
|
|
|
|
expect(page).not_to have_selector('a.shortcuts-monitor')
|
|
|
|
end
|
2020-11-27 07:09:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-09-14 20:14:10 -04:00
|
|
|
context 'with new monitor visiblity flag enabled' do
|
|
|
|
context 'when monitor project feature is PRIVATE' do
|
|
|
|
let(:access_level) { ProjectFeature::PRIVATE }
|
|
|
|
|
|
|
|
it 'does not show the `Monitor` menu' do
|
|
|
|
expect(page).not_to have_selector('a.shortcuts-monitor')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when operations project feature is DISABLED' do
|
|
|
|
let(:access_level) { ProjectFeature::DISABLED }
|
2020-11-27 07:09:14 -05:00
|
|
|
|
2022-09-14 20:14:10 -04:00
|
|
|
it 'does not show the `Operations` menu' do
|
|
|
|
expect(page).not_to have_selector('a.shortcuts-monitor')
|
|
|
|
end
|
2020-11-27 07:09:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-09-14 20:14:10 -04:00
|
|
|
context 'when user has guest role' do
|
2020-09-30 17:10:09 -04:00
|
|
|
let(:role) { :guest }
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it 'has the correct `Monitor` menu items' do
|
2022-09-14 20:14:10 -04:00
|
|
|
visit project_issues_path(project)
|
2021-05-18 11:10:46 -04:00
|
|
|
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('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
|
|
|
|
|
2022-09-14 20:14:10 -04:00
|
|
|
context 'when user has reporter role' do
|
2020-09-30 17:10:09 -04:00
|
|
|
let(:role) { :reporter }
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it 'has the correct `Monitor` menu items' do
|
2022-09-14 20:14:10 -04:00
|
|
|
visit project_issues_path(project)
|
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('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
|
|
|
|
|
2022-09-14 20:14:10 -04:00
|
|
|
context 'when user has developer role' do
|
2020-09-30 17:10:09 -04:00
|
|
|
let(:role) { :developer }
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it 'has the correct `Monitor` menu items' do
|
2022-09-14 20:14:10 -04:00
|
|
|
visit project_issues_path(project)
|
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))
|
2022-01-27 19:14:06 -05:00
|
|
|
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
|
|
|
|
|
2022-09-14 20:14:10 -04:00
|
|
|
context 'when user has maintainer role' do
|
2020-09-30 17:10:09 -04:00
|
|
|
let(:role) { :maintainer }
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
it 'has the correct `Monitor` menu items' do
|
2022-09-14 20:14:10 -04:00
|
|
|
visit project_issues_path(project)
|
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('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
|