diff --git a/ee/app/helpers/ee/users/callouts_helper.rb b/ee/app/helpers/ee/users/callouts_helper.rb index 714070dd299940a5af3429a23f97a6f4059031ab..6494b64b107d13063aba3277338d6e9d84f42145 100644 --- a/ee/app/helpers/ee/users/callouts_helper.rb +++ b/ee/app/helpers/ee/users/callouts_helper.rb @@ -23,7 +23,11 @@ def render_dashboard_ultimate_trial(user) !user.owns_paid_namespace? && user.owns_group_without_trial? - render 'shared/ultimate_trial_callout_content' + if ::Feature.enabled?(:duo_enterprise_trials, user) + render 'shared/ultimate_with_enterprise_trial_callout_content' + else + render 'shared/ultimate_trial_callout_content' + end end def render_two_factor_auth_recovery_settings_check diff --git a/ee/app/views/shared/_ultimate_with_enterprise_trial_callout_content.html.haml b/ee/app/views/shared/_ultimate_with_enterprise_trial_callout_content.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..bc8e28cd7070c4e9be60cb5f5f56b801717e7a51 --- /dev/null +++ b/ee/app/views/shared/_ultimate_with_enterprise_trial_callout_content.html.haml @@ -0,0 +1,9 @@ +- callout = local_assigns.fetch(:callout, Users::CalloutsHelper::ULTIMATE_TRIAL) +- banner_title = 'ultimate_banner' + += render Pajamas::BannerComponent.new(svg_path: 'illustrations/gitlab_logo.svg', banner_options: { class: 'gl-mt-6 js-gold-trial-callout', data: { track_action: 'render', track_label: banner_title, uid: 'trial_callout_dismissed', feature_id: callout, dismiss_endpoint: callouts_path, testid: 'start-trial-banner' } }, close_options: { class: 'js-close', data: { track_action: 'dismiss_banner', track_label: banner_title }, 'aria-label': _('Dismiss trial promotion') }) do |c| + - c.with_title do + = _('Free Ultimate Trial with GitLab Duo Enterprise') + - c.with_primary_action do + = link_button_to _('Start your free trial'), new_trial_path(glm_source: glm_source, glm_content: 'gold-callout'), target: '_blank', rel: 'noopener noreferrer', data: { track_action: 'click_button', track_label: 'start_your_trial', track_property: banner_title }, variant: :confirm + %p= _('Get access to all Ultimate and GitLab Duo AI-powered features, free for 60 days. No credit card required.') diff --git a/ee/spec/helpers/ee/users/callouts_helper_spec.rb b/ee/spec/helpers/ee/users/callouts_helper_spec.rb index b1844da8dac6c3c162fafd4813b121d571990698..b9a618df4640ba7f21e7ba1f98888bfda5197009 100644 --- a/ee/spec/helpers/ee/users/callouts_helper_spec.rb +++ b/ee/spec/helpers/ee/users/callouts_helper_spec.rb @@ -7,49 +7,74 @@ using RSpec::Parameterized::TableSyntax describe '#render_dashboard_ultimate_trial', :saas do - let_it_be(:namespace) { create(:namespace) } - let_it_be(:ultimate_plan) { create(:ultimate_plan) } - - let(:user) { namespace.owner } - - where(:owns_group_without_trial?, :show_ultimate_trial?, :user_default_dashboard?, :has_no_trial_or_paid_plan?, :should_render?) do - true | true | true | true | true - true | true | true | false | false - true | true | false | true | false - true | false | true | true | false - true | true | false | false | false - true | false | false | true | false - true | false | true | false | false - true | false | false | false | false - false | true | true | true | false - false | true | true | false | false - false | true | false | true | false - false | false | true | true | false - false | true | false | false | false - false | false | false | true | false - false | false | true | false | false - false | false | false | false | false + let_it_be(:namespace) { build_stubbed(:namespace) } + let_it_be(:user) { namespace.owner } + + let(:show_ultimate_trial?) { true } + let(:user_default_dashboard?) { true } + let(:owns_paid_namespace?) { false } + let(:owns_group_without_trial?) { true } + let(:duo_enterprise_trials_enabled?) { true } + + let(:render) { helper.render_dashboard_ultimate_trial(user) } + + before do + allow(helper).to receive(:show_ultimate_trial?).with(user, described_class::ULTIMATE_TRIAL).and_return(show_ultimate_trial?) + allow(helper).to receive(:user_default_dashboard?).with(user).and_return(user_default_dashboard?) + allow(user).to receive(:owns_paid_namespace?).and_return(owns_paid_namespace?) + allow(user).to receive(:owns_group_without_trial?).and_return(owns_group_without_trial?) + stub_feature_flags(duo_enterprise_trials: duo_enterprise_trials_enabled?) end - with_them do - before do - allow(helper).to receive(:show_ultimate_trial?) { show_ultimate_trial? } - allow(helper).to receive(:user_default_dashboard?) { user_default_dashboard? } - allow(user).to receive(:owns_group_without_trial?) { owns_group_without_trial? } + context 'when all conditions are met' do + it 'renders the ultimate_with_enterprise_trial_callout_content' do + expect(helper).to receive(:render).with('shared/ultimate_with_enterprise_trial_callout_content') + render + end + end - unless has_no_trial_or_paid_plan? - create(:gitlab_subscription, hosted_plan: ultimate_plan, namespace: namespace) - end + context 'when duo_enterprise_trials feature flag is disabled' do + let(:duo_enterprise_trials_enabled?) { false } + + it 'renders the ultimate_trial_callout_content' do + expect(helper).to receive(:render).with('shared/ultimate_trial_callout_content') + render end + end - it do - if should_render? - expect(helper).to receive(:render).with('shared/ultimate_trial_callout_content') - else - expect(helper).not_to receive(:render) - end + context 'when show_ultimate_trial? is false' do + let(:show_ultimate_trial?) { false } + + it 'does not render any content' do + expect(helper).not_to receive(:render) + render + end + end + + context 'when user_default_dashboard? is false' do + let(:user_default_dashboard?) { false } + + it 'does not render any content' do + expect(helper).not_to receive(:render) + render + end + end + + context 'when user owns a paid namespace' do + let(:owns_paid_namespace?) { true } + + it 'does not render any content' do + expect(helper).not_to receive(:render) + render + end + end + + context 'when user does not own a group without trial' do + let(:owns_group_without_trial?) { false } - helper.render_dashboard_ultimate_trial(user) + it 'does not render any content' do + expect(helper).not_to receive(:render) + render end end end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 0fb3f35065ba80d8d7c43653a03c232ca5917c83..155a09666049f97cf337700f303740801ec2e4c0 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -23773,6 +23773,9 @@ msgstr "" msgid "Free Trial of GitLab.com Ultimate" msgstr "" +msgid "Free Ultimate Trial with GitLab Duo Enterprise" +msgstr "" + msgid "Free groups are limited to %{free_user_limit} member and the remaining members will get a status of over-limit and lose access to the group." msgid_plural "Free groups are limited to %{free_user_limit} members and the remaining members will get a status of over-limit and lose access to the group." msgstr[0] "" @@ -24436,6 +24439,9 @@ msgstr "" msgid "Get a support subscription" msgstr "" +msgid "Get access to all Ultimate and GitLab Duo AI-powered features, free for 60 days. No credit card required." +msgstr "" + msgid "Get free trial" msgstr ""