debian-mirror-gitlab/spec/features/explore/user_explores_projects_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

126 lines
3.4 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'User explores projects' do
2021-01-29 00:20:46 +05:30
context 'when some projects exist' do
let_it_be(:archived_project) { create(:project, :archived) }
let_it_be(:internal_project) { create(:project, :internal) }
let_it_be(:private_project) { create(:project, :private) }
let_it_be(:public_project) { create(:project, :public) }
context 'when not signed in' do
context 'when viewing public projects' do
before do
visit(explore_projects_path)
end
include_examples 'shows public projects'
2018-03-17 18:26:18 +05:30
end
2021-01-29 00:20:46 +05:30
context 'when visibility is restricted to public' do
before do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
visit(explore_projects_path)
end
it 'redirects to login page' do
expect(page).to have_current_path(new_user_session_path)
end
end
2018-03-17 18:26:18 +05:30
end
2020-04-22 19:07:51 +05:30
2021-01-29 00:20:46 +05:30
context 'when signed in' do
let_it_be(:user) { create(:user) }
2020-04-22 19:07:51 +05:30
before do
2021-01-29 00:20:46 +05:30
sign_in(user)
stub_feature_flags(project_list_filter_bar: false)
2020-04-22 19:07:51 +05:30
end
2021-01-29 00:20:46 +05:30
shared_examples 'empty search results' do
it 'shows correct empty state message', :js do
fill_in 'name', with: 'zzzzzzzzzzzzzzzzzzz'
expect(page).to have_content('Explore public groups to find projects to contribute to.')
end
2020-04-22 19:07:51 +05:30
end
2018-03-17 18:26:18 +05:30
2021-01-29 00:20:46 +05:30
shared_examples 'minimum search length' do
it 'shows a prompt to enter a longer search term', :js do
fill_in 'name', with: 'z'
2018-03-17 18:26:18 +05:30
2021-01-29 00:20:46 +05:30
expect(page).to have_content('Enter at least three characters to search')
end
end
2020-12-08 15:28:05 +05:30
2021-01-29 00:20:46 +05:30
context 'when viewing public projects' do
before do
visit(explore_projects_path)
end
2020-12-08 15:28:05 +05:30
2021-01-29 00:20:46 +05:30
include_examples 'shows public and internal projects'
include_examples 'empty search results'
include_examples 'minimum search length'
end
2020-12-08 15:28:05 +05:30
2021-01-29 00:20:46 +05:30
context 'when viewing most starred projects' do
before do
visit(starred_explore_projects_path)
end
include_examples 'shows public and internal projects'
include_examples 'empty search results'
include_examples 'minimum search length'
end
context 'when viewing trending projects' do
before do
[archived_project, public_project].each { |project| create(:note_on_issue, project: project) }
TrendingProject.refresh!
visit(trending_explore_projects_path)
end
include_examples 'shows public projects'
include_examples 'empty search results'
include_examples 'minimum search length'
end
end
end
context 'when there are no projects' do
shared_examples 'explore page empty state' do
it 'shows correct empty state message' do
expect(page).to have_content('Explore public groups to find projects to contribute to.')
2020-12-08 15:28:05 +05:30
end
2018-03-17 18:26:18 +05:30
end
context 'when viewing public projects' do
before do
2021-01-29 00:20:46 +05:30
visit explore_projects_path
2018-03-17 18:26:18 +05:30
end
2021-01-29 00:20:46 +05:30
it_behaves_like 'explore page empty state'
2018-03-17 18:26:18 +05:30
end
context 'when viewing most starred projects' do
before do
2021-01-29 00:20:46 +05:30
visit starred_explore_projects_path
2018-03-17 18:26:18 +05:30
end
2021-01-29 00:20:46 +05:30
it_behaves_like 'explore page empty state'
2018-03-17 18:26:18 +05:30
end
context 'when viewing trending projects' do
before do
2021-01-29 00:20:46 +05:30
visit trending_explore_projects_path
2018-03-17 18:26:18 +05:30
end
2021-01-29 00:20:46 +05:30
it_behaves_like 'explore page empty state'
2018-03-17 18:26:18 +05:30
end
end
end