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

alerts.rb « settings « project « page « qa « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7b1d738ec3cca06492f35b38c850dcb1290a7fc3 (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
# frozen_string_literal: true

module QA
  module Page
    module Project
      module Settings
        class Alerts < Page::Base
          view 'app/assets/javascripts/alerts_settings/components/alerts_form.vue' do
            element :create_incident_checkbox
            element :incident_templates_dropdown
            element :save_changes_button
            element :incident_templates_item
          end

          view 'app/assets/javascripts/alerts_settings/components/alerts_settings_wrapper.vue' do
            element :add_integration_button
          end

          view 'app/assets/javascripts/alerts_settings/components/alerts_settings_form.vue' do
            element :integration_type_dropdown
            element :integration_name_field
            element :active_toggle_container
            element :save_and_create_alert_button
            element :test_payload_field
            element :send_test_alert_button
            element :prometheus_url_field
          end

          def enable_incident_for_alert
            check_element(:create_incident_checkbox)
          end

          def select_issue_template(template)
            click_element(:incident_templates_dropdown)
            within_element :incident_templates_dropdown do
              find_element(:incident_templates_item, text: template).click
            end
          end

          def save_incident_settings
            click_element :save_changes_button
          end

          def has_template?(template)
            within_element :incident_templates_dropdown do
              has_text?(template)
            end
          end

          def add_new_integration
            wait_for_requests
            click_element(:add_integration_button)
          end

          def select_http_endpoint
            click_element(:integration_type_dropdown)
            find("option[value='HTTP']").click

            # Click outside of the list to close it
            click_element(:integration_name_field)
          end

          def select_prometheus
            click_element(:integration_type_dropdown)
            find("option[value='PROMETHEUS']").click

            # Click outside of the list to close it
            click_element(:prometheus_url_field)
          end

          def enter_integration_name(name)
            fill_element(:integration_name_field, name)
          end

          def fill_in_prometheus_url(url = Runtime::Scenario.gitlab_address)
            fill_element(:prometheus_url_field, url)
          end

          def activate_integration
            within_element(:active_toggle_container) do
              find('.gl-toggle').click
            end

            wait_for_requests
          end

          def save_and_create_alert
            click_element(:save_and_create_alert_button)
          end

          def fill_in_test_payload(payload)
            fill_element(:test_payload_field, payload)
          end

          def send_test_alert
            click_element(:send_test_alert_button)
          end

          def go_to_view_credentials
            click_link_with_text('View credentials')
          end

          def webhook_url
            find('input[id="url"]').value
          end

          def authorization_key
            find('input[id="authorization-key"]').value
          end
        end
      end
    end
  end
end