From 7341b36af7b735314566c175cf6fe10b044f02ae Mon Sep 17 00:00:00 2001 From: Bizz <56281168+dr-bizz@users.noreply.github.com> Date: Wed, 13 Mar 2024 14:24:36 -0400 Subject: [PATCH] Revert "[EP-2486] Prevent invalid payment methods from being chosen" (#1092) --- .../existingPaymentMethods.component.js | 5 ++- .../existingPaymentMethods.component.spec.js | 36 ------------------- src/app/checkout/step-2/step-2.tpl.html | 2 +- 3 files changed, 3 insertions(+), 40 deletions(-) diff --git a/src/app/checkout/step-2/existingPaymentMethods/existingPaymentMethods.component.js b/src/app/checkout/step-2/existingPaymentMethods/existingPaymentMethods.component.js index b51affc3b..f160a12c3 100644 --- a/src/app/checkout/step-2/existingPaymentMethods/existingPaymentMethods.component.js +++ b/src/app/checkout/step-2/existingPaymentMethods/existingPaymentMethods.component.js @@ -71,14 +71,13 @@ class ExistingPaymentMethodsController { } selectDefaultPaymentMethod () { - const paymentMethods = this.paymentMethods.filter(paymentMethod => this.validPaymentMethod(paymentMethod)) - const chosenPaymentMethod = find(paymentMethods, { chosen: true }) + const chosenPaymentMethod = find(this.paymentMethods, { chosen: true }) if (chosenPaymentMethod) { // Select the payment method previously chosen for the order this.selectedPaymentMethod = chosenPaymentMethod } else { // Select the first payment method - this.selectedPaymentMethod = paymentMethods[0] + this.selectedPaymentMethod = this.paymentMethods[0] } this.switchPayment() } diff --git a/src/app/checkout/step-2/existingPaymentMethods/existingPaymentMethods.component.spec.js b/src/app/checkout/step-2/existingPaymentMethods/existingPaymentMethods.component.spec.js index 6d908ee41..fe1024014 100644 --- a/src/app/checkout/step-2/existingPaymentMethods/existingPaymentMethods.component.spec.js +++ b/src/app/checkout/step-2/existingPaymentMethods/existingPaymentMethods.component.spec.js @@ -156,10 +156,6 @@ describe('checkout', () => { }) describe('selectDefaultPaymentMethod', () => { - beforeEach(() => { - jest.spyOn(self.controller, 'validPaymentMethod').mockReturnValue(true) - }) - it('should choose the payment method that is marked chosen in cortex', () => { self.controller.paymentMethods = [ { @@ -189,38 +185,6 @@ describe('checkout', () => { expect(self.controller.selectedPaymentMethod).toEqual({ selectAction: 'first uri' }) }) - it('should choose the first payment method if the one marked chosen in cortex is invalid', () => { - jest.spyOn(self.controller, 'validPaymentMethod').mockImplementation(paymentMethod => paymentMethod.selectAction === 'first uri') - self.controller.paymentMethods = [ - { - selectAction: 'first uri' - }, - { - selectAction: 'second uri', - chosen: true - } - ] - self.controller.selectDefaultPaymentMethod() - - expect(self.controller.selectedPaymentMethod).toEqual({ selectAction: 'first uri' }) - }) - - it('should set selectedPaymentMethod to undefined if none are valid', () => { - jest.spyOn(self.controller, 'validPaymentMethod').mockReturnValue(undefined) - self.controller.paymentMethods = [ - { - selectAction: 'first uri' - }, - { - selectAction: 'second uri', - chosen: true - } - ] - self.controller.selectDefaultPaymentMethod() - - expect(self.controller.selectedPaymentMethod).toBeUndefined() - }) - it('should check whether or not the fee coverage should be altered based on selected payment type', () => { jest.spyOn(self.controller, 'switchPayment').mockImplementation(() => {}) self.controller.paymentMethods = [ diff --git a/src/app/checkout/step-2/step-2.tpl.html b/src/app/checkout/step-2/step-2.tpl.html index 56d40a1fe..d44101041 100644 --- a/src/app/checkout/step-2/step-2.tpl.html +++ b/src/app/checkout/step-2/step-2.tpl.html @@ -42,7 +42,7 @@
-