fix: [SFCC-526] Miscellaneous fixes#279
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
TIP This summary will be updated as you push new changes.
| if (promoPrices.length > 0) { | ||
| lowestPromoPrice = promoPrices.reduce(function (a, b) { | ||
| return Math.min(a.value, b.value); | ||
| return a.getValue() <= b.getValue() ? a : b; |
There was a problem hiding this comment.
The original code typecast the Money object into a number, which can lead to issues downstream (e.g. when trying to call .getValue() or .getCurrencyCode() on it).
|
|
||
| if (promotionPrice.getValue() && promotionPrice.getValue() < minPrice ) { | ||
| minPrice = promotionPrice.getValue(); | ||
| if (promotionPrice.isAvailable() && promotionValue < minPrice) { |
There was a problem hiding this comment.
A promotion can legitimately drive the price to 0 (100%-off / free gift). The original if (promotionPrice.getValue() && ...) treats that 0 as falsy and skips the promotion, and it calls getValue() three times. The fix caches the value once and gates on promotionPrice.isAvailable(), which correctly rejects NOT_AVAILABLE prices (where getValue() returns NaN) while letting a real 0 through.
| this.brand = null; | ||
| this.bundle = false; | ||
| this.bundled = false; | ||
| this.images = images || PRODUCT_IMAGES; |
There was a problem hiding this comment.
The constructor sets this.bundle but isBundled() read this.bundled, which is a different attribute (but still valid). Added a distinct this.bundled field. Both this.bundle and this.bundled should be false for a master.
|
|
||
| e2e-tests: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 |
There was a problem hiding this comment.
Added the 15-minute timeout from #277. If the job doesn't finish in 15 minutes, chances are high that it will not be successful. With the timeout the job can be retried at least.
| if (promoPrices.length > 0) { | ||
| lowestPromoPrice = promoPrices.reduce(function (a, b) { | ||
| return Math.min(a.value, b.value); | ||
| return a.getValue() <= b.getValue() ? a : b; |
Various fixes for some of the issues flagged by the automated reviewer on PR #278.
I've added the details for each fix as PR comments.