diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /spec/views | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'spec/views')
8 files changed, 200 insertions, 27 deletions
diff --git a/spec/views/groups/settings/_remove.html.haml_spec.rb b/spec/views/groups/settings/_remove.html.haml_spec.rb index 07fe900bc2d..e40fda58a72 100644 --- a/spec/views/groups/settings/_remove.html.haml_spec.rb +++ b/spec/views/groups/settings/_remove.html.haml_spec.rb @@ -9,8 +9,8 @@ RSpec.describe 'groups/settings/_remove.html.haml' do render 'groups/settings/remove', group: group - expect(rendered).to have_selector '[data-testid="remove-group-button"]' - expect(rendered).not_to have_selector '[data-testid="remove-group-button"].disabled' + expect(rendered).to have_selector '[data-button-testid="remove-group-button"]' + expect(rendered).not_to have_selector '[data-button-testid="remove-group-button"].disabled' expect(rendered).not_to have_selector '[data-testid="group-has-linked-subscription-alert"]' end end diff --git a/spec/views/groups/settings/_transfer.html.haml_spec.rb b/spec/views/groups/settings/_transfer.html.haml_spec.rb index b557c989eae..911eb5b7ab3 100644 --- a/spec/views/groups/settings/_transfer.html.haml_spec.rb +++ b/spec/views/groups/settings/_transfer.html.haml_spec.rb @@ -9,9 +9,9 @@ RSpec.describe 'groups/settings/_transfer.html.haml' do render 'groups/settings/transfer', group: group - expect(rendered).to have_selector '[data-qa-selector="select_group_dropdown"]' # rubocop:disable QA/SelectorUsage - expect(rendered).not_to have_selector '[data-qa-selector="select_group_dropdown"][disabled]' # rubocop:disable QA/SelectorUsage - expect(rendered).not_to have_selector '[data-testid="group-to-transfer-has-linked-subscription-alert"]' + expect(rendered).to have_button 'Select parent group' + expect(rendered).not_to have_button 'Select parent group', disabled: true + expect(rendered).not_to have_text "This group can't be transfered because it is linked to a subscription." end end end diff --git a/spec/views/jira_connect/subscriptions/index.html.haml_spec.rb b/spec/views/jira_connect/subscriptions/index.html.haml_spec.rb index dcc36c93327..0a4d283a983 100644 --- a/spec/views/jira_connect/subscriptions/index.html.haml_spec.rb +++ b/spec/views/jira_connect/subscriptions/index.html.haml_spec.rb @@ -7,7 +7,7 @@ RSpec.describe 'jira_connect/subscriptions/index.html.haml' do before do allow(view).to receive(:current_user).and_return(user) - assign(:subscriptions, []) + assign(:subscriptions, create_list(:jira_connect_subscription, 1)) end context 'when the user is signed in' do diff --git a/spec/views/layouts/_published_experiments.html.haml_spec.rb b/spec/views/layouts/_published_experiments.html.haml_spec.rb new file mode 100644 index 00000000000..d1ade8ddd6e --- /dev/null +++ b/spec/views/layouts/_published_experiments.html.haml_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'layouts/_published_experiments', :experiment do + before do + stub_const('TestControlExperiment', ApplicationExperiment) + stub_const('TestCandidateExperiment', ApplicationExperiment) + stub_const('TestExcludedExperiment', ApplicationExperiment) + + TestControlExperiment.new('test_control').tap do |e| + e.variant(:control) + e.publish + end + TestCandidateExperiment.new('test_candidate').tap do |e| + e.variant(:candidate) + e.publish + end + TestExcludedExperiment.new('test_excluded').tap do |e| + e.exclude! + e.publish + end + + render + end + + it 'renders out data for all non-excluded, published experiments' do + output = rendered + + expect(output).to include('gl.experiments = {') + expect(output).to match(/"test_control":\{[^}]*"variant":"control"/) + expect(output).to match(/"test_candidate":\{[^}]*"variant":"candidate"/) + expect(output).not_to include('"test_excluded"') + end +end diff --git a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb index 20c5d9992be..f7da288b9f3 100644 --- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb +++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb @@ -987,28 +987,10 @@ RSpec.describe 'layouts/nav/sidebar/_project' do end describe 'Usage Quotas' do - context 'with project_storage_ui feature flag enabled' do - before do - stub_feature_flags(project_storage_ui: true) - end - - it 'has a link to Usage Quotas' do - render - - expect(rendered).to have_link('Usage Quotas', href: project_usage_quotas_path(project)) - end - end - - context 'with project_storage_ui feature flag disabled' do - before do - stub_feature_flags(project_storage_ui: false) - end - - it 'does not have a link to Usage Quotas' do - render + it 'has a link to Usage Quotas' do + render - expect(rendered).not_to have_link('Usage Quotas', href: project_usage_quotas_path(project)) - end + expect(rendered).to have_link('Usage Quotas', href: project_usage_quotas_path(project)) end end end diff --git a/spec/views/profiles/audit_log.html.haml_spec.rb b/spec/views/profiles/audit_log.html.haml_spec.rb new file mode 100644 index 00000000000..d5f6a2d64e7 --- /dev/null +++ b/spec/views/profiles/audit_log.html.haml_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'profiles/audit_log' do + let(:user) { create(:user) } + + before do + assign(:user, user) + assign(:events, AuthenticationEvent.all.page(params[:page])) + allow(controller).to receive(:current_user).and_return(user) + end + + context 'when user has successful and failure events' do + before do + create(:authentication_event, :successful, user: user) + create(:authentication_event, :failed, user: user) + end + + it 'only shows successful events' do + render + + expect(rendered).to have_text('Signed in with standard authentication', count: 1) + end + end +end diff --git a/spec/views/projects/edit.html.haml_spec.rb b/spec/views/projects/edit.html.haml_spec.rb index b44d07d2ee4..60f4c1664f7 100644 --- a/spec/views/projects/edit.html.haml_spec.rb +++ b/spec/views/projects/edit.html.haml_spec.rb @@ -57,6 +57,41 @@ RSpec.describe 'projects/edit' do end end + context 'merge commit template' do + it 'displays all possible variables' do + render + + expect(rendered).to have_content('%{source_branch}') + expect(rendered).to have_content('%{target_branch}') + expect(rendered).to have_content('%{title}') + expect(rendered).to have_content('%{issues}') + expect(rendered).to have_content('%{description}') + expect(rendered).to have_content('%{reference}') + end + + it 'displays a placeholder if none is set' do + render + + expect(rendered).to have_field('project[merge_commit_template]', placeholder: <<~MSG.rstrip) + Merge branch '%{source_branch}' into '%{target_branch}' + + %{title} + + %{issues} + + See merge request %{reference} + MSG + end + + it 'displays the user entered value' do + project.update!(merge_commit_template: '%{title}') + + render + + expect(rendered).to have_field('project[merge_commit_template]', with: '%{title}') + end + end + context 'forking' do before do assign(:project, project) diff --git a/spec/views/projects/issues/_service_desk_info_content.html.haml_spec.rb b/spec/views/projects/issues/_service_desk_info_content.html.haml_spec.rb new file mode 100644 index 00000000000..1c6d729ddce --- /dev/null +++ b/spec/views/projects/issues/_service_desk_info_content.html.haml_spec.rb @@ -0,0 +1,95 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'projects/issues/_service_desk_info_content' do + let_it_be(:project) { create(:project) } + let_it_be(:user) { create(:user) } + let_it_be(:service_desk_address) { 'address@example.com' } + + before do + assign(:project, project) + allow(project).to receive(:service_desk_address).and_return(service_desk_address) + allow(view).to receive(:current_user).and_return(user) + end + + context 'when service desk is disabled' do + before do + allow(project).to receive(:service_desk_enabled?).and_return(false) + end + + context 'when the logged user is at least maintainer' do + before do + project.add_maintainer(user) + end + + it 'shows the info including the project settings link', :aggregate_failures do + render + + expect(rendered).to have_text('Use Service Desk') + expect(rendered).not_to have_text(service_desk_address) + expect(rendered).to have_link(href: "/#{project.full_path}/edit") + end + end + + context 'when the logged user is at only a developer' do + before do + project.add_developer(user) + end + + it 'shows the info without the project settings link', :aggregate_failures do + render + + expect(rendered).to have_text('Use Service Desk') + expect(rendered).not_to have_text(service_desk_address) + expect(rendered).not_to have_link(href: "/#{project.full_path}/edit") + end + end + end + + context 'when service desk is enabled' do + before do + allow(project).to receive(:service_desk_enabled?).and_return(true) + end + + context 'when the logged user is at least reporter' do + before do + project.add_reporter(user) + end + + it 'shows the info including the email address', :aggregate_failures do + render + + expect(rendered).to have_text('Use Service Desk') + expect(rendered).to have_text(service_desk_address) + expect(rendered).not_to have_link(href: "/#{project.full_path}/edit") + end + end + + context 'when the logged user is at only a guest' do + before do + project.add_guest(user) + end + + it 'shows the info without the email address', :aggregate_failures do + render + + expect(rendered).to have_text('Use Service Desk') + expect(rendered).not_to have_text(service_desk_address) + expect(rendered).not_to have_link(href: "/#{project.full_path}/edit") + end + end + + context 'when user is not logged in' do + let(:user) { nil } + + it 'shows the info without the email address', :aggregate_failures do + render + + expect(rendered).to have_text('Use Service Desk') + expect(rendered).not_to have_text(service_desk_address) + expect(rendered).not_to have_link(href: "/#{project.full_path}/edit") + end + end + end +end |