diff --git a/src/iss-components/cart-dropdown/__snapshots__/cart-dropdown.spec.js.snap b/src/iss-components/cart-dropdown/__snapshots__/cart-dropdown.spec.js.snap index e6e66827..af4e64e3 100644 --- a/src/iss-components/cart-dropdown/__snapshots__/cart-dropdown.spec.js.snap +++ b/src/iss-components/cart-dropdown/__snapshots__/cart-dropdown.spec.js.snap @@ -4,7 +4,10 @@ exports[`cart-dropdown component initial data rendered as expected 1`] = ` Object { "baseServiceLineItems": Array [], "deductible": null, - "isExpanded": false, + "glassToReplace": Array [], + "isExpanded": true, + "isRepair": null, + "vapsInOrder": Array [], "widget": Object { "amountDue": "AmountDueTextWidget", "basePrice": "BasePriceWidget", @@ -12,6 +15,7 @@ Object { "mobileFee": "MobileServiceWidget", "recycleFee": "RecycleFeeWidget", "salesTax": "SalesTaxWidget", + "servicePackage": "ServicePackageTitle", "subtotal": "SubtotalWidget", }, } diff --git a/src/iss-components/cart-dropdown/cart-dropdown.spec.js b/src/iss-components/cart-dropdown/cart-dropdown.spec.js index 5d125a0b..a5a59a15 100644 --- a/src/iss-components/cart-dropdown/cart-dropdown.spec.js +++ b/src/iss-components/cart-dropdown/cart-dropdown.spec.js @@ -161,6 +161,45 @@ describe('cart-dropdown component', () => { // Assert expect(salesTax.exists()).toBeTruthy(); }); + test('recycle fee when preset in supported items', () => { + // Arrange + const reference = '#recycle-fee-item'; + const { wrapper } = getMountedComponent({ + order: { + lineItems: { + supportingItems: [{ + partType: partTypeStrings.REPLACE_FEE + }] + } + } + }); + + // Act + const recycleFee = wrapper.find(reference); + + // Assert + expect(wrapper.vm.recycleFeeCartItem).not.toBeNull(); + expect(recycleFee.exists()).toBeTruthy(); + }); + test('mobile fee when preset', () => { + // Arrange + const reference = '#mobile-fee-item'; + const { wrapper } = getMountedComponent({ + order: { + lineItems: { + supportingItems: [], + mobileFee: {} + } + } + }); + + // Act + const mobileFee = wrapper.find(reference); + + // Assert + expect(wrapper.vm.mobileFeeCartItem).not.toBeNull(); + expect(mobileFee.exists()).toBeTruthy(); + }); test('bottom amount due', () => { // Arrange const reference = '#bottom-amount-due'; @@ -174,6 +213,25 @@ describe('cart-dropdown component', () => { // Assert expect(bottomAmountDue.exists()).toBeTruthy(); }); + test('Hides recycle fee when not in supported items', () => { + // Arrange + const reference = '#mobile-fee-item'; + const { wrapper } = getMountedComponent({ + order: { + lineItems: { + supportingItems: [], + mobileFee: null + } + } + }); + + // Act + const cartDeductible = wrapper.find(reference); + + // Assert + expect(wrapper.vm.mobileFeeCartItem).toBeNull(); + expect(cartDeductible.exists()).toBeFalsy(); + }); }); describe('does not display', () => { test('cart deductible when showDeductibleLineItem is false', () => { @@ -226,6 +284,43 @@ describe('cart-dropdown component', () => { // Assert expect(cartBasePrice.exists()).toBeFalsy(); }); + test('recycle fee when not in supported items', () => { + // Arrange + const reference = '#recycle-fee-item'; + const { wrapper } = getMountedComponent({ + order: { + lineItems: { + supportingItems: [] + } + } + }); + + // Act + const recycleFee = wrapper.find(reference); + + // Assert + expect(wrapper.vm.recycleFeeCartItem).toBeNull(); + expect(recycleFee.exists()).toBeFalsy(); + }); + test('mobile fee when not in supported items', () => { + // Arrange + const reference = '#mobile-fee-item'; + const { wrapper } = getMountedComponent({ + order: { + lineItems: { + supportingItems: [], + mobileFee: null + } + } + }); + + // Act + const mobileFee = wrapper.find(reference); + + // Assert + expect(wrapper.vm.mobileFeeCartItem).toBeNull(); + expect(mobileFee.exists()).toBeFalsy(); + }); }); describe('computed', () => { describe('showDeductibleLineItem', () => { @@ -235,7 +330,7 @@ describe('cart-dropdown component', () => { order: { policy: { isITAC: isItac, - noCoverage: true, + noCoverage: true } } }; @@ -297,7 +392,7 @@ describe('cart-dropdown component', () => { order: { policy: { isITAC: false, - noCoverage: true, + noCoverage: true }, currentDeductible: null } @@ -549,85 +644,5 @@ describe('cart-dropdown component', () => { expect(result).toBe(dollarAmount); }); }); - describe('Recyle fee', () => { - test('Shows recycle fee when preset in supported items', () => { - // Arrange - const reference = '#recycle-fee-item'; - const { wrapper } = getMountedComponent({ - order: { - lineItems: { - supportingItems: [{ - partType: partTypeStrings.REPLACE_FEE - }] - } - } - }); - - // Act - const cartDeductible = wrapper.find(reference); - - // Assert - expect(wrapper.vm.recycleFeeCartItem).not.toBeNull(); - expect(cartDeductible.exists()).toBeTruthy(); - }); - test('Hides recycle fee when not in supported items', () => { - // Arrange - const reference = '#recycle-fee-item'; - const { wrapper } = getMountedComponent({ - order: { - lineItems: { - supportingItems: [] - } - } - }); - - // Act - const cartDeductible = wrapper.find(reference); - - // Assert - expect(wrapper.vm.recycleFeeCartItem).toBeNull(); - expect(cartDeductible.exists()).toBeFalsy(); - }); - }); - describe('Mobile Fee', () => { - test('Shows mobile fee when preset', () => { - // Arrange - const reference = '#mobile-fee-item'; - const { wrapper } = getMountedComponent({ - order: { - lineItems: { - supportingItems: [], - mobileFee: {} - } - } - }); - - // Act - const cartDeductible = wrapper.find(reference); - - // Assert - expect(wrapper.vm.mobileFeeCartItem).not.toBeNull(); - expect(cartDeductible.exists()).toBeTruthy(); - }); - test('Hides recycle fee when not in supported items', () => { - // Arrange - const reference = '#mobile-fee-item'; - const { wrapper } = getMountedComponent({ - order: { - lineItems: { - supportingItems: [], - mobileFee: null - } - } - }); - - // Act - const cartDeductible = wrapper.find(reference); - - // Assert - expect(wrapper.vm.mobileFeeCartItem).toBeNull(); - expect(cartDeductible.exists()).toBeFalsy(); - }); - }); }); }); diff --git a/src/iss-components/cart-dropdown/cart-dropdown.vue b/src/iss-components/cart-dropdown/cart-dropdown.vue index 5ad0bd20..448764ad 100644 --- a/src/iss-components/cart-dropdown/cart-dropdown.vue +++ b/src/iss-components/cart-dropdown/cart-dropdown.vue @@ -231,7 +231,7 @@ export default { return [ ...(glassParts ?? []), ...(supportingItems ?? []), - ...this.availableVaps + ...(this.availableVaps ?? []) ]; }, servicePackageTier() { @@ -277,7 +277,7 @@ export default { rainDefenseCartItem() { const rainDefenseLabel = this.getCmsContentForVapsType(partTypeStrings.RAIN_DEFENSE); const rainDefenseLineItem = this.vapsInOrder - .find((vapsLineItem) => vapsLineItem.partType === partTypeStrings.RAIN_DEFENSE); + ?.find((vapsLineItem) => vapsLineItem.partType === partTypeStrings.RAIN_DEFENSE); return this.getCartItem(rainDefenseLabel, [rainDefenseLineItem]); }, packagePrice() { @@ -307,7 +307,6 @@ export default { }, servicePackageLabelWidget() { if (!this.servicePackageNames) { - console.log('no service package names'); return ''; } const currentPackage = this.servicePackageNames @@ -316,16 +315,23 @@ export default { return currentPackage.SubWidgetName ?? ''; }, recycleFeeCartItem() { - return this.getCartItem( - this.getCmsContent(this.widget.recycleFee, widgetFields.TEXT_BLOCK_WIDGET.TEXT), - [useMainStore().lineItems.supportingItems.find((lineItem) => lineItem.partType === partTypeStrings.REPLACE_FEE)] - ); + const recycleFeeLineItem = useMainStore().lineItems.supportingItems + ?.find((lineItem) => lineItem.partType === partTypeStrings.REPLACE_FEE); + return recycleFeeLineItem + ? this.getCartItem( + this.getCmsContent(this.widget.recycleFee, widgetFields.TEXT_BLOCK_WIDGET.TEXT), + [recycleFeeLineItem] + ) + : null; }, mobileFeeCartItem() { - return this.getCartItem( - this.getCmsContent(this.widget.mobileFee, widgetFields.TEXT_BLOCK_WIDGET.TEXT), - [useMainStore().lineItems.mobileFee] - ); + const mobileFeeLineItem = useMainStore().lineItems.mobileFee; + return mobileFeeLineItem + ? this.getCartItem( + this.getCmsContent(this.widget.mobileFee, widgetFields.TEXT_BLOCK_WIDGET.TEXT), + [mobileFeeLineItem] + ) + : null; } }, methods: { @@ -364,7 +370,7 @@ export default { return ''; } - const vapsTypeName = vapsItemDescriptions.find((entry) => entry.Name === vapsType); + const vapsTypeName = vapsItemDescriptions?.find((entry) => entry.Name === vapsType); return vapsTypeName.Text; }, diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index 89023f6d..158f5dd5 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -129,7 +129,7 @@ export default { vm.setCmsContent(resultMap.cmsContent); vm.updateFooterButtonText(vm.customCallToActionButtonCopy); vm.$refs.reviewDropdown.initializeComponent(resultMap.reviewDropdownData); - vm.setAvailableVaps(pricedVaps); + vm.setAvailableVaps(pricedVaps ?? []); }); } },