summaryrefslogtreecommitdiff
path: root/spec/requests/api/graphql/project/alert_management/alert/todos_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/api/graphql/project/alert_management/alert/todos_spec.rb')
-rw-r--r--spec/requests/api/graphql/project/alert_management/alert/todos_spec.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/requests/api/graphql/project/alert_management/alert/todos_spec.rb b/spec/requests/api/graphql/project/alert_management/alert/todos_spec.rb
new file mode 100644
index 00000000000..3a9077061ad
--- /dev/null
+++ b/spec/requests/api/graphql/project/alert_management/alert/todos_spec.rb
@@ -0,0 +1,51 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'getting Alert Management Alert Assignees' do
+ include GraphqlHelpers
+
+ let_it_be(:project) { create(:project) }
+ let_it_be(:current_user) { create(:user) }
+ let_it_be(:alert) { create(:alert_management_alert, project: project) }
+ let_it_be(:other_alert) { create(:alert_management_alert, project: project) }
+ let_it_be(:todo) { create(:todo, :pending, target: alert, user: current_user, project: project) }
+ let_it_be(:other_todo) { create(:todo, :pending, target: other_alert, user: current_user, project: project) }
+
+ let(:fields) do
+ <<~QUERY
+ nodes {
+ iid
+ todos {
+ nodes {
+ id
+ }
+ }
+ }
+ QUERY
+ end
+
+ let(:graphql_query) do
+ graphql_query_for(
+ 'project',
+ { 'fullPath' => project.full_path },
+ query_graphql_field('alertManagementAlerts', {}, fields)
+ )
+ end
+
+ let(:gql_alerts) { graphql_data.dig('project', 'alertManagementAlerts', 'nodes') }
+ let(:gql_todos) { gql_alerts.map { |gql_alert| [gql_alert['iid'], gql_alert['todos']['nodes']] }.to_h }
+ let(:gql_alert_todo) { gql_todos[alert.iid.to_s].first }
+ let(:gql_other_alert_todo) { gql_todos[other_alert.iid.to_s].first }
+
+ before do
+ project.add_developer(current_user)
+ end
+
+ it 'includes the correct metrics dashboard url' do
+ post_graphql(graphql_query, current_user: current_user)
+
+ expect(gql_alert_todo['id']).to eq(todo.to_global_id.to_s)
+ expect(gql_other_alert_todo['id']).to eq(other_todo.to_global_id.to_s)
+ end
+end