Commit 5a8bfd9f authored by Dallas Reedy's avatar Dallas Reedy Committed by Savas Vedova

Promote the "display active trial status" experiment

parent 807fd6a7
......@@ -2,10 +2,6 @@
- root_group = group.root_ancestor
- return unless show_trial_status_widget?(root_group)
-# For the current Growth::Conversion experiment
- record_experiment_group(:show_trial_status_in_sidebar, root_group)
- return unless experiment_enabled?(:show_trial_status_in_sidebar, subject: root_group)
= nav_link do
#js-trial-status-widget{ data: trial_status_widget_data_attrs(root_group) }
#js-trial-status-popover{ data: trial_status_popover_data_attrs(root_group) }
---
name: show_trial_status_in_sidebar_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/50090
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/281019
milestone: '13.8'
type: experiment
group: group::conversion
default_enabled: false
......@@ -15,12 +15,17 @@ RSpec.describe 'Billing plan pages', :feature, :js do
let(:plans_data) { billing_plans_data }
before do
stub_application_setting(check_namespace_plan: true)
stub_feature_flags(show_billing_eoa_banner: true)
stub_feature_flags(hide_deprecated_billing_plans: false)
stub_billing_plans(nil)
stub_billing_plans(namespace.id, plan.name, plans_data.to_json)
stub_eoa_eligibility_request(namespace.id)
stub_application_setting(check_namespace_plan: true)
allow(Gitlab).to receive(:com?) { true }
sign_in(user)
end
......@@ -412,8 +417,11 @@ RSpec.describe 'Billing plan pages', :feature, :js do
let(:plan) { free_plan }
let!(:subscription) do
create(:gitlab_subscription, namespace: namespace, hosted_plan: premium_plan,
trial: true, trial_ends_on: Date.current.tomorrow, seats: 15)
create(:gitlab_subscription, :active_trial,
namespace: namespace,
hosted_plan: premium_plan,
seats: 15
)
end
before do
......
......@@ -23,6 +23,7 @@ RSpec.describe 'Billings > Extend / Reactivate Trial', :js do
allow(Gitlab).to receive(:com?).and_return(true)
stub_ee_application_setting(should_check_namespace_plan: true)
stub_feature_flags(allow_extend_reactivate_trial: true)
stub_billing_plans(nil)
stub_full_request("#{EE::SUBSCRIPTIONS_URL}/gitlab_plans?plan=#{plan.name}&namespace_id=#{group.id}")
.to_return(status: 200, body: plans_data.to_json)
stub_full_request("#{EE::SUBSCRIPTIONS_URL}/trials/extend_reactivate_trial", method: :put)
......
......@@ -3,37 +3,40 @@
require 'spec_helper'
RSpec.describe 'Show trial banner', :js do
include StubRequests
include SubscriptionPortalHelpers
let!(:user) { create(:user) }
let!(:group) { create(:group) }
let!(:ultimate_plan) { create(:ultimate_plan) }
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let(:ultimate_plan) { create(:ultimate_plan) }
before do
stub_application_setting(check_namespace_plan: true)
allow(Gitlab).to receive(:com?).and_return(true).at_least(:once)
stub_billing_plans(namespace_id)
group.add_owner(user)
create(:gitlab_subscription, namespace: user.namespace, hosted_plan: ultimate_plan, trial: true, trial_ends_on: Date.current + 1.month)
create(:gitlab_subscription, namespace: group, hosted_plan: ultimate_plan, trial: true, trial_ends_on: Date.current + 1.month)
stub_billing_plans(nil)
gitlab_sign_in(user)
sign_in(user)
end
context "when user's trial is active" do
let(:namespace_id) { user.namespace_id }
before do
create(:gitlab_subscription, :active_trial, namespace: user.namespace, hosted_plan: ultimate_plan)
stub_billing_plans(user.namespace_id)
end
it 'renders congratulations banner for user in profile billing page' do
visit profile_billings_path + '?trial=true'
visit profile_billings_path(trial: true)
expect(page).to have_content('Congratulations, your free trial is activated.')
end
end
context "when group's trial is active" do
let(:namespace_id) { group.id }
before do
group.add_owner(user)
create(:gitlab_subscription, :active_trial, namespace: group, hosted_plan: ultimate_plan)
stub_billing_plans(group.id)
end
it 'renders congratulations banner for group in group details page' do
visit group_path(group, trial: true)
......
......@@ -3,75 +3,37 @@
require 'spec_helper'
RSpec.describe 'layouts/nav/sidebar/_group' do
let_it_be_with_refind(:group) { create(:group) }
let_it_be(:user) { create(:user) }
before do
assign(:group, group)
allow(view).to receive(:show_trial_status_widget?).and_return(false)
end
let(:group) { create(:group) }
let(:user) { create(:user) }
describe 'trial status widget', :aggregate_failures do
using RSpec::Parameterized::TableSyntax
let(:experiment_key) { :show_trial_status_in_sidebar }
let(:show_widget) { false }
let(:experiment_enabled) { false }
before do
allow(view).to receive(:show_trial_status_widget?).and_return(show_widget)
allow(view).to receive(:experiment_enabled?).with(experiment_key, subject: group).and_return(experiment_enabled)
allow(view).to receive(:record_experiment_group)
allow(view).to receive(:trial_status_widget_data_attrs)
allow(view).to receive(:trial_status_popover_data_attrs)
render
end
subject do
render
rendered
end
shared_examples 'does not render the widget & popover' do
it 'does not render' do
context 'when the widget should not be shown' do
it 'does not render the widget & popover' do
is_expected.not_to have_selector '#js-trial-status-widget'
is_expected.not_to have_selector '#js-trial-status-popover'
end
end
shared_examples 'renders the widget & popover' do
it 'renders both the widget & popover component initialization elements' do
is_expected.to have_selector '#js-trial-status-widget'
is_expected.to have_selector '#js-trial-status-popover'
end
end
shared_examples 'does record experiment subject' do
it 'records the group as an experiment subject' do
expect(view).to receive(:record_experiment_group).with(experiment_key, group)
subject
end
end
shared_examples 'does not record experiment subject' do
it 'does not record the group as an experiment subject' do
expect(view).not_to receive(:record_experiment_group)
subject
context 'when the widget should be shown' do
before do
allow(view).to receive(:show_trial_status_widget?).and_return(true)
allow(view).to receive(:trial_status_widget_data_attrs).and_return({ foo: 'bar' })
allow(view).to receive(:trial_status_popover_data_attrs).and_return({ baz: 'quux' })
end
end
where :show_widget, :experiment_enabled, :examples_to_include do
true | true | ['does record experiment subject', 'renders the widget & popover']
true | false | ['does record experiment subject', 'does not render the widget & popover']
false | true | ['does not record experiment subject', 'does not render the widget & popover']
false | false | ['does not record experiment subject', 'does not render the widget & popover']
end
with_them do
params[:examples_to_include].each do |example_set|
include_examples(example_set)
it 'renders both the widget & popover component initialization elements' do
is_expected.to have_selector '#js-trial-status-widget[data-foo="bar"]'
is_expected.to have_selector '#js-trial-status-popover[data-baz="quux"]'
end
end
end
......
......@@ -40,10 +40,6 @@ module Gitlab
},
invite_members_new_dropdown: {
tracking_category: 'Growth::Expansion::Experiment::InviteMembersNewDropdown'
},
show_trial_status_in_sidebar: {
tracking_category: 'Growth::Conversion::Experiment::ShowTrialStatusInSidebar',
rollout_strategy: :group
}
}.freeze
......
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