From 1535369c24e80d6e47031e60aade49c76731cfc3 Mon Sep 17 00:00:00 2001
From: Ankit Gade Merchant Center is required to sync products so they show on Google. Google Ads is required to set up conversion measurement for your store.
You don’t have Merchant Center nor Google Ads accounts, so we’re creating them for you.
', + 'google-listings-and-ads' + ), + { + p: , + } + ) + : ''; + + return ( +You don’t have Merchant Center nor Google Ads accounts, so we’re creating them for you.
', 'google-listings-and-ads' @@ -70,13 +71,37 @@ const ConnectedGoogleComboAccountCard = ( { { p: , } - ) - : ''; + ); + } + + return ( + <> +{ googleAccount?.email }
++ { sprintf( + // Translators: %s is the Merchant Center ID + __( + 'Merchant Center ID: %s', + 'google-listings-and-ads' + ), + googleMCAccount?.id + ) } +
++ { sprintf( + // Translators: %s is the Google Ads ID + __( 'Google Ads ID: %s', 'google-listings-and-ads' ), + googleAdsAccount?.id + ) } +
+ > + ); + }; return (Merchant Center is required to sync products so they show on Google. Google Ads is required to set up conversion measurement for your store.
', @@ -86,12 +111,11 @@ const ConnectedGoogleComboAccountCard = ( { p: , } ) } - indicator={ 'Creating...' } + indicator={ isCreatingAccounts ? 'Creating...' : null } > { ! existingAccounts && (You don’t have Merchant Center nor Google Ads accounts, so we’re creating them for you.
', @@ -100,7 +108,7 @@ const ConnectedGoogleComboAccountCard = ( { googleAccount } ) => { p: , } ) } - indicator={ isCreatingAccounts ? 'Creating...' : null } + indicator={ creatingAccounts ? 'Creating...' : null } /> ); }; diff --git a/js/src/components/google-combo-account-card/useCreateAccounts.js b/js/src/components/google-combo-account-card/useCreateAccounts.js index 341e57ec6f..bd50116b2f 100644 --- a/js/src/components/google-combo-account-card/useCreateAccounts.js +++ b/js/src/components/google-combo-account-card/useCreateAccounts.js @@ -21,6 +21,7 @@ import useGoogleAdsAccount from '.~/hooks/useGoogleAdsAccount'; const useCreateAccounts = () => { const accountCreationResolvedRef = useRef( false ); const isCreatingAccountsRef = useRef( false ); + const accountsCreatedRef = useRef( false ); const { googleAdsAccount, @@ -49,6 +50,7 @@ const useCreateAccounts = () => { receiveMCAccount( account ); invalidateResolution( 'getExistingGoogleAdsAccounts' ); isCreatingAccountsRef.current = false; + accountsCreatedRef.current = true; } }, [ response, loading ] ); @@ -58,10 +60,14 @@ const useCreateAccounts = () => { hasFinishedResolutionForExistingMCAccounts && isCreatingAccountsRef.current === false && accountCreationResolvedRef.current === false && - account === undefined + account === undefined && + ! googleAdsAccount && + ! hasFinishedResolutionForExistingAdsccounts ) { accountCreationResolvedRef.current = true; - const hasExistingAccounts = true; + const hasExistingAccounts = + existingMCAccounts?.length > 0 && + existingAdsAccount?.length > 0; if ( ! hasExistingAccounts ) { const createAccounts = async () => { @@ -70,6 +76,7 @@ const useCreateAccounts = () => { }; isCreatingAccountsRef.current = true; + accountsCreatedRef.current = false; createAccounts(); } } @@ -81,6 +88,7 @@ const useCreateAccounts = () => { return { isCreatingAccounts: isCreatingAccountsRef.current, accountCreationResolved: accountCreationResolvedRef.current, + accountsCreated: accountsCreatedRef.current, }; }; From b9977132234e7843231a621b33df2295fb25d9f3 Mon Sep 17 00:00:00 2001 From: Ankit Gade+ { __( + 'You don’t have Merchant Center nor Google Ads accounts, so we’re creating them for you.', + 'google-listings-and-ads' + ) } +
+ ); + } else if ( isCreatingAdsAccount ) { + description = ( + <> ++ { __( + 'You don’t have Google Ads account, so we’re creating one for you.', + 'google-listings-and-ads' + ) } +
+ + { __( + 'Required to set up conversion measurement for your store.', + 'google-listings-and-ads' + ) } + + > + ); + } else if ( isCreatingMCAccount ) { + description = ( + <> ++ { __( + 'You don’t have Merchant Center account, so we’re creating one for you.', + 'google-listings-and-ads' + ) } +
+ + { __( + 'Required to sync products so they show on Google.', + 'google-listings-and-ads' + ) } + + > + ); + } + + return description; + } + + return ( +{ googleAccount?.email }
++ { sprintf( + // Translators: %s is the Merchant Center ID + __( 'Merchant Center ID: %s', 'google-listings-and-ads' ), + googleMCAccount.id ?? 0 + ) } +
++ { sprintf( + // Translators: %s is the Google Ads ID + __( 'Google Ads ID: %s', 'google-listings-and-ads' ), + googleAdsAccount.id ?? 0 + ) } +
+You don’t have Merchant Center nor Google Ads accounts, so we’re creating them for you.
', - 'google-listings-and-ads' - ), - { - p: , - } - ); - } - - return ( - <> -{ googleAccount?.email }
-- { sprintf( - // Translators: %s is the Merchant Center ID - __( - 'Merchant Center ID: %s', - 'google-listings-and-ads' - ), - googleMCAccount?.id - ) } -
-- { sprintf( - // Translators: %s is the Google Ads ID - __( 'Google Ads ID: %s', 'google-listings-and-ads' ), - googleAdsAccount?.id - ) } -
- > - ); - }; - - const Indicator = () => { - if ( creatingAccounts ) { - return ( - <> -Merchant Center is required to sync products so they show on Google. Google Ads is required to set up conversion measurement for your store.
', - 'google-listings-and-ads' - ), - { - p: , - } - ) } - indicator={+ { __( + 'Merchant Center is required to sync products so they show on Google. Google Ads is required to set up conversion measurement for your store.', + 'google-listings-and-ads' + ) } +
+ ) + } + indicator={ + creatingAccounts ? ( +- { __( - 'You don’t have Merchant Center nor Google Ads accounts, so we’re creating them for you.', - 'google-listings-and-ads' - ) } -
- ); - } else if ( isCreatingAdsAccount ) { - description = ( - <> + if ( isCreatingAccounts ) { + if ( isCreatingMCAccount && isCreatingAdsAccount ) { + description = ({ __( - 'You don’t have Google Ads account, so we’re creating one for you.', + 'You don’t have Merchant Center nor Google Ads accounts, so we’re creating them for you.', 'google-listings-and-ads' ) }
- - { __( - 'Required to set up conversion measurement for your store.', - 'google-listings-and-ads' - ) } - - > - ); - } else if ( isCreatingMCAccount ) { + ); + } else if ( isCreatingAdsAccount ) { + description = ( + <> ++ { __( + 'You don’t have Google Ads account, so we’re creating one for you.', + 'google-listings-and-ads' + ) } +
+ + { __( + 'Required to set up conversion measurement for your store.', + 'google-listings-and-ads' + ) } + + > + ); + } else if ( isCreatingMCAccount ) { + description = ( + <> ++ { __( + 'You don’t have Merchant Center account, so we’re creating one for you.', + 'google-listings-and-ads' + ) } +
+ + { __( + 'Required to sync products so they show on Google.', + 'google-listings-and-ads' + ) } + + > + ); + } + } else { description = ( <> -- { __( - 'You don’t have Merchant Center account, so we’re creating one for you.', - 'google-listings-and-ads' - ) } -
- - { __( - 'Required to sync products so they show on Google.', - 'google-listings-and-ads' - ) } - +{ google?.email }
+ { googleMCAccount?.id && ( ++ { sprintf( + // Translators: %s is the Merchant Center ID + __( + 'Merchant Center ID: %s', + 'google-listings-and-ads' + ), + googleMCAccount.id + ) } +
+ ) } + { googleAdsAccount?.id && ( ++ { sprintf( + // Translators: %s is the Google Ads ID + __( + 'Google Ads ID: %s', + 'google-listings-and-ads' + ), + googleAdsAccount.id + ) } +
+ ) } > ); } return description; - } + }; return ({ googleAccount?.email }
-- { sprintf( - // Translators: %s is the Merchant Center ID - __( 'Merchant Center ID: %s', 'google-listings-and-ads' ), - googleMCAccount.id ?? 0 - ) } -
-- { sprintf( - // Translators: %s is the Google Ads ID - __( 'Google Ads ID: %s', 'google-listings-and-ads' ), - googleAdsAccount.id ?? 0 - ) } -
+ { getDescription() }+ { __( + 'Merchant Center is required to sync products so they show on Google. Google Ads is required to set up conversion measurement for your store.', + 'google-listings-and-ads' + ) } +
+ ); + + const getIndicator = () => { + if ( creatingAccounts ) { + return ( +- { __( - 'Merchant Center is required to sync products so they show on Google. Google Ads is required to set up conversion measurement for your store.', - 'google-listings-and-ads' - ) } -
- ) - } - indicator={ - creatingAccounts ? ( -{ __( 'You don’t have Merchant Center nor Google Ads accounts, so we’re creating them for you.', @@ -41,7 +41,7 @@ const AccountCreationDescription = ( {
); } else if ( isCreatingAdsAccount ) { - description = ( + return ( <>{ __( @@ -58,7 +58,7 @@ const AccountCreationDescription = ( { > ); } else if ( isCreatingMCAccount ) { - description = ( + return ( <>
{ __( @@ -75,39 +75,37 @@ const AccountCreationDescription = ( { > ); } - } else { - description = ( - <> -
{ google?.email }
- { googleMCAccount?.id && ( -- { sprintf( - // Translators: %s is the Merchant Center ID - __( - 'Merchant Center ID: %s', - 'google-listings-and-ads' - ), - googleMCAccount.id - ) } -
- ) } - { googleAdsAccount?.id && ( -- { sprintf( - // Translators: %s is the Google Ads ID - __( - 'Google Ads ID: %s', - 'google-listings-and-ads' - ), - googleAdsAccount.id - ) } -
- ) } - > - ); } - return description; + return ( + <> +{ google?.email }
+ { googleMCAccount?.id && ( ++ { sprintf( + // Translators: %s is the Merchant Center ID + __( + 'Merchant Center ID: %s', + 'google-listings-and-ads' + ), + googleMCAccount.id + ) } +
+ ) } + { googleAdsAccount?.id && ( ++ { sprintf( + // Translators: %s is the Google Ads ID + __( + 'Google Ads ID: %s', + 'google-listings-and-ads' + ), + googleAdsAccount.id + ) } +
+ ) } + > + ); }; return ( diff --git a/js/src/components/google-combo-account-card/connected-google-combo-account-card.js b/js/src/components/google-combo-account-card/connected-google-combo-account-card.js index 618549ac3c..0bee8a26e0 100644 --- a/js/src/components/google-combo-account-card/connected-google-combo-account-card.js +++ b/js/src/components/google-combo-account-card/connected-google-combo-account-card.js @@ -96,7 +96,6 @@ const ConnectedGoogleComboAccountCard = ( { googleAccount } ) => { isCreatingAccounts={ creatingAccounts } isCreatingAdsAccount={ isCreatingAdsAccount } isCreatingMCAccount={ isCreatingMCAccount } - googleAccount={ googleAccount } googleMCAccount={ googleMCAccount } googleAdsAccount={ googleAdsAccount } /> diff --git a/js/src/hooks/useAutoCreateAdsMCAccounts.js b/js/src/hooks/useAutoCreateAdsMCAccounts.js index d5e21de5c7..f41fb79058 100644 --- a/js/src/hooks/useAutoCreateAdsMCAccounts.js +++ b/js/src/hooks/useAutoCreateAdsMCAccounts.js @@ -43,7 +43,7 @@ const useAutoCreateAdsMCAccounts = () => { const { existingAccounts: existingAdsAccount, - isResolving: isResolvingExistingAdsAccount, + hasFinishedResolution: hasFinishedResolutionForExistingAdsAccount, } = useExistingGoogleAdsAccounts(); const [ handleCreateAccount, { response } ] = useCreateMCAccount(); @@ -82,7 +82,7 @@ const useAutoCreateAdsMCAccounts = () => { useEffect( () => { const existingAccountsResolved = - ! isResolvingExistingAdsAccount && + hasFinishedResolutionForExistingAdsAccount && hasFinishedResolutionForExistingMCAccounts; accountCreationChecksResolvedRef.current = existingAccountsResolved; @@ -100,7 +100,7 @@ const useAutoCreateAdsMCAccounts = () => { } // eslint-disable-next-line react-hooks/exhaustive-deps }, [ - isResolvingExistingAdsAccount, + hasFinishedResolutionForExistingAdsAccount, hasFinishedResolutionForExistingMCAccounts, ] ); diff --git a/js/src/hooks/useExistingGoogleAdsAccounts.js b/js/src/hooks/useExistingGoogleAdsAccounts.js index 8eda3b9a2f..1e84516710 100644 --- a/js/src/hooks/useExistingGoogleAdsAccounts.js +++ b/js/src/hooks/useExistingGoogleAdsAccounts.js @@ -15,8 +15,11 @@ const useExistingGoogleAdsAccounts = () => { const isResolving = select( STORE_KEY ).isResolving( 'getExistingGoogleAdsAccounts' ); + const hasFinishedResolution = select( STORE_KEY ).hasFinishedResolution( + 'getExistingGoogleAdsAccounts' + ); - return { existingAccounts, isResolving }; + return { existingAccounts, hasFinishedResolution, isResolving }; }, [] ); }; From 1a24f0dbb9877653e9776ed634b0cb3bb7733c7d Mon Sep 17 00:00:00 2001 From: Ankit Gade+ { __( + 'You don’t have Merchant Center nor Google Ads accounts, so we’re creating them for you.', + 'google-listings-and-ads' + ) } +
+ ); + } else if ( isCreatingAdsAccount ) { + return ( + <>{ __( - 'You don’t have Merchant Center nor Google Ads accounts, so we’re creating them for you.', + 'You don’t have Google Ads account, so we’re creating one for you.', 'google-listings-and-ads' ) }
- ); - } else if ( isCreatingAdsAccount ) { - return ( - <> -- { __( - 'You don’t have Google Ads account, so we’re creating one for you.', - 'google-listings-and-ads' - ) } -
- - { __( - 'Required to set up conversion measurement for your store.', - 'google-listings-and-ads' - ) } - - > - ); - } else if ( isCreatingMCAccount ) { - return ( - <> -- { __( - 'You don’t have Merchant Center account, so we’re creating one for you.', - 'google-listings-and-ads' - ) } -
- - { __( - 'Required to sync products so they show on Google.', - 'google-listings-and-ads' - ) } - - > - ); - } + + { __( + 'Required to set up conversion measurement for your store.', + 'google-listings-and-ads' + ) } + + > + ); + } else if ( isCreatingMCAccount ) { + return ( + <> ++ { __( + 'You don’t have Merchant Center account, so we’re creating one for you.', + 'google-listings-and-ads' + ) } +
+ + { __( + 'Required to sync products so they show on Google.', + 'google-listings-and-ads' + ) } + + > + ); + } + + if ( isLoading ) { + return null; } return ( <>{ google?.email }
- { googleMCAccount?.id && ( + { googleMCAccount?.id && googleMCAccount.id !== 0 && ({ sprintf( // Translators: %s is the Merchant Center ID @@ -92,7 +92,7 @@ const AccountCreationDescription = ( { ) }
) } - { googleAdsAccount?.id && ( + { googleAdsAccount?.id && googleAdsAccount.id !== 0 && (
{ sprintf(
// Translators: %s is the Google Ads ID
diff --git a/js/src/components/google-combo-account-card/connected-google-combo-account-card.js b/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
index 0bee8a26e0..eab37bc936 100644
--- a/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
+++ b/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
@@ -24,12 +24,9 @@ import AccountCreationDescription from './account-creation-description';
* Renders a Google account card UI with connected account information.
* It will also kickoff Ads and Merchant Center account creation if the user does not have accounts.
*
- * @param {Object} props React props.
- * @param {{ googleAccount: object }} props.googleAccount The Google account.
- *
* @fires gla_google_account_connect_different_account_button_click
*/
-const ConnectedGoogleComboAccountCard = ( { googleAccount } ) => {
+const ConnectedGoogleComboAccountCard = () => {
const {
googleMCAccount,
hasFinishedResolution: hasFinishedResolutionForCurrentMCAccount,
@@ -93,7 +90,10 @@ const ConnectedGoogleComboAccountCard = ( { googleAccount } ) => {
className="gla-google-combo-account-card--connected"
description={
{ text } { google?.email }
- { sprintf(
- // Translators: %s is the Merchant Center ID
- __(
- 'Merchant Center ID: %s',
- 'google-listings-and-ads'
- ),
- googleMCAccount.id
- ) }
-
- { sprintf(
- // Translators: %s is the Google Ads ID
- __(
- 'Google Ads ID: %s',
- 'google-listings-and-ads'
- ),
- googleAdsAccount.id
- ) }
-
+ { __(
+ 'Merchant Center is required to sync products so they show on Google. Google Ads is required to set up conversion measurement for your store.',
+ 'google-listings-and-ads'
+ ) }
+
- { __(
- 'Merchant Center is required to sync products so they show on Google. Google Ads is required to set up conversion measurement for your store.',
- 'google-listings-and-ads'
- ) }
-
{ __(
diff --git a/js/src/components/google-combo-account-card/connected-google-combo-account-card.js b/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
index 22c1937239..d58944cd63 100644
--- a/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
+++ b/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
@@ -92,6 +92,7 @@ const ConnectedGoogleComboAccountCard = () => {
! hasFinishedResolutionForCurrentAdsAccount ||
! hasFinishedResolutionForCurrentMCAccount
}
+ isCreatingBothAccounts={ isCreatingBothAccounts }
isCreatingAdsAccount={ isCreatingAdsAccount }
isCreatingMCAccount={ isCreatingMCAccount }
googleMCAccount={ googleMCAccount }
diff --git a/js/src/hooks/useAutoCreateAdsMCAccounts.js b/js/src/hooks/useAutoCreateAdsMCAccounts.js
index 06935d2589..4a1ea0932a 100644
--- a/js/src/hooks/useAutoCreateAdsMCAccounts.js
+++ b/js/src/hooks/useAutoCreateAdsMCAccounts.js
@@ -33,7 +33,7 @@ const useAutoCreateAdsMCAccounts = () => {
const isCreatingBothAccountsRef = useRef( false );
const isCreatingAdsAccountsRef = useRef( false );
const isCreatingMCAccountsRef = useRef( false );
- const initHasExistingMCAAccountsRef = useRef( null );
+ const initHasExistingMCAccountsRef = useRef( null );
const initHasExistingAdsAccountsRef = useRef( null );
const accountsCreatedRef = useRef( false );
@@ -44,7 +44,7 @@ const useAutoCreateAdsMCAccounts = () => {
const {
existingAccounts: existingAdsAccount,
- isResolving: isResolvingExistingAdsAccount,
+ hasFinishedResolution: hasFinishedResolutionForExistingAdsAccount,
} = useExistingGoogleAdsAccounts();
const [ handleCreateAccount, { response } ] = useCreateMCAccount();
@@ -54,15 +54,15 @@ const useAutoCreateAdsMCAccounts = () => {
const hasExistingAdsAccount = existingAdsAccount?.length > 0;
if (
- initHasExistingMCAAccountsRef.current === null &&
+ initHasExistingMCAccountsRef.current === null &&
hasFinishedResolutionForExistingMCAccounts
) {
- initHasExistingMCAAccountsRef.current = hasExistingMCAccount;
+ initHasExistingMCAccountsRef.current = hasExistingMCAccount;
}
if (
initHasExistingAdsAccountsRef.current === null &&
- ! isResolvingExistingAdsAccount
+ hasFinishedResolutionForExistingAdsAccount
) {
initHasExistingAdsAccountsRef.current = hasExistingAdsAccount;
}
@@ -82,19 +82,19 @@ const useAutoCreateAdsMCAccounts = () => {
const accountCreationChecksResolved =
initHasExistingAdsAccountsRef.current !== null &&
- initHasExistingMCAAccountsRef.current !== null;
+ initHasExistingMCAccountsRef.current !== null;
const shouldCreateAdsAccount =
initHasExistingAdsAccountsRef.current === false &&
- initHasExistingMCAAccountsRef.current === true;
+ initHasExistingMCAccountsRef.current === true;
const shouldCreateMCAccount =
initHasExistingAdsAccountsRef.current === true &&
- initHasExistingMCAAccountsRef.current === false;
+ initHasExistingMCAccountsRef.current === false;
const shouldCreateBothAccounts =
! initHasExistingAdsAccountsRef.current &&
- ! initHasExistingMCAAccountsRef.current;
+ ! initHasExistingMCAccountsRef.current;
const isCreatingAccounts =
isCreatingAdsAccountsRef.current ||
diff --git a/js/src/setup-mc/setup-stepper/setup-accounts/index.js b/js/src/setup-mc/setup-stepper/setup-accounts/index.js
index d4bfc68f86..3288e46f61 100644
--- a/js/src/setup-mc/setup-stepper/setup-accounts/index.js
+++ b/js/src/setup-mc/setup-stepper/setup-accounts/index.js
@@ -127,6 +127,9 @@ const SetupAccounts = ( props ) => {
( googleMCAccount?.status === 'incomplete' &&
googleMCAccount?.step === 'link_ads' ) );
+ console.log('isGoogleAdsReady', isGoogleAdsReady);
+ console.log('isGoogleMCReady', isGoogleMCReady);
+
const isContinueButtonDisabled = ! (
hasFinishedResolution &&
isGoogleAdsReady &&
diff --git a/tests/e2e/specs/setup-mc/step-1-accounts.test.js b/tests/e2e/specs/setup-mc/step-1-accounts.test.js
index de4c235120..432b159729 100644
--- a/tests/e2e/specs/setup-mc/step-1-accounts.test.js
+++ b/tests/e2e/specs/setup-mc/step-1-accounts.test.js
@@ -223,23 +223,70 @@ test.describe( 'Set up accounts', () => {
await setUpAccountsPage.mockJetpackConnected();
await setUpAccountsPage.mockGoogleConnected();
- await setupAdsAccountPage.fulfillAdsAccountsRequests( [
+ await page.route( /\/wc\/gla\/mc\/accounts\b/, ( route ) => {
+ if ( route.request().method() === 'POST' ) {
+ // Do nothing.
+ } else {
+ route.continue();
+ }
+ } );
+
+ await page.route( /\/wc\/gla\/ads\/accounts\b/, ( route ) => {
+ if ( route.request().method() === 'POST' ) {
+ // Do nothing.
+ } else {
+ route.continue();
+ }
+ } );
+
+ await setupAdsAccountPage.fulfillAdsAccounts(
+ [
+ [],
+ {
+ id: 78787878,
+ name: 'gla',
+ },
+ ],
+ 200,
+ [ 'GET' ]
+ );
+
+ await setupAdsAccountPage.fulfillMCAccounts(
+ [
+ [],
+ {
+ id: 5432178,
+ name: null,
+ subaccount: null,
+ domain: null,
+ },
+ ],
+ 200,
+ 'GET'
+ );
+
+ await setUpAccountsPage.fulfillAdsConnection( [
{
id: 0,
currency: 'USD',
- status: 'disconnected',
+ status: 'approved',
symbol: '$',
},
{
- id: 119119119,
+ id: 78787878,
currency: 'USD',
- status: 'disconnected',
+ status: 'approved',
symbol: '$',
},
] );
- await setupAdsAccountPage.fulfillMCAccountsRequests( [
- [],
+ await setUpAccountsPage.fulfillMCConnection( [
+ {
+ id: 0,
+ name: null,
+ subaccount: null,
+ domain: null,
+ },
{
id: 5432178,
name: null,
@@ -262,20 +309,98 @@ test.describe( 'Set up accounts', () => {
} );
test( 'should see the merchant center id and ads account id if connected', async () => {
+ await setUpAccountsPage.mockJetpackConnected();
await setUpAccountsPage.mockGoogleConnected();
- await setUpAccountsPage.mockAdsAccountConnected();
- await setUpAccountsPage.mockMCConnected();
await setUpAccountsPage.goto();
+ await setupAdsAccountPage.fulfillAdsAccounts(
+ {
+ message:
+ 'Account must be accepted before completing setup.',
+ has_access: false,
+ step: 'account_access',
+ invite_link: 'https://ads.google.com/nav/',
+ },
+ 428,
+ [ 'POST' ]
+ );
+
+ await setupAdsAccountPage.fulfillMCAccounts(
+ {
+ id: 5432178,
+ name: null,
+ subaccount: null,
+ domain: null,
+ },
+ 200,
+ [ 'POST' ]
+ );
+
+ await setupAdsAccountPage.fulfillAdsAccounts(
+ [
+ [],
+ {
+ id: 78787878,
+ name: 'gla',
+ },
+ ],
+ 200,
+ [ 'GET' ]
+ );
+
+ await setupAdsAccountPage.fulfillMCAccounts(
+ [
+ [],
+ {
+ id: 5432178,
+ name: null,
+ subaccount: null,
+ domain: null,
+ },
+ ],
+ 200,
+ 'GET'
+ );
+
+ await setUpAccountsPage.fulfillAdsConnection( [
+ {
+ id: 0,
+ currency: 'USD',
+ status: 'approved',
+ symbol: '$',
+ },
+ {
+ id: 78787878,
+ currency: 'USD',
+ status: 'approved',
+ symbol: '$',
+ },
+ ] );
+
+ await setUpAccountsPage.fulfillMCConnection( [
+ {
+ id: 0,
+ name: null,
+ subaccount: null,
+ domain: null,
+ },
+ {
+ id: 5432178,
+ name: null,
+ subaccount: null,
+ domain: null,
+ },
+ ] );
+
const googleAccountCard = setUpAccountsPage.getGoogleAccountCard();
await expect(
- googleAccountCard.getByText( 'Merchant Center ID: 1234', {
+ googleAccountCard.getByText( 'Merchant Center ID: 5432178', {
exact: true,
} )
).toBeVisible();
await expect(
- googleAccountCard.getByText( 'Google Ads ID: 12345', {
+ googleAccountCard.getByText( 'Google Ads ID: 78787878', {
exact: true,
} )
).toBeVisible();
@@ -326,6 +451,8 @@ test.describe( 'Set up accounts', () => {
test.describe( 'When all accounts are connected', async () => {
test.beforeAll( async () => {
+ await setupAdsAccountPage.mockJetpackConnected();
+ await setUpAccountsPage.mockGoogleConnected();
await setupAdsAccountPage.mockAdsAccountConnected();
await setupAdsAccountPage.mockAdsStatusClaimed();
await setUpAccountsPage.mockMCConnected();
diff --git a/tests/e2e/utils/mock-requests.js b/tests/e2e/utils/mock-requests.js
index a94caebe59..477c608057 100644
--- a/tests/e2e/utils/mock-requests.js
+++ b/tests/e2e/utils/mock-requests.js
@@ -21,49 +21,38 @@ export default class MockRequests {
* @return {Promise
- { __(
- 'You don’t have Merchant Center nor Google Ads accounts, so we’re creating them for you.',
- 'google-listings-and-ads'
- ) }
-
- { __(
- 'You don’t have Google Ads account, so we’re creating one for you.',
- 'google-listings-and-ads'
- ) }
-
- { __(
- 'You don’t have Merchant Center account, so we’re creating one for you.',
- 'google-listings-and-ads'
- ) }
- { text } { google?.email } { text }
+ { __(
+ 'You don’t have Merchant Center nor Google Ads accounts, so we’re creating them for you.',
+ 'google-listings-and-ads'
+ ) }
+
+ { __(
+ 'You don’t have Google Ads account, so we’re creating one for you.',
+ 'google-listings-and-ads'
+ ) }
+
+ { __(
+ 'You don’t have Merchant Center account, so we’re creating one for you.',
+ 'google-listings-and-ads'
+ ) }
+ { google?.email } { google?.email } { text } { google?.email }
+ { sprintf(
// Translators: %s is the Merchant Center ID
__(
'Merchant Center ID: %s',
@@ -109,12 +106,11 @@ const AccountCreationDescription = ( {
),
googleMCAccount.id
) }
- />
+
+ { sprintf(
// Translators: %s is the Google Ads ID
__(
'Google Ads ID: %s',
@@ -122,7 +118,7 @@ const AccountCreationDescription = ( {
),
googleAdsAccount.id
) }
- />
+
@@ -73,7 +73,7 @@ const AccountCreationDescription = ( {
>
);
- } else if ( isCreatingMCAccount ) {
+ } else if ( isCreatingOnlyMCAccount ) {
return (
<>
diff --git a/js/src/components/google-combo-account-card/connected-google-combo-account-card.js b/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
index 6ef37ab844..1d0b28123d 100644
--- a/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
+++ b/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
@@ -38,8 +38,8 @@ const ConnectedGoogleComboAccountCard = () => {
const {
isCreatingAccounts,
isCreatingBothAccounts,
- isCreatingAdsAccount,
- isCreatingMCAccount,
+ isCreatingOnlyAdsAccount,
+ isCreatingOnlyMCAccount,
accountCreationChecksResolved,
accountsCreated,
} = useAutoCreateAdsMCAccounts();
@@ -104,8 +104,8 @@ const ConnectedGoogleComboAccountCard = () => {
description={
@@ -73,7 +73,7 @@ const AccountCreationDescription = ( {
>
);
- } else if ( isCreatingOnlyMCAccount ) {
+ } else if ( isCreatingMCAccountOnly ) {
return (
<>
diff --git a/js/src/components/google-combo-account-card/connected-google-combo-account-card.js b/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
index 1d0b28123d..f198f50929 100644
--- a/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
+++ b/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
@@ -38,8 +38,8 @@ const ConnectedGoogleComboAccountCard = () => {
const {
isCreatingAccounts,
isCreatingBothAccounts,
- isCreatingOnlyAdsAccount,
- isCreatingOnlyMCAccount,
+ isCreatingAdsAccountOnly,
+ isCreatingMCAccountOnly,
accountCreationChecksResolved,
accountsCreated,
} = useAutoCreateAdsMCAccounts();
@@ -104,8 +104,8 @@ const ConnectedGoogleComboAccountCard = () => {
description={
- { __(
- 'You don’t have Merchant Center nor Google Ads accounts, so we’re creating them for you.',
- 'google-listings-and-ads'
- ) }
-
- { __(
- 'You don’t have Google Ads account, so we’re creating one for you.',
- 'google-listings-and-ads'
- ) }
-
{ __(
- 'You don’t have Merchant Center account, so we’re creating one for you.',
+ 'You don’t have Merchant Center nor Google Ads accounts, so we’re creating them for you.',
'google-listings-and-ads'
) }
+ { __(
+ 'You don’t have Google Ads account, so we’re creating one for you.',
+ 'google-listings-and-ads'
+ ) }
+
+ { __(
+ 'You don’t have Merchant Center account, so we’re creating one for you.',
+ 'google-listings-and-ads'
+ ) }
+ { google?.email }
{ sprintf(
// Translators: %s is the Merchant Center ID
@@ -108,7 +98,7 @@ const AccountCreationDescription = ( {
) }
{ sprintf(
// Translators: %s is the Google Ads ID
diff --git a/js/src/components/google-combo-account-card/connected-google-combo-account-card.js b/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
index f198f50929..9a0f7c26f4 100644
--- a/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
+++ b/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
@@ -15,10 +15,7 @@ import './connected-google-combo-account-card.scss';
import useGoogleAdsAccount from '.~/hooks/useGoogleAdsAccount';
import useGoogleMCAccount from '.~/hooks/useGoogleMCAccount';
import ConnectedIconLabel from '../connected-icon-label';
-import {
- GOOGLE_ADS_ACCOUNT_STATUS,
- GOOGLE_MC_ACCOUNT_STATUS,
-} from '.~/constants';
+import { CREATING_BOTH_ACCOUNTS } from '.~/constants';
/**
* Renders a Google account card UI with connected account information.
@@ -36,12 +33,9 @@ const ConnectedGoogleComboAccountCard = () => {
} = useGoogleMCAccount();
const {
- isCreatingAccounts,
- isCreatingBothAccounts,
- isCreatingAdsAccountOnly,
- isCreatingMCAccountOnly,
accountCreationChecksResolved,
- accountsCreated,
+ isCreatingAccounts,
+ isCreatingWhichAccount,
} = useAutoCreateAdsMCAccounts();
if (
@@ -52,21 +46,11 @@ const ConnectedGoogleComboAccountCard = () => {
return
{ __(
@@ -89,7 +73,7 @@ const ConnectedGoogleComboAccountCard = () => {
);
}
- if ( isGoogleAdsAccountConnected && isGoogleMCAccountConnected ) {
+ if ( isGoogleAdsReady && isGoogleMCReady ) {
return { google?.email }
{ sprintf(
// Translators: %s is the Merchant Center ID
@@ -98,7 +101,7 @@ const AccountCreationDescription = ( {
) }
{ sprintf(
// Translators: %s is the Google Ads ID
diff --git a/js/src/components/google-combo-account-card/connected-google-combo-account-card.js b/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
index a2656ea9ce..cc7011c915 100644
--- a/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
+++ b/js/src/components/google-combo-account-card/connected-google-combo-account-card.js
@@ -7,15 +7,16 @@ import { __ } from '@wordpress/i18n';
* Internal dependencies
*/
import AccountCard, { APPEARANCE } from '../account-card';
+import AccountCreationDescription from './account-creation-description';
import AppSpinner from '../app-spinner';
-import useAutoCreateAdsMCAccounts from '../../hooks/useAutoCreateAdsMCAccounts';
+import ConnectedIconLabel from '../connected-icon-label';
+import { CREATING_BOTH_ACCOUNTS } from './constants';
import LoadingLabel from '../loading-label/loading-label';
-import AccountCreationDescription from './account-creation-description';
-import './connected-google-combo-account-card.scss';
+import useAutoCreateAdsMCAccounts from '../../hooks/useAutoCreateAdsMCAccounts';
import useGoogleAdsAccount from '.~/hooks/useGoogleAdsAccount';
+import useGoogleAdsAccountStatus from '.~/hooks/useGoogleAdsAccountStatus';
import useGoogleMCAccount from '.~/hooks/useGoogleMCAccount';
-import ConnectedIconLabel from '../connected-icon-label';
-import { CREATING_BOTH_ACCOUNTS } from '.~/constants';
+import './connected-google-combo-account-card.scss';
/**
* Renders a Google account card UI with connected account information.
@@ -23,30 +24,43 @@ import { CREATING_BOTH_ACCOUNTS } from '.~/constants';
*/
const ConnectedGoogleComboAccountCard = () => {
const {
- googleAdsAccount,
+ hasGoogleAdsConnection,
hasFinishedResolution: hasFinishedResolutionForCurrentAdsAccount,
} = useGoogleAdsAccount();
const {
googleMCAccount,
+ isPreconditionReady,
hasFinishedResolution: hasFinishedResolutionForCurrentMCAccount,
} = useGoogleMCAccount();
- const { accountCreationChecksResolved, isCreatingWhichAccount } =
- useAutoCreateAdsMCAccounts();
+ const {
+ hasFinishedResolutionForExistingAdsMCAccounts,
+ isCreatingWhichAccount,
+ } = useAutoCreateAdsMCAccounts();
+
+ const { hasAccess, step } = useGoogleAdsAccountStatus();
const isCreatingAccounts = !! isCreatingWhichAccount;
if (
- ! accountCreationChecksResolved ||
+ ! hasFinishedResolutionForExistingAdsMCAccounts ||
! hasFinishedResolutionForCurrentAdsAccount ||
! hasFinishedResolutionForCurrentMCAccount
) {
return { text }
- { __(
- 'You don’t have Merchant Center nor Google Ads accounts, so we’re creating them for you.',
- 'google-listings-and-ads'
- ) }
-
- { __(
- 'You don’t have Google Ads account, so we’re creating one for you.',
- 'google-listings-and-ads'
- ) }
-
- { __(
- 'You don’t have Merchant Center account, so we’re creating one for you.',
- 'google-listings-and-ads'
- ) }
- { google?.email }
- { sprintf(
- // Translators: %s is the Merchant Center ID
- __(
- 'Merchant Center ID: %s',
- 'google-listings-and-ads'
- ),
- googleMCAccount.id
- ) }
-
- { sprintf(
- // Translators: %s is the Google Ads ID
- __(
- 'Google Ads ID: %s',
- 'google-listings-and-ads'
- ),
- googleAdsAccount.id
- ) }
-
- { __(
- 'Merchant Center is required to sync products so they show on Google. Google Ads is required to set up conversion measurement for your store.',
- 'google-listings-and-ads'
- ) }
- { text } { text } { google.email }
{ sprintf(
// Translators: %s is the Merchant Center ID
__( 'Merchant Center ID: %s', 'google-listings-and-ads' ),
googleMCAccount.id
) }
-
{ sprintf(
// Translators: %s is the Google Ads ID
__( 'Google Ads ID: %s', 'google-listings-and-ads' ),
googleAdsAccount.id
) }
- { google.email }
{ sprintf(
@@ -36,7 +36,7 @@ const AccountDetails = () => {
googleAdsAccount.id
) }
{ google.email }
- { sprintf(
- // Translators: %s is the Merchant Center ID
- __( 'Merchant Center ID: %s', 'google-listings-and-ads' ),
- googleMCAccount.id
- ) }
+ { googleMCAccount.id > 0 &&
+ sprintf(
+ // Translators: %s is the Merchant Center ID
+ __(
+ 'Merchant Center ID: %s',
+ 'google-listings-and-ads'
+ ),
+ googleMCAccount.id
+ ) }
- { sprintf(
- // Translators: %s is the Google Ads ID
- __( 'Google Ads ID: %s', 'google-listings-and-ads' ),
- googleAdsAccount.id
- ) }
+ { googleAdsAccount.id > 0 &&
+ sprintf(
+ // Translators: %s is the Google Ads ID
+ __( 'Google Ads ID: %s', 'google-listings-and-ads' ),
+ googleAdsAccount.id
+ ) }