summaryrefslogtreecommitdiff
path: root/qa/qa/page/project/settings/deploy_tokens.rb
blob: 2d42372cbc507aa68c9451a8a3c881e09772f6f5 (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
module QA
  module Page
    module Project
      module Settings
        class DeployTokens < Page::Base
          view 'app/views/projects/deploy_tokens/_form.html.haml' do
            element :deploy_token_name
            element :deploy_token_expires_at
            element :deploy_token_read_repository
            element :deploy_token_read_registry
            element :create_deploy_token
          end

          view 'app/views/projects/deploy_tokens/_new_deploy_token.html.haml' do
            element :created_deploy_token_section
            element :deploy_token_user
            element :deploy_token
          end

          def fill_token_name(name)
            fill_element :deploy_token_name, name
          end

          def fill_token_expires_at(expires_at)
            fill_element :deploy_token_expires_at, expires_at.to_s + "\n"
          end

          def fill_scopes(read_repository:, read_registry:)
            check_element :deploy_token_read_repository if read_repository
            check_element :deploy_token_read_registry if read_registry
          end

          def add_token
            click_element :create_deploy_token
          end

          def token_username
            within_new_project_deploy_token do
              find_element(:deploy_token_user).value
            end
          end

          def token_password
            within_new_project_deploy_token do
              find_element(:deploy_token).value
            end
          end

          private

          def within_new_project_deploy_token
            wait(reload: false) do
              has_css?(element_selector_css(:created_deploy_token_section))
            end

            within_element(:created_deploy_token_section) do
              yield
            end
          end
        end
      end
    end
  end
end