2021-01-06 04:10:31 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2021-05-19 20:10:36 -04:00
|
|
|
RSpec.describe 'Projects > Members > Tabs', :js do
|
2021-02-09 10:09:39 -05:00
|
|
|
include Spec::Support::Helpers::Features::MembersHelpers
|
2021-01-06 04:10:31 -05:00
|
|
|
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-03-10 16:09:10 -05:00
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
visit project_project_members_path(project)
|
|
|
|
end
|
|
|
|
|
2021-01-06 04:10:31 -05:00
|
|
|
shared_examples 'active "Members" tab' do
|
|
|
|
it 'displays "Members" tab' do
|
|
|
|
expect(page).to have_selector('.nav-link.active', text: 'Members')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-02-09 10:09:39 -05:00
|
|
|
context 'tabs' do
|
|
|
|
where(:tab, :count) do
|
|
|
|
'Members' | 3
|
|
|
|
'Invited' | 2
|
|
|
|
'Groups' | 2
|
|
|
|
'Access requests' | 2
|
|
|
|
end
|
2021-01-06 04:10:31 -05:00
|
|
|
|
2021-02-09 10:09:39 -05:00
|
|
|
with_them do
|
|
|
|
it "renders #{params[:tab]} tab" do
|
|
|
|
expect(page).to have_selector('.nav-link', text: "#{tab} #{count}")
|
|
|
|
end
|
2021-01-06 04:10:31 -05:00
|
|
|
end
|
|
|
|
|
2021-02-09 10:09:39 -05:00
|
|
|
context 'displays "Members" tab by default' do
|
|
|
|
it_behaves_like 'active "Members" tab'
|
|
|
|
end
|
2021-01-06 04:10:31 -05:00
|
|
|
end
|
|
|
|
|
2021-05-19 20:10:36 -04:00
|
|
|
context 'when searching "Groups"' do
|
2021-01-06 04:10:31 -05:00
|
|
|
before do
|
2021-03-10 16:09:10 -05:00
|
|
|
click_link 'Groups'
|
2021-02-09 10:09:39 -05:00
|
|
|
|
2021-03-10 16:09:10 -05:00
|
|
|
fill_in_filtered_search 'Search groups', with: 'group'
|
2021-01-06 04:10:31 -05:00
|
|
|
end
|
|
|
|
|
2021-03-10 16:09:10 -05:00
|
|
|
it 'displays "Groups" tab' do
|
|
|
|
expect(page).to have_selector('.nav-link.active', text: 'Groups')
|
2021-01-06 04:10:31 -05:00
|
|
|
end
|
|
|
|
|
2021-03-10 16:09:10 -05:00
|
|
|
context 'and then searching "Members"' do
|
2021-01-06 04:10:31 -05:00
|
|
|
before do
|
2021-03-10 16:09:10 -05:00
|
|
|
click_link 'Members 3'
|
2021-01-06 04:10:31 -05:00
|
|
|
|
2021-03-10 16:09:10 -05:00
|
|
|
fill_in_filtered_search 'Filter members', with: 'user'
|
2021-01-06 04:10:31 -05:00
|
|
|
end
|
|
|
|
|
2021-03-10 16:09:10 -05:00
|
|
|
it_behaves_like 'active "Members" tab'
|
2021-01-06 04:10:31 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|