-
Notifications
You must be signed in to change notification settings - Fork 2
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
[TITAN-298] - Update Cart by Removing and Changing Quantity #65
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one minor point, LGTM otherwise.
@@ -4,6 +4,10 @@ import styles from './ProductNotification.module.scss'; | |||
const cx = classNames.bind(styles); | |||
|
|||
const ProductNotification = ({ productNotification, cartPage }) => { | |||
if (productNotification.close) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a scenario for this condition?
Also, can we refactor this early return into a ternary operator in the return below?
return productNotification.close ? null : (
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We talked about testing this in the component itself but there is no assertion, nothing is rendered, so what do we test?
We could test it in Cart.test.js
by making sure that the notice is shown when the max quantity is reached and then disappears when its decreased again - that's the real world scenario and the reason for introducing this prop. See line 75 of CartTable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alvarocavalcanti I added that test in the latest commit. Let me know what you think, probably a more accurate test of this scenario.
Co-authored-by: Alvaro Cavalcanti <alvaro.cavalcanti@wpengine.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
This PR implements the
CartLinesUpdate
mutation from Shopify API when clicking the increase and decrease quantity buttons on the cart page.We have handled a few edge cases such as:
ProductNotification
component )Testing
Add a couple of items to the cart
Test increasing and decreasing the quantities on the cart page
Test decreasing to zero, it should remove that line item from cart and show a message
Test increasing the item quantity until the max available has been reached, it should show a message
The prices in both the cart table and the cart quick view component should update based on the change of quantity
Tests are added for the scenarios mentioned above