summaryrefslogtreecommitdiff
path: root/spec/features/callouts/service_templates_deprecation_spec.rb
blob: b6403b54e290d4594b8341ead766b3bc4e674b2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Service templates deprecation callout' do
  let_it_be(:admin) { create(:admin) }
  let_it_be(:non_admin) { create(:user) }
  let_it_be(:callout_content) { 'Service templates are deprecated and will be removed in GitLab 14.0.' }

  context 'when a non-admin is logged in' do
    before do
      sign_in(non_admin)
      visit root_dashboard_path
    end

    it 'does not display callout' do
      expect(page).not_to have_content callout_content
    end
  end

  context 'when an admin is logged in' do
    before do
      sign_in(admin)
      gitlab_enable_admin_mode_sign_in(admin)

      visit root_dashboard_path
    end

    context 'with no active service templates' do
      it 'does not display callout' do
        expect(page).not_to have_content callout_content
      end
    end

    context 'with active service template' do
      before do
        create(:service, :template, type: 'MattermostService', active: true)
        visit root_dashboard_path
      end

      it 'displays callout' do
        expect(page).to have_content callout_content
        expect(page).to have_link 'See affected service templates', href: admin_application_settings_services_path
      end

      context 'when callout is dismissed', :js do
        before do
          find('[data-testid="close-service-templates-deprecated-callout"]').click

          visit root_dashboard_path
        end

        it 'does not display callout' do
          expect(page).not_to have_content callout_content
        end
      end
    end
  end
end