Commit b7b26416 authored by Alper Akgun's avatar Alper Akgun

Group namespace billing hand raise test improvement

parent 394460bd
...@@ -63,65 +63,71 @@ RSpec.describe 'Billing plan pages', :feature, :js do ...@@ -63,65 +63,71 @@ RSpec.describe 'Billing plan pages', :feature, :js do
end end
end end
shared_examples 'can contact sales' do shared_examples 'can not contact sales' do
before do before do
visit page_path visit page_path
end end
it 'displays the in-app hand raise lead', :aggregate_failures do it 'does not render in-app hand raise lead' do
if namespace.group_namespace? expect(page).to have_selector(".js-hand-raise-lead-button[data-namespace-id='#{namespace.id}'][data-user-name='#{user.username}']", visible: false)
form_data = { end
first_name: user.first_name, end
last_name: user.last_name,
phone_number: '+1 23 456-78-90',
company_size: '1 - 99',
company_name: user.organization,
country: { id: 'US', name: 'United States of America' },
state: { id: 'CA', name: 'California' }
}
hand_raise_lead_params = {
"first_name" => form_data[:first_name],
"last_name" => form_data[:last_name],
"company_name" => form_data[:company_name],
"company_size" => form_data[:company_size].delete(' '),
"phone_number" => form_data[:phone_number],
"country" => form_data.dig(:country, :id),
"state" => form_data.dig(:state, :id),
"namespace_id" => namespace.id,
"comment" => '',
"glm_content" => 'billing-group',
"work_email" => user.email,
"uid" => user.id,
"setup_for_company" => user.setup_for_company,
"provider" => "gitlab",
"glm_source" => 'gitlab.com'
}
lead_params = ActionController::Parameters.new(hand_raise_lead_params).permit! shared_examples 'can contact sales' do
before do
visit page_path
end
expect_next_instance_of(GitlabSubscriptions::CreateHandRaiseLeadService) do |service| it 'displays the in-app hand raise lead', :aggregate_failures do
expect(service).to receive(:execute).with(lead_params).and_return(double('lead', success?: true )) form_data = {
end first_name: user.first_name,
last_name: user.last_name,
phone_number: '+1 23 456-78-90',
company_size: '1 - 99',
company_name: user.organization,
country: { id: 'US', name: 'United States of America' },
state: { id: 'CA', name: 'California' }
}
hand_raise_lead_params = {
"first_name" => form_data[:first_name],
"last_name" => form_data[:last_name],
"company_name" => form_data[:company_name],
"company_size" => form_data[:company_size].delete(' '),
"phone_number" => form_data[:phone_number],
"country" => form_data.dig(:country, :id),
"state" => form_data.dig(:state, :id),
"namespace_id" => namespace.id,
"comment" => '',
"glm_content" => 'billing-group',
"work_email" => user.email,
"uid" => user.id,
"setup_for_company" => user.setup_for_company,
"provider" => "gitlab",
"glm_source" => 'gitlab.com'
}
lead_params = ActionController::Parameters.new(hand_raise_lead_params).permit!
expect_next_instance_of(GitlabSubscriptions::CreateHandRaiseLeadService) do |service|
expect(service).to receive(:execute).with(lead_params).and_return(double('lead', success?: true ))
end
page.within('[data-testid="plan-card-premium"]') do page.within('[data-testid="plan-card-premium"]') do
click_button 'Contact sales' click_button 'Contact sales'
end end
expect(page).to have_content('Contact our Sales team') expect(page).to have_content('Contact our Sales team')
expect(page).to have_field('First Name', with: form_data[:first_name]) expect(page).to have_field('First Name', with: form_data[:first_name])
expect(page).to have_field('Last Name', with: form_data[:last_name]) expect(page).to have_field('Last Name', with: form_data[:last_name])
expect(page).to have_field('Company Name', with: form_data[:company_name]) expect(page).to have_field('Company Name', with: form_data[:company_name])
page.within('[data-testid="hand-raise-lead-modal"]') do page.within('[data-testid="hand-raise-lead-modal"]') do
select form_data[:company_size], from: 'company-size' select form_data[:company_size], from: 'company-size'
fill_in 'phone-number', with: form_data[:phone_number] fill_in 'phone-number', with: form_data[:phone_number]
select form_data.dig(:country, :name), from: 'country' select form_data.dig(:country, :name), from: 'country'
select form_data.dig(:state, :name), from: 'state' select form_data.dig(:state, :name), from: 'state'
click_button 'Submit information' click_button 'Submit information'
end
else
expect(page).to have_selector(".js-hand-raise-lead-button[data-namespace-id='#{namespace.id}'][data-user-name='#{user.username}']", visible: false)
end end
end end
end end
...@@ -293,7 +299,7 @@ RSpec.describe 'Billing plan pages', :feature, :js do ...@@ -293,7 +299,7 @@ RSpec.describe 'Billing plan pages', :feature, :js 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 'can not contact sales'
it_behaves_like 'plan with subscription table' it_behaves_like 'plan with subscription table'
context 'when hide_deprecated_billing_plans is active' do context 'when hide_deprecated_billing_plans is active' do
...@@ -327,7 +333,7 @@ RSpec.describe 'Billing plan pages', :feature, :js do ...@@ -327,7 +333,7 @@ RSpec.describe 'Billing plan pages', :feature, :js 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 'can not contact sales'
it_behaves_like 'plan with subscription table' it_behaves_like 'plan with subscription table'
it_behaves_like 'does not display EoA banner' it_behaves_like 'does not display EoA banner'
end end
...@@ -386,7 +392,7 @@ RSpec.describe 'Billing plan pages', :feature, :js do ...@@ -386,7 +392,7 @@ RSpec.describe 'Billing plan pages', :feature, :js 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 'can not contact sales'
end end
context 'on ultimate plan' do context 'on ultimate plan' do
......
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