Commit bd1261cb authored by Sarah Yasonik's avatar Sarah Yasonik Committed by Michael Kozono

Show alert management list when there are active alerts

parent ecc20f06
......@@ -28,7 +28,7 @@ module Projects::AlertManagementHelper
def alert_management_enabled?(project)
!!(
project.alerts_service_activated? ||
project.alert_management_alerts.any? ||
project.prometheus_service_active? ||
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,54 +5,54 @@ require 'spec_helper'
RSpec.describe 'Alert Management index', :js do
let_it_be(:project) { create(:project) }
let_it_be(:developer) { create(:user) }
let_it_be(:alert) { create(:alert_management_alert, project: project, status: 'triggered') }
before_all do
project.add_developer(developer)
end
before do
sign_in(developer)
context 'when a developer displays the alert list' do
before do
sign_in(developer)
visit project_alert_management_index_path(project)
wait_for_requests
end
context 'when a developer displays the alert list and alert integrations are not enabled' do
it 'shows the alert page title' do
expect(page).to have_content('Alerts')
visit project_alert_management_index_path(project)
wait_for_requests
end
it 'shows the empty state by default' do
it 'shows the alert page title and empty state without filtered search or alert table' do
expect(page).to have_content('Alerts')
expect(page).to have_content('Surface alerts in GitLab')
end
it 'does not show the filtered search' do
expect(page).not_to have_selector('.gl-table')
page.within('.layout-page') do
expect(page).not_to have_css('[data-testid="search-icon"]')
end
end
it 'does not show the alert table' do
expect(page).not_to have_selector('.gl-table')
shared_examples 'alert page with title, filtered search, and table' do
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
context 'when a developer displays the alert list and an HTTP integration is enabled' do
let_it_be(:integration) { create(:alert_management_http_integration, project: project) }
context 'when alerts have already been created' do
let_it_be(:alert) { create(:alert_management_alert, project: project) }
it 'shows the alert page title' do
expect(page).to have_content('Alerts')
it_behaves_like 'alert page with title, filtered search, and table'
end
it 'shows the filtered search' do
page.within('.layout-page') do
expect(page).to have_css('[data-testid="search-icon"]')
end
context 'when an HTTP integration is enabled' do
let_it_be(:integration) { create(:alert_management_http_integration, project: project) }
it_behaves_like 'alert page with title, filtered search, and table'
end
it 'shows the alert table' do
expect(page).to have_selector('.gl-table')
context 'when the prometheus integration is enabled' do
let_it_be(:integration) { create(:prometheus_service, project: project) }
it_behaves_like 'alert page with title, filtered search, and table'
end
end
end
......@@ -39,28 +39,6 @@ RSpec.describe Projects::AlertManagementHelper do
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
let_it_be(:prometheus_service) { create(:prometheus_service, project: project) }
......@@ -105,6 +83,16 @@ RSpec.describe Projects::AlertManagementHelper do
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
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