fix(ep-commerce): the two 0.4.0 regressions the tests were defending - #447
Merged
Conversation
The component still read a `checkoutCartData` selector nothing provides, and its item branch still read `imageUrl` and `formattedPrice` off a line that now carries `image.href` and `meta.display_price`. It resolves against the `cart` published by EPCheckoutCartSummary through the same field-value resolver EPCartField and EPCartItemField use, so the saved choices keep working. MOCK_CHECKOUT_CART_DATA was still the old flat shape while being published as `cart`, so the canvas and EPOrderTotalsBreakdown's cart source both read zeros. Repoints the two tests that encoded the removed shapes and adds the tests EPCheckoutCartField never had — the bug passed the suite while breaking production.
… the checkout money going stale findChildProduct returned the first child whenever the choices did not resolve to one, so a renamed option in Commerce Manager or a stale saved selection put a different variant at a different price in front of the shopper. It returns undefined; both callers already treat that as no-match, and registerEPProductVariantPicker was already refusing to call it on a partial selection. The three memos that format checkout money called fmt() in their bodies while omitting currencyDisplay and locale from their dependencies — as did a fourth site, EPCheckoutProvider's checkoutData memo. Both values are bindable props on EpCommerceProvider, so a designer-wired switcher left every checkout total formatted as first rendered. A bound useMoneyFormat replaces the closure: the memos depend on the formatter, which they cannot silently omit, and the triplicated defaulting goes with it. The stale-money tests pin the selector data to a stable object. A fresh one per render re-runs the memo whatever its dependencies are, which is how this passed a green suite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes #438 left behind, both of which passed the suite while breaking production.
EPCheckoutCartField read a
checkoutCartDataselector nothing provides, and its item branch readimageUrl/formattedPriceoff a line that now carriesimage.href/meta.display_price. It resolves against thecartpublished by EPCheckoutCartSummary, through the same resolver EPCartField and EPCartItemField use, so saved choices keep working.MOCK_CHECKOUT_CART_DATAwas also still the old flat shape while being published ascart, so the canvas and EPOrderTotalsBreakdown's cart source read zeros.findChildProduct returned the first child whenever the choices resolved to none, so a renamed option in Commerce Manager or a stale saved selection showed the shopper a different variant at a different price. It returns
undefined; both callers already treat that as no-match.Stale checkout money. Three memos formatting totals, order summaries and shipping rates closed over
currencyDisplayandlocalewithout depending on them, as did a fourth site in EPCheckoutProvider. Both are bindable props onEpCommerceProvider, so a designer-wired switcher left every checkout total formatted as first rendered. A bounduseMoneyFormatreplaces the closure.The stale-money tests pin their selector data to a stable object — a fresh one per render re-runs the memo whatever its dependencies are, which is how this passed a green suite.
The extension-path half of this work landed separately in #443; this branch was rebased onto it.