From c99fb974ca42742fc9daa87873858a2abc97c7f2 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Thu, 6 Jun 2024 12:21:05 -0400 Subject: [PATCH 1/6] hide payment options if amountDue = 0 implemented via an emit --- .../cart-dropdown/cart-dropdown.vue | 5 ++++- src/layouts/payment-method/payment-method.spec.js | 15 ++++++++++++++- src/layouts/payment-method/payment-method.vue | 10 ++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/iss-components/cart-dropdown/cart-dropdown.vue b/src/iss-components/cart-dropdown/cart-dropdown.vue index d99747a4..03570058 100644 --- a/src/iss-components/cart-dropdown/cart-dropdown.vue +++ b/src/iss-components/cart-dropdown/cart-dropdown.vue @@ -193,6 +193,7 @@ export default { isInitiallyExpanded: Boolean, submittedOrder: Object }, + emits: ['amountDueUpdated'], data() { return { isExpanded: this.isInitiallyExpanded, @@ -249,7 +250,9 @@ export default { return getCartTotal(this.cartOrder); }, amountDue() { - return this.showAsPaid ? 0 : this.total; + const newAmountDue = this.showAsPaid ? 0 : this.total; + this.$emit('amountDueUpdated', newAmountDue); + return newAmountDue; }, amountPaid() { return !this.showAsPaid ? 0 : this.total; diff --git a/src/layouts/payment-method/payment-method.spec.js b/src/layouts/payment-method/payment-method.spec.js index 3e526b84..c3261972 100644 --- a/src/layouts/payment-method/payment-method.spec.js +++ b/src/layouts/payment-method/payment-method.spec.js @@ -184,10 +184,11 @@ describe('payment-method.vue', () => { // Assert expect(result).toBeTruthy(); }); - test('returns false when coverageStatus is verified', () => { + test('returns false when coverageStatus is verified and cartAmountDue > 0', () => { // Arrange store.order.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED; const wrapper = setupMocks({}, store, mixin); + wrapper.vm.cartAmountDue = 34.99; // Act const result = wrapper.vm.isPayInAdvanceDisabled; @@ -195,6 +196,18 @@ describe('payment-method.vue', () => { // Assert expect(result).toBeFalsy(); }); + test('returns true when coverageStatus is verified and cartAmountDue = 0', () => { + // Arrange + store.order.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED; + const wrapper = setupMocks({}, store, mixin); + wrapper.vm.cartAmountDue = 0; + + // Act + const result = wrapper.vm.isPayInAdvanceDisabled; + + // Assert + expect(result).toBeTruthy(); + }); test('returns true when pia not enabled', () => { // Arrange mixin = { diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index 164c6bbe..f92340a9 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -32,7 +32,8 @@ :showDropdownHeader="true" :isInitiallyExpanded="false" recyclingModalCmsWidgetName="RecycleModal" - servicePackageTitleWidgetName="ServicePackageTitle" /> + servicePackageTitleWidgetName="ServicePackageTitle" + @amountDueUpdated="updateAmountDue" />
Date: Mon, 10 Jun 2024 16:01:59 -0400 Subject: [PATCH 2/6] update to only use 0 check on deductible coverage small linting update --- .../cart-dropdown/cart-dropdown.vue | 10 ++++----- .../payment-method/payment-method.spec.js | 8 +++---- src/layouts/payment-method/payment-method.vue | 22 ++++++++----------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/iss-components/cart-dropdown/cart-dropdown.vue b/src/iss-components/cart-dropdown/cart-dropdown.vue index 03570058..48677c2c 100644 --- a/src/iss-components/cart-dropdown/cart-dropdown.vue +++ b/src/iss-components/cart-dropdown/cart-dropdown.vue @@ -193,7 +193,7 @@ export default { isInitiallyExpanded: Boolean, submittedOrder: Object }, - emits: ['amountDueUpdated'], + emits: ['deductibleTotalUpdated'], data() { return { isExpanded: this.isInitiallyExpanded, @@ -216,7 +216,9 @@ export default { }, computed: { deductible() { - return getDeductible(this.cartOrder); + const newDeductibleTotal = getDeductible(this.cartOrder); + this.$emit('deductibleTotalUpdated', newDeductibleTotal); + return newDeductibleTotal; }, showDeductibleCartItem() { return this.isUnverified || (!this.isNoComp && !this.isITAC); @@ -250,9 +252,7 @@ export default { return getCartTotal(this.cartOrder); }, amountDue() { - const newAmountDue = this.showAsPaid ? 0 : this.total; - this.$emit('amountDueUpdated', newAmountDue); - return newAmountDue; + return this.showAsPaid ? 0 : this.total; }, amountPaid() { return !this.showAsPaid ? 0 : this.total; diff --git a/src/layouts/payment-method/payment-method.spec.js b/src/layouts/payment-method/payment-method.spec.js index c3261972..fce089bf 100644 --- a/src/layouts/payment-method/payment-method.spec.js +++ b/src/layouts/payment-method/payment-method.spec.js @@ -184,11 +184,11 @@ describe('payment-method.vue', () => { // Assert expect(result).toBeTruthy(); }); - test('returns false when coverageStatus is verified and cartAmountDue > 0', () => { + test('returns false when coverageStatus is verified and deductibleTotal > 0', () => { // Arrange store.order.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED; const wrapper = setupMocks({}, store, mixin); - wrapper.vm.cartAmountDue = 34.99; + wrapper.vm.deductibleTotal = 34.99; // Act const result = wrapper.vm.isPayInAdvanceDisabled; @@ -196,11 +196,11 @@ describe('payment-method.vue', () => { // Assert expect(result).toBeFalsy(); }); - test('returns true when coverageStatus is verified and cartAmountDue = 0', () => { + test('returns true when coverageStatus is verified and deductibleTotal = 0', () => { // Arrange store.order.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED; const wrapper = setupMocks({}, store, mixin); - wrapper.vm.cartAmountDue = 0; + wrapper.vm.deductibleTotal = 0; // Act const result = wrapper.vm.isPayInAdvanceDisabled; diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index f92340a9..6457386f 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -33,7 +33,7 @@ :isInitiallyExpanded="false" recyclingModalCmsWidgetName="RecycleModal" servicePackageTitleWidgetName="ServicePackageTitle" - @amountDueUpdated="updateAmountDue" /> + @deductibleTotalUpdated="updateDeductibleTotal" />
Date: Tue, 11 Jun 2024 12:52:35 -0400 Subject: [PATCH 3/6] use store value and not child component. --- src/iss-components/cart-dropdown/cart-dropdown.vue | 5 +---- src/layouts/payment-method/payment-method.vue | 8 ++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/iss-components/cart-dropdown/cart-dropdown.vue b/src/iss-components/cart-dropdown/cart-dropdown.vue index 48677c2c..d99747a4 100644 --- a/src/iss-components/cart-dropdown/cart-dropdown.vue +++ b/src/iss-components/cart-dropdown/cart-dropdown.vue @@ -193,7 +193,6 @@ export default { isInitiallyExpanded: Boolean, submittedOrder: Object }, - emits: ['deductibleTotalUpdated'], data() { return { isExpanded: this.isInitiallyExpanded, @@ -216,9 +215,7 @@ export default { }, computed: { deductible() { - const newDeductibleTotal = getDeductible(this.cartOrder); - this.$emit('deductibleTotalUpdated', newDeductibleTotal); - return newDeductibleTotal; + return getDeductible(this.cartOrder); }, showDeductibleCartItem() { return this.isUnverified || (!this.isNoComp && !this.isITAC); diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index 6457386f..55e324d3 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -32,8 +32,7 @@ :showDropdownHeader="true" :isInitiallyExpanded="false" recyclingModalCmsWidgetName="RecycleModal" - servicePackageTitleWidgetName="ServicePackageTitle" - @deductibleTotalUpdated="updateDeductibleTotal" /> + servicePackageTitleWidgetName="ServicePackageTitle" />
Date: Tue, 11 Jun 2024 12:55:07 -0400 Subject: [PATCH 4/6] update test --- src/layouts/payment-method/payment-method.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/layouts/payment-method/payment-method.spec.js b/src/layouts/payment-method/payment-method.spec.js index fce089bf..acfaeafe 100644 --- a/src/layouts/payment-method/payment-method.spec.js +++ b/src/layouts/payment-method/payment-method.spec.js @@ -187,8 +187,8 @@ describe('payment-method.vue', () => { test('returns false when coverageStatus is verified and deductibleTotal > 0', () => { // Arrange store.order.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED; + store.order.currentDeductible = 34.99; const wrapper = setupMocks({}, store, mixin); - wrapper.vm.deductibleTotal = 34.99; // Act const result = wrapper.vm.isPayInAdvanceDisabled; @@ -199,8 +199,8 @@ describe('payment-method.vue', () => { test('returns true when coverageStatus is verified and deductibleTotal = 0', () => { // Arrange store.order.insuranceCoverage.coverageStatus = coverageStatuses.VERIFIED; + store.order.currentDeductible = 0; const wrapper = setupMocks({}, store, mixin); - wrapper.vm.deductibleTotal = 0; // Act const result = wrapper.vm.isPayInAdvanceDisabled; From 2a28e952d8444e8360d12f4460d13a06025b7db8 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Tue, 11 Jun 2024 12:56:08 -0400 Subject: [PATCH 5/6] remove console.log --- src/layouts/payment-method/payment-method.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index 55e324d3..b8310f43 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -189,8 +189,6 @@ export default { const isEnabled = piaExperience === 'true'; const isDeductibleTotalEqualToZero = useMainStore().order.currentDeductible === 0; - console.log(useMainStore().order.currentDeductible); - return !isEnabled || useMainStore().isUnverified || (useMainStore().isDeductible && isDeductibleTotalEqualToZero); }, paymentMethod() { From 82d3fedeaf01c1c9eb1450ccc9b524a154b7ffb5 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Tue, 11 Jun 2024 12:57:20 -0400 Subject: [PATCH 6/6] remove unneeded method --- src/layouts/payment-method/payment-method.vue | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index b8310f43..7dee7636 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -292,9 +292,6 @@ export default { ? payInAdvanceType : paymentMethods.PAY_AT_TIME_OF_SERVICE; }, - updateDeductibleTotal(newDeductibleTotal) { - this.deductibleTotal = newDeductibleTotal; - }, updateFooterButtonText(newValue) { this.$refs.siteFooter.updateButtonText(newValue); },