Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sentry_js_spec.rb « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d3880011914e6c1af1210653ec7ad2a16fd32c17 (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
60
61
62
63
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Sentry', feature_category: :error_tracking do
  context 'when enable_new_sentry_clientside_integration is disabled' do
    before do
      stub_feature_flags(enable_new_sentry_clientside_integration: false)
    end

    it 'does not load sentry if sentry is disabled' do
      allow(Gitlab.config.sentry).to receive(:enabled).and_return(false)

      visit new_user_session_path

      expect(has_requested_legacy_sentry).to eq(false)
    end

    it 'loads legacy sentry if sentry config is enabled', :js do
      allow(Gitlab.config.sentry).to receive(:enabled).and_return(true)

      visit new_user_session_path

      expect(has_requested_legacy_sentry).to eq(true)
      expect(evaluate_script('window._Sentry.SDK_VERSION')).to match(%r{^5\.})
    end
  end

  context 'when enable_new_sentry_clientside_integration is enabled' do
    before do
      stub_feature_flags(enable_new_sentry_clientside_integration: true)
    end

    it 'does not load sentry if sentry settings are disabled' do
      allow(Gitlab::CurrentSettings).to receive(:sentry_enabled).and_return(false)

      visit new_user_session_path

      expect(has_requested_sentry).to eq(false)
    end

    it 'loads sentry if sentry settings are enabled', :js do
      allow(Gitlab::CurrentSettings).to receive(:sentry_enabled).and_return(true)

      visit new_user_session_path

      expect(has_requested_sentry).to eq(true)
      expect(evaluate_script('window._Sentry.SDK_VERSION')).to match(%r{^7\.})
    end
  end

  def has_requested_legacy_sentry
    page.all('script', visible: false).one? do |elm|
      elm[:src] =~ %r{/legacy_sentry.*\.chunk\.js\z}
    end
  end

  def has_requested_sentry
    page.all('script', visible: false).one? do |elm|
      elm[:src] =~ %r{/sentry.*\.chunk\.js\z}
    end
  end
end