Commit 4a9cf749 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch '335439-track-trial-reassurance-experiment-through-onboarding-flow' into 'master'

Track trial reassurance experiment in the trial_onboarding_flow path

See merge request gitlab-org/gitlab!69127
parents a1faefe7 ecb287f4
...@@ -10,6 +10,8 @@ module Registrations ...@@ -10,6 +10,8 @@ module Registrations
feature_category :onboarding feature_category :onboarding
def new def new
experiment(:trial_registration_with_reassurance, actor: current_user)
.track(:render, label: 'registrations:groups:new', user: current_user)
@group = Group.new(visibility_level: helpers.default_group_visibility) @group = Group.new(visibility_level: helpers.default_group_visibility)
end end
...@@ -62,6 +64,13 @@ module Registrations ...@@ -62,6 +64,13 @@ module Registrations
record_experiment_user(:remove_known_trial_form_fields_welcoming, namespace_id: @group.id) record_experiment_user(:remove_known_trial_form_fields_welcoming, namespace_id: @group.id)
record_experiment_conversion_event(:remove_known_trial_form_fields_welcoming) record_experiment_conversion_event(:remove_known_trial_form_fields_welcoming)
experiment(:trial_registration_with_reassurance, actor: current_user).track(
:apply_trial,
label: 'registrations:groups:create',
namespace: @group,
user: current_user
)
redirect_to new_users_sign_up_project_path(namespace_id: @group.id, trial: helpers.in_trial_during_signup_flow?, trial_onboarding_flow: true) redirect_to new_users_sign_up_project_path(namespace_id: @group.id, trial: helpers.in_trial_during_signup_flow?, trial_onboarding_flow: true)
else else
render action: :new render action: :new
......
...@@ -30,7 +30,7 @@ RSpec.describe Registrations::GroupsController do ...@@ -30,7 +30,7 @@ RSpec.describe Registrations::GroupsController do
describe 'GET #new', :aggregate_failures do describe 'GET #new', :aggregate_failures do
let(:dev_env_or_com) { true } let(:dev_env_or_com) { true }
subject { get :new } subject(:get_new) { get :new }
context 'with an unauthenticated user' do context 'with an unauthenticated user' do
it { is_expected.to have_gitlab_http_status(:redirect) } it { is_expected.to have_gitlab_http_status(:redirect) }
...@@ -48,12 +48,28 @@ RSpec.describe Registrations::GroupsController do ...@@ -48,12 +48,28 @@ RSpec.describe Registrations::GroupsController do
it { is_expected.to render_template(:new) } it { is_expected.to render_template(:new) }
it 'assigns the group variable to a new Group with the default group visibility' do it 'assigns the group variable to a new Group with the default group visibility' do
subject get_new
expect(assigns(:group)).to be_a_new(Group) expect(assigns(:group)).to be_a_new(Group)
expect(assigns(:group).visibility_level).to eq(Gitlab::CurrentSettings.default_group_visibility) expect(assigns(:group).visibility_level).to eq(Gitlab::CurrentSettings.default_group_visibility)
end end
context 'when the trial_registration_with_reassurance experiment is active', :experiment do
before do
stub_experiments(trial_registration_with_reassurance: :control)
end
it 'tracks a "render" event' do
expect(experiment(:trial_registration_with_reassurance)).to track(
:render,
user: user,
label: 'registrations:groups:new'
).with_context(actor: user).on_next_instance
get_new
end
end
context 'user without the ability to create a group' do context 'user without the ability to create a group' do
let(:user) { create(:user, can_create_group: false) } let(:user) { create(:user, can_create_group: false) }
...@@ -82,7 +98,7 @@ RSpec.describe Registrations::GroupsController do ...@@ -82,7 +98,7 @@ RSpec.describe Registrations::GroupsController do
{ group: group_params }.merge(glm_params).merge(trial_form_params).merge(trial_onboarding_flow_params) { group: group_params }.merge(glm_params).merge(trial_form_params).merge(trial_onboarding_flow_params)
end end
subject { post :create, params: params } subject(:post_create) { post :create, params: params }
context 'with an unauthenticated user' do context 'with an unauthenticated user' do
it { is_expected.to have_gitlab_http_status(:redirect) } it { is_expected.to have_gitlab_http_status(:redirect) }
...@@ -100,7 +116,7 @@ RSpec.describe Registrations::GroupsController do ...@@ -100,7 +116,7 @@ RSpec.describe Registrations::GroupsController do
context 'when group can be created' do context 'when group can be created' do
it 'creates a group' do it 'creates a group' do
expect { subject }.to change { Group.count }.by(1) expect { post_create }.to change { Group.count }.by(1)
end end
it 'tracks an event for the jobs_to_be_done experiment', :experiment do it 'tracks an event for the jobs_to_be_done experiment', :experiment do
...@@ -111,7 +127,7 @@ RSpec.describe Registrations::GroupsController do ...@@ -111,7 +127,7 @@ RSpec.describe Registrations::GroupsController do
.for(:candidate) .for(:candidate)
.with_context(user: user) .with_context(user: user)
subject post_create
end end
context 'when in trial onboarding - apply_trial_for_trial_onboarding_flow' do context 'when in trial onboarding - apply_trial_for_trial_onboarding_flow' do
...@@ -150,6 +166,19 @@ RSpec.describe Registrations::GroupsController do ...@@ -150,6 +166,19 @@ RSpec.describe Registrations::GroupsController do
context 'with redirection to projects page' do context 'with redirection to projects page' do
it { is_expected.to redirect_to(new_users_sign_up_project_path(namespace_id: group.id, trial: false, trial_onboarding_flow: true)) } it { is_expected.to redirect_to(new_users_sign_up_project_path(namespace_id: group.id, trial: false, trial_onboarding_flow: true)) }
end end
it 'tracks an event for the trial_registration_with_reassurance experiment', :experiment do
stub_experiments(trial_registration_with_reassurance: :control)
expect(experiment(:trial_registration_with_reassurance)).to track(
:apply_trial,
user: user,
namespace: group,
label: 'registrations:groups:create'
).with_context(actor: user).on_next_instance
post_create
end
end end
context 'when failing to apply trial' do context 'when failing to apply trial' do
...@@ -238,7 +267,7 @@ RSpec.describe Registrations::GroupsController do ...@@ -238,7 +267,7 @@ RSpec.describe Registrations::GroupsController do
expect(e).to receive(:track).with(:create_trial, namespace: an_instance_of(Group), user: user, label: 'registrations_groups_controller') expect(e).to receive(:track).with(:create_trial, namespace: an_instance_of(Group), user: user, label: 'registrations_groups_controller')
end end
subject post_create
end end
end end
...@@ -264,14 +293,14 @@ RSpec.describe Registrations::GroupsController do ...@@ -264,14 +293,14 @@ RSpec.describe Registrations::GroupsController do
expect(service).to receive(:execute).and_return(group) expect(service).to receive(:execute).and_return(group)
end end
expect(subject).to redirect_to(new_users_sign_up_project_path(namespace_id: group.id, trial: false)) expect(post_create).to redirect_to(new_users_sign_up_project_path(namespace_id: group.id, trial: false))
end end
it 'does not call trial creation methods' do it 'does not call trial creation methods' do
expect(controller).not_to receive(:create_lead) expect(controller).not_to receive(:create_lead)
expect(controller).not_to receive(:apply_trial) expect(controller).not_to receive(:apply_trial)
subject post_create
end end
it 'selectively tracks for the force_company_trial experiment', :experiment do it 'selectively tracks for the force_company_trial experiment', :experiment do
...@@ -281,7 +310,7 @@ RSpec.describe Registrations::GroupsController do ...@@ -281,7 +310,7 @@ RSpec.describe Registrations::GroupsController do
expect(e).not_to receive(:track).with(:create_trial, namespace: an_instance_of(Group), user: user) expect(e).not_to receive(:track).with(:create_trial, namespace: an_instance_of(Group), user: user)
end end
subject post_create
end end
end end
end end
...@@ -292,14 +321,14 @@ RSpec.describe Registrations::GroupsController do ...@@ -292,14 +321,14 @@ RSpec.describe Registrations::GroupsController do
let(:group_params) { { name: '', path: '' } } let(:group_params) { { name: '', path: '' } }
it 'does not create a group', :aggregate_failures do it 'does not create a group', :aggregate_failures do
expect { subject }.not_to change { Group.count } expect { post_create }.not_to change { Group.count }
expect(assigns(:group).errors).not_to be_blank expect(assigns(:group).errors).not_to be_blank
end end
it 'does not call call the successful flow' do it 'does not call call the successful flow' do
expect(controller).not_to receive(:create_successful_flow) expect(controller).not_to receive(:create_successful_flow)
subject post_create
end end
it { is_expected.to have_gitlab_http_status(:ok) } it { is_expected.to have_gitlab_http_status(:ok) }
......
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