2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
describe 'Help Pages' do
|
2017-08-17 22:00:37 +05:30
|
|
|
describe 'Get the main help page' do
|
|
|
|
shared_examples_for 'help page' do |prefix: ''|
|
|
|
|
it 'prefixes links correctly' do
|
2019-02-15 15:39:39 +05:30
|
|
|
expect(page).to have_selector(%(div.documentation-index > table tbody tr td a[href="#{prefix}/help/api/README.md"]))
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'without a trailing slash' do
|
|
|
|
before do
|
|
|
|
visit help_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'help page'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a trailing slash' do
|
|
|
|
before do
|
|
|
|
visit help_path + '/'
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'help page'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a relative installation' do
|
|
|
|
before do
|
|
|
|
stub_config_setting(relative_url_root: '/gitlab')
|
|
|
|
visit help_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'help page', prefix: '/gitlab'
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
context 'quick link shortcuts', :js do
|
|
|
|
before do
|
|
|
|
visit help_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'focuses search bar' do
|
|
|
|
find('.js-trigger-search-bar').click
|
|
|
|
|
|
|
|
expect(page).to have_selector('#search:focus')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'opens shortcuts help dialog' do
|
|
|
|
find('.js-trigger-shortcut').click
|
|
|
|
|
|
|
|
expect(page).to have_selector('#modal-shortcuts')
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
context 'in a production environment with version check enabled' do
|
2015-04-26 12:48:37 +05:30
|
|
|
before do
|
2018-03-17 18:26:18 +05:30
|
|
|
stub_application_setting(version_check_enabled: true)
|
2019-02-15 15:39:39 +05:30
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
stub_rails_env('production')
|
2019-02-15 15:39:39 +05:30
|
|
|
allow(VersionCheck).to receive(:url).and_return('/version-check-url')
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(create(:user))
|
2017-08-17 22:00:37 +05:30
|
|
|
visit help_path
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
it 'has a version check image' do
|
2019-02-15 15:39:39 +05:30
|
|
|
# Check `data-src` due to lazy image loading
|
|
|
|
expect(find('.js-version-status-badge', visible: false)['data-src'])
|
|
|
|
.to end_with('/version-check-url')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
describe 'when help page is customized' do
|
|
|
|
before do
|
2018-03-17 18:26:18 +05:30
|
|
|
stub_application_setting(help_page_hide_commercial_content: true,
|
|
|
|
help_page_text: 'My Custom Text',
|
|
|
|
help_page_support_url: 'http://example.com/help')
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(create(:user))
|
|
|
|
visit help_path
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it 'displays custom help page text' do
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(page).to have_text "My Custom Text"
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it 'hides marketing content when enabled' do
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(page).not_to have_link "Get a support subscription"
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
it 'uses a custom support url' do
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(page).to have_link "See our website for getting help", href: "http://example.com/help"
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|