summaryrefslogtreecommitdiff
path: root/spec/requests/api/graphql/project/alert_management/integrations_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/api/graphql/project/alert_management/integrations_spec.rb')
-rw-r--r--spec/requests/api/graphql/project/alert_management/integrations_spec.rb98
1 files changed, 72 insertions, 26 deletions
diff --git a/spec/requests/api/graphql/project/alert_management/integrations_spec.rb b/spec/requests/api/graphql/project/alert_management/integrations_spec.rb
index b13805a61ce..0e029aee9e8 100644
--- a/spec/requests/api/graphql/project/alert_management/integrations_spec.rb
+++ b/spec/requests/api/graphql/project/alert_management/integrations_spec.rb
@@ -13,6 +13,8 @@ RSpec.describe 'getting Alert Management Integrations' do
let_it_be(:inactive_http_integration) { create(:alert_management_http_integration, :inactive, project: project) }
let_it_be(:other_project_http_integration) { create(:alert_management_http_integration) }
+ let(:params) { {} }
+
let(:fields) do
<<~QUERY
nodes {
@@ -25,7 +27,7 @@ RSpec.describe 'getting Alert Management Integrations' do
graphql_query_for(
'project',
{ 'fullPath' => project.full_path },
- query_graphql_field('alertManagementIntegrations', {}, fields)
+ query_graphql_field('alertManagementIntegrations', params, fields)
)
end
@@ -50,34 +52,78 @@ RSpec.describe 'getting Alert Management Integrations' do
post_graphql(query, current_user: current_user)
end
- let(:http_integration) { integrations.first }
- let(:prometheus_integration) { integrations.second }
+ context 'when no extra params given' do
+ let(:http_integration) { integrations.first }
+ let(:prometheus_integration) { integrations.second }
- it_behaves_like 'a working graphql query'
+ it_behaves_like 'a working graphql query'
+
+ it { expect(integrations.size).to eq(2) }
+
+ it 'returns the correct properties of the integrations' do
+ expect(http_integration).to include(
+ 'id' => global_id_of(active_http_integration),
+ 'type' => 'HTTP',
+ 'name' => active_http_integration.name,
+ 'active' => active_http_integration.active,
+ 'token' => active_http_integration.token,
+ 'url' => active_http_integration.url,
+ 'apiUrl' => nil
+ )
- it { expect(integrations.size).to eq(2) }
-
- it 'returns the correct properties of the integrations' do
- expect(http_integration).to include(
- 'id' => GitlabSchema.id_from_object(active_http_integration).to_s,
- 'type' => 'HTTP',
- 'name' => active_http_integration.name,
- 'active' => active_http_integration.active,
- 'token' => active_http_integration.token,
- 'url' => active_http_integration.url,
- 'apiUrl' => nil
- )
-
- expect(prometheus_integration).to include(
- 'id' => GitlabSchema.id_from_object(prometheus_service).to_s,
- 'type' => 'PROMETHEUS',
- 'name' => 'Prometheus',
- 'active' => prometheus_service.manual_configuration?,
- 'token' => project_alerting_setting.token,
- 'url' => "http://localhost/#{project.full_path}/prometheus/alerts/notify.json",
- 'apiUrl' => prometheus_service.api_url
- )
+ expect(prometheus_integration).to include(
+ 'id' => global_id_of(prometheus_service),
+ 'type' => 'PROMETHEUS',
+ 'name' => 'Prometheus',
+ 'active' => prometheus_service.manual_configuration?,
+ 'token' => project_alerting_setting.token,
+ 'url' => "http://localhost/#{project.full_path}/prometheus/alerts/notify.json",
+ 'apiUrl' => prometheus_service.api_url
+ )
+ end
end
+
+ context 'when HTTP Integration ID is given' do
+ let(:params) { { id: global_id_of(active_http_integration) } }
+
+ it_behaves_like 'a working graphql query'
+
+ it { expect(integrations).to be_one }
+
+ it 'returns the correct properties of the HTTP integration' do
+ expect(integrations.first).to include(
+ 'id' => global_id_of(active_http_integration),
+ 'type' => 'HTTP',
+ 'name' => active_http_integration.name,
+ 'active' => active_http_integration.active,
+ 'token' => active_http_integration.token,
+ 'url' => active_http_integration.url,
+ 'apiUrl' => nil
+ )
+ end
+ end
+
+ context 'when Prometheus Integration ID is given' do
+ let(:params) { { id: global_id_of(prometheus_service) } }
+
+ it_behaves_like 'a working graphql query'
+
+ it { expect(integrations).to be_one }
+
+ it 'returns the correct properties of the Prometheus Integration' do
+ expect(integrations.first).to include(
+ 'id' => global_id_of(prometheus_service),
+ 'type' => 'PROMETHEUS',
+ 'name' => 'Prometheus',
+ 'active' => prometheus_service.manual_configuration?,
+ 'token' => project_alerting_setting.token,
+ 'url' => "http://localhost/#{project.full_path}/prometheus/alerts/notify.json",
+ 'apiUrl' => prometheus_service.api_url
+ )
+ end
+ end
+
+ it_behaves_like 'GraphQL query with several integrations requested', graphql_query_name: 'alertManagementIntegrations'
end
end
end