summaryrefslogtreecommitdiff
path: root/qa/qa/page/project/settings/secret_variables.rb
blob: e3bfbfcf0802fe20ebb511453da7e98ec2387a7e (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
module QA
  module Page
    module Project
      module Settings
        class SecretVariables < Page::Base
          include Common

          view 'app/views/ci/variables/_table.html.haml' do
            element :variable_key, '.variable-key'
            element :variable_value, '.variable-value'
          end

          view 'app/views/ci/variables/_index.html.haml' do
            element :add_new_variable, 'btn_text: "Add new variable"'
          end

          view 'app/assets/javascripts/behaviors/secret_values.js' do
            element :reveal_value, 'Reveal value'
            element :hide_value, 'Hide value'
          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 reveal_value
            click_button('Reveal value')

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