@ W-18953852: Merge Feature/auto bonus product in to Develop#2704
@ W-18953852: Merge Feature/auto bonus product in to Develop#2704
Conversation
…407137V2 @W-18407137 Trigger a modal if new bonus products exist in AddToCart response
…roducts-merge Merged Develop in to Feature/Bonus-Product
| } | ||
|
|
||
| // Categorize products into regular and bonus | ||
| const categorizedProducts = basket.productItems?.reduce( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Let's use useMemo to make sure this does not run again unless basket has changed
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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
| ]) | ||
| describe('Bonus products', () => { | ||
| beforeEach(() => { | ||
| global.server.use( |
There was a problem hiding this comment.
How about using prependHandlersToServer to reduce the boilerplate code for api mock?
|
|
||
| describe('Unavailable products tests', () => { | ||
| beforeEach(() => { | ||
| global.server.use( |
There was a problem hiding this comment.
Why is this test changed?
There was a problem hiding this comment.
not sure, undid this
| }) | ||
|
|
||
| const regularProduct = screen.getByTestId('sf-cart-item-013742335262M') | ||
| expect(regularProduct).toBeInTheDocument() |
There was a problem hiding this comment.
Why is this test changed?
There was a problem hiding this comment.
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} />) |
There was a problem hiding this comment.
Can we use renderWithProviders from test-utils.js?
… feature/auto-bonus-product
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. |
Signed-off-by: sf-deepali-bharmal <deepali.bharmal@salesforce.com>
5f37a75
* 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>
Description
Merge the Feature/Auto-Bonus-Product branch that contains support for automatic bonus products in to the develop branch
Types of Changes
Changes
How to Test-Drive This PR
Checklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization