Skip to content

@ W-18953852: Merge Feature/auto bonus product in to Develop#2704

Merged
ddiazccrz merged 56 commits intodevelopfrom
feature/auto-bonus-product
Jul 8, 2025
Merged

@ W-18953852: Merge Feature/auto bonus product in to Develop#2704
ddiazccrz merged 56 commits intodevelopfrom
feature/auto-bonus-product

Conversation

@ddiazccrz
Copy link
Contributor

@ddiazccrz ddiazccrz commented Jul 1, 2025

Description

Merge the Feature/Auto-Bonus-Product branch that contains support for automatic bonus products in to the develop branch

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • (change1)

How to Test-Drive This PR

  • On the refArch store, women's dresses have an automatic promotion where adding 250 worth of dresses will trigger an automatic bonus product to show up in the cart

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

}

// Categorize products into regular and bonus
const categorizedProducts = basket.productItems?.reduce(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it is worth to extract this logic to a util function? I think we want to do this for PDP as well when adding an item to cart?

Copy link
Contributor

@alexvuong alexvuong Jul 3, 2025

Choose a reason for hiding this comment

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

Let's use useMemo to make sure this does not run again unless basket has changed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dont think we need this on PDP yet, when/if we do we can extract. Updated to useMemo though

).toBeVisible()
})
const regularProduct = screen.getByTestId('sf-cart-item-701642889830M')
const bonusProduct = screen.getByTestId('sf-cart-item-013742335262M')
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we look for product name being render on the UI? From react-testing-library best practise, it is better to test using getByText/getByLabelText instead of relying on getByTestId

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

])
describe('Bonus products', () => {
beforeEach(() => {
global.server.use(
Copy link
Contributor

Choose a reason for hiding this comment

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

How about using prependHandlersToServer to reduce the boilerplate code for api mock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


describe('Unavailable products tests', () => {
beforeEach(() => {
global.server.use(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this test changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure, undid this

})

const regularProduct = screen.getByTestId('sf-cart-item-013742335262M')
expect(regularProduct).toBeInTheDocument()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this test changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dont know, undid this change

Co-authored-by: Alex Vuong <alex.vuong@salesforce.com>
Signed-off-by: Daniel Diaz <38542490+ddiazccrz@users.noreply.github.com>
{id: '2', bonusProductLineItem: false}
]
}
render(<MockedComponent basketData={basketData} />)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use renderWithProviders from test-utils.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@ddiazccrz
Copy link
Contributor Author

I can't remove bonus item from cart despite it said item is removed from cart from a toast.

auto.bonus.cart.mov

I removed the remove button, for auto-bonus products you cant actually remove them as the server just keeps adding them back in on cart calculation. We dont have anything but auto-bonus products right now so not a need to change this yet.

kzheng-sfdc
kzheng-sfdc previously approved these changes Jul 4, 2025
Signed-off-by: sf-deepali-bharmal <deepali.bharmal@salesforce.com>
@sf-deepali-bharmal sf-deepali-bharmal dismissed stale reviews from kzheng-sfdc and themself via 5f37a75 July 7, 2025 16:13
@ddiazccrz ddiazccrz enabled auto-merge (squash) July 8, 2025 14:27
@ddiazccrz ddiazccrz merged commit cf94a6a into develop Jul 8, 2025
36 checks passed
kumaravinashcommercecloud pushed a commit that referenced this pull request Aug 12, 2025
* Trigger a modal if bonus products exist in AddToCart response

* skip changelog

* skip changelog

* fixed import issue

* Added bonus products on the cart page

* Updated change log

* Removed unused import

* Updated cart secondary buttons remove is gift and wishlist for bonus products

* Add bonus products title partial test

* Fixed linting issues

* Review suggestions

* removed localstorage and updated bonus products info from current basket

* removed unnecessary code

* nit space

* Code review comments

* fixed 2 failing tests

* Fix linting issues

* fixed a unit test

* fixed lint errors

* Moved mock data, removed un-needed index

* Addressed PR comments

* use current basket query

* nit

* removed unnecessary code

* Switched to test from it

* fixed infinite re-render issue

* Merged Develop in to Feature

* fixed lint issue when merging

* Update CHANGELOG.md

Signed-off-by: Daniel Diaz <38542490+ddiazccrz@users.noreply.github.com>

* Removed label check since no longer present

* Removed partials and made them components

* Updated translations

* Update translation and missing label

* Reverted bonus product modal

* Removed bonus product from test util

* Fixed whitespace issues

* Fixed change log

* Fixed more whitespace

* Added in the PR: 2562

* Refactored onblur and onChange to be functions

* Update packages/template-retail-react-app/app/pages/cart/partials/bonus-products-title.jsx

Co-authored-by: Ken Zheng <33469941+kzheng-sfdc@users.noreply.github.com>
Signed-off-by: Daniel Diaz <38542490+ddiazccrz@users.noreply.github.com>

* Update packages/template-retail-react-app/app/mocks/mock-data.js

Co-authored-by: Alex Vuong <alex.vuong@salesforce.com>
Signed-off-by: Daniel Diaz <38542490+ddiazccrz@users.noreply.github.com>

* Fixed unit test

* Fixed lint

---------

Signed-off-by: Daniel Diaz <38542490+ddiazccrz@users.noreply.github.com>
Signed-off-by: sf-deepali-bharmal <deepali.bharmal@salesforce.com>
Co-authored-by: madhuri-uppu <madhuri.uppu@salesforce.com>
Co-authored-by: Ken Zheng <33469941+kzheng-sfdc@users.noreply.github.com>
Co-authored-by: Alex Vuong <alex.vuong@salesforce.com>
Co-authored-by: sf-deepali-bharmal <deepali.bharmal@salesforce.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review PR is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.