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

module Spec
  module Support
    module Helpers
      module Features
        module MembersHelpers
          def members_table
            page.find('[data-testid="members-table"]')
          end

          def all_rows
            page.within(members_table) do
              page.all('tbody > tr')
            end
          end

          def first_row
            all_rows[0]
          end

          def second_row
            all_rows[1]
          end

          def third_row
            all_rows[2]
          end

          def find_row(name)
            page.within(members_table) do
              page.find('tbody > tr', text: name)
            end
          end

          def find_member_row(user)
            find_row(user.name)
          end

          def find_invited_member_row(email)
            find_row(email)
          end

          def find_group_row(group)
            find_row(group.full_name)
          end

          def fill_in_filtered_search(label, with:)
            page.within '[data-testid="members-filtered-search-bar"]' do
              find_field(label).click
              find('input').native.send_keys(with)
              click_button 'Search'
            end
          end
        end
      end
    end
  end
end