summaryrefslogtreecommitdiff
path: root/spec/features/alert_management_spec.rb
blob: 3322c9c574f3a594cc00435842b2d6721e0fc268 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Alert management', :js do
  let_it_be(:project) { create(:project) }
  let_it_be(:developer) { create(:user) }

  before_all do
    project.add_developer(developer)
  end

  context 'when visiting the alert details page' do
    let!(:alert) { create(:alert_management_alert, :resolved, :with_fingerprint, title: 'dos-test', project: project, **options) }
    let(:options) { {} }

    before do
      sign_in(user)
    end

    context 'when actor has permission to see the alert' do
      let(:user) { developer }

      it 'shows the alert details' do
        visit(details_project_alert_management_path(project, alert))

        within('.alert-management-details-table') do
          expect(page).to have_content(alert.title)
        end
      end

      context 'when alert belongs to an environment' do
        let(:options) { { environment: environment } }
        let!(:environment) { create(:environment, name: 'production', project: project) }

        it 'shows the environment name' do
          visit(details_project_alert_management_path(project, alert))

          expect(page).to have_link(environment.name, href: project_environment_path(project, environment))
          within('.alert-management-details-table') do
            expect(page).to have_content(environment.name)
          end
        end
      end
    end
  end
end