2018-12-14 12:49:58 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-01-15 20:06:32 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Help Pages' do
|
2016-11-25 12:26:24 -05:00
|
|
|
describe 'Get the main help page' do
|
2020-05-06 05:10:02 -04:00
|
|
|
before do
|
|
|
|
allow(File).to receive(:read).and_call_original
|
|
|
|
allow(File).to receive(:read).with(Rails.root.join('doc', 'README.md')).and_return(fixture_file('sample_doc.md'))
|
2016-12-01 06:07:52 -05:00
|
|
|
end
|
2017-12-19 11:18:48 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-02-11 10:09:11 -05:00
|
|
|
expect(page).to have_selector('[data-testid="modal-shortcuts"]')
|
2017-12-19 11:18:48 -05:00
|
|
|
end
|
|
|
|
end
|
2016-11-25 12:26:24 -05:00
|
|
|
end
|
2017-01-12 09:00:06 -05:00
|
|
|
|
2022-01-07 13:16:06 -05:00
|
|
|
describe 'with version check enabled' do
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
|
2017-01-12 09:00:06 -05:00
|
|
|
before do
|
2017-12-15 05:23:11 -05:00
|
|
|
stub_application_setting(version_check_enabled: true)
|
2022-01-07 13:16:06 -05:00
|
|
|
allow(User).to receive(:single_user).and_return(double(user, requires_usage_stats_consent?: false))
|
|
|
|
allow(user).to receive(:can_read_all_resources?).and_return(true)
|
2018-12-14 12:47:49 -05:00
|
|
|
|
2022-01-07 13:16:06 -05:00
|
|
|
sign_in(user)
|
2017-01-12 09:00:06 -05:00
|
|
|
visit help_path
|
|
|
|
end
|
|
|
|
|
2022-01-07 13:16:06 -05:00
|
|
|
it 'renders the version check badge' do
|
|
|
|
expect(page).to have_selector('.js-gitlab-version-check')
|
2017-01-12 09:00:06 -05:00
|
|
|
end
|
|
|
|
end
|
2017-06-13 12:46:02 -04:00
|
|
|
|
|
|
|
describe 'when help page is customized' do
|
|
|
|
before do
|
2017-12-15 05:23:11 -05:00
|
|
|
stub_application_setting(help_page_hide_commercial_content: true,
|
|
|
|
help_page_text: 'My Custom Text',
|
|
|
|
help_page_support_url: 'http://example.com/help')
|
2017-06-13 12:46:02 -04:00
|
|
|
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(create(:user))
|
2017-06-13 12:46:02 -04:00
|
|
|
visit help_path
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'displays custom help page text' do
|
2017-06-13 12:46:02 -04:00
|
|
|
expect(page).to have_text "My Custom Text"
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'hides marketing content when enabled' do
|
2017-06-13 12:46:02 -04:00
|
|
|
expect(page).not_to have_link "Get a support subscription"
|
|
|
|
end
|
|
|
|
|
2019-04-05 04:43:27 -04:00
|
|
|
it 'uses a custom support url' do
|
2021-07-15 11:09:41 -04:00
|
|
|
expect(page).to have_link "See our website for help", href: "http://example.com/help"
|
2017-06-13 12:46:02 -04:00
|
|
|
end
|
|
|
|
end
|
2015-01-15 20:06:32 -05:00
|
|
|
end
|