Commit 89710c5b authored by Shinya Maeda's avatar Shinya Maeda

Merge branch '219944-eng-mvc-add-contact-sales-option-in-app' into 'master'

Create the first iteration of the “Contact sales” buttons experiment

See merge request gitlab-org/gitlab!38508
parents d429e468 e04e9f32
...@@ -194,6 +194,10 @@ module ApplicationHelper ...@@ -194,6 +194,10 @@ module ApplicationHelper
'https://' + promo_host 'https://' + promo_host
end end
def contact_sales_url
promo_url + '/sales'
end
def support_url def support_url
Gitlab::CurrentSettings.current_application_settings.help_page_support_url.presence || promo_url + '/getting-help/' Gitlab::CurrentSettings.current_application_settings.help_page_support_url.presence || promo_url + '/getting-help/'
end end
......
...@@ -56,6 +56,11 @@ module BillingPlansHelper ...@@ -56,6 +56,11 @@ module BillingPlansHelper
end end
end end
def show_contact_sales_button?(purchase_link_action)
experiment_enabled?(:contact_sales_btn_in_app) &&
purchase_link_action == 'upgrade'
end
def plan_feature_short_list(plan) def plan_feature_short_list(plan)
return [] unless plan.features return [] unless plan.features
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
- if purchase_link - if purchase_link
.card-footer.p-3 .card-footer.p-3
.float-right{ class: ("invisible" unless purchase_link.action == 'upgrade' || is_current_plan) } .float-right{ class: ("invisible" unless purchase_link.action == 'upgrade' || is_current_plan) }
- if show_contact_sales_button?(purchase_link.action)
= link_to s_('BillingPlan|Contact sales'), "#{contact_sales_url}?test=inappcontactsales#{plan.code}", class: "btn btn-success btn-inverted"
- upgrade_button_class = "disabled" if is_current_plan && !namespace.trial_active? - upgrade_button_class = "disabled" if is_current_plan && !namespace.trial_active?
- cta_class = '-new' if use_new_purchase_flow?(namespace) - cta_class = '-new' if use_new_purchase_flow?(namespace)
= link_to s_('BillingPlan|Upgrade'), plan_purchase_or_upgrade_url(namespace, plan, current_plan), class: "btn btn-success #{upgrade_button_class} billing-cta-purchase#{cta_class}" = link_to s_('BillingPlan|Upgrade'), plan_purchase_or_upgrade_url(namespace, plan, current_plan), class: "btn btn-success #{upgrade_button_class} billing-cta-purchase#{cta_class}"
...@@ -18,6 +18,7 @@ RSpec.describe 'Billing plan pages', :feature do ...@@ -18,6 +18,7 @@ RSpec.describe 'Billing plan pages', :feature do
end end
before do before do
stub_experiment_for_user(contact_sales_btn_in_app: true)
stub_full_request("#{EE::SUBSCRIPTIONS_URL}/gitlab_plans?plan=#{plan.name}") stub_full_request("#{EE::SUBSCRIPTIONS_URL}/gitlab_plans?plan=#{plan.name}")
.to_return(status: 200, body: plans_data.to_json) .to_return(status: 200, body: plans_data.to_json)
stub_application_setting(check_namespace_plan: true) stub_application_setting(check_namespace_plan: true)
...@@ -43,6 +44,20 @@ RSpec.describe 'Billing plan pages', :feature do ...@@ -43,6 +44,20 @@ RSpec.describe 'Billing plan pages', :feature do
end end
end end
shared_examples 'can contact sales' do
before do
visit page_path
end
it 'displays the contact sales link' do
# see ApplicationHelper#contact_sales_url
contact_sales_url = 'https://about.gitlab.com/sales'
page.within('.content') do
expect(page).to have_link('Contact sales', href: %r{#{contact_sales_url}\?test=inappcontactsales(bronze|silver|gold)})
end
end
end
shared_examples 'non-upgradable plan' do shared_examples 'non-upgradable plan' do
before do before do
visit page_path visit page_path
...@@ -141,6 +156,7 @@ RSpec.describe 'Billing plan pages', :feature do ...@@ -141,6 +156,7 @@ RSpec.describe 'Billing plan pages', :feature do
end end
it_behaves_like 'plan with subscription table' it_behaves_like 'plan with subscription table'
it_behaves_like 'can contact sales'
end end
context 'on bronze plan' do context 'on bronze plan' do
...@@ -153,6 +169,7 @@ RSpec.describe 'Billing plan pages', :feature do ...@@ -153,6 +169,7 @@ RSpec.describe 'Billing plan pages', :feature do
it_behaves_like 'plan with header' it_behaves_like 'plan with header'
it_behaves_like 'downgradable plan' it_behaves_like 'downgradable plan'
it_behaves_like 'upgradable plan' it_behaves_like 'upgradable plan'
it_behaves_like 'can contact sales'
it_behaves_like 'plan with subscription table' it_behaves_like 'plan with subscription table'
end end
...@@ -166,6 +183,7 @@ RSpec.describe 'Billing plan pages', :feature do ...@@ -166,6 +183,7 @@ RSpec.describe 'Billing plan pages', :feature do
it_behaves_like 'plan with header' it_behaves_like 'plan with header'
it_behaves_like 'downgradable plan' it_behaves_like 'downgradable plan'
it_behaves_like 'upgradable plan' it_behaves_like 'upgradable plan'
it_behaves_like 'can contact sales'
it_behaves_like 'plan with subscription table' it_behaves_like 'plan with subscription table'
end end
...@@ -231,6 +249,8 @@ RSpec.describe 'Billing plan pages', :feature do ...@@ -231,6 +249,8 @@ RSpec.describe 'Billing plan pages', :feature do
end end
end end
end end
it_behaves_like 'can contact sales'
end end
context 'on bronze plan' do context 'on bronze plan' do
...@@ -243,6 +263,7 @@ RSpec.describe 'Billing plan pages', :feature do ...@@ -243,6 +263,7 @@ RSpec.describe 'Billing plan pages', :feature do
it_behaves_like 'plan with header' it_behaves_like 'plan with header'
it_behaves_like 'downgradable plan' it_behaves_like 'downgradable plan'
it_behaves_like 'upgradable plan' it_behaves_like 'upgradable plan'
it_behaves_like 'can contact sales'
end end
context 'on gold plan' do context 'on gold plan' do
...@@ -319,6 +340,8 @@ RSpec.describe 'Billing plan pages', :feature do ...@@ -319,6 +340,8 @@ RSpec.describe 'Billing plan pages', :feature do
it 'displays subscription table', :js do it 'displays subscription table', :js do
expect(page).to have_selector('.js-subscription-table') expect(page).to have_selector('.js-subscription-table')
end end
it_behaves_like 'can contact sales'
end end
end end
end end
......
...@@ -87,4 +87,27 @@ RSpec.describe BillingPlansHelper do ...@@ -87,4 +87,27 @@ RSpec.describe BillingPlansHelper do
end end
end end
end end
describe '#show_contact_sales_button?' do
using RSpec::Parameterized::TableSyntax
where(:experiment_enabled, :link_action, :result) do
true | 'downgrade' | false
true | 'current' | false
true | 'upgrade' | true
false | 'downgrade' | false
false | 'current' | false
false | 'upgrade' | false
end
with_them do
before do
allow(helper).to receive(:experiment_enabled?).with(:contact_sales_btn_in_app).and_return(experiment_enabled)
end
subject { helper.show_contact_sales_button?(link_action) }
it { is_expected.to eq(result) }
end
end
end end
...@@ -56,6 +56,9 @@ module Gitlab ...@@ -56,6 +56,9 @@ module Gitlab
}, },
terms_opt_in: { terms_opt_in: {
tracking_category: 'Growth::Acquisition::Experiment::TermsOptIn' tracking_category: 'Growth::Acquisition::Experiment::TermsOptIn'
},
contact_sales_btn_in_app: {
tracking_category: 'Growth::Conversion::Experiment::ContactSalesInApp'
} }
}.freeze }.freeze
......
...@@ -3824,6 +3824,9 @@ msgstr "" ...@@ -3824,6 +3824,9 @@ msgstr ""
msgid "BillingPlans|per user" msgid "BillingPlans|per user"
msgstr "" msgstr ""
msgid "BillingPlan|Contact sales"
msgstr ""
msgid "BillingPlan|Upgrade" msgid "BillingPlan|Upgrade"
msgstr "" msgstr ""
......
...@@ -168,6 +168,19 @@ RSpec.describe ApplicationHelper do ...@@ -168,6 +168,19 @@ RSpec.describe ApplicationHelper do
it { expect(helper.active_when(false)).to eq(nil) } it { expect(helper.active_when(false)).to eq(nil) }
end end
describe '#contact_sales_url' do
subject { helper.contact_sales_url }
it 'passes a smoke test' do
is_expected.to eq('https://about.gitlab.com/sales')
end
it 'changes if promo_url changes' do
allow(helper).to receive(:promo_url).and_return('https://somewhere.else')
is_expected.to eq('https://somewhere.else/sales')
end
end
describe '#support_url' do describe '#support_url' do
context 'when alternate support url is specified' do context 'when alternate support url is specified' do
let(:alternate_url) { 'http://company.example.com/getting-help' } let(:alternate_url) { 'http://company.example.com/getting-help' }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment