Conversation
Code Review Results✅ StrengthsThe fix is minimal, targeted, and correctly identifies the root cause: when 🚨 Critical IssuesNone.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the data-cnstrc-item-variation-id attribute was not being rendered when the getSwatches function throws an error. The fix adds a fallback to use item.variationId when productSwatch.selectedVariation.variationId is unavailable, following the same pattern already established for other fields like itemName, itemPrice, and itemImageUrl.
Changes:
- Added fallback logic in
useProductInfohook to useitem.variationIdwhenproductSwatch.selectedVariation.variationIdis undefined - Added test coverage to verify the fallback behavior when
getSwatchesthrows an error - Applied code formatting improvements to existing test cases
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/hooks/useProduct.ts |
Added fallback to item.variationId for the variationId variable, consistent with existing fallback patterns for other fields |
spec/hooks/useProductInfo/useProductInfo.test.js |
Added new test case to verify fallback behavior when getSwatches throws an error, and applied formatting improvements to existing tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR Description
useProductInfodoesn't returnvariationIdifuseSwatchesdoesn't successfully return a swatch listPull Request Checklist
Before you submit a pull request, please make sure you have to following:
PR Type
What kind of change does this PR introduce?