diff options
Diffstat (limited to 'spec/views/layouts')
4 files changed, 73 insertions, 3 deletions
diff --git a/spec/views/layouts/_flash.html.haml_spec.rb b/spec/views/layouts/_flash.html.haml_spec.rb index a4bed09368f..d88977b194a 100644 --- a/spec/views/layouts/_flash.html.haml_spec.rb +++ b/spec/views/layouts/_flash.html.haml_spec.rb @@ -3,9 +3,20 @@ require 'spec_helper' RSpec.describe 'layouts/_flash' do + let_it_be(:template) { 'layouts/_flash' } + let_it_be(:flash_container_no_margin_class) { 'flash-container-no-margin' } + + let(:locals) { {} } + before do allow(view).to receive(:flash).and_return(flash) - render + render(template: template, locals: locals) + end + + describe 'default' do + it 'does not render flash container no margin class' do + expect(rendered).not_to have_selector(".#{flash_container_no_margin_class}") + end end describe 'closable flash messages' do @@ -17,7 +28,7 @@ RSpec.describe 'layouts/_flash' do let(:flash) { { flash_type => 'This is a closable flash message' } } it 'shows a close button' do - expect(rendered).to include('js-close-icon') + expect(rendered).to include('js-close') end end end @@ -31,8 +42,16 @@ RSpec.describe 'layouts/_flash' do let(:flash) { { flash_type => 'This is a non closable flash message' } } it 'does not show a close button' do - expect(rendered).not_to include('js-close-icon') + expect(rendered).not_to include('js-close') end end end + + describe 'with flash_class in locals' do + let(:locals) { { flash_container_no_margin: true } } + + it 'adds class to flash-container' do + expect(rendered).to have_selector(".flash-container.#{flash_container_no_margin_class}") + end + end end diff --git a/spec/views/layouts/fullscreen.html.haml_spec.rb b/spec/views/layouts/fullscreen.html.haml_spec.rb index 14b382bc238..7b345fea2ad 100644 --- a/spec/views/layouts/fullscreen.html.haml_spec.rb +++ b/spec/views/layouts/fullscreen.html.haml_spec.rb @@ -3,6 +3,10 @@ require 'spec_helper' RSpec.describe 'layouts/fullscreen' do + let_it_be(:template) { 'layouts/fullscreen' } + let_it_be(:top_nav_partial) { 'layouts/header/_default' } + let_it_be(:top_nav_responsive_partial) { 'layouts/nav/_top_nav_responsive' } + let_it_be(:user) { create(:user) } before do @@ -16,6 +20,20 @@ RSpec.describe 'layouts/fullscreen' do expect(rendered).to have_selector(".gl--flex-full.gl-w-full") end + it 'renders flash container' do + render + + expect(view).to render_template("layouts/_flash") + expect(rendered).to have_selector(".flash-container.flash-container-no-margin") + end + + it 'renders top nav' do + render + + expect(view).to render_template(top_nav_partial) + expect(view).to render_template(top_nav_responsive_partial) + end + it_behaves_like 'a layout which reflects the application theme setting' describe 'sidebar' do @@ -51,4 +69,15 @@ RSpec.describe 'layouts/fullscreen' do end end end + + context 'when minimal is set' do + subject { render(template: template, formats: :html, locals: { minimal: true }) } + + it 'does not render top nav' do + subject + + expect(view).not_to render_template(top_nav_partial) + expect(view).not_to render_template(top_nav_responsive_partial) + end + end end diff --git a/spec/views/layouts/header/_gitlab_version.html.haml_spec.rb b/spec/views/layouts/header/_gitlab_version.html.haml_spec.rb index 0e24810f835..2f423c72ca6 100644 --- a/spec/views/layouts/header/_gitlab_version.html.haml_spec.rb +++ b/spec/views/layouts/header/_gitlab_version.html.haml_spec.rb @@ -12,5 +12,11 @@ RSpec.describe 'layouts/header/_gitlab_version' do it 'renders the version check badge' do expect(rendered).to have_selector('.js-gitlab-version-check') end + + it 'renders the container as a link' do + expect(rendered).to have_selector( + 'a[data-testid="gitlab-version-container"][href="/help/update/index"]' + ) + end end end diff --git a/spec/views/layouts/nav/sidebar/_profile.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_profile.html.haml_spec.rb index 3d28be68b25..f5a0a7a935c 100644 --- a/spec/views/layouts/nav/sidebar/_profile.html.haml_spec.rb +++ b/spec/views/layouts/nav/sidebar/_profile.html.haml_spec.rb @@ -11,4 +11,20 @@ RSpec.describe 'layouts/nav/sidebar/_profile' do it_behaves_like 'has nav sidebar' it_behaves_like 'sidebar includes snowplow attributes', 'render', 'user_side_navigation', 'user_side_navigation' + + it 'has a link to access tokens' do + render + + expect(rendered).to have_link(_('Access Tokens'), href: profile_personal_access_tokens_path) + end + + context 'when personal access tokens are disabled' do + it 'does not have a link to access tokens' do + allow(::Gitlab::CurrentSettings).to receive_messages(personal_access_tokens_disabled?: true) + + render + + expect(rendered).not_to have_link(_('Access Tokens'), href: profile_personal_access_tokens_path) + end + end end |