summaryrefslogtreecommitdiff
path: root/spec/features/user_can_display_performance_bar_spec.rb
blob: 1bd7e0389393c20dcb783b4e0ef009133f822d8a (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require 'rails_helper'

describe 'User can display performacne bar', :js do
  shared_examples 'performance bar is disabled' do
    it 'does not show the performance bar by default' do
      expect(page).not_to have_css('#peek')
    end

    context 'when user press `pb`' do
      before do
        find('body').native.send_keys('pb')
      end

      it 'does not show the performance bar by default' do
        expect(page).not_to have_css('#peek')
      end
    end
  end

  shared_examples 'performance bar is enabled' do
    it 'does not show the performance bar by default' do
      expect(page).not_to have_css('#peek')
    end

    context 'when user press `pb`' do
      before do
        find('body').native.send_keys('pb')
      end

      it 'does not show the performance bar by default' do
        expect(page).not_to have_css('#peek')
      end
    end
  end

  context 'when user is logged-out' do
    before do
      visit root_path
    end

    context 'when the gitlab_performance_bar feature is disabled' do
      before do
        Feature.disable('gitlab_performance_bar')
      end

      it_behaves_like 'performance bar is disabled'
    end

    context 'when the gitlab_performance_bar feature is enabled' do
      before do
        Feature.enable('gitlab_performance_bar')
      end

      it_behaves_like 'performance bar is disabled'
    end
  end

  context 'when user is logged-in' do
    before do
      gitlab_sign_in(create(:user))

      visit root_path
    end

    context 'when the gitlab_performance_bar feature is disabled' do
      before do
        Feature.disable('gitlab_performance_bar')
      end

      it_behaves_like 'performance bar is disabled'
    end

    context 'when the gitlab_performance_bar feature is enabled' do
      before do
        Feature.enable('gitlab_performance_bar')
      end

      it_behaves_like 'performance bar is enabled'
    end
  end
end