Commit b412362c authored by Michael Kozono's avatar Michael Kozono

Merge branch 'sy-ensure-alerts-viewable-if-present' into 'master'

Show alert management list when there are active alerts

See merge request gitlab-org/gitlab!49257
parents d659306e bd1261cb
...@@ -28,7 +28,7 @@ module Projects::AlertManagementHelper ...@@ -28,7 +28,7 @@ module Projects::AlertManagementHelper
def alert_management_enabled?(project) def alert_management_enabled?(project)
!!( !!(
project.alerts_service_activated? || project.alert_management_alerts.any? ||
project.prometheus_service_active? || project.prometheus_service_active? ||
AlertManagement::HttpIntegrationsFinder.new(project, active: true).execute.any? AlertManagement::HttpIntegrationsFinder.new(project, active: true).execute.any?
) )
......
---
title: Allow alert list to be visible when alerts exist, even if alerting integrations
are disabled
merge_request: 49257
author:
type: changed
...@@ -5,12 +5,12 @@ require 'spec_helper' ...@@ -5,12 +5,12 @@ require 'spec_helper'
RSpec.describe 'Alert Management index', :js do RSpec.describe 'Alert Management index', :js do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:developer) { create(:user) } let_it_be(:developer) { create(:user) }
let_it_be(:alert) { create(:alert_management_alert, project: project, status: 'triggered') }
before_all do before_all do
project.add_developer(developer) project.add_developer(developer)
end end
context 'when a developer displays the alert list' do
before do before do
sign_in(developer) sign_in(developer)
...@@ -18,41 +18,41 @@ RSpec.describe 'Alert Management index', :js do ...@@ -18,41 +18,41 @@ RSpec.describe 'Alert Management index', :js do
wait_for_requests wait_for_requests
end end
context 'when a developer displays the alert list and alert integrations are not enabled' do it 'shows the alert page title and empty state without filtered search or alert table' do
it 'shows the alert page title' do
expect(page).to have_content('Alerts') expect(page).to have_content('Alerts')
end
it 'shows the empty state by default' do
expect(page).to have_content('Surface alerts in GitLab') expect(page).to have_content('Surface alerts in GitLab')
end expect(page).not_to have_selector('.gl-table')
it 'does not show the filtered search' do
page.within('.layout-page') do page.within('.layout-page') do
expect(page).not_to have_css('[data-testid="search-icon"]') expect(page).not_to have_css('[data-testid="search-icon"]')
end end
end end
it 'does not show the alert table' do shared_examples 'alert page with title, filtered search, and table' do
expect(page).not_to have_selector('.gl-table') it 'renders correctly' do
expect(page).to have_content('Alerts')
expect(page).to have_selector('.gl-table')
page.within('.layout-page') do
expect(page).to have_css('[data-testid="search-icon"]')
end
end end
end end
context 'when a developer displays the alert list and an HTTP integration is enabled' do context 'when alerts have already been created' do
let_it_be(:integration) { create(:alert_management_http_integration, project: project) } let_it_be(:alert) { create(:alert_management_alert, project: project) }
it 'shows the alert page title' do it_behaves_like 'alert page with title, filtered search, and table'
expect(page).to have_content('Alerts')
end end
it 'shows the filtered search' do context 'when an HTTP integration is enabled' do
page.within('.layout-page') do let_it_be(:integration) { create(:alert_management_http_integration, project: project) }
expect(page).to have_css('[data-testid="search-icon"]')
end it_behaves_like 'alert page with title, filtered search, and table'
end end
it 'shows the alert table' do context 'when the prometheus integration is enabled' do
expect(page).to have_selector('.gl-table') let_it_be(:integration) { create(:prometheus_service, project: project) }
it_behaves_like 'alert page with title, filtered search, and table'
end end
end end
end end
...@@ -39,28 +39,6 @@ RSpec.describe Projects::AlertManagementHelper do ...@@ -39,28 +39,6 @@ RSpec.describe Projects::AlertManagementHelper do
end end
end end
context 'with alerts service' do
let_it_be(:alerts_service) { create(:alerts_service, project: project) }
context 'when alerts service is active' do
it 'enables alert management' do
expect(data).to include(
'alert-management-enabled' => 'true'
)
end
end
context 'when alerts service is inactive' do
it 'disables alert management' do
alerts_service.update!(active: false)
expect(data).to include(
'alert-management-enabled' => 'false'
)
end
end
end
context 'with prometheus service' do context 'with prometheus service' do
let_it_be(:prometheus_service) { create(:prometheus_service, project: project) } let_it_be(:prometheus_service) { create(:prometheus_service, project: project) }
...@@ -105,6 +83,16 @@ RSpec.describe Projects::AlertManagementHelper do ...@@ -105,6 +83,16 @@ RSpec.describe Projects::AlertManagementHelper do
end end
end end
context 'with an alert' do
let_it_be(:alert) { create(:alert_management_alert, project: project) }
it 'enables alert management' do
expect(data).to include(
'alert-management-enabled' => 'true'
)
end
end
context 'when user does not have requisite enablement permissions' do context 'when user does not have requisite enablement permissions' do
let(:user_can_enable_alert_management) { false } let(:user_can_enable_alert_management) { false }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment