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

results.rb « search « page « qa « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f9e5e97b96f3b7916f46fc173a953d5974176bb3 (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
# frozen_string_literal: true

module QA
  module Page
    module Search
      class Results < QA::Page::Base
        view 'app/assets/javascripts/search/sidebar/components/scope_legacy_navigation.vue' do
          element :code_tab, ':data-qa-selector="qaSelectorValue(item)"' # rubocop:disable QA/ElementWithPattern
          element :projects_tab, ':data-qa-selector="qaSelectorValue(item)"' # rubocop:disable QA/ElementWithPattern
        end

        view 'app/views/search/results/_blob_data.html.haml' do
          element :result_item_content
          element :file_title_content
          element :file_text_content
        end

        view 'app/views/shared/projects/_project.html.haml' do
          element 'project-content'
        end

        def switch_to_code
          click_element(:nav_item_link, submenu_item: 'Code')
        end

        def switch_to_projects
          switch_to_tab(:projects_tab)
        end

        def has_project_in_search_result?(project_name)
          has_element?(:result_item_content, text: project_name)
        end

        def has_file_in_project?(file_name, project_name)
          within_element(:result_item_content, text: project_name) do
            has_element?(:file_title_content, text: file_name)
          end
        end

        def has_file_in_project_with_content?(file_text, file_path)
          within_element(:result_item_content,
            text: file_path) do
            has_element?(:file_text_content, text: file_text)
          end
        end

        def has_project?(project_name)
          has_element?('project-content', project_name: project_name)
        end

        private

        def switch_to_tab(tab)
          retry_until do
            click_element(tab)
            has_active_element?(tab)
          end
        end
      end
    end
  end
end