Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the billing setup page from the Ads setup flow #2577

Open
wants to merge 35 commits into
base: feature/2459-campaign-creation-flow
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
40ea4eb
remove ads campaign steps
kt-12 Sep 4, 2024
8a9a10a
cs fixes
kt-12 Sep 4, 2024
94c8208
e2e support
kt-12 Sep 4, 2024
39a2090
cs fixes
kt-12 Sep 4, 2024
09871a5
cs fixes
kt-12 Sep 4, 2024
5b14c07
fix cs issue
kt-12 Sep 4, 2024
9728b03
address review comments and also add submitbuttontext
kt-12 Sep 7, 2024
f06b5d2
fix doc block
kt-12 Sep 7, 2024
3409919
cs fixes
kt-12 Sep 7, 2024
0c74f98
cs fixes
kt-12 Sep 9, 2024
779eac3
sert default submitButtonText
kt-12 Sep 11, 2024
ef31827
update doc block and remove unused files
kt-12 Sep 13, 2024
e7afe1e
Update tests/e2e/specs/add-paid-campaigns/add-paid-campaigns.test.js
kt-12 Sep 13, 2024
daa483a
fix e2e
kt-12 Sep 13, 2024
71c81ec
Merge branch 'feature/2536-remove-billing' of https://github.com/wooc…
kt-12 Sep 13, 2024
b5a2467
Update js/src/components/paid-ads/ads-campaign.js
kt-12 Sep 13, 2024
0ca45f1
clear jest files
kt-12 Sep 17, 2024
98cd72d
Update js/src/components/paid-ads/ads-campaign.js
kt-12 Sep 17, 2024
52ca19d
conditional enabling continue button
kt-12 Sep 19, 2024
b8178b4
remove file
kt-12 Sep 19, 2024
c5be7e0
update disabled button logic
kt-12 Sep 19, 2024
1833363
only to check in setup-ads context
kt-12 Sep 19, 2024
d053b77
fix billing e2e
kt-12 Sep 26, 2024
c8ee77f
ads campaign request
kt-12 Sep 26, 2024
1b31ca9
change mock
kt-12 Sep 27, 2024
e7da33a
move billing page to bottom
kt-12 Sep 27, 2024
a6d79a0
create a new mock for campaign creation.
kt-12 Sep 27, 2024
7edeb3b
Merge branch 'feature/2536-remove-billing' of https://github.com/wooc…
kt-12 Sep 27, 2024
4ff5165
move budget to top.
kt-12 Sep 27, 2024
b90f77c
e2e cr fixes
kt-12 Sep 30, 2024
0c6d250
remove title button component
kt-12 Sep 30, 2024
fdd3aae
Merge branch 'feature/2459-campaign-creation-flow' into feature/2536-…
joemcgill Sep 30, 2024
104b368
remove accidently functions
kt-12 Oct 1, 2024
2c84851
remove newly introduced function
kt-12 Oct 2, 2024
fe7bab6
Add ContinueButton component.
asvinb Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions js/src/components/paid-ads/ads-campaign.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import StepContentFooter from '.~/components/stepper/step-content-footer';
import AppDocumentationLink from '.~/components/app-documentation-link';
import AppButton from '.~/components/app-button';
import { useAdaptiveFormContext } from '.~/components/adaptive-form';
import useGoogleAdsAccountBillingStatus from '.~/hooks/useGoogleAdsAccountBillingStatus';
import AudienceSection from './audience-section';
import BudgetSection from './budget-section';
import { CampaignPreviewCard } from './campaign-preview';
import FaqsSection from './faqs-section';
import { GOOGLE_ADS_BILLING_STATUS } from '.~/constants';

/**
* @typedef {import('.~/data/actions').Campaign} Campaign
Expand All @@ -25,24 +27,29 @@ import FaqsSection from './faqs-section';
/**
* Renders the container of the form content for campaign management.
*
* Please note that this component relies on an CampaignAssetsForm's context and custom adapter,
* so it expects a `CampaignAssetsForm` to existing in its parents.
* Please note that this component relies on a CampaignAssetsForm's context and custom adapter,
* so it expects a `CampaignAssetsForm` to exist in its parents.
*
* @fires gla_documentation_link_click with `{ context: 'create-ads' | 'edit-ads' | 'setup-ads', link_id: 'see-what-ads-look-like', href: 'https://support.google.com/google-ads/answer/6275294' }`
*
* @param {Object} props React props.
* @param {Campaign} [props.campaign] Campaign data to be edited. If not provided, this component will show campaign creation UI.
* @param {() => void} props.onContinue Callback called once continue button is clicked.
* @param {boolean} [props.isLoading] If true, the Continue button will display a loading spinner .
* @param {string} [props.submitButtonText] Text to display on submit button.
* @param {'create-ads'|'edit-ads'|'setup-ads'} props.trackingContext A context indicating which page this component is used on. This will be the value of `context` in the track event properties.
*/
export default function AdsCampaign( {
campaign,
onContinue,
isLoading,
submitButtonText = __( 'Continue', 'google-listings-and-ads' ),
trackingContext,
} ) {
const isCreation = ! campaign;
const formContext = useAdaptiveFormContext();
const { isValidForm } = formContext;
const { billingStatus } = useGoogleAdsAccountBillingStatus();

const disabledBudgetSection = ! formContext.values.countryCodes.length;
const helperText = isCreation
Expand Down Expand Up @@ -101,10 +108,16 @@ export default function AdsCampaign( {
<StepContentFooter>
<AppButton
isPrimary
disabled={ ! isValidForm }
disabled={
! isValidForm ||
( trackingContext === 'setup-ads' &&
asvinb marked this conversation as resolved.
Show resolved Hide resolved
billingStatus?.status !==
GOOGLE_ADS_BILLING_STATUS.APPROVED )
}
loading={ isLoading }
onClick={ onContinue }
>
{ __( 'Continue', 'google-listings-and-ads' ) }
{ submitButtonText }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering this button now requires 5 props to render and its only internal dependency is on one of those conditions, its degree of customization makes it unsuitable to be part of this component. It's better to externalize it as a single prop such as continueButton to composite this component.

<StepContentFooter>
	{ continueButton }
</StepContentFooter>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eason9487 I believe this continue button is only temporarily going to need to handle this many conditions until #2535 is completed, to ensure that the current flow could still be tested properly. I'd like to avoid making any additional modifications to the AdsCampaign component in this PR, which is really only meant to remove the billing step because it will be handled during step 3 once we've consolidated the form from the onboarding flow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let continueButtonProps = {
text: __( 'Continue', 'google-listings-and-ads' ),
};
if ( isOnboardingFlow ) {
continueButtonProps = {
'data-action': ACTION_COMPLETE,
text: __( 'Complete setup', 'google-listings-and-ads' ),
eventName: 'gla_onboarding_complete_with_paid_ads_button_click',
eventProps: {
budget: paidAds.amount,
audiences: countryCodes?.join( ',' ),
},
};
}

<AppButton
isPrimary
disabled={ disabledComplete }
onClick={ handleCompleteClick }
loading={ completing === ACTION_COMPLETE }
{ ...continueButtonProps }
/>

From the current revision of AdsCampaign in #2623, I couldn't figure out how this button only temporarily needs to handle 5 props, because both PRs currently increase the complexity and conditional branching of this button to varying degrees.

All of these changes convinced me that both PRs should try to see if it's possible to move this button out of the AdsCampaign component sooner rather than having to resolve more code conflicts and re-test all button scenarios when merging them with each other.

</AppButton>
</StepContentFooter>
</StepContent>
Expand Down
22 changes: 8 additions & 14 deletions js/src/setup-ads/ads-stepper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { useState } from '@wordpress/element';
*/
import SetupAccounts from './setup-accounts';
import AdsCampaign from '.~/components/paid-ads/ads-campaign';
import SetupBilling from './setup-billing';
asvinb marked this conversation as resolved.
Show resolved Hide resolved
import useEventPropertiesFilter from '.~/hooks/useEventPropertiesFilter';
import {
recordStepperChangeEvent,
Expand All @@ -22,8 +21,8 @@ import {
/**
* @param {Object} props React props
* @param {Object} props.formProps Form props forwarded from `Form` component.
* @fires gla_setup_ads with `{ triggered_by: 'step1-continue-button' | 'step2-continue-button' , action: 'go-to-step2' | 'go-to-step3' }`.
* @fires gla_setup_ads with `{ triggered_by: 'stepper-step1-button' | 'stepper-step2-button', action: 'go-to-step1' | 'go-to-step2' }`.
* @fires gla_setup_ads with `{ triggered_by: 'step1-continue-button', action: 'go-to-step2' }`.
* @fires gla_setup_ads with `{ triggered_by: 'stepper-step1-button', action: 'go-to-step1'}`.
*/
const AdsStepper = ( { formProps } ) => {
const [ step, setStep ] = useState( '1' );
Expand Down Expand Up @@ -58,10 +57,6 @@ const AdsStepper = ( { formProps } ) => {
continueStep( '2' );
};

const handleCreateCampaignContinue = () => {
continueStep( '3' );
};

return (
// This Stepper with this class name
// should be refactored into separate shared component.
Expand Down Expand Up @@ -92,17 +87,16 @@ const AdsStepper = ( { formProps } ) => {
content: (
<AdsCampaign
trackingContext="setup-ads"
onContinue={ handleCreateCampaignContinue }
onContinue={ formProps.handleSubmit }
isLoading={ formProps.isSubmitting }
submitButtonText={ __(
'Launch paid campaign',
'google-listings-and-ads'
) }
/>
),
onClick: handleStepClick,
},
{
key: '3',
label: __( 'Set up billing', 'google-listings-and-ads' ),
content: <SetupBilling formProps={ formProps } />,
onClick: handleStepClick,
},
] }
/>
);
Expand Down
4 changes: 0 additions & 4 deletions js/src/setup-ads/ads-stepper/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
jest.mock( '.~/components/paid-ads/ads-campaign', () =>
jest.fn().mockName( 'AdsCampaign' )
);
jest.mock( './setup-billing', () => jest.fn().mockName( 'SetupBilling' ) );

/**
* External dependencies
Expand All @@ -23,7 +22,6 @@
import AdsStepper from './';
import SetupAccounts from './setup-accounts';
import AdsCampaign from '.~/components/paid-ads/ads-campaign';
import SetupBilling from './setup-billing';

describe( 'AdsStepper', () => {
let continueToStep2;
Expand All @@ -39,8 +37,6 @@
continueToStep3 = onContinue;
return null;
} );

SetupBilling.mockReturnValue( null );
} );

afterEach( () => {
Expand Down Expand Up @@ -91,7 +87,7 @@
expect( recordEvent ).toHaveBeenNthCalledWith( 2, 'gla_setup_ads', {
action: 'go-to-step1',
triggered_by: 'stepper-step1-button',
} );

Check failure on line 90 in js/src/setup-ads/ads-stepper/index.test.js

View workflow job for this annotation

GitHub Actions / JavaScript unit tests

TypeError: Cannot read properties of undefined (reading 'handleSubmit') at AdsStepper (/home/runner/work/google-listings-and-ads/google-listings-and-ads/js/src/setup-ads/ads-stepper/index.js:90:31) at renderWithHooks (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:14985:18) at mountIndeterminateComponent (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:17811:13) at beginWork (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:19049:16) at HTMLUnknownElement.callCallback (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:3945:14) at HTMLUnknownElement.callTheUserObjectsOperation (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30) at innerInvokeEventListeners (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:338:25) at invokeEventListeners (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:274:3) at HTMLUnknownElementImpl._dispatch (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:221:9) at HTMLUnknownElementImpl.dispatchEvent (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:94:17) at HTMLUnknownElement.dispatchEvent (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:231:34) at Object.invokeGuardedCallbackDev (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:3994:16) at invokeGuardedCallback (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:4056:31) at beginWork$1 (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:23964:7) at performUnitOfWork (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:22779:12) at workLoopSync (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:22707:5) at renderRootSync (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:22670:7) at performSyncWorkOnRoot (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:22293:18) at scheduleUpdateOnFiber (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:21881:7) at updateContainer (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:25482:3) at /home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:26021:7 at unbatchedUpdates (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:22431:12) at legacyRenderSubtreeIntoContainer (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:26020:5) at Object.render (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:26103

Check failure on line 90 in js/src/setup-ads/ads-stepper/index.test.js

View workflow job for this annotation

GitHub Actions / JavaScript unit tests

TypeError: Cannot read properties of undefined (reading 'handleSubmit') at AdsStepper (/home/runner/work/google-listings-and-ads/google-listings-and-ads/js/src/setup-ads/ads-stepper/index.js:90:31) at renderWithHooks (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:14985:18) at mountIndeterminateComponent (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:17811:13) at beginWork (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:19049:16) at HTMLUnknownElement.callCallback (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:3945:14) at HTMLUnknownElement.callTheUserObjectsOperation (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30) at innerInvokeEventListeners (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:338:25) at invokeEventListeners (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:274:3) at HTMLUnknownElementImpl._dispatch (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:221:9) at HTMLUnknownElementImpl.dispatchEvent (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:94:17) at HTMLUnknownElement.dispatchEvent (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:231:34) at Object.invokeGuardedCallbackDev (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:3994:16) at invokeGuardedCallback (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:4056:31) at beginWork$1 (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:23964:7) at performUnitOfWork (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:22779:12) at workLoopSync (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:22707:5) at renderRootSync (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:22670:7) at performSyncWorkOnRoot (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:22293:18) at scheduleUpdateOnFiber (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:21881:7) at updateContainer (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:25482:3) at /home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:26021:7 at unbatchedUpdates (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:22431:12) at legacyRenderSubtreeIntoContainer (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:26020:5) at Object.render (/home/runner/work/google-listings-and-ads/google-listings-and-ads/node_modules/react-dom/cjs/react-dom.development.js:26103

// Step 3 -> Step 1
continueUntilStep3();
Expand Down

This file was deleted.

This file was deleted.

88 changes: 0 additions & 88 deletions js/src/setup-ads/ads-stepper/setup-billing/index.js

This file was deleted.

Loading
Loading