2021-01-03 14:25:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'Alert Management index', :js do
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
let_it_be(:developer) { create(:user) }
|
|
|
|
|
|
|
|
before_all do
|
|
|
|
project.add_developer(developer)
|
|
|
|
end
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
context 'when a developer displays the alert list' do
|
|
|
|
before do
|
|
|
|
sign_in(developer)
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
visit project_alert_management_index_path(project)
|
|
|
|
wait_for_requests
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
it 'shows the alert page title and empty state without filtered search or alert table' do
|
|
|
|
expect(page).to have_content('Alerts')
|
2021-01-03 14:25:43 +05:30
|
|
|
expect(page).to have_content('Surface alerts in GitLab')
|
2021-02-22 17:27:13 +05:30
|
|
|
expect(page).not_to have_selector('.gl-table')
|
2021-01-03 14:25:43 +05:30
|
|
|
page.within('.layout-page') do
|
|
|
|
expect(page).not_to have_css('[data-testid="search-icon"]')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
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
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
context 'when alerts have already been created' do
|
|
|
|
let_it_be(:alert) { create(:alert_management_alert, project: project) }
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
it_behaves_like 'alert page with title, filtered search, and table'
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
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'
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
context 'when the prometheus integration is enabled' do
|
2021-09-30 23:02:18 +05:30
|
|
|
let_it_be(:integration) { create(:prometheus_integration, project: project) }
|
2021-02-22 17:27:13 +05:30
|
|
|
|
|
|
|
it_behaves_like 'alert page with title, filtered search, and table'
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
end
|
2021-09-04 01:27:46 +05:30
|
|
|
|
|
|
|
describe 'managed_alerts_deprecation feature flag' do
|
|
|
|
subject { page }
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_feature_flags(managed_alerts_deprecation: feature_flag_value)
|
|
|
|
sign_in(developer)
|
|
|
|
|
|
|
|
visit project_alert_management_index_path(project)
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'feature flag on' do
|
|
|
|
let(:feature_flag_value) { true }
|
|
|
|
|
|
|
|
it { is_expected.to have_pushed_frontend_feature_flags(managedAlertsDeprecation: true) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'feature flag off' do
|
|
|
|
let(:feature_flag_value) { false }
|
|
|
|
|
|
|
|
it { is_expected.to have_pushed_frontend_feature_flags(managedAlertsDeprecation: false) }
|
|
|
|
end
|
|
|
|
end
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|