2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-06 08:40:33 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 14:08:28 -04:00
|
|
|
RSpec.describe 'Projects > User sees sidebar' do
|
2018-04-06 08:40:33 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :private, public_builds: false, namespace: user.namespace) }
|
|
|
|
|
2019-03-04 03:23:55 -05:00
|
|
|
# NOTE: See documented behaviour https://design.gitlab.com/regions/navigation#contextual-navigation
|
|
|
|
context 'on different viewports', :js do
|
2019-03-03 23:49:18 -05:00
|
|
|
include MobileHelpers
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
2019-03-04 03:23:55 -05:00
|
|
|
shared_examples 'has a expanded nav sidebar' do
|
|
|
|
it 'has a expanded desktop nav-sidebar on load' do
|
|
|
|
expect(page).to have_content('Collapse sidebar')
|
|
|
|
expect(page).not_to have_selector('.sidebar-collapsed-desktop')
|
|
|
|
expect(page).not_to have_selector('.sidebar-expanded-mobile')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'can collapse the nav-sidebar' do
|
|
|
|
page.find('.nav-sidebar .js-toggle-sidebar').click
|
|
|
|
expect(page).to have_selector('.sidebar-collapsed-desktop')
|
|
|
|
expect(page).not_to have_content('Collapse sidebar')
|
|
|
|
expect(page).not_to have_selector('.sidebar-expanded-mobile')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples 'has a collapsed nav sidebar' do
|
2019-03-03 23:49:18 -05:00
|
|
|
it 'has a collapsed desktop nav-sidebar on load' do
|
|
|
|
expect(page).not_to have_content('Collapse sidebar')
|
|
|
|
expect(page).not_to have_selector('.sidebar-expanded-mobile')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'can expand the nav-sidebar' do
|
|
|
|
page.find('.nav-sidebar .js-toggle-sidebar').click
|
|
|
|
expect(page).to have_selector('.sidebar-expanded-mobile')
|
|
|
|
expect(page).to have_content('Collapse sidebar')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-04 03:23:55 -05:00
|
|
|
shared_examples 'has a mobile nav-sidebar' do
|
|
|
|
it 'has a hidden nav-sidebar on load' do
|
|
|
|
expect(page).not_to have_content('.mobile-nav-open')
|
2019-03-04 00:57:40 -05:00
|
|
|
expect(page).not_to have_selector('.sidebar-expanded-mobile')
|
|
|
|
end
|
|
|
|
|
2019-03-04 03:23:55 -05:00
|
|
|
it 'can expand the nav-sidebar' do
|
|
|
|
page.find('.toggle-mobile-nav').click
|
|
|
|
expect(page).to have_selector('.mobile-nav-open')
|
|
|
|
expect(page).to have_selector('.sidebar-expanded-mobile')
|
2019-03-04 00:57:40 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-04 03:23:55 -05:00
|
|
|
context 'with a extra small viewport' do
|
2019-03-03 23:49:18 -05:00
|
|
|
before do
|
|
|
|
resize_screen_xs
|
|
|
|
visit project_path(project)
|
|
|
|
expect(page).to have_selector('.nav-sidebar')
|
|
|
|
expect(page).to have_selector('.toggle-mobile-nav')
|
|
|
|
end
|
|
|
|
|
2019-03-04 03:23:55 -05:00
|
|
|
it_behaves_like 'has a mobile nav-sidebar'
|
|
|
|
end
|
2019-03-03 23:49:18 -05:00
|
|
|
|
2019-03-04 03:23:55 -05:00
|
|
|
context 'with a small size viewport' do
|
|
|
|
before do
|
|
|
|
resize_screen_sm
|
|
|
|
visit project_path(project)
|
|
|
|
expect(page).to have_selector('.nav-sidebar')
|
|
|
|
expect(page).to have_selector('.toggle-mobile-nav')
|
2019-03-03 23:49:18 -05:00
|
|
|
end
|
2019-03-04 03:23:55 -05:00
|
|
|
|
|
|
|
it_behaves_like 'has a mobile nav-sidebar'
|
2019-03-03 23:49:18 -05:00
|
|
|
end
|
|
|
|
|
2019-03-04 03:23:55 -05:00
|
|
|
context 'with medium size viewport' do
|
2019-03-03 23:49:18 -05:00
|
|
|
before do
|
2019-03-04 03:23:55 -05:00
|
|
|
resize_window(768, 800)
|
2019-03-03 23:49:18 -05:00
|
|
|
visit project_path(project)
|
|
|
|
expect(page).to have_selector('.nav-sidebar')
|
|
|
|
end
|
|
|
|
|
2019-03-04 03:23:55 -05:00
|
|
|
it_behaves_like 'has a collapsed nav sidebar'
|
2019-03-03 23:49:18 -05:00
|
|
|
end
|
|
|
|
|
2019-03-04 03:23:55 -05:00
|
|
|
context 'with viewport size 1199px' do
|
2019-03-03 23:49:18 -05:00
|
|
|
before do
|
2019-03-04 00:57:40 -05:00
|
|
|
resize_window(1199, 800)
|
2019-03-03 23:49:18 -05:00
|
|
|
visit project_path(project)
|
|
|
|
expect(page).to have_selector('.nav-sidebar')
|
|
|
|
end
|
|
|
|
|
2019-03-04 03:23:55 -05:00
|
|
|
it_behaves_like 'has a collapsed nav sidebar'
|
2019-03-03 23:49:18 -05:00
|
|
|
end
|
|
|
|
|
2019-03-04 03:23:55 -05:00
|
|
|
context 'with a extra large viewport' do
|
2019-03-03 23:49:18 -05:00
|
|
|
before do
|
2019-03-04 00:57:40 -05:00
|
|
|
resize_window(1200, 800)
|
2019-03-03 23:49:18 -05:00
|
|
|
visit project_path(project)
|
|
|
|
expect(page).to have_selector('.nav-sidebar')
|
|
|
|
end
|
|
|
|
|
2019-03-04 03:23:55 -05:00
|
|
|
it_behaves_like 'has a expanded nav sidebar'
|
2019-03-03 23:49:18 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-06 08:40:33 -04:00
|
|
|
context 'as owner' do
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when snippets are disabled' do
|
|
|
|
before do
|
|
|
|
project.project_feature.update_attribute('snippets_access_level', ProjectFeature::DISABLED)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not display a "Snippets" link' do
|
|
|
|
visit project_path(project)
|
|
|
|
|
|
|
|
within('.nav-sidebar') do
|
|
|
|
expect(page).not_to have_content 'Snippets'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-10-14 20:08:42 -04:00
|
|
|
context 'as anonymous' do
|
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
let!(:issue) { create(:issue, :opened, project: project, author: user) }
|
|
|
|
|
|
|
|
describe 'project landing page' do
|
|
|
|
before do
|
|
|
|
project.project_feature.update!(
|
|
|
|
builds_access_level: ProjectFeature::DISABLED,
|
|
|
|
merge_requests_access_level: ProjectFeature::DISABLED,
|
|
|
|
repository_access_level: ProjectFeature::DISABLED,
|
|
|
|
issues_access_level: ProjectFeature::DISABLED,
|
|
|
|
wiki_access_level: ProjectFeature::DISABLED
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show the project file list landing page, but the activity' do
|
|
|
|
visit project_path(project)
|
|
|
|
|
|
|
|
expect(page).not_to have_selector '.project-stats'
|
|
|
|
expect(page).not_to have_selector '.project-last-commit'
|
|
|
|
expect(page).not_to have_selector '.project-show-files'
|
|
|
|
expect(page).to have_selector '.project-show-activity'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the wiki when enabled' do
|
|
|
|
project.project_feature.update!(wiki_access_level: ProjectFeature::ENABLED)
|
|
|
|
|
|
|
|
visit project_path(project)
|
|
|
|
|
|
|
|
expect(page).to have_selector '.project-show-wiki'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the issues when enabled' do
|
|
|
|
project.project_feature.update!(issues_access_level: ProjectFeature::ENABLED)
|
|
|
|
|
|
|
|
visit project_path(project)
|
|
|
|
|
|
|
|
expect(page).to have_selector '.issues-list'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the wiki when wiki and issues are enabled' do
|
|
|
|
project.project_feature.update!(
|
|
|
|
issues_access_level: ProjectFeature::ENABLED,
|
|
|
|
wiki_access_level: ProjectFeature::ENABLED
|
|
|
|
)
|
|
|
|
|
|
|
|
visit project_path(project)
|
|
|
|
|
|
|
|
expect(page).to have_selector '.project-show-wiki'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-06 08:40:33 -04:00
|
|
|
context 'as guest' do
|
|
|
|
let(:guest) { create(:user) }
|
2020-08-24 08:10:17 -04:00
|
|
|
let!(:issue) { create(:issue, :opened, project: project, author: guest) }
|
2018-04-06 08:40:33 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_guest(guest)
|
|
|
|
|
|
|
|
sign_in(guest)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows allowed tabs only' do
|
|
|
|
visit project_path(project)
|
|
|
|
|
|
|
|
within('.nav-sidebar') do
|
2018-05-21 12:19:55 -04:00
|
|
|
expect(page).to have_content 'Project'
|
2018-04-06 08:40:33 -04:00
|
|
|
expect(page).to have_content 'Issues'
|
|
|
|
expect(page).to have_content 'Wiki'
|
2021-05-18 11:10:46 -04:00
|
|
|
expect(page).to have_content 'Monitor'
|
2018-04-06 08:40:33 -04:00
|
|
|
|
|
|
|
expect(page).not_to have_content 'Repository'
|
2021-03-10 13:09:32 -05:00
|
|
|
expect(page).not_to have_content 'CI/CD'
|
2018-04-06 08:40:33 -04:00
|
|
|
expect(page).not_to have_content 'Merge Requests'
|
2018-05-29 07:37:59 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows build tab if builds are public' do
|
|
|
|
project.public_builds = true
|
2021-04-03 23:08:52 -04:00
|
|
|
project.save!
|
2018-05-29 07:37:59 -04:00
|
|
|
|
|
|
|
visit project_path(project)
|
|
|
|
|
|
|
|
within('.nav-sidebar') do
|
2021-03-10 13:09:32 -05:00
|
|
|
expect(page).to have_content 'CI/CD'
|
2018-04-06 08:40:33 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show fork button' do
|
|
|
|
visit project_path(project)
|
|
|
|
|
|
|
|
within('.count-buttons') do
|
|
|
|
expect(page).not_to have_link 'Fork'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show clone path' do
|
|
|
|
visit project_path(project)
|
|
|
|
|
|
|
|
within('.project-repo-buttons') do
|
|
|
|
expect(page).not_to have_selector '.project-clone-holder'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'project landing page' do
|
|
|
|
before do
|
|
|
|
project.project_feature.update!(
|
|
|
|
issues_access_level: ProjectFeature::DISABLED,
|
|
|
|
wiki_access_level: ProjectFeature::DISABLED
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show the project file list landing page' do
|
|
|
|
visit project_path(project)
|
|
|
|
|
|
|
|
expect(page).not_to have_selector '.project-stats'
|
|
|
|
expect(page).not_to have_selector '.project-last-commit'
|
|
|
|
expect(page).not_to have_selector '.project-show-files'
|
2020-10-14 20:08:42 -04:00
|
|
|
expect(page).to have_selector '.project-show-activity'
|
2018-04-06 08:40:33 -04:00
|
|
|
end
|
|
|
|
|
2020-10-14 20:08:42 -04:00
|
|
|
it 'shows the project activity when issues and wiki are disabled' do
|
2018-04-06 08:40:33 -04:00
|
|
|
visit project_path(project)
|
|
|
|
|
2020-10-14 20:08:42 -04:00
|
|
|
expect(page).to have_selector '.project-show-activity'
|
2018-04-06 08:40:33 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the wiki when enabled' do
|
|
|
|
project.project_feature.update!(wiki_access_level: ProjectFeature::PRIVATE)
|
|
|
|
|
|
|
|
visit project_path(project)
|
|
|
|
|
|
|
|
expect(page).to have_selector '.project-show-wiki'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the issues when enabled' do
|
|
|
|
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
|
|
|
|
|
|
|
|
visit project_path(project)
|
|
|
|
|
|
|
|
expect(page).to have_selector '.issues-list'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|