Commit e5c44a3c authored by Nick Thomas's avatar Nick Thomas

Merge branch '328710-experiment-cleanup-optionally-start-a-trial-during-free-signup' into 'master'

Experiment cleanup: Optionally start a trial during free signup [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!62174
parents 78412844 c6ed9500
......@@ -2,7 +2,6 @@
module Registrations
class GroupsController < ApplicationController
include GroupInviteMembers
include ::Gitlab::Utils::StrongMemoize
layout 'checkout'
......@@ -13,7 +12,6 @@ module Registrations
feature_category :onboarding
def new
record_experiment_user(:trial_during_signup)
record_experiment_user(:learn_gitlab_a, learn_gitlab_context)
record_experiment_user(:learn_gitlab_b, learn_gitlab_context)
@group = Group.new(visibility_level: helpers.default_group_visibility)
......@@ -66,62 +64,37 @@ module Registrations
record_experiment_conversion_event(:remove_known_trial_form_fields)
record_experiment_conversion_event(:trial_onboarding_issues)
experiment(:registrations_group_invite, actor: current_user) do |experiment_instance|
experiment_instance.use { redirect_to new_users_sign_up_project_path(namespace_id: @group.id, trial: helpers.in_trial_during_signup_flow?, trial_onboarding_flow: true) } # control
experiment_instance.try(:invite_page) { redirect_to new_users_sign_up_group_invite_path(group_id: @group.id, trial: helpers.in_trial_during_signup_flow?, trial_onboarding_flow: true) } # with separate page
experiment_instance.track(:created, property: @group.id.to_s)
end
registrations_group_invite_flow(trial_onboarding_flow: true)
else
render action: :new
end
end
def registration_onboarding_flow
record_experiment_user(:trial_during_signup, trial_chosen: helpers.in_trial_during_signup_flow?, namespace_id: @group.id)
record_experiment_conversion_event(:learn_gitlab_a, namespace_id: @group.id)
record_experiment_conversion_event(:learn_gitlab_b, namespace_id: @group.id)
if experiment_enabled?(:trial_during_signup)
trial_during_signup_flow
else
experiment(:registrations_group_invite, actor: current_user) do |experiment_instance|
experiment_instance.use { invite_on_create } # control
experiment_instance.try(:invite_page) { redirect_to new_users_sign_up_group_invite_path(group_id: @group.id, trial: helpers.in_trial_during_signup_flow?) } # with separate page
experiment_instance.track(:created, property: @group.id.to_s)
end
end
end
def invite_on_create
invite_members(@group)
redirect_to new_users_sign_up_project_path(namespace_id: @group.id, trial: helpers.in_trial_during_signup_flow?)
create_lead_and_apply_trial_flow
end
def trial_during_signup_flow
def create_lead_and_apply_trial_flow
if helpers.in_trial_during_signup_flow?
create_lead_and_apply_trial_flow
if create_lead && apply_trial
registrations_group_invite_flow
else
experiment(:registrations_group_invite, actor: current_user) do |experiment_instance|
experiment_instance.use { redirect_to new_users_sign_up_project_path(namespace_id: @group.id, trial: helpers.in_trial_during_signup_flow?) } # control
experiment_instance.try(:invite_page) { redirect_to new_users_sign_up_group_invite_path(group_id: @group.id, trial: helpers.in_trial_during_signup_flow?) } # with separate page
experiment_instance.track(:created, property: @group.id.to_s)
render action: :new
end
else
registrations_group_invite_flow
end
end
def create_lead_and_apply_trial_flow
if create_lead && apply_trial
record_experiment_conversion_event(:trial_during_signup)
def registrations_group_invite_flow(options = {})
experiment(:registrations_group_invite, actor: current_user) do |experiment_instance|
experiment_instance.use { redirect_to new_users_sign_up_project_path(namespace_id: @group.id, trial: helpers.in_trial_during_signup_flow?) } # control
experiment_instance.try(:invite_page) { redirect_to new_users_sign_up_group_invite_path(group_id: @group.id, trial: helpers.in_trial_during_signup_flow?) } # with separate page
experiment_instance.use { redirect_to new_users_sign_up_project_path({ namespace_id: @group.id, trial: helpers.in_trial_during_signup_flow? }.merge(options) ) } # control
experiment_instance.try(:invite_page) { redirect_to new_users_sign_up_group_invite_path({ group_id: @group.id, trial: helpers.in_trial_during_signup_flow? }.merge(options)) } # with separate page
experiment_instance.track(:created, property: @group.id.to_s)
end
else
render action: :new
end
end
def create_lead
......
......@@ -41,7 +41,7 @@
.row
.form-group.col-sm-12
= render partial: 'shared/groups/visibility_level', locals: { f: f }
- if !in_trial_onboarding_flow? && experiment_enabled?(:trial_during_signup)
- if !in_trial_onboarding_flow?
= render partial: 'shared/groups/trial_form'
- else
- experiment(:registrations_group_invite, actor: current_user) do |experiment_instance|
......
---
name: trial_during_signup_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45147/
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/251231
milestone: '13.8'
type: experiment
group: group::conversion
default_enabled: false
......@@ -73,7 +73,6 @@ RSpec.describe Registrations::GroupsController do
with_them do
it 'sets the correct context', :aggregate_failures do
expect(controller).to receive(:record_experiment_user).with(:trial_during_signup)
expect(controller).to receive(:record_experiment_user).with(:learn_gitlab_a, context)
expect(controller).to receive(:record_experiment_user).with(:learn_gitlab_b, context)
......@@ -215,18 +214,17 @@ RSpec.describe Registrations::GroupsController do
context 'when not in the trial onboarding - registration_onboarding_flow' do
let_it_be(:group) { create(:group) }
it 'calls the record user trial_during_signup experiment' do
it 'calls the record user for learn gitlab experiment' do
expect_next_instance_of(Groups::CreateService) do |service|
expect(service).to receive(:execute).and_return(group)
end
expect(controller).to receive(:record_experiment_user).with(:trial_during_signup, trial_chosen: false, namespace_id: group.id)
expect(controller).to receive(:record_experiment_conversion_event).with(:learn_gitlab_a, namespace_id: group.id)
expect(controller).to receive(:record_experiment_conversion_event).with(:learn_gitlab_b, namespace_id: group.id)
subject
end
context 'when in experiment group for trial_during_signup - trial_during_signup_flow' do
context 'when trial_during_signup - trial_during_signup_flow' do
let_it_be(:glm_params) { { glm_source: 'gitlab.com', glm_content: 'content' } }
let_it_be(:trial_form_params) do
{
......@@ -273,10 +271,6 @@ RSpec.describe Registrations::GroupsController do
}
end
before do
allow(controller).to receive(:experiment_enabled?).with(:trial_during_signup).and_return(true)
end
context 'when a user chooses a trial - create_lead_and_apply_trial_flow' do
context 'when successfully creating a lead and applying trial' do
before do
......@@ -336,17 +330,15 @@ RSpec.describe Registrations::GroupsController do
context 'when user chooses no trial' do
let_it_be(:trial_form_params) { { trial: 'false' } }
it 'calls the record user trial_during_signup experiment' do
it 'redirects user to the new user signup page' do
expect_next_instance_of(Groups::CreateService) do |service|
expect(service).to receive(:execute).and_return(group)
end
expect(controller).to receive(:record_experiment_user).with(:trial_during_signup, trial_chosen: false, namespace_id: group.id)
expect(subject).to redirect_to(new_users_sign_up_project_path(namespace_id: group.id, trial: false))
end
it 'does not call trial_during_signup experiment methods' do
it 'does not call trial creation methods' do
expect(controller).not_to receive(:create_lead)
expect(controller).not_to receive(:apply_trial)
......@@ -385,42 +377,6 @@ RSpec.describe Registrations::GroupsController do
end
end
end
context 'when not in experiment group for trial_during_signup' do
before do
allow(controller).to receive(:experiment_enabled?).with(:trial_during_signup).and_return(false)
end
it 'tracks experiment as expected', :experiment do
expect_next_instance_of(Groups::CreateService) do |service|
expect(service).to receive(:execute).and_return(group)
end
expect(experiment(:registrations_group_invite))
.to track(:created, { property: group.id.to_s })
.on_next_instance
.with_context(actor: user)
subject
end
context 'when registrations_group_invite invite_page path is taken' do
before do
stub_experiments(registrations_group_invite: :invite_page)
end
it { is_expected.to redirect_to(new_users_sign_up_group_invite_path(group_id: user.groups.last.id, trial: false)) }
end
context 'when registrations_group_invite experiment control path is taken' do
before do
stub_experiments(registrations_group_invite: :control)
end
it { is_expected.to redirect_to(new_users_sign_up_project_path(namespace_id: user.groups.last.id, trial: false)) }
it_behaves_like GroupInviteMembers
end
end
end
end
......
......@@ -6,13 +6,10 @@ RSpec.describe 'User is able to invite members to group during signup', :js, :ex
include Select2Helper
let_it_be(:user) { create(:user) }
let(:trial_during_signup) { true }
let(:path_params) { {} }
before do
allow(Gitlab).to receive(:dev_env_or_com?).and_return(true)
stub_experiment(trial_during_signup: trial_during_signup)
stub_experiment_for_subject(trial_during_signup: trial_during_signup)
stub_experiments(registrations_group_invite: :invite_page)
sign_in(user)
end
......@@ -46,15 +43,11 @@ RSpec.describe 'User is able to invite members to group during signup', :js, :ex
end
end
context 'when trial during signup is not enabled' do
let(:trial_during_signup) { false }
it 'validates group invites are displayed as separate page' do
create_group_through_form
expect_group_invites_page
end
end
context 'when in trial_onboarding_flow' do
let(:path_params) { { trial_onboarding_flow: true } }
......
......@@ -5,12 +5,11 @@ require 'spec_helper'
RSpec.describe 'registrations/group_invites/new' do
let(:group) { build(:group) }
let(:trial_onboarding_flow) { false }
let(:trial_during_signup_flow) { false }
before do
assign(:group, group)
allow(view).to receive(:in_trial_onboarding_flow?).and_return(trial_onboarding_flow)
allow(view).to receive(:in_trial_during_signup_flow?).and_return(trial_during_signup_flow)
allow(view).to receive(:in_trial_during_signup_flow?).and_return(true)
render
end
......@@ -31,8 +30,6 @@ RSpec.describe 'registrations/group_invites/new' do
end
context 'in trial flow' do
let(:trial_during_signup_flow) { true }
it 'show the trial activation' do
expect(rendered).to have_content('Congratulations, your free trial is activated.')
end
......
......@@ -4,14 +4,12 @@ require 'spec_helper'
RSpec.describe 'registrations/groups/new' do
let_it_be(:user) { create(:user) }
let_it_be(:trial_during_signup) { false }
let_it_be(:group) { create(:group) }
let_it_be(:trial_onboarding_flow) { false }
before do
assign(:group, group)
allow(view).to receive(:current_user).and_return(user)
allow(view).to receive(:experiment_enabled?).with(:trial_during_signup).and_return(trial_during_signup)
allow(view).to receive(:in_trial_onboarding_flow?).and_return(trial_onboarding_flow)
render
......@@ -19,14 +17,15 @@ RSpec.describe 'registrations/groups/new' do
subject { rendered }
context 'feature flag trial_during_signup is enabled' do
let_it_be(:trial_during_signup) { true }
it 'shows trial form and hides invite members' do
is_expected.to have_content('Company name')
is_expected.not_to have_selector('.js-invite-members')
end
it 'shows the progress bar' do
expect(rendered).to have_selector('#progress-bar')
end
context 'in trial onboarding' do
let_it_be(:trial_onboarding_flow) { true }
......@@ -34,22 +33,6 @@ RSpec.describe 'registrations/groups/new' do
is_expected.not_to have_content('Company name')
is_expected.to have_selector('.js-invite-members')
end
end
end
context 'feature flag trial_during_signup is disabled' do
it 'hides trial form and shows invite members' do
is_expected.not_to have_content('Company name')
is_expected.to have_selector('.js-invite-members')
end
end
it 'shows the progress bar' do
expect(rendered).to have_selector('#progress-bar')
end
context 'in trial onboarding' do
let_it_be(:trial_onboarding_flow) { true }
it 'hides the progress bar' do
expect(rendered).not_to have_selector('#progress-bar')
......
......@@ -48,9 +48,6 @@ module Gitlab
invite_members_empty_project_version_a: {
tracking_category: 'Growth::Expansion::Experiment::InviteMembersEmptyProjectVersionA'
},
trial_during_signup: {
tracking_category: 'Growth::Conversion::Experiment::TrialDuringSignup'
},
invite_members_new_dropdown: {
tracking_category: 'Growth::Expansion::Experiment::InviteMembersNewDropdown'
},
......
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