Skip to content
Snippets Groups Projects
Commit b10debf8 authored by Paul Gascou-Vaillancourt's avatar Paul Gascou-Vaillancourt :palm_tree: Committed by Gary Holtz
Browse files

Hide new nav callout for new users

Users that registered after the new navigation feature flag was fully
rolled out do not need to see the announcement about it. This adds a
date check to ensure only users created before June 2nd 2023 get the
callout.

Changelog: changed
parent adaf9539
No related branches found
No related tags found
1 merge request!122695Hide new nav callout for new users
......@@ -81,7 +81,15 @@ def show_branch_rules_info?
end
def show_new_navigation_callout?
show_super_sidebar? && !user_dismissed?(NEW_NAVIGATION_CALLOUT)
show_super_sidebar? &&
!user_dismissed?(NEW_NAVIGATION_CALLOUT) &&
# GitLab.com users created after the feature flag's full rollout (June 2nd 2023) don't need to see the callout.
# Remove the gitlab_com_user_created_after_new_nav_rollout? method when the callout isn't needed anymore.
!gitlab_com_user_created_after_new_nav_rollout?
end
def gitlab_com_user_created_after_new_nav_rollout?
Gitlab.com? && current_user.created_at >= Date.new(2023, 6, 2)
end
def ultimate_feature_removal_banner_dismissed?(project)
......
......@@ -6,8 +6,13 @@ def show_code_suggestions_alert?
return false if cookies[:code_suggestions_alert_dismissed] == 'true'
return false if Feature.disabled?(:code_suggestions_alert, current_user)
return true if current_user.blank? # check user is logged in
return false unless user_dismissed_before?(::Users::CalloutsHelper::NEW_NAVIGATION_CALLOUT, 30.minutes.ago)
return false unless new_nav_callout_hidden?
!current_user.code_suggestions_enabled?
end
def new_nav_callout_hidden?
user_dismissed_before?(::Users::CalloutsHelper::NEW_NAVIGATION_CALLOUT, 30.minutes.ago) ||
gitlab_com_user_created_after_new_nav_rollout?
end
end
......@@ -55,38 +55,51 @@
end
context 'when new navigation alert is present' do
let_it_be(:user) { create(:user, use_new_navigation: true) }
before do
sign_in(user)
visit group_path(group)
allow(Gitlab).to receive(:com?).and_return(true)
end
it 'does not show code suggestions alert' do
expect_new_nav_alert_to_be_present
expect_group_page_for(group)
expect_banner_to_be_absent
end
context 'when user was created before the new navigation rollout' do
let_it_be(:user) { create(:user, created_at: Date.new(2023, 6, 1), use_new_navigation: true) }
context 'when user dismisses new navigation alert' do
it 'hides new nav alert and shows code suggestions alert' do
it 'does not show code suggestions alert' do
expect_new_nav_alert_to_be_present
expect_group_page_for(group)
expect_banner_to_be_absent
end
page.within(find('[data-feature-id="new_navigation_callout"]')) do
find('[data-testid="close-icon"]').click
end
context 'when user dismisses new navigation alert' do
it 'hides new nav alert and shows code suggestions alert' do
expect_new_nav_alert_to_be_present
page.within(find('[data-feature-id="new_navigation_callout"]')) do
find('[data-testid="close-icon"]').click
end
wait_for_requests
wait_for_requests
# simulate delay in showing code suggestions alert
travel_to(Time.current + 31.minutes) do
visit group_path(group)
# simulate delay in showing code suggestions alert
travel_to(Time.current + 31.minutes) do
visit group_path(group)
expect_new_nav_alert_be_absent
expect_banner_to_be_present
expect_new_nav_alert_be_absent
expect_banner_to_be_present
end
end
end
end
context 'when user was created after the new navigation rollout' do
let_it_be(:user) { create(:user, created_at: Date.new(2023, 6, 2), use_new_navigation: true) }
it 'shows code suggestions alert' do
expect_new_nav_alert_be_absent
expect_group_page_for(group)
expect_banner_to_be_present
end
end
end
def dismiss_button
......
......@@ -4,14 +4,16 @@
RSpec.describe 'new navigation callout', :js, feature_category: :navigation do
let_it_be(:callout_title) { _('Welcome to a new navigation experience') }
let(:dot_com) { false }
before do
allow(Gitlab).to receive(:com?).and_return(dot_com)
sign_in(user)
visit root_path
end
context 'with new navigation toggled on' do
let_it_be(:user) { create(:user, use_new_navigation: true) }
let_it_be(:user) { create(:user, created_at: Date.new(2023, 6, 1), use_new_navigation: true) }
it 'shows a callout about the new navigation' do
expect(page).to have_content callout_title
......@@ -34,8 +36,26 @@
end
end
context 'when user registered on or after June 2nd 2023' do
let_it_be(:user) { create(:user, created_at: Date.new(2023, 6, 2), use_new_navigation: true) }
context 'when on GitLab.com' do
let(:dot_com) { true }
it 'does not show the callout about the new navigation' do
expect(page).not_to have_content callout_title
end
end
context 'when on a self-managed instance' do
it 'shows the callout about the new navigation' do
expect(page).to have_content callout_title
end
end
end
context 'with new navigation toggled off' do
let_it_be(:user) { create(:user, use_new_navigation: false) }
let_it_be(:user) { create(:user, created_at: Date.new(2023, 6, 1), use_new_navigation: false) }
it 'does not show the callout' do
expect(page).not_to have_content callout_title
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment