summaryrefslogtreecommitdiff
path: root/qa/qa/page/project/operations/kubernetes/show.rb
blob: 3bb51d2d579d4f9b57ca63f10ca8507a2e7c06bb (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
# frozen_string_literal: true

module QA
  module Page
    module Project
      module Operations
        module Kubernetes
          class Show < Page::Base
            view 'app/assets/javascripts/clusters/components/applications.vue' do
              element :ingress_ip_address, 'id="ingress-endpoint"' # rubocop:disable QA/ElementWithPattern
            end

            view 'app/assets/javascripts/clusters/forms/components/integration_form.vue' do
              element :integration_status_toggle, required: true
              element :base_domain_field, required: true
              element :save_changes_button, required: true
            end

            view 'app/views/clusters/clusters/_details_tab.html.haml' do
              element :details, required: true
            end

            view 'app/views/clusters/clusters/_applications_tab.html.haml' do
              element :applications, required: true
            end

            view 'app/assets/javascripts/clusters/components/application_row.vue' do
              element :install_button
              element :uninstall_button
            end

            view 'app/views/clusters/clusters/_health.html.haml' do
              element :cluster_health_section
            end

            view 'app/views/clusters/clusters/_health_tab.html.haml' do
              element :health, required: true
            end

            def open_details
              has_element?(:details, wait: 30)
              click_element :details
            end

            def open_applications
              has_element?(:applications, wait: 30)
              click_element :applications
            end

            def install!(application_name)
              within_element(application_name) do
                has_element?(:install_button, application: application_name, wait: 30)
                click_element :install_button
              end
            end

            def await_installed(application_name)
              within_element(application_name) do
                has_element?(:uninstall_button, application: application_name, wait: 300, skip_finished_loading_check: true)
              end
            end

            def has_application_installed?(application_name)
              within_element(application_name) do
                has_element?(:uninstall_button, application: application_name, wait: 300)
              end
            end

            def ingress_ip
              # We need to wait longer since it can take some time before the
              # ip address is assigned for the ingress controller
              page.find('#ingress-endpoint', wait: 1200).value
            end

            def set_domain(domain)
              fill_element :base_domain_field, domain
            end

            def save_domain
              click_element :save_changes_button, Page::Project::Operations::Kubernetes::Show
            end

            def wait_for_cluster_health
              wait_until(max_duration: 120, sleep_interval: 3, reload: true) do
                has_cluster_health_graphs?
              end
            end

            def open_health
              has_element?(:health, wait: 30)
              click_element :health
            end

            def has_cluster_health_graphs?
              within_cluster_health_section do
                has_text?('CPU Usage')
              end
            end

            def within_cluster_health_section
              within_element :cluster_health_section do
                yield
              end
            end
          end
        end
      end
    end
  end
end