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

Show promo for setting up Google Ads on the product feed tabs #2539 #2641

Merged
merged 39 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
57b4adb
intial commit
kt-12 Oct 10, 2024
3922ab1
CreateCampaignNotice component
kt-12 Oct 12, 2024
711160d
Add CreateCampaignNotice to the product-feed page
kt-12 Oct 12, 2024
656c4a8
check for google ads connection
kt-12 Oct 12, 2024
0170b7d
Get Campaign Notice on prodict feed E2E
kt-12 Oct 14, 2024
7b963a4
fix bug
kt-12 Oct 14, 2024
cefcd7a
fix e2e account connection
kt-12 Oct 14, 2024
25365e5
add more spaces.
kt-12 Oct 14, 2024
a3b00cb
remove unused dashboard variable.
kt-12 Oct 14, 2024
df22e4a
remove incorrect comment
kt-12 Oct 14, 2024
15123b0
remove unused fulfill's
kt-12 Oct 14, 2024
120d5fd
Avoid querying campaigns in useAdsCampaigns before connection
joemcgill Oct 15, 2024
922edb4
Fix E2E tests
joemcgill Oct 15, 2024
c19de71
replace child with text content
kt-12 Oct 18, 2024
1536e4b
simplyfy logic
kt-12 Oct 18, 2024
4631978
simplify logic
kt-12 Oct 18, 2024
6181299
slight rearragment
kt-12 Oct 18, 2024
c65f071
change variable name
kt-12 Oct 18, 2024
59ac898
remove alaising
kt-12 Oct 18, 2024
1b739a6
remove class name
kt-12 Oct 18, 2024
6d90bb9
fix jest error
kt-12 Oct 21, 2024
199675d
Fix notice styling
joemcgill Oct 21, 2024
71a823c
Fix CSS lint issues
joemcgill Oct 21, 2024
80016a2
Review styles.
asvinb Oct 22, 2024
81aba99
Merge branch 'feature/2460-google-ads-value-prop' into feature/2539-s…
kt-12 Oct 23, 2024
05aecee
Merge branch 'feature/2539-show-promo' of https://github.com/woocomme…
kt-12 Oct 23, 2024
165543c
Convert notice to a Flex component in the CardFooter
joemcgill Oct 24, 2024
51dfbca
this could be null so return []
kt-12 Oct 25, 2024
3f824c0
update condition here
kt-12 Oct 25, 2024
660ad11
only fetch campaigns from fully connected account
kt-12 Oct 25, 2024
052a386
match loading attributes with that of google ads account api status
kt-12 Oct 25, 2024
77dd887
remove button click
kt-12 Oct 25, 2024
30237f3
revert back changes to useAdsCampaigns
kt-12 Oct 28, 2024
65972ac
fix e2e
kt-12 Oct 28, 2024
2954cf6
update e2e
kt-12 Oct 30, 2024
09146cf
add page reload
kt-12 Oct 30, 2024
c1bfc5b
remove unused variable.
kt-12 Oct 30, 2024
33ebb24
remove unused css
kt-12 Oct 30, 2024
616756f
remove unused mock. use page.goto instead or reload and rearrage tests
kt-12 Oct 31, 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
5 changes: 3 additions & 2 deletions js/src/dashboard/all-programs-table-card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ const AllProgramsTableCard = ( props ) => {
const { formatAmount } = useAdsCurrency();
const { data: finalCountryCodesData } =
useTargetAudienceFinalCountryCodes();
const { data: adsCampaignsData } = useAdsCampaigns();
const { data: adsCampaignsData, loaded: adsCampaignsLoaded } =
useAdsCampaigns();
const map = useCountryKeyNameMap();

if ( ! finalCountryCodesData || ! adsCampaignsData ) {
if ( ! finalCountryCodesData || ! adsCampaignsLoaded ) {
return <AppSpinner />;
}

Expand Down
2 changes: 1 addition & 1 deletion js/src/dashboard/all-programs-table-card/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe( 'AllProgramsTableCard', () => {
let mockedCampaigns = [];

useAdsCampaigns.mockImplementation( () => {
return { data: mockedCampaigns };
return { data: mockedCampaigns, loaded: true };
} );

mockCampaigns = ( ...campaigns ) => {
Expand Down
23 changes: 12 additions & 11 deletions js/src/hooks/useAdsCampaigns.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useSelect } from '@wordpress/data';
* Internal dependencies
*/
import { STORE_KEY } from '.~/data';
import { glaData } from '.~/constants';
import useGoogleAdsAccount from '.~/hooks/useGoogleAdsAccount';
import useIsEqualRefValue from '.~/hooks/useIsEqualRefValue';

const selectorName = 'getAdsCampaigns';
Expand All @@ -30,19 +30,15 @@ const selectorName = 'getAdsCampaigns';
*/
const useAdsCampaigns = ( ...query ) => {
const queryRefValue = useIsEqualRefValue( query );
const { hasGoogleAdsConnection, hasFinishedResolution, isResolving } =
useGoogleAdsAccount();

return useSelect(
( select ) => {
// TODO: ideally adsSetupComplete should be retrieved from API endpoint
// and then put into wp-data.
// With that in place, then we don't need to depend on glaData
// which requires force reload using window.location.href.
const { adsSetupComplete } = glaData;

if ( ! adsSetupComplete ) {
eason9487 marked this conversation as resolved.
Show resolved Hide resolved
if ( ! hasGoogleAdsConnection ) {
return {
loading: false,
loaded: true,
loading: isResolving,
loaded: hasFinishedResolution,
data: [],
};
}
Expand All @@ -62,7 +58,12 @@ const useAdsCampaigns = ( ...query ) => {
data,
};
},
[ queryRefValue ]
[
hasFinishedResolution,
hasGoogleAdsConnection,
isResolving,
queryRefValue,
]
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { Notice } from '@wordpress/components';

/**
* Internal dependencies
*/
import AddPaidCampaignButton from '.~/components/paid-ads/add-paid-campaign-button';
import useMCProductStatistics from '.~/hooks/useMCProductStatistics';
import useAdsCampaigns from '.~/hooks/useAdsCampaigns';
import './index.scss';

const CreateCampaignNotice = () => {
const { hasFinishedResolution, data: products } = useMCProductStatistics();
const { loaded: campaignsLoaded, data: campaigns } = useAdsCampaigns();

const isLoading =
! hasFinishedResolution || products?.loading || ! campaignsLoaded;

if (
isLoading ||
! products ||
products?.statistics?.active === 0 ||
! campaigns ||
campaigns?.length > 0

Check warning on line 27 in js/src/product-feed/product-statistics/create-campaign-notice/index.js

View check run for this annotation

Codecov / codecov/patch

js/src/product-feed/product-statistics/create-campaign-notice/index.js#L24-L27

Added lines #L24 - L27 were not covered by tests
) {
eason9487 marked this conversation as resolved.
Show resolved Hide resolved
return null;
}

return (

Check warning on line 32 in js/src/product-feed/product-statistics/create-campaign-notice/index.js

View check run for this annotation

Codecov / codecov/patch

js/src/product-feed/product-statistics/create-campaign-notice/index.js#L32

Added line #L32 was not covered by tests
<Notice isDismissible={ false } className="gla-ads-inline-notice">
eason9487 marked this conversation as resolved.
Show resolved Hide resolved
<section>
<p>
{ __(
'You have approved products. Create a Google Ads campaign to reach more customers and drive more sales.',
'google-listings-and-ads'
) }
</p>
<AddPaidCampaignButton
isSmall={ false }
eventProps={ {
context: 'product-feed-overview-promotion',
} }
>
{ __( 'Create Campaign', 'google-listings-and-ads' ) }{ ' ' }
eason9487 marked this conversation as resolved.
Show resolved Hide resolved
</AddPaidCampaignButton>
</section>
</Notice>
);
};

export default CreateCampaignNotice;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.gla-ads-inline-notice{

Check failure on line 1 in js/src/product-feed/product-statistics/create-campaign-notice/index.scss

View workflow job for this annotation

GitHub Actions / Lint CSS

Expected single space before "{" (block-opening-brace-space-before)
margin: $grid-unit-20;
border-left: none;
eason9487 marked this conversation as resolved.
Show resolved Hide resolved
padding: .75rem 1rem;

Check failure on line 4 in js/src/product-feed/product-statistics/create-campaign-notice/index.scss

View workflow job for this annotation

GitHub Actions / Lint CSS

Expected a leading zero (number-leading-zero)

&.is-info {
background-color: #f0f6fc;
}

.components-notice__content p:first-child {
margin-top: 2px;
}
}
2 changes: 2 additions & 0 deletions js/src/product-feed/product-statistics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import SyncStatus from '.~/product-feed/product-statistics/status-box/sync-statu
import SyncProductStatistics from '.~/product-feed/product-statistics/status-box/sync-product-statistics';
import FeedStatus from '.~/product-feed/product-statistics/status-box/feed-status';
import AccountStatus from '.~/product-feed/product-statistics/status-box/account-status';
import CreateCampaignNotice from '.~/product-feed/product-statistics/create-campaign-notice';
import Text from '.~/components/app-text';
import AppSpinner from '.~/components/app-spinner';
import './index.scss';
Expand Down Expand Up @@ -133,6 +134,7 @@ const ProductStatistics = () => {
</SummaryList>
) }
</CardBody>
<CreateCampaignNotice />
eason9487 marked this conversation as resolved.
Show resolved Hide resolved
<CardFooter gap={ 0 }>
<FeedStatus />
<SyncStatus />
Expand Down
26 changes: 26 additions & 0 deletions tests/e2e/specs/add-paid-campaigns/add-paid-campaigns.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,18 @@ test.describe( 'Set up Ads account', () => {
)
).toBeVisible();

await setupBudgetPage.fulfillAdsCampaignsRequest( [
{
id: 111111111,
name: 'Test Campaign',
status: 'enabled',
type: 'performance_max',
amount: budget,
country: 'US',
targeted_locations: [ 'US' ],
},
] );

//It should redirect to the dashboard page
await page.waitForURL(
'/wp-admin/admin.php?page=wc-admin&path=%2Fgoogle%2Fdashboard&guide=campaign-creation-success',
Expand Down Expand Up @@ -499,6 +511,20 @@ test.describe( 'Set up Ads account', () => {
} );

test.describe( 'Create Ads with billing data already setup', () => {
test.beforeAll( async () => {
// Reset the campaigns set in the previous tests.
await setupBudgetPage.fulfillAdsCampaignsRequest( [] );

// Mock budget recommendations.
await setupBudgetPage.fulfillRequest(
kt-12 marked this conversation as resolved.
Show resolved Hide resolved
/\/wc\/gla\/ads\/campaigns\/budget-recommendation\b/,
{
currency: 'USD',
recommendations: [ { country: 'US', daily_budget: 15 } ],
}
);
} );

test( 'Launch paid campaign should be enabled', async () => {
//Click Add paid Campaign
await adsConnectionButton.click();
Expand Down
Loading
Loading