Welcome to mirror list, hosted at ThFree Co, Russian Federation.

multiselect_blob.rb « source « project « steps « features - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b749ba493719cbb7610e4ef0122ccb9b1caaa428 (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
class Spinach::Features::ProjectSourceMultiselectBlob < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedProject
  include SharedPaths

  class << self
    def click_line_steps(*line_numbers)
      line_numbers.each do |line_number|
        step "I click line #{line_number} in file" do
          find("#L#{line_number}").click
        end

        step "I shift-click line #{line_number} in file" do
          script = "$('#L#{line_number}').trigger($.Event('click', { shiftKey: true }));"
          execute_script(script)
        end
      end
    end

    def check_state_steps(*ranges)
      ranges.each do |range|
        fragment = range.kind_of?(Array) ? "L#{range.first}-#{range.last}" : "L#{range}"
        pluralization = range.kind_of?(Array) ? "s" : ""

        step "I should see \"#{fragment}\" as URI fragment" do
          URI.parse(current_url).fragment.should == fragment
        end

        step "I should see line#{pluralization} #{fragment[1..-1]} highlighted" do
          ids = Array(range).map { |n| "LC#{n}" }
          extra = false

          highlighted = all("#tree-content-holder .highlight .line.hll")
          highlighted.each do |element|
            extra ||= ids.delete(element[:id]).nil?
          end

          extra.should be_false and ids.should be_empty
        end
      end
    end
  end

  click_line_steps *Array(1..5)
  check_state_steps *Array(1..5), Array(1..2), Array(1..3), Array(1..4), Array(1..5), Array(3..5)

  step 'I go back in history' do
    go_back
  end

  step 'I go forward in history' do
    go_forward
  end

  step 'I click on ".gitignore" file in repo' do
    click_link ".gitignore"
  end
end