summaryrefslogtreecommitdiff
path: root/spec/support/helpers/features/mirroring_helpers.rb
blob: 0c3006cd1d168a22472c982cd90e7f9b8cd87ae1 (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
# frozen_string_literal: true

# These helpers allow you to set up mirroring.
#
# Usage:
#   describe "..." do
#     include Features::MirroringHelpers
#     ...
#
#     fill_and_wait_for_mirror_url_javascript("url", "ssh://user@localhost/project.git")
#     wait_for_mirror_field_javascript("protected", "0")
#
module Features
  module MirroringHelpers
    # input_identifier - identifier of the input field, passed to `fill_in` (can be an ID or a label).
    # url - the URL to fill the input field with.
    def fill_and_wait_for_mirror_url_javascript(input_identifier, url)
      fill_in input_identifier, with: url
      wait_for_mirror_field_javascript('url', url)
    end

    # attribute - can be `url` or `protected`. It's used in the `.js-mirror-<field>-hidden` selector.
    # expected_value - the expected value of the hidden field.
    def wait_for_mirror_field_javascript(attribute, expected_value)
      expect(page).to have_css(".js-mirror-#{attribute}-hidden[value=\"#{expected_value}\"]", visible: :hidden)
    end
  end
end