diff options
Diffstat (limited to 'spec/views')
7 files changed, 171 insertions, 47 deletions
diff --git a/spec/views/admin/identities/index.html.haml_spec.rb b/spec/views/admin/identities/index.html.haml_spec.rb new file mode 100644 index 00000000000..3e8def003ae --- /dev/null +++ b/spec/views/admin/identities/index.html.haml_spec.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'admin/identities/index.html.haml', :aggregate_failures do + include Admin::IdentitiesHelper + + let_it_be(:ldap_user) { create(:omniauth_user, provider: 'ldapmain', extern_uid: 'ldap-uid') } + + before do + assign(:user, ldap_user) + view.lookup_context.prefixes = ['admin/identities'] + end + + context 'without identities' do + before do + assign(:identities, []) + end + + it 'shows table headers' do + render + + expect(rendered).to include('<th class="gl-border-t-0!">').exactly(5) + expect(rendered).to include(_('Provider')) + expect(rendered).to include(s_('Identity|Provider ID')) + expect(rendered).to include(_('Group')) + expect(rendered).to include(_('Identifier')) + expect(rendered).to include(_('Actions')) + end + + it 'shows information text' do + render + + expect(rendered).to include('<td colspan="5">').exactly(1) + expect(rendered).to include(_('This user has no identities')) + end + end + + context 'with LDAP identities' do + before do + assign(:identities, ldap_user.identities) + end + + it 'shows exactly 5 columns' do + render + + expect(rendered).to include('</td>').exactly(5) + end + + it 'shows identity without provider ID or group' do + render + + # Provider + expect(rendered).to include('ldap (ldapmain)') + # Provider ID + expect(rendered).to include('data-testid="provider_id_blank"') + # Group + expect(rendered).to include('data-testid="saml_group_blank"') + # Identifier + expect(rendered).to include('ldap-uid') + end + + it 'shows edit and delete identity buttons' do + render + + expect(rendered).to include("aria-label=\"#{_('Edit')}\"") + expect(rendered).to include("aria-label=\"#{_('Delete identity')}\"") + end + end +end diff --git a/spec/views/devise/sessions/new.html.haml_spec.rb b/spec/views/devise/sessions/new.html.haml_spec.rb index b3cd1493149..c8e9aa15287 100644 --- a/spec/views/devise/sessions/new.html.haml_spec.rb +++ b/spec/views/devise/sessions/new.html.haml_spec.rb @@ -9,6 +9,7 @@ RSpec.describe 'devise/sessions/new' do before do stub_devise disable_captcha + stub_feature_flags(restyle_login_page: false) allow(Gitlab).to receive(:com?).and_return(true) end @@ -29,67 +30,74 @@ RSpec.describe 'devise/sessions/new' do end end - describe 'ldap' do - include LdapHelpers - - let(:server) { { provider_name: 'ldapmain', label: 'LDAP' }.with_indifferent_access } - + flag_values = [true, false] + flag_values.each do |val| before do - enable_ldap - stub_devise - disable_captcha - disable_sign_up - disable_other_signin_methods - - allow(view).to receive(:experiment_enabled?).and_return(false) + stub_feature_flags(restyle_login_page: val) end - it 'is shown when enabled' do - render + describe 'ldap' do + include LdapHelpers - expect(rendered).to have_selector('.new-session-tabs') - expect(rendered).to have_selector('[data-qa-selector="ldap_tab"]') # rubocop:disable QA/SelectorUsage - expect(rendered).to have_field('LDAP Username') - end + let(:server) { { provider_name: 'ldapmain', label: 'LDAP' }.with_indifferent_access } - it 'is not shown when LDAP sign in is disabled' do - disable_ldap_sign_in + before do + enable_ldap + stub_devise + disable_captcha + disable_sign_up + disable_other_signin_methods - render + allow(view).to receive(:experiment_enabled?).and_return(false) + end - expect(rendered).to have_content('No authentication methods configured') - expect(rendered).not_to have_selector('[data-qa-selector="ldap_tab"]') # rubocop:disable QA/SelectorUsage - expect(rendered).not_to have_field('LDAP Username') - end - end + it 'is shown when enabled' do + render - describe 'Google Tag Manager' do - let!(:gtm_id) { 'GTM-WWKMTWS'} + expect(rendered).to have_selector('.new-session-tabs') + expect(rendered).to have_selector('[data-qa-selector="ldap_tab"]') # rubocop:disable QA/SelectorUsage + expect(rendered).to have_field('LDAP Username') + end - subject { rendered } + it 'is not shown when LDAP sign in is disabled' do + disable_ldap_sign_in - before do - stub_devise - disable_captcha - stub_config(extra: { google_tag_manager_id: gtm_id, google_tag_manager_nonce_id: gtm_id }) + render + + expect(rendered).to have_content('No authentication methods configured') + expect(rendered).not_to have_selector('[data-qa-selector="ldap_tab"]') # rubocop:disable QA/SelectorUsage + expect(rendered).not_to have_field('LDAP Username') + end end - describe 'when Google Tag Manager is enabled' do + describe 'Google Tag Manager' do + let!(:gtm_id) { 'GTM-WWKMTWS' } + + subject { rendered } + before do - enable_gtm - render + stub_devise + disable_captcha + stub_config(extra: { google_tag_manager_id: gtm_id, google_tag_manager_nonce_id: gtm_id }) end - it { is_expected.to match /www.googletagmanager.com/ } - end + describe 'when Google Tag Manager is enabled' do + before do + enable_gtm + render + end - describe 'when Google Tag Manager is disabled' do - before do - disable_gtm - render + it { is_expected.to match /www.googletagmanager.com/ } end - it { is_expected.not_to match /www.googletagmanager.com/ } + describe 'when Google Tag Manager is disabled' do + before do + disable_gtm + render + end + + it { is_expected.not_to match /www.googletagmanager.com/ } + end end end diff --git a/spec/views/groups/group_members/index.html.haml_spec.rb b/spec/views/groups/group_members/index.html.haml_spec.rb index 2d7d50555d6..c7aebb94a45 100644 --- a/spec/views/groups/group_members/index.html.haml_spec.rb +++ b/spec/views/groups/group_members/index.html.haml_spec.rb @@ -21,7 +21,7 @@ RSpec.describe 'groups/group_members/index', :aggregate_failures do render expect(rendered).to have_content('Group members') - expect(rendered).to have_content('You can invite a new member') + expect(rendered).to have_content("You're viewing members") expect(rendered).to have_selector('.js-invite-group-trigger') expect(rendered).to have_selector('.js-invite-members-trigger') diff --git a/spec/views/layouts/header/_new_dropdown.haml_spec.rb b/spec/views/layouts/header/_new_dropdown.haml_spec.rb index 208da345e7f..79c22871b44 100644 --- a/spec/views/layouts/header/_new_dropdown.haml_spec.rb +++ b/spec/views/layouts/header/_new_dropdown.haml_spec.rb @@ -40,7 +40,10 @@ RSpec.describe 'layouts/header/_new_dropdown' do it 'has a "New subgroup" link' do render - expect(rendered).to have_link('New subgroup', href: new_group_path(parent_id: group.id)) + expect(rendered).to have_link( + 'New subgroup', + href: new_group_path(parent_id: group.id, anchor: 'create-group-pane') + ) end end diff --git a/spec/views/projects/blob/_viewer.html.haml_spec.rb b/spec/views/projects/blob/_viewer.html.haml_spec.rb index 893cfec1491..2761d10f9ad 100644 --- a/spec/views/projects/blob/_viewer.html.haml_spec.rb +++ b/spec/views/projects/blob/_viewer.html.haml_spec.rb @@ -24,6 +24,7 @@ RSpec.describe 'projects/blob/_viewer.html.haml' do before do assign(:project, project) assign(:blob, blob) + assign(:ref, 'master') assign(:id, File.join('master', blob.path)) controller.params[:controller] = 'projects/blob' diff --git a/spec/views/projects/pages/new.html.haml_spec.rb b/spec/views/projects/pages/new.html.haml_spec.rb new file mode 100644 index 00000000000..919b2fe84ee --- /dev/null +++ b/spec/views/projects/pages/new.html.haml_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true +require 'spec_helper' + +RSpec.describe 'projects/pages/new' do + let_it_be(:project) { create(:project, :repository) } + let_it_be(:user) { create(:user) } + + before do + allow(project).to receive(:show_pages_onboarding?).and_return(true) + project.add_maintainer(user) + + assign(:project, project) + allow(view).to receive(:current_user).and_return(user) + end + + describe 'with onboarding wizard feature enabled' do + before do + Feature.enable(:use_pipeline_wizard_for_pages) + end + + it "shows the onboarding wizard" do + render + expect(rendered).to have_selector('#js-pages') + end + end + + describe 'with onboarding wizard feature disabled' do + before do + Feature.disable(:use_pipeline_wizard_for_pages) + end + + it "does not show the onboarding wizard" do + render + expect(rendered).not_to have_selector('#js-pages') + end + + it "renders the usage instructions" do + render + expect(rendered).to render_template('projects/pages/_use') + end + end +end diff --git a/spec/views/projects/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb b/spec/views/projects/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb index e650e183bc8..37c9908af1d 100644 --- a/spec/views/projects/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb +++ b/spec/views/projects/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb @@ -28,7 +28,7 @@ RSpec.describe 'projects/pipeline_schedules/_pipeline_schedule' do it 'non-owner can take ownership of pipeline' do render - expect(rendered).to have_link('Take ownership') + expect(rendered).to have_button('Take ownership') end end @@ -42,7 +42,7 @@ RSpec.describe 'projects/pipeline_schedules/_pipeline_schedule' do it 'owner cannot take ownership of pipeline' do render - expect(rendered).not_to have_link('Take ownership') + expect(rendered).not_to have_button('Take ownership') end end end |