diff --git a/.rubocop_todo/capybara/visibility_matcher.yml b/.rubocop_todo/capybara/visibility_matcher.yml index e354dd7196b88390e595f3c6e138872a4ef4c1d8..dce663c1eb98997c8d19df5fea9b577dfe897c81 100644 --- a/.rubocop_todo/capybara/visibility_matcher.yml +++ b/.rubocop_todo/capybara/visibility_matcher.yml @@ -14,7 +14,7 @@ Capybara/VisibilityMatcher: - 'ee/spec/features/projects/requirements_management/requirements_list_spec.rb' - 'ee/spec/features/projects/settings/ee/repository_mirrors_settings_spec.rb' - 'ee/spec/features/promotion_spec.rb' - - 'ee/spec/support/helpers/billing_plans_helpers.rb' + - 'ee/spec/support/helpers/features/billing_plans_helpers.rb' - 'ee/spec/support/shared_examples/features/password_complexity_shared_examples.rb' - 'ee/spec/support/shared_examples/views/issuable_bulk_dropdown_shared_examples.rb' - 'ee/spec/views/registrations/welcome/show.html.haml_spec.rb' diff --git a/app/assets/javascripts/super_sidebar/super_sidebar_bundle.js b/app/assets/javascripts/super_sidebar/super_sidebar_bundle.js index 284f98b867cb0c17f984938a4b122e0f72d9f933..443a7a21dab024b69c87e3bdb8e3a21e929289af 100644 --- a/app/assets/javascripts/super_sidebar/super_sidebar_bundle.js +++ b/app/assets/javascripts/super_sidebar/super_sidebar_bundle.js @@ -45,6 +45,7 @@ const getTrialStatusWidgetData = (sidebarData) => { createHandRaiseLeadPath, trackAction, trackLabel, + productInteraction, } = convertObjectPropsToCamelCase(sidebarData.trial_status_popover_data_attrs); return { @@ -63,7 +64,15 @@ const getTrialStatusWidgetData = (sidebarData) => { trackLabel, trialEndDate: new Date(trialEndDate), trialDiscoverPagePath, - user: { namespaceId, userName, firstName, lastName, companyName, glmContent }, + user: { + namespaceId, + userName, + firstName, + lastName, + companyName, + glmContent, + productInteraction, + }, }; } return { showTrialStatusWidget: false }; diff --git a/ee/app/assets/javascripts/contextual_sidebar/components/trial_status_popover.vue b/ee/app/assets/javascripts/contextual_sidebar/components/trial_status_popover.vue index c46c06f5189c8efc81e957d1625cc5cb038d204b..da4f2e02a4b4c07645016ff73e36e837c8ccfd30 100644 --- a/ee/app/assets/javascripts/contextual_sidebar/components/trial_status_popover.vue +++ b/ee/app/assets/javascripts/contextual_sidebar/components/trial_status_popover.vue @@ -51,6 +51,7 @@ export default { class: 'gl-w-full', buttonTextClasses: 'gl-font-sm', href: '#', + 'data-testid': 'trial-popover-hand-raise-lead-button', }, computed: { isTrialActive() { @@ -139,6 +140,7 @@ export default { :disabled="disabled" :delay="{ hide: 400 } /* eslint-disable-line @gitlab/vue-no-new-non-primitive-in-template */" :css-classes="cssClasses" + data-testid="trial-status-popover" @shown="onShown" > <template #title> @@ -183,6 +185,7 @@ export default { :data-last-name="user.lastName" :data-company-name="user.companyName" :data-glm-content="user.glmContent" + :data-product-interaction="user.productInteraction" :data-track-category="handRaiseLeadBtnTracking.category" :data-track-action="handRaiseLeadBtnTracking.action" :data-track-label="handRaiseLeadBtnTracking.label" diff --git a/ee/app/assets/javascripts/contextual_sidebar/components/trial_status_widget.vue b/ee/app/assets/javascripts/contextual_sidebar/components/trial_status_widget.vue index 121a3a482df53521a5287cb23f83a8b8a584431c..b7cb43d0e36e919281c96b59917b9340760a9473 100644 --- a/ee/app/assets/javascripts/contextual_sidebar/components/trial_status_widget.vue +++ b/ee/app/assets/javascripts/contextual_sidebar/components/trial_status_widget.vue @@ -71,7 +71,7 @@ export default { <template> <gl-link :id="containerId" :title="widgetTitle" :href="widgetLink"> <div - data-testid="widget-menu" + data-testid="trial-widget-menu" class="gl-display-flex gl-flex-direction-column gl-align-items-stretch gl-w-full" @click="onWidgetClick" > diff --git a/ee/app/helpers/ee/groups_helper.rb b/ee/app/helpers/ee/groups_helper.rb index 30359afe2f3496bfec4b079f61f31ff6edd90941..e526dea7e0c1454588fc0122496e39750882a48e 100644 --- a/ee/app/helpers/ee/groups_helper.rb +++ b/ee/app/helpers/ee/groups_helper.rb @@ -140,7 +140,7 @@ def code_suggestions_hand_raise_props(namespace) .merge(track_action: 'click_button', track_label: 'code_suggestions_hand_raise_lead_form') .merge( button_attributes: { - 'data-testid': 'code_suggestions_hand_raise_lead_button', + 'data-testid': 'code-suggestions-hand-raise-lead-button', category: 'tertiary', variant: 'confirm', class: 'gl-w-full' diff --git a/ee/app/views/groups/discovers/_discover_page_actions.html.haml b/ee/app/views/groups/discovers/_discover_page_actions.html.haml index c54f52530947aab55e8343dc625c33253d3096cc..d247234f7c6a9b1ab42ff3af46c1ce0663e7f4af 100644 --- a/ee/app/views/groups/discovers/_discover_page_actions.html.haml +++ b/ee/app/views/groups/discovers/_discover_page_actions.html.haml @@ -4,7 +4,8 @@ = s_('TrialDiscoverPage|Compare all plans') .js-hand-raise-lead-button{ data: { **hand_raise_props(group, glm_content: 'trial_discover_page'), - button_attributes: { variant: 'confirm', category: 'secondary' }.to_json, + button_attributes: { variant: 'confirm', category: 'secondary', + 'data-testid': 'trial-discover-hand-raise-lead-button' }.to_json, track_action: 'click_contact_sales', track_label: group_trial_status(group), track_experiment: :trial_discover_page } } diff --git a/ee/spec/factories/groups.rb b/ee/spec/factories/groups.rb index ed28af07f988975dd4de588117c7f0fb6e570623..691e55ecb047fe60ae35ccfc6ec2e9255b416ba1 100644 --- a/ee/spec/factories/groups.rb +++ b/ee/spec/factories/groups.rb @@ -85,6 +85,7 @@ factory :group_with_plan, parent: :group do transient do plan { :free_plan } + trial_starts_on { nil } trial_ends_on { nil } end @@ -95,6 +96,7 @@ namespace: group, hosted_plan: create(evaluator.plan), trial: evaluator.trial_ends_on.present?, + trial_starts_on: evaluator.trial_starts_on, trial_ends_on: evaluator.trial_ends_on ) end diff --git a/ee/spec/features/billings/billing_plans_spec.rb b/ee/spec/features/billings/billing_plans_spec.rb index 29b158cffa10f9d3f938d2b84d40e89753570b89..2b0dc95f99ad42138c49f5ad2437f9febd6942bb 100644 --- a/ee/spec/features/billings/billing_plans_spec.rb +++ b/ee/spec/features/billings/billing_plans_spec.rb @@ -4,7 +4,8 @@ RSpec.describe 'Billing plan pages', :feature, :saas, :js, feature_category: :subscription_management do include SubscriptionPortalHelpers - include BillingPlansHelpers + include Features::HandRaiseLeadHelpers + include Features::BillingPlansHelpers let(:user) { create(:user, first_name: 'James', last_name: 'Bond', organization: 'ACME') } let(:auditor) { create(:auditor, first_name: 'James', last_name: 'Bond', organization: 'ACME') } @@ -71,9 +72,11 @@ def external_upgrade_url(namespace, plan) end it 'renders in-app hand raise lead for code suggestions' do - find_by_testid('code_suggestions_hand_raise_lead_button').click + find_by_testid('code-suggestions-hand-raise-lead-button').click - fill_in_and_submit_code_suggestions_hand_raise_lead + fill_in_and_submit_hand_raise_lead( + user, namespace, glm_content: 'code-suggestions', product_interaction: 'Requested Contact-Duo Pro Add-On' + ) end end @@ -328,49 +331,6 @@ def external_upgrade_url(namespace, plan) let(:namespace) { create(:group) } let!(:group_member) { create(:group_member, :owner, group: namespace, user: user) } - shared_context 'hand raise lead form setup' do - let(:form_data) do - { - 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' } - } - end - - let(:hand_raise_lead_params) do - { - "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, :name), - "namespace_id" => namespace.id, - "comment" => '', - "glm_content" => 'billing-group', - "product_interaction" => 'Hand Raise PQL', - "work_email" => user.email, - "uid" => user.id, - "setup_for_company" => user.setup_for_company, - "provider" => "gitlab", - "glm_source" => 'gitlab.com' - } - end - - let(:lead_params) { ActionController::Parameters.new(hand_raise_lead_params).permit! } - - before do - expect_next_instance_of(GitlabSubscriptions::CreateHandRaiseLeadService) do |service| - expect(service).to receive(:execute).with(lead_params).and_return(double('lead', success?: true)) - end - end - end - context 'when a group is the top-level group' do let(:page_path) { group_billings_path(namespace) } @@ -417,10 +377,8 @@ def external_upgrade_url(namespace, plan) end context 'when submitting hand raise lead' do - include_context 'hand raise lead form setup' - it 'displays the in-app hand raise lead' do - click_premium_contact_sales_button_and_submit_form(form_data) + click_premium_contact_sales_button_and_submit_form(user, namespace) end end @@ -431,14 +389,12 @@ def external_upgrade_url(namespace, plan) context 'on free' do let(:plan) { free_plan } - include_context 'hand raise lead form setup' - it 'submits hand raise lead form' do visit page_path click_button 'Talk to an expert' - fill_hand_raise_lead_form_and_submit(form_data) + fill_in_and_submit_hand_raise_lead(user, namespace, glm_content: 'billing-group') end end @@ -516,66 +472,9 @@ def external_upgrade_url(namespace, plan) end end - def fill_in_and_submit_code_suggestions_hand_raise_lead - form_data = { - 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, :name), - "namespace_id" => namespace.id, - "comment" => '', - "glm_content" => 'code-suggestions', - "product_interaction" => 'Requested Contact-Duo Pro Add-On', - "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 - - fill_hand_raise_lead_form_and_submit(form_data) - end - def seats_currently_in_use find_by_testid('seats-currently-in-use').text end - - def fill_hand_raise_lead_form_and_submit(form_data) - within_testid('hand-raise-lead-modal') do - aggregate_failures do - 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('Last Name', with: form_data[:last_name]) - expect(page).to have_field('Company Name', with: form_data[:company_name]) - end - - select form_data[:company_size], from: 'company-size' - fill_in 'phone-number', with: form_data[:phone_number] - select form_data.dig(:country, :name), from: 'country' - select form_data.dig(:state, :name), from: 'state' - - click_button 'Submit information' - end - end end context 'with unexpected JSON' do diff --git a/ee/spec/features/groups/discovers/hand_raise_lead_spec.rb b/ee/spec/features/groups/discovers/hand_raise_lead_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..d6ba6fa9e97047a15cb2c87f3caac40b4580b506 --- /dev/null +++ b/ee/spec/features/groups/discovers/hand_raise_lead_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Groups > Discovers > Hand Raise Lead', :js, :saas, feature_category: :activation do + include Features::HandRaiseLeadHelpers + + let_it_be(:user) { create(:user, :with_namespace, organization: 'YMCA') } + let_it_be(:group) do + create(:group_with_plan, plan: :ultimate_trial_plan, trial_ends_on: Date.tomorrow, owners: user) + end + + before do + stub_saas_features(subscriptions_trials: true) + stub_experiments(trial_discover_page: :candidate) + + sign_in(user) + + visit group_discover_path(group) + end + + context 'when user interacts with hand raise lead and submits' do + it 'renders and submits the top of the page instance' do + all_by_testid('trial-discover-hand-raise-lead-button').first.click + + fill_in_and_submit_hand_raise_lead(user, group, glm_content: 'trial_discover_page') + end + + it 'renders and submits the bottom of the page instance' do + all_by_testid('trial-discover-hand-raise-lead-button').last.click + + fill_in_and_submit_hand_raise_lead(user, group, glm_content: 'trial_discover_page') + end + end +end diff --git a/ee/spec/features/groups/usage_quotas/code_suggestions_usage_tab_spec.rb b/ee/spec/features/groups/usage_quotas/code_suggestions_usage_tab_spec.rb index 6a1f5e39c60974995612f173c0b505c51edba680..702cdf854abec7f2d32d4e63e0401d7192ee61dc 100644 --- a/ee/spec/features/groups/usage_quotas/code_suggestions_usage_tab_spec.rb +++ b/ee/spec/features/groups/usage_quotas/code_suggestions_usage_tab_spec.rb @@ -4,9 +4,10 @@ RSpec.describe 'Groups > Usage Quotas > Code Suggestions tab', :js, :saas, feature_category: :seat_cost_management do include SubscriptionPortalHelpers + include Features::HandRaiseLeadHelpers - let(:user) { create(:user, first_name: 'Joe', last_name: 'Blow', organization: 'YMCA') } - let(:group) { create(:group_with_plan, plan: :premium_plan) } + let_it_be(:user) { create(:user, :with_namespace, organization: 'YMCA') } + let_it_be(:group) { create(:group_with_plan, plan: :premium_plan, owners: user) } before do stub_signing_key @@ -14,23 +15,25 @@ stub_subscription_permissions_data(group.id) stub_licensed_features(code_suggestions: true) - group.add_owner(user) - sign_in(user) visit group_usage_quotas_path(group, anchor: 'code-suggestions-usage-tab') - wait_for_requests + wait_for_all_requests end context 'when user interactive with hand raise lead button' do it 'renders and submits in-app hand raise lead for code suggestions' do - find_by_testid('code_suggestions_hand_raise_lead_button').click + find_by_testid('code-suggestions-hand-raise-lead-button').click - fill_in_and_submit_code_suggestions_hand_raise_lead + fill_in_and_submit_hand_raise_lead( + user, group, glm_content: 'code-suggestions', product_interaction: 'Requested Contact-Duo Pro Add-On' + ) end end context 'when bulk assign and unassign duo pro seats' do - let_it_be(:group) { create(:group_with_plan, plan: :premium_plan) } + let_it_be(:add_on_purchase, reload: true) do + create(:gitlab_subscription_add_on_purchase, :gitlab_duo_pro, quantity: 10, namespace: group) + end context 'when user is owner' do before_all do @@ -40,11 +43,6 @@ end context 'when bulk assigning seats' do - let_it_be(:add_on) { create(:gitlab_subscription_add_on) } - let_it_be(:add_on_purchase) do - create(:gitlab_subscription_add_on_purchase, quantity: 10, namespace: group, add_on: add_on) - end - context 'when success' do it 'assigns the selected users' do expect(add_on_purchase.assigned_users.size).to eq(0) @@ -92,10 +90,6 @@ context 'when bulk unassigning seats' do let_it_be(:users) { create_list(:user, 3) } - let_it_be(:add_on) { create(:gitlab_subscription_add_on) } - let_it_be(:add_on_purchase) do - create(:gitlab_subscription_add_on_purchase, quantity: 10, namespace: group, add_on: add_on) - end before_all do users.each do |user| @@ -127,60 +121,4 @@ end end end - - def fill_in_and_submit_code_suggestions_hand_raise_lead - form_data = { - 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, :name), - "namespace_id" => group.id, - "comment" => '', - "glm_content" => 'code-suggestions', - "product_interaction" => 'Requested Contact-Duo Pro Add-On', - "work_email" => user.email, - "uid" => user.id, - "setup_for_company" => user.setup_for_company, - "provider" => "gitlab", - "glm_source" => 'gitlab.com' - } - - expect_next_instance_of(GitlabSubscriptions::CreateHandRaiseLeadService) do |service| - expect(service).to receive(:execute).with(hand_raise_lead_params).and_return(instance_double('ServiceResponse', - success?: true)) - end - - fill_hand_raise_lead_form_and_submit(form_data) - end - - def fill_hand_raise_lead_form_and_submit(form_data) - within_testid('hand-raise-lead-modal') do - aggregate_failures do - 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('Last Name', with: form_data[:last_name]) - expect(page).to have_field('Company Name', with: form_data[:company_name]) - end - - select form_data[:company_size], from: 'company-size' - fill_in 'phone-number', with: form_data[:phone_number] - select form_data.dig(:country, :name), from: 'country' - select form_data.dig(:state, :name), from: 'state' - - click_button 'Submit information' - end - end end diff --git a/ee/spec/features/trials/trial_widget_in_sidebar_spec.rb b/ee/spec/features/trials/trial_widget_in_sidebar_spec.rb index c4baff267cb2469ddece21158a78ebf501f299c8..4ba2f6506e684d9d22ba31fca99dd700bbd74c3b 100644 --- a/ee/spec/features/trials/trial_widget_in_sidebar_spec.rb +++ b/ee/spec/features/trials/trial_widget_in_sidebar_spec.rb @@ -3,23 +3,17 @@ require 'spec_helper' RSpec.describe 'Trial Widget in Sidebar', :saas, :js, feature_category: :acquisition do - let_it_be(:user) { create(:user) } + include Features::HandRaiseLeadHelpers + + let_it_be(:user) { create(:user, :with_namespace, organization: 'YMCA') } let_it_be(:group) do - create(:group).tap do |record| + create( + :group_with_plan, plan: :ultimate_trial_plan, trial_starts_on: Date.current, trial_ends_on: 30.days.from_now + ) do |record| record.add_owner(user) end end - let_it_be(:subscription) do - create( - :gitlab_subscription, - :active_trial, - namespace: group, - trial_starts_on: Date.current, - trial_ends_on: 30.days.from_now - ) - end - before do stub_application_setting(check_namespace_plan: true) allow_next_instance_of(GitlabSubscriptions::FetchSubscriptionPlansService, plan: :free) do |instance| @@ -65,12 +59,18 @@ visit group_path(group) end - it 'shows the popover for the trial status widget' do + it 'shows the popover for the trial status widget and submits hand raise lead' do expect(page).not_to have_selector('.js-sidebar-collapsed') - find('#trial-status-sidebar-widget').hover + find_by_testid('trial-widget-menu').hover + + within_testid('trial-status-popover') do + expect(page).to have_content("We hope you’re enjoying the features of GitLab") - expect(page).to have_content("We hope you’re enjoying the features of GitLab") + find_by_testid('trial-popover-hand-raise-lead-button').click + end + + fill_in_and_submit_hand_raise_lead(user, group, glm_content: 'trial-status-show-group') end end @@ -84,9 +84,11 @@ it 'shows the popover for the trial status widget' do expect(page).not_to have_selector('.js-sidebar-collapsed') - find('#trial-status-sidebar-widget').hover + find_by_testid('trial-widget-menu').hover - expect(page).to have_content("We hope you’re enjoying the features of GitLab") + within_testid('trial-status-popover') do + expect(page).to have_content("We hope you’re enjoying the features of GitLab") + end end end end diff --git a/ee/spec/frontend/contextual_sidebar/__snapshots__/trial_status_widget_spec.js.snap b/ee/spec/frontend/contextual_sidebar/__snapshots__/trial_status_widget_spec.js.snap index 3322edc51474ce0fe4f51acf3ae7066d2518e7b0..8737920edf7f3dafbfa47f27a5a9f787e53a359a 100644 --- a/ee/spec/frontend/contextual_sidebar/__snapshots__/trial_status_widget_spec.js.snap +++ b/ee/spec/frontend/contextual_sidebar/__snapshots__/trial_status_widget_spec.js.snap @@ -7,7 +7,7 @@ exports[`TrialStatusWidget component without the optional containerId prop match > <div class="gl-align-items-stretch gl-display-flex gl-flex-direction-column gl-w-full" - data-testid="widget-menu" + data-testid="trial-widget-menu" > <div> <div @@ -55,7 +55,7 @@ exports[`TrialStatusWidget component without the optional containerId prop match > <div class="gl-align-items-stretch gl-display-flex gl-flex-direction-column gl-w-full" - data-testid="widget-menu" + data-testid="trial-widget-menu" > <div class="gl-display-flex gl-gap-5 gl-px-2 gl-w-full" diff --git a/ee/spec/frontend/contextual_sidebar/trial_status_popover_spec.js b/ee/spec/frontend/contextual_sidebar/trial_status_popover_spec.js index 640878d053c4a36e8e2e827f95f40aa77cf2cd65..2609c8471cf2c13619f835eb8dbe664ef895815a 100644 --- a/ee/spec/frontend/contextual_sidebar/trial_status_popover_spec.js +++ b/ee/spec/frontend/contextual_sidebar/trial_status_popover_spec.js @@ -45,6 +45,7 @@ describe('TrialStatusPopover component', () => { lastName: 'lastName', companyName: 'companyName', glmContent: 'glmContent', + productInteraction: 'productInteraction', }, ...providers, }, @@ -125,6 +126,7 @@ describe('TrialStatusPopover component', () => { 'data-last-name': 'lastName', 'data-company-name': 'companyName', 'data-glm-content': 'glmContent', + 'data-product-interaction': 'productInteraction', 'data-track-category': trackingEvents.activeTrialCategory, 'data-track-action': trackingEvents.contactSalesBtnClick.action, 'data-track-label': trackingEvents.contactSalesBtnClick.label, diff --git a/ee/spec/frontend/contextual_sidebar/trial_status_widget_spec.js b/ee/spec/frontend/contextual_sidebar/trial_status_widget_spec.js index d02114c95db3bad004c6df56a17822e0f240171c..1b4a565c1a324b97eeb6609278afda168aea8aca 100644 --- a/ee/spec/frontend/contextual_sidebar/trial_status_widget_spec.js +++ b/ee/spec/frontend/contextual_sidebar/trial_status_widget_spec.js @@ -72,7 +72,7 @@ describe('TrialStatusWidget component', () => { describe('tracks when the widget menu is clicked', () => { it('tracks with correct information when namespace is in an active trial', async () => { const { category, label } = trackingEvents.activeTrialOptions; - await wrapper.findByTestId('widget-menu').trigger('click'); + await wrapper.findByTestId('trial-widget-menu').trigger('click'); expect(trackingSpy).toHaveBeenCalledWith(category, trackingEvents.action, { category, @@ -84,7 +84,7 @@ describe('TrialStatusWidget component', () => { wrapper = createComponent({ percentageComplete: 110 }); const { category, label } = trackingEvents.trialEndedOptions; - await wrapper.findByTestId('widget-menu').trigger('click'); + await wrapper.findByTestId('trial-widget-menu').trigger('click'); expect(trackingSpy).toHaveBeenCalledWith(category, trackingEvents.action, { category, diff --git a/ee/spec/helpers/ee/groups_helper_spec.rb b/ee/spec/helpers/ee/groups_helper_spec.rb index cf35f9afbba1e369f0d765be39270c5ad06ba486..fca2bdbdcdf7cf4c3494e996ab0088e633686efb 100644 --- a/ee/spec/helpers/ee/groups_helper_spec.rb +++ b/ee/spec/helpers/ee/groups_helper_spec.rb @@ -566,7 +566,7 @@ track_label: 'code_suggestions_hand_raise_lead_form', button_attributes: { - 'data-testid': 'code_suggestions_hand_raise_lead_button', + 'data-testid': 'code-suggestions-hand-raise-lead-button', category: 'tertiary', variant: 'confirm', class: 'gl-w-full' diff --git a/ee/spec/support/helpers/billing_plans_helpers.rb b/ee/spec/support/helpers/billing_plans_helpers.rb deleted file mode 100644 index 0201ce6b49d3cc9c87aa7bd3160cd9efd679da10..0000000000000000000000000000000000000000 --- a/ee/spec/support/helpers/billing_plans_helpers.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -# We write these in helper methods so that JH can override them -# Related issue: https://gitlab.com/gitlab-org/gitlab/-/issues/361718 -module BillingPlansHelpers - def should_have_hand_raise_lead_button - expect(page).to have_selector( - ".js-hand-raise-lead-button[data-namespace-id='#{namespace.id}'][data-user-name='#{user.username}']", - visible: false) - end - - def click_premium_contact_sales_button_and_submit_form(form_data) - page.within('[data-testid="plan-card-premium"]') do - click_button 'Contact sales' - end - - fill_hand_raise_lead_form_and_submit(form_data) - end -end - -BillingPlansHelpers.prepend_mod diff --git a/ee/spec/support/helpers/features/billing_plans_helpers.rb b/ee/spec/support/helpers/features/billing_plans_helpers.rb new file mode 100644 index 0000000000000000000000000000000000000000..74218f685f580a19f928b2d68e9d2e4ff313a4e3 --- /dev/null +++ b/ee/spec/support/helpers/features/billing_plans_helpers.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require_relative 'hand_raise_lead_helpers' + +# We write these in helper methods so that JH can override them +# Related issue: https://gitlab.com/gitlab-org/gitlab/-/issues/361718 +module Features + module BillingPlansHelpers + include HandRaiseLeadHelpers + + def should_have_hand_raise_lead_button + expect(page).to( + have_selector( + ".js-hand-raise-lead-button[data-namespace-id='#{namespace.id}'][data-user-name='#{user.username}']", + visible: false + ) + ) + end + + def click_premium_contact_sales_button_and_submit_form(user, namespace) + within_testid('plan-card-premium') do + click_button 'Contact sales' + end + + fill_in_and_submit_hand_raise_lead(user, namespace, glm_content: 'billing-group') + end + end +end + +Features::BillingPlansHelpers.prepend_mod diff --git a/ee/spec/support/helpers/features/hand_raise_lead_helpers.rb b/ee/spec/support/helpers/features/hand_raise_lead_helpers.rb new file mode 100644 index 0000000000000000000000000000000000000000..a7ae69a0ff58f7864fa3b1da8d4bfa78ca233135 --- /dev/null +++ b/ee/spec/support/helpers/features/hand_raise_lead_helpers.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +module Features + module HandRaiseLeadHelpers + def fill_in_and_submit_hand_raise_lead(user, namespace, glm_content: nil, product_interaction: 'Hand Raise PQL') + form_data = { + 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, :name), + "namespace_id" => namespace.id, + "comment" => '', + "glm_content" => glm_content, + "product_interaction" => product_interaction, + "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(ServiceResponse.success) + end + + fill_hand_raise_lead_form_and_submit(form_data) + end + + def fill_hand_raise_lead_form_and_submit(form_data) + within_testid('hand-raise-lead-modal') do + aggregate_failures do + 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('Last Name', with: form_data[:last_name]) + expect(page).to have_field('Company Name', with: form_data[:company_name]) + end + + select form_data[:company_size], from: 'company-size' + fill_in 'phone-number', with: form_data[:phone_number] + select form_data.dig(:country, :name), from: 'country' + select form_data.dig(:state, :name), from: 'state' + + click_button 'Submit information' + end + end + end +end diff --git a/spec/support/helpers/features/dom_helpers.rb b/spec/support/helpers/features/dom_helpers.rb index 96d02e8f03d4da0a935d75f03a3f4138235207ca..5201b59da098e9ff8f57e0e3da9bbb492b673c25 100644 --- a/spec/support/helpers/features/dom_helpers.rb +++ b/spec/support/helpers/features/dom_helpers.rb @@ -10,6 +10,10 @@ def find_by_testid(testid, context: page, **kwargs) context.find("[data-testid='#{testid}']", **kwargs) end + def all_by_testid(testid, context: page, **kwargs) + context.all("[data-testid='#{testid}']", **kwargs) + end + def within_testid(testid, context: page, **kwargs, &block) context.within("[data-testid='#{testid}']", **kwargs, &block) end