blob: c2ec709576b452d4b83eb8e0e81939f30891f4a5 (
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
87
88
89
90
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Groups > Members > Filter members', :js, feature_category: :subgroups do
include Features::MembersHelpers
let(:user) { create(:user) }
let(:nested_group_user) { create(:user) }
let(:user_with_2fa) { create(:user, :two_factor_via_otp) }
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
filtered_search_bar_selector = '[data-testid="members-filtered-search-bar"]'
before do
group.add_owner(user)
group.add_maintainer(user_with_2fa)
nested_group.add_maintainer(nested_group_user)
sign_in(user)
end
it 'shows all members' do
visit_members_list(group)
expect(member(0)).to include(user.name)
expect(member(1)).to include(user_with_2fa.name)
end
it 'shows only 2FA members' do
visit_members_list(group, two_factor: 'enabled')
expect(member(0)).to include(user_with_2fa.name)
expect(all_rows.size).to eq(1)
within filtered_search_bar_selector do
expect(page).to have_content '2FA = Enabled'
end
end
it 'shows only non 2FA members' do
visit_members_list(group, two_factor: 'disabled')
expect(member(0)).to include(user.name)
expect(all_rows.size).to eq(1)
within filtered_search_bar_selector do
expect(page).to have_content '2FA = Disabled'
end
end
it 'shows inherited members by default' do
visit_members_list(nested_group)
expect(member(0)).to include(user.name)
expect(member(1)).to include(user_with_2fa.name)
expect(member(2)).to include(nested_group_user.name)
expect(all_rows.size).to eq(3)
end
it 'shows only group members' do
visit_members_list(nested_group, with_inherited_permissions: 'exclude')
expect(member(0)).to include(nested_group_user.name)
expect(all_rows.size).to eq(1)
within filtered_search_bar_selector do
expect(page).to have_content 'Membership = Direct'
end
end
it 'shows only inherited members' do
visit_members_list(nested_group, with_inherited_permissions: 'only')
expect(member(0)).to include(user.name)
expect(member(1)).to include(user_with_2fa.name)
expect(all_rows.size).to eq(2)
within filtered_search_bar_selector do
expect(page).to have_content 'Membership = Inherited'
end
end
def visit_members_list(group, options = {})
visit group_group_members_path(group.to_param, options)
end
def member(number)
all_rows[number].text
end
end
|