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

Recommended Products: fix toggling of the favorite icon (@W-16093853@) #1861

Merged
merged 3 commits into from
Jun 25, 2024

Conversation

vmarta
Copy link
Contributor

@vmarta vmarta commented Jun 24, 2024

This PR fixes a bug with the RecommendedProducts such that clicking on the heart icon would toggle the favourite state successfully. It was not doing anything at all previously.

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

  1. Visit this PLP: http://localhost:3000/global/en-GB/category/womens-clothing-tops
  2. Verify that you can still add one of the items there to your wishlist
  3. Now navigate to the PDP and scroll down to the recommended products section
  4. Verify that you can add one of the recommended products to your wishlist
  5. There's a success message and the heart icon is updated correctly

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)

Comment on lines +200 to +201
onFavouriteToggle: (toBeFavourite) => {
const action = toBeFavourite ? addItemToWishlist : removeItemFromWishlist
Copy link
Contributor Author

Choose a reason for hiding this comment

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

By renaming the parameter, I think this should be clearer that it's the target favourite state (not the current state). So we don't get confused whether to add or remove the item.

Comment on lines +200 to +201
onFavouriteToggle: (toBeFavourite) => {
const action = toBeFavourite ? addItemToWishlist : removeItemFromWishlist
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's not add a test yet this time. For this case, we would have to create a test file from scratch because RecommendedProducts do not have one yet.

Since I wanted to test the favourite toggle only, I'd have to mock a bunch of things just to get to the favourite-toggle part of the code. I don't think this is going to be a good test file.

I think a better approach is to do some refactoring (and then test the new code). There are many places with very similar code and they all add/remove item to/from the wishlist.

@vmarta vmarta marked this pull request as ready for review June 25, 2024 16:30
@vmarta vmarta requested a review from a team as a code owner June 25, 2024 16:30
@vmarta vmarta changed the title Recommended Products: fix toggling of the favorite icon Recommended Products: fix toggling of the favorite icon (@W-16093853@) Jun 25, 2024
Copy link
Contributor

@vcua-mobify vcua-mobify left a comment

Choose a reason for hiding this comment

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

I've verified that we can now add to wishlist from the recommended products section

@vmarta vmarta merged commit 6d9ca82 into develop Jun 25, 2024
28 checks passed
@vmarta vmarta deleted the fix/recommended-product-wishlist branch June 25, 2024 17:55
@vmarta vmarta mentioned this pull request Jun 25, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants