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

Add minimum budget limit #2583

Merged

Conversation

dsawardekar
Copy link
Collaborator

@dsawardekar dsawardekar commented Sep 5, 2024

Changes proposed in this Pull Request:

Closes #2503

This PR updates the campaign flow to include validation of minimum daily limits. An error message is shown if the amount is less than the daily limit.

Screenshots:

With an insufficient amount:
image

With a sufficient amount:
image

Detailed test instructions:

  1. On the final step of the onboarding flow, Click create a campaign
  2. You should see the Set your budget section
  3. In the Daily avg cost, enter 1 < value < 5
  4. You should see the above error below the input (red styling TBD)

Additional details:

Update - Enforce the daily limit of 30% in setup your budget section

Changelog entry

Update - Adjust the minimum average daily cost of a campaign to 30% of the highest recommended value among audience countries.

@github-actions github-actions bot added the changelog: update Big changes to something that wasn't broken. label Sep 5, 2024
Copy link

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 70.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 63.1%. Comparing base (1626f8a) to head (9dd2744).
Report is 71 commits behind head on feature/2459-campaign-creation-flow.

Files with missing lines Patch % Lines
js/src/pages/edit-paid-ads-campaign/index.js 0.0% 4 Missing and 1 partial ⚠️
js/src/components/paid-ads/campaign-assets-form.js 66.7% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                          Coverage Diff                          @@
##           feature/2459-campaign-creation-flow   #2583     +/-   ##
=====================================================================
+ Coverage                                 62.6%   63.1%   +0.5%     
=====================================================================
  Files                                      329     329             
  Lines                                     5166    5183     +17     
  Branches                                  1254    1262      +8     
=====================================================================
+ Hits                                      3232    3268     +36     
+ Misses                                    1752    1735     -17     
+ Partials                                   182     180      -2     
Flag Coverage Δ
js-unit-tests 63.1% <70.0%> (+0.5%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
js/src/components/paid-ads/validateCampaign.js 100.0% <100.0%> (ø)
js/src/pages/create-paid-ads-campaign/index.js 10.0% <ø> (ø)
js/src/setup-ads/ads-stepper/setup-paid-ads.js 62.1% <ø> (ø)
js/src/components/paid-ads/campaign-assets-form.js 76.9% <66.7%> (-0.9%) ⬇️
js/src/pages/edit-paid-ads-campaign/index.js 8.6% <0.0%> (-0.6%) ⬇️

... and 6 files with indirect coverage changes

@dsawardekar
Copy link
Collaborator Author

@asvinb We need a styling update to the error message shown when a minimum limit is shown to the user. The input box also needs to be updated when in that invalid input state. Can you please take a look? Thanks!

image

@dsawardekar
Copy link
Collaborator Author

@joemcgill As part of this work, I extracted the getHighestBudget into a utility.

  • Should we update js/src/components/paid-ads/budget-section/budget-recommendation/index.js to use this utility
    • If yes, should those changes be part of this PR or a separate one

@joemcgill
Copy link
Collaborator

Thanks @dsawardekar. Re:

Should we update js/src/components/paid-ads/budget-section/budget-recommendation/index.js to use this utility

Let's not update the Paid Ads flow at this time. It should end up getting handled as part of #2535.

@dsawardekar dsawardekar changed the base branch from develop to feature/2459-campaign-creation-flow September 11, 2024 05:32
@dsawardekar
Copy link
Collaborator Author

@joemcgill This is ready for code review. Note that I needed to create a new mock helper for the budget recommendation, let me know if that needs to be refactored.

@dsawardekar dsawardekar marked this pull request as ready for review September 11, 2024 06:37
Copy link
Collaborator

@asvinb asvinb left a comment

Choose a reason for hiding this comment

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

@dsawardekar I left some comments on the PR. Can you kindly check please and let me know what you think?

js/src/components/paid-ads/validateCampaign.js Outdated Show resolved Hide resolved
js/src/utils/getHighestBudget.js Outdated Show resolved Hide resolved
@dsawardekar
Copy link
Collaborator Author

@asvinb I've updated the PR per the feedback. Can you take another look? thanks!

asvinb
asvinb previously requested changes Sep 13, 2024
Copy link
Collaborator

@asvinb asvinb left a comment

Choose a reason for hiding this comment

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

@dsawardekar Thanks for the updates. I think it's very close to approval. Can you check my latest comments please? Thanks!

@asvinb asvinb changed the title Update/2459 add minimum budget limit Add minimum budget limit Sep 16, 2024
Copy link
Collaborator

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

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

@asvinb I have one small tweak for this that I'd like to make, but am pre-approving and this can go to QA.

js/src/components/paid-ads/validateCampaign.js Outdated Show resolved Hide resolved
@eason9487
Copy link
Member

Hi @asvinb @joemcgill

Before starting a new round of code reviews, could you help me clarify the two questions in #2583 (comment)?

Using the current 78fc8bb revision and replacing:

const minAmount = ( dailyBudget * BUDGET_MIN_PERCENT ).toFixed(
precision
);

with:

const minAmount = Math.ceil( dailyBudget * BUDGET_MIN_PERCENT );

Apart from using the greater than wording, It works pretty well and fulfills the rest requirements without the semantic inaccuracies in the error message.

Kapture.2024-10-04.at.18.58.34.mp4

I have read all the relevant discussions in the PR. However, taking the decimals into account when calculating the minimum budget value still confuses me.

@asvinb
Copy link
Collaborator

asvinb commented Oct 4, 2024

Hello @eason9487
I think it's the word "rounding" which is causing some confusion here and what happens when the decimal places are set in the store settings and using Math.round. I think Math.ceil works well as well and we just need to align that we can use the at least instead of greater than (where we'll need to take the decimal points into account. For e.g if "greater than" was to be used, then 5.99 should be displayed if the decimal points setting is set to 2 decimals).

@joemcgill
Copy link
Collaborator

I think Math.ceil works well as well and we just need to align that we can use the at least instead of greater than

I agree and using "at least" is totally appropriate here and more accurate than the original requirements that I had written for the issue.

@eason9487
Copy link
Member

eason9487 commented Oct 4, 2024

Hi @asvinb

I think it's the word "rounding" which is causing some confusion here and what happens when the decimal places are set in the store settings and using Math.round. I think Math.ceil works well as well [...]

This question should not be related to the word "rounding" and it's not the cause of the confusion. I used Math.ceil in the example just because #2503 (comment) mentioned "rounding up".

[...] and we just need to align that we can use the at least instead of greater than (where we'll need to take the decimal points into account. For e.g if "greater than" was to be used, then 5.99 should be displayed if the decimal points setting is set to 2 decimals)

Yes, and the current implementation has already rephrased to at least. So my confusion is, what is the reason for still taking the decimals into account when there is no need?

@asvinb
Copy link
Collaborator

asvinb commented Oct 4, 2024

@eason9487 If we use Math.ceil, then there's no need to take any decimals into account.

@eason9487
Copy link
Member

Consider this PR is based on the update/2535-consolidate-ad-creation-ccf-merged branch, and the branch's PR #2623 may have several code changes that conflict with this PR, and even need some rewriting. Therefore, I'm going to hold off on reviewing this PR until the code review for #2623 is done first and the possible code conflicts are resolved.

Base automatically changed from update/2535-consolidate-ad-creation-ccf-merged to feature/2459-campaign-creation-flow October 16, 2024 09:14
js/src/components/paid-ads/campaign-assets-form.js Outdated Show resolved Hide resolved
js/src/components/paid-ads/campaign-assets-form.test.js Outdated Show resolved Hide resolved
js/src/components/paid-ads/validateCampaign.js Outdated Show resolved Hide resolved
js/src/components/paid-ads/validateCampaign.js Outdated Show resolved Hide resolved
js/src/components/paid-ads/validateCampaign.test.js Outdated Show resolved Hide resolved
tests/e2e/specs/setup-mc/step-4-complete-campaign.test.js Outdated Show resolved Hide resolved
tests/e2e/specs/setup-mc/step-4-complete-campaign.test.js Outdated Show resolved Hide resolved
tests/e2e/specs/setup-mc/step-4-complete-campaign.test.js Outdated Show resolved Hide resolved
tests/e2e/utils/pages/setup-ads/setup-budget.js Outdated Show resolved Hide resolved
Copy link
Member

@eason9487 eason9487 left a comment

Choose a reason for hiding this comment

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

Thanks for the work. LGTM.

@asvinb asvinb merged commit 266009c into feature/2459-campaign-creation-flow Oct 24, 2024
8 checks passed
@asvinb asvinb deleted the update/2459-add-minimum-budget-limit branch October 24, 2024 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: update Big changes to something that wasn't broken.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Campaign Creation: Add minimum budget limit
5 participants