diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /spec/features/monitor_sidebar_link_spec.rb | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'spec/features/monitor_sidebar_link_spec.rb')
-rw-r--r-- | spec/features/monitor_sidebar_link_spec.rb | 102 |
1 files changed, 74 insertions, 28 deletions
diff --git a/spec/features/monitor_sidebar_link_spec.rb b/spec/features/monitor_sidebar_link_spec.rb index b888e2f4171..f612956600f 100644 --- a/spec/features/monitor_sidebar_link_spec.rb +++ b/spec/features/monitor_sidebar_link_spec.rb @@ -4,39 +4,59 @@ require 'spec_helper' RSpec.describe 'Monitor dropdown sidebar', :aggregate_failures do let_it_be_with_reload(:project) { create(:project, :internal, :repository) } + let_it_be(:user) { create(:user) } - let(:user) { create(:user) } - let(:access_level) { ProjectFeature::PUBLIC } let(:role) { nil } before do project.add_role(user, role) if role - project.project_feature.update_attribute(:operations_access_level, access_level) - sign_in(user) - visit project_issues_path(project) end shared_examples 'shows Monitor menu based on the access level' do - context 'when operations project feature is PRIVATE' do - let(:access_level) { ProjectFeature::PRIVATE } - - it 'shows the `Monitor` menu' do - expect(page).to have_selector('a.shortcuts-monitor', text: 'Monitor') - end + 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 end - context 'when operations project feature is DISABLED' do - let(:access_level) { ProjectFeature::DISABLED } + 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) - it 'does not show the `Monitor` menu' do - expect(page).not_to have_selector('a.shortcuts-monitor') + if render + expect(page).to have_selector('a.shortcuts-monitor', text: 'Monitor') + else + expect(page).not_to have_selector('a.shortcuts-monitor') + end end end end - context 'user is not a member' do + 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 + it 'has the correct `Monitor` menu items', :aggregate_failures do + visit project_issues_path(project) expect(page).to have_selector('a.shortcuts-monitor', text: 'Monitor') expect(page).to have_link('Incidents', href: project_incidents_path(project)) expect(page).to have_link('Environments', href: project_environments_path(project)) @@ -48,27 +68,50 @@ RSpec.describe 'Monitor dropdown sidebar', :aggregate_failures do expect(page).not_to have_link('Kubernetes', href: project_clusters_path(project)) end - context 'when operations project feature is PRIVATE' do - let(:access_level) { ProjectFeature::PRIVATE } + context 'with new monitor visiblity flag disabled' do + stub_feature_flags(split_operations_visibility_permissions: false) - it 'does not show the `Monitor` menu' do - expect(page).not_to have_selector('a.shortcuts-monitor') + 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 end end - context 'when operations project feature is DISABLED' do - let(:access_level) { ProjectFeature::DISABLED } + 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 } - it 'does not show the `Operations` menu' do - expect(page).not_to have_selector('a.shortcuts-monitor') + it 'does not show the `Operations` menu' do + expect(page).not_to have_selector('a.shortcuts-monitor') + end end end end - context 'user has guest role' do + context 'when user has guest role' do let(:role) { :guest } it 'has the correct `Monitor` menu items' do + visit project_issues_path(project) expect(page).to have_selector('a.shortcuts-monitor', text: 'Monitor') expect(page).to have_link('Incidents', href: project_incidents_path(project)) expect(page).to have_link('Environments', href: project_environments_path(project)) @@ -83,10 +126,11 @@ RSpec.describe 'Monitor dropdown sidebar', :aggregate_failures do it_behaves_like 'shows Monitor menu based on the access level' end - context 'user has reporter role' do + context 'when user has reporter role' do let(:role) { :reporter } it 'has the correct `Monitor` menu items' do + visit project_issues_path(project) 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)) @@ -100,10 +144,11 @@ RSpec.describe 'Monitor dropdown sidebar', :aggregate_failures do it_behaves_like 'shows Monitor menu based on the access level' end - context 'user has developer role' do + context 'when user has developer role' do let(:role) { :developer } it 'has the correct `Monitor` menu items' do + visit project_issues_path(project) 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)) @@ -116,10 +161,11 @@ RSpec.describe 'Monitor dropdown sidebar', :aggregate_failures do it_behaves_like 'shows Monitor menu based on the access level' end - context 'user has maintainer role' do + context 'when user has maintainer role' do let(:role) { :maintainer } it 'has the correct `Monitor` menu items' do + visit project_issues_path(project) 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)) |