Welcome to mirror list, hosted at ThFree Co, Russian Federation.

promote_from_note_spec.rb « timeline_event « incident_management « mutations « graphql « api « requests « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9272e2181721c543d22f95e829be07f1301b2180 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Promote an incident timeline event from a comment' do
  include GraphqlHelpers

  let_it_be(:user) { create(:user) }
  let_it_be(:project) { create(:project) }
  let_it_be(:incident) { create(:incident, project: project) }
  let_it_be(:comment) { create(:note, project: project, noteable: incident) }

  let(:input) { { note_id: comment.to_global_id.to_s } }
  let(:mutation) do
    graphql_mutation(:timeline_event_promote_from_note, input) do
      <<~QL
        clientMutationId
        errors
        timelineEvent {
          author { id username }
          incident { id title }
          promotedFromNote { id }
          note
          action
          editable
          occurredAt
        }
      QL
    end
  end

  let(:mutation_response) { graphql_mutation_response(:timeline_event_promote_from_note) }

  before do
    project.add_developer(user)
  end

  it 'creates incident timeline event from the note', :aggregate_failures do
    post_graphql_mutation(mutation, current_user: user)

    timeline_event_response = mutation_response['timelineEvent']

    expect(response).to have_gitlab_http_status(:success)
    expect(timeline_event_response).to include(
      'author' => {
        'id' => user.to_global_id.to_s,
        'username' => user.username
      },
      'incident' => {
        'id' => incident.to_global_id.to_s,
        'title' => incident.title
      },
      'promotedFromNote' => {
        'id' => comment.to_global_id.to_s
      },
      'note' => comment.note,
      'action' => 'comment',
      'editable' => true,
      'occurredAt' => comment.created_at.iso8601
    )
  end
end