2021-01-21 04:08:52 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require "spec_helper"
|
|
|
|
|
2021-04-15 11:09:11 -04:00
|
|
|
RSpec.describe "renders a `whats new` dropdown item" do
|
2021-01-21 04:08:52 -05:00
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
|
2021-04-15 11:09:11 -04:00
|
|
|
context 'when not logged in' do
|
|
|
|
it 'and on .com it renders' do
|
|
|
|
allow(Gitlab).to receive(:com?).and_return(true)
|
2021-01-21 04:08:52 -05:00
|
|
|
|
2021-04-15 11:09:11 -04:00
|
|
|
visit user_path(user)
|
2021-01-21 04:08:52 -05:00
|
|
|
|
2021-04-15 11:09:11 -04:00
|
|
|
page.within '.header-help' do
|
|
|
|
find('.header-help-dropdown-toggle').click
|
2021-01-21 04:08:52 -05:00
|
|
|
|
2021-04-15 11:09:11 -04:00
|
|
|
expect(page).to have_button(text: "What's new")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't render what's new" do
|
|
|
|
visit user_path(user)
|
2021-01-21 04:08:52 -05:00
|
|
|
|
2021-04-15 11:09:11 -04:00
|
|
|
page.within '.header-help' do
|
|
|
|
find('.header-help-dropdown-toggle').click
|
|
|
|
|
|
|
|
expect(page).not_to have_button(text: "What's new")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-01-21 04:08:52 -05:00
|
|
|
|
2021-04-15 11:09:11 -04:00
|
|
|
context 'when logged in', :js do
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
2021-01-21 04:08:52 -05:00
|
|
|
end
|
|
|
|
|
2021-04-27 11:09:52 -04:00
|
|
|
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
|
|
|
|
|
2021-04-15 11:09:11 -04:00
|
|
|
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
|
2021-01-21 04:08:52 -05:00
|
|
|
|
2021-04-15 11:09:11 -04:00
|
|
|
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
|
2021-01-21 04:08:52 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|