summaryrefslogtreecommitdiff
path: root/qa/qa/page/component/groups_filter.rb
blob: cc50bb439b42e09077fa7ec659f7fd18c89dbc07 (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
# frozen_string_literal: true

module QA
  module Page
    module Component
      module GroupsFilter
        def self.included(base)
          base.view 'app/views/shared/groups/_search_form.html.haml' do
            element :groups_filter
          end

          base.view 'app/assets/javascripts/groups/components/groups.vue' do
            element :groups_list_tree_container
          end
        end

        private

        def has_filtered_group?(name)
          # Filter and submit to reload the page and only retrieve the filtered results
          find_element(:groups_filter).set(name).send_keys(:return)

          # Since we submitted after filtering, the presence of
          # groups_list_tree_container means we have the complete filtered list
          # of groups
          wait(reload: false) do
            page.has_css?(element_selector_css(:groups_list_tree_container))
          end

          # If there are no groups we'll know immediately because we filtered the list
          return false if page.has_text?('No groups or projects matched your search', wait: 0)

          # The name will be present as filter input so we check for a link, not text
          page.has_link?(name, wait: 0)
        end
      end
    end
  end
end