summaryrefslogtreecommitdiff
path: root/spec/support/protected_branch_helpers.rb
blob: b34b9ec4641bf6ba4051e6fc5b841db3c7a034a9 (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
# frozen_string_literal: true

module ProtectedBranchHelpers
  def set_allowed_to(operation, option = 'Maintainers', form: '.js-new-protected-branch')
    within form do
      select_elem = find(".js-allowed-to-#{operation}")
      select_elem.click

      wait_for_requests

      within('.dropdown-content') do
        Array(option).each { |opt| click_on(opt) }
      end

      # Enhanced select is used in EE, therefore an extra click is needed.
      select_elem.click if select_elem['aria-expanded'] == 'true'
    end
  end

  def set_protected_branch_name(branch_name)
    find('.js-protected-branch-select').click
    find('.dropdown-input-field').set(branch_name)
    click_on("Create wildcard #{branch_name}")
  end

  def set_defaults
    set_allowed_to('merge')
    set_allowed_to('push')
  end

  def click_on_protect
    click_on "Protect"
    wait_for_requests
  end
end