debian-mirror-gitlab/spec/features/projects/members/tabs_spec.rb

69 lines
1.9 KiB
Ruby
Raw Normal View History

2021-03-08 18:12:59 +05:30
# frozen_string_literal: true
require 'spec_helper'
2021-09-04 01:27:46 +05:30
RSpec.describe 'Projects > Members > Tabs', :js do
2021-03-11 19:13:27 +05:30
include Spec::Support::Helpers::Features::MembersHelpers
2021-03-08 18:12:59 +05:30
using RSpec::Parameterized::TableSyntax
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, creator: user, namespace: user.namespace) }
let_it_be(:group) { create(:group) }
let_it_be(:project_members) { create_list(:project_member, 2, project: project) }
let_it_be(:access_requests) { create_list(:project_member, 2, :access_request, project: project) }
let_it_be(:invites) { create_list(:project_member, 2, :invited, project: project) }
let_it_be(:project_group_links) { create_list(:project_group_link, 2, project: project) }
2021-04-17 20:07:23 +05:30
before do
sign_in(user)
visit project_project_members_path(project)
end
2021-03-08 18:12:59 +05:30
shared_examples 'active "Members" tab' do
it 'displays "Members" tab' do
expect(page).to have_selector('.nav-link.active', text: 'Members')
end
end
2021-03-11 19:13:27 +05:30
context 'tabs' do
where(:tab, :count) do
'Members' | 3
'Invited' | 2
'Groups' | 2
'Access requests' | 2
end
2021-03-08 18:12:59 +05:30
2021-03-11 19:13:27 +05:30
with_them do
it "renders #{params[:tab]} tab" do
expect(page).to have_selector('.nav-link', text: "#{tab} #{count}")
end
2021-03-08 18:12:59 +05:30
end
2021-03-11 19:13:27 +05:30
context 'displays "Members" tab by default' do
it_behaves_like 'active "Members" tab'
end
2021-03-08 18:12:59 +05:30
end
2021-09-04 01:27:46 +05:30
context 'when searching "Groups"' do
2021-03-08 18:12:59 +05:30
before do
2021-04-17 20:07:23 +05:30
click_link 'Groups'
2021-03-11 19:13:27 +05:30
2021-04-17 20:07:23 +05:30
fill_in_filtered_search 'Search groups', with: 'group'
2021-03-08 18:12:59 +05:30
end
2021-04-17 20:07:23 +05:30
it 'displays "Groups" tab' do
expect(page).to have_selector('.nav-link.active', text: 'Groups')
2021-03-08 18:12:59 +05:30
end
2021-04-17 20:07:23 +05:30
context 'and then searching "Members"' do
2021-03-08 18:12:59 +05:30
before do
2021-04-17 20:07:23 +05:30
click_link 'Members 3'
2021-03-08 18:12:59 +05:30
2021-04-17 20:07:23 +05:30
fill_in_filtered_search 'Filter members', with: 'user'
2021-03-08 18:12:59 +05:30
end
2021-04-17 20:07:23 +05:30
it_behaves_like 'active "Members" tab'
2021-03-08 18:12:59 +05:30
end
end
end