summaryrefslogtreecommitdiff
path: root/spec/features/alert_management/alert_management_list_spec.rb
blob: c2514d80474df8e7c13b2f6d0713e0e4a88254df (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Alert Management index', :js do
  let_it_be(:project) { create(:project) }
  let_it_be(:developer) { create(:user) }
  let_it_be(:alert) { create(:alert_management_alert, project: project, status: 'triggered') }

  before_all do
    project.add_developer(developer)
  end

  before do
    sign_in(developer)

    visit project_alert_management_index_path(project)
    wait_for_requests
  end

  context 'when a developer displays the alert list and the alert service is not enabled' do
    it 'shows the alert page title' do
      expect(page).to have_content('Alerts')
    end

    it 'shows the empty state by default' do
      expect(page).to have_content('Surface alerts in GitLab')
    end

    it 'does not show the filtered search' do
      page.within('.layout-page') do
        expect(page).not_to have_css('[data-testid="search-icon"]')
      end
    end

    it 'does not show the alert table' do
      expect(page).not_to have_selector('.gl-table')
    end
  end

  context 'when a developer displays the alert list and the alert service is enabled' do
    let_it_be(:alerts_service) { create(:alerts_service, project: project) }

    it 'shows the alert page title' do
      expect(page).to have_content('Alerts')
    end

    it 'shows the filtered search' do
      page.within('.layout-page') do
        expect(page).to have_css('[data-testid="search-icon"]')
      end
    end

    it 'shows the alert table' do
      expect(page).to have_selector('.gl-table')
    end
  end
end