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

incident_issue_spec.rb « issues « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d6ec7f1c53939b40201186143559accdd3558916 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Incident Detail', :js do
  let_it_be(:project) { create(:project, :public) }
  let_it_be(:payload) do
    {
      'title' => 'Alert title',
      'start_time' => '2020-04-27T10:10:22.265949279Z',
      'custom' => {
        'alert' => {
          'fields' => %w[one two]
        }
      },
      'yet' => {
        'another' => 73
      }
    }
  end

  let_it_be(:user) { create(:user) }
  let_it_be(:started_at) { Time.now.rfc3339 }
  let_it_be(:alert) { create(:alert_management_alert, project: project, payload: payload, started_at: started_at) }
  let_it_be(:incident) { create(:incident, project: project, description: 'hello', alert_management_alert: alert) }

  context 'when user displays the incident' do
    before do
      stub_feature_flags(incident_timeline: project)
      project.add_developer(user)
      sign_in(user)

      visit project_issue_path(project, incident)
      wait_for_requests
    end

    it 'shows incident and alert data' do
      page.within('.issuable-details') do
        incident_tabs = find('[data-testid="incident-tabs"]')

        aggregate_failures 'shows title and Summary tab' do
          expect(find('h1')).to have_content(incident.title)
          expect(incident_tabs).to have_content('Summary')
          expect(incident_tabs).to have_content(incident.description)
        end

        aggregate_failures 'shows the incident highlight bar' do
          expect(incident_tabs).to have_content('Alert events: 1')
          expect(incident_tabs).to have_content('Original alert: #1')
        end

        aggregate_failures 'shows the Alert details tab' do
          click_link 'Alert details'

          expect(incident_tabs).to have_content('"title": "Alert title"')
          expect(incident_tabs).to have_content('"yet.another": 73')
        end
      end
    end

    context 'when on summary tab' do
      before do
        click_link 'Summary'
      end

      it 'shows the summary tab with all components' do
        page.within('.issuable-details') do
          hidden_items = find_all('.js-issue-widgets')

          # Linked Issues/MRs and comment box
          expect(hidden_items.count).to eq(2)

          expect(hidden_items).to all(be_visible)
        end
      end

      it 'shows the edit title and description button' do
        edit_button = find_all('[aria-label="Edit title and description"]')

        expect(edit_button).to all(be_visible)
      end
    end

    context 'when on alert details tab' do
      before do
        click_link 'Alert details'
      end

      it 'does not show the linked issues and notes/comment components' do
        page.within('.issuable-details') do
          hidden_items = find_all('.js-issue-widgets')

          # Linked Issues/MRs and comment box are hidden on page
          expect(hidden_items.count).to eq(0)
        end
      end

      it 'does not show the edit title and description button' do
        edit_button = find_all('[aria-label="Edit title and description"]')

        expect(edit_button.count).to eq(0)
      end
    end

    context 'when on timeline events tab from incident route' do
      before do
        visit project_issues_incident_path(project, incident)
        wait_for_requests
        click_link 'Timeline'
      end

      it 'does not show the linked issues and notes/comment components' do
        page.within('.issuable-details') do
          hidden_items = find_all('.js-issue-widgets')

          # Linked Issues/MRs and comment box are hidden on page
          expect(hidden_items.count).to eq(0)
        end
      end
    end

    context 'when on timeline events tab from issue route' do
      before do
        visit project_issue_path(project, incident)
        wait_for_requests
        click_link 'Timeline'
      end

      it 'does not show the linked issues and notes/comment commponents' do
        page.within('.issuable-details') do
          hidden_items = find_all('.js-issue-widgets')

          # Linked Issues/MRs and comment box are hidden on page
          expect(hidden_items.count).to eq(0)
        end
      end
    end

    context 'when incident_timeline feature flag is disabled' do
      before do
        stub_feature_flags(incident_timeline: false)

        visit project_issue_path(project, incident)
        wait_for_requests
      end

      it 'does not show Timeline tab' do
        tabs = find('[data-testid="incident-tabs"]')

        expect(tabs).not_to have_content('Timeline')
      end
    end
  end
end