Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
9b10995c52
commit
2bb7288463
|
|
@ -503,6 +503,7 @@ export default {
|
|||
v-model="integrationForm.apiUrl"
|
||||
type="text"
|
||||
:placeholder="$options.placeholders.prometheus"
|
||||
data-qa-selector="prometheus_url_field"
|
||||
@input="validateApiUrl"
|
||||
/>
|
||||
<span class="gl-text-gray-400">
|
||||
|
|
|
|||
|
|
@ -22,6 +22,22 @@ module QA
|
|||
end
|
||||
end
|
||||
|
||||
def setup_prometheus_and_send_alert(payload: nil)
|
||||
payload ||= { title: random_word, description: random_word }
|
||||
Page::Project::Menu.perform(&:go_to_monitor_settings)
|
||||
Page::Project::Settings::Monitor.perform do |setting|
|
||||
setting.expand_alerts do |alert|
|
||||
alert.add_new_integration
|
||||
alert.select_prometheus
|
||||
alert.activate_integration
|
||||
alert.fill_in_prometheus_url
|
||||
alert.save_and_create_alert
|
||||
alert.fill_in_test_payload(payload.to_json)
|
||||
alert.send_test_alert
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def random_word
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ module QA
|
|||
element :save_and_create_alert_button
|
||||
element :test_payload_field
|
||||
element :send_test_alert_button
|
||||
element :prometheus_url_field
|
||||
end
|
||||
|
||||
def enable_incident_for_alert
|
||||
|
|
@ -59,10 +60,22 @@ module QA
|
|||
click_element(:integration_name_field)
|
||||
end
|
||||
|
||||
def select_prometheus
|
||||
click_element(:integration_type_dropdown)
|
||||
find("option[value='PROMETHEUS']").click
|
||||
|
||||
# Click outside of the list to close it
|
||||
click_element(:prometheus_url_field)
|
||||
end
|
||||
|
||||
def enter_integration_name(name)
|
||||
fill_element(:integration_name_field, name)
|
||||
end
|
||||
|
||||
def fill_in_prometheus_url(url = Runtime::Scenario.gitlab_address)
|
||||
fill_element(:prometheus_url_field, url)
|
||||
end
|
||||
|
||||
def activate_integration
|
||||
within_element(:active_toggle_container) do
|
||||
find('.gl-toggle').click
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module QA
|
||||
RSpec.describe 'Monitor', product_group: :respond do
|
||||
describe 'Alert settings' do
|
||||
shared_examples 'sends test alert' do
|
||||
it 'creates new alert' do
|
||||
Page::Project::Menu.perform(&:go_to_monitor_alerts)
|
||||
Page::Project::Monitor::Alerts::Index.perform do |index|
|
||||
expect(index).to have_alert_with_title(alert_title)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
let(:project) do
|
||||
Resource::Project.fabricate_via_api! do |project|
|
||||
project.name = 'project-for-alerts'
|
||||
project.description = 'Project for alerts'
|
||||
end
|
||||
end
|
||||
|
||||
let(:alert_title) { Faker::Lorem.word }
|
||||
|
||||
before do
|
||||
Flow::Login.sign_in
|
||||
project.visit!
|
||||
end
|
||||
|
||||
context(
|
||||
'when using HTTP endpoint integration',
|
||||
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/382803'
|
||||
) do
|
||||
let(:payload) do
|
||||
{ title: alert_title, description: alert_title }
|
||||
end
|
||||
|
||||
before do
|
||||
Flow::AlertSettings.setup_http_endpoint_and_send_alert(payload: payload)
|
||||
end
|
||||
|
||||
it_behaves_like 'sends test alert'
|
||||
end
|
||||
|
||||
context(
|
||||
'when using Prometheus integration',
|
||||
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/385792'
|
||||
) do
|
||||
let(:payload) do
|
||||
{
|
||||
version: '4',
|
||||
groupKey: nil,
|
||||
status: 'firing',
|
||||
receiver: '',
|
||||
groupLabels: {},
|
||||
commonLabels: {},
|
||||
commonAnnotations: {},
|
||||
externalURL: '',
|
||||
alerts: [
|
||||
{
|
||||
startsAt: Time.now,
|
||||
generatorURL: Faker::Internet.url,
|
||||
endsAt: nil,
|
||||
status: 'firing',
|
||||
labels: { gitlab_environment_name: Faker::Lorem.word },
|
||||
annotations:
|
||||
{
|
||||
title: alert_title,
|
||||
gitlab_y_label: 'status'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
Flow::AlertSettings.setup_prometheus_and_send_alert(payload: payload)
|
||||
end
|
||||
|
||||
it_behaves_like 'sends test alert'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module QA
|
||||
RSpec.describe 'Monitor', product_group: :respond do
|
||||
describe 'Http endpoint integration' do
|
||||
let(:project) do
|
||||
Resource::Project.fabricate_via_api! do |project|
|
||||
project.name = 'project-for-alerts'
|
||||
project.description = 'Project for alerts'
|
||||
end
|
||||
end
|
||||
|
||||
let(:random_word) { Faker::Lorem.word }
|
||||
|
||||
let(:payload) do
|
||||
{ title: random_word, description: random_word }
|
||||
end
|
||||
|
||||
before do
|
||||
Flow::Login.sign_in
|
||||
project.visit!
|
||||
Flow::AlertSettings.setup_http_endpoint_and_send_alert(payload: payload)
|
||||
end
|
||||
|
||||
it(
|
||||
'can send test alert that creates new alert',
|
||||
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/382803'
|
||||
) do
|
||||
Page::Project::Menu.perform(&:go_to_monitor_alerts)
|
||||
Page::Project::Monitor::Alerts::Index.perform do |alerts|
|
||||
expect(alerts).to have_alert_with_title(random_word)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue