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

blob_content.rb « component « page « qa « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4d36a6dcefeeb6bb8f259466f7cb19e206a1cbd1 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# frozen_string_literal: true

module QA
  module Page
    module Component
      module BlobContent
        extend QA::Page::PageConcern

        def self.included(base)
          super

          base.view 'app/assets/javascripts/blob/components/blob_header_filepath.vue' do
            element :file_title_content
          end

          base.view 'app/assets/javascripts/blob/components/blob_content.vue' do
            element :blob_viewer_file_content
          end

          base.view 'app/assets/javascripts/blob/components/blob_header_default_actions.vue' do
            element :default_actions_container
            element :copy_contents_button
          end

          base.view 'app/views/projects/blob/_header_content.html.haml' do
            element :file_name_content
          end

          base.view 'app/views/shared/_file_highlight.html.haml' do
            element :file_content
          end
        end

        def has_file?(name)
          has_file_name?(name)
        end

        def has_no_file?(name)
          has_no_file_name?(name)
        end

        def has_file_name?(file_name, file_number = nil)
          within_file_by_number(file_name_element, file_number) { has_text?(file_name) }
        end

        def has_no_file_name?(file_name)
          within_element(file_name_element) do
            has_no_text?(file_name)
          end
        end

        def has_file_content?(file_content, file_number = nil)
          within_file_by_number(file_content_element, file_number) { has_text?(file_content) }
        end

        def has_no_file_content?(file_content)
          within_element(file_content_element) do
            has_no_text?(file_content)
          end
        end

        def click_copy_file_contents(file_number = nil)
          within_file_by_number(:default_actions_container, file_number) { click_element(:copy_contents_button) }
        end

        private

        def file_content_element
          feature_flag_controlled_element(:refactor_blob_viewer, :blob_viewer_file_content, :file_content)
        end

        def file_name_element
          feature_flag_controlled_element(:refactor_blob_viewer, :file_title_content, :file_name_content)
        end

        def within_file_by_number(element, file_number)
          if file_number
            within_element_by_index(element, file_number - 1) { yield }
          else
            within_element(element) { yield }
          end
        end
      end
    end
  end
end