summaryrefslogtreecommitdiff
path: root/qa/qa/page/project/settings/secret_variables.rb
blob: 880ef58ab54d6bab44a2c21c55663657da4b76f4 (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
module QA
  module Page
    module Project
      module Settings
        class SecretVariables < Page::Base
          view 'app/views/ci/variables/_table.html.haml' do
            element :variable_key, '.variable-key'
            element :variable_value, '.variable-value'
          end

          view 'app/views/projects/settings/ci_cd/show.html.haml' do
            element :secret_variable
          end

          def fill_variable_key(key)
            fill_in 'variable_key', with: key
          end

          def fill_variable_value(value)
            fill_in 'variable_value', with: value
          end

          def add_variable
            click_on 'Add new variable'
          end

          def variable_key
            page.find('.variable-key').text
          end

          def variable_value
            reveal_value do
              page.find('.variable-value').text
            end
          end

          private

          def within_section
            page.within('.qa-secret-variables') do
              yield
            end
          end

          def reveal_value
            within_section do
              click_button('Reveal value')
            end

            yield.tap do
              within_section do
                click_button('Hide value')
              end
            end
          end
        end
      end
    end
  end
end