summaryrefslogtreecommitdiff
path: root/spec/features/whats_new_spec.rb
blob: 6b19ab28b448e4f72985101f828edc5e2627a05d (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
# frozen_string_literal: true

require "spec_helper"

RSpec.describe "renders a `whats new` dropdown item", feature_category: :not_owned do
  let_it_be(:user) { create(:user) }

  context 'when not logged in' do
    it 'and on .com it renders' do
      allow(Gitlab).to receive(:com?).and_return(true)

      visit user_path(user)

      page.within '.header-help' do
        find('.header-help-dropdown-toggle').click

        expect(page).to have_button(text: "What's new")
      end
    end

    it "doesn't render what's new" do
      visit user_path(user)

      page.within '.header-help' do
        find('.header-help-dropdown-toggle').click

        expect(page).not_to have_button(text: "What's new")
      end
    end
  end

  context 'when logged in', :js do
    before do
      sign_in(user)
    end

    it 'renders dropdown item when feature enabled' do
      Gitlab::CurrentSettings.update!(whats_new_variant: ApplicationSetting.whats_new_variants[:all_tiers])

      visit root_dashboard_path
      find('.header-help-dropdown-toggle').click

      expect(page).to have_button(text: "What's new")
    end

    it 'does not render dropdown item when feature disabled' do
      Gitlab::CurrentSettings.update!(whats_new_variant: ApplicationSetting.whats_new_variants[:disabled])

      visit root_dashboard_path
      find('.header-help-dropdown-toggle').click

      expect(page).not_to have_button(text: "What's new")
    end

    it 'shows notification dot and count and removes it once viewed' do
      visit root_dashboard_path

      page.within '.header-help' do
        expect(page).to have_selector('.notification-dot', visible: true)

        find('.header-help-dropdown-toggle').click

        expect(page).to have_button(text: "What's new")
        expect(page).to have_selector('.js-whats-new-notification-count')

        find('button', text: "What's new").click
      end

      find('.whats-new-drawer .gl-drawer-close-button').click
      find('.header-help-dropdown-toggle').click

      page.within '.header-help' do
        expect(page).not_to have_selector('.notification-dot', visible: true)
        expect(page).to have_button(text: "What's new")
        expect(page).not_to have_selector('.js-whats-new-notification-count')
      end
    end
  end
end