From 480eebbfa2877eca9754caea38d9c628cae0c28a Mon Sep 17 00:00:00 2001 From: Bill Randall Date: Wed, 25 Oct 2023 15:23:38 -0400 Subject: [PATCH] Do not prematurely error on the invalid input --- .../productConfigForm.component.js | 11 ++--------- .../productConfigForm.component.spec.js | 15 ++------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/app/productConfig/productConfigForm/productConfigForm.component.js b/src/app/productConfig/productConfigForm/productConfigForm.component.js index 6b5c26bd8..7e7331a2c 100644 --- a/src/app/productConfig/productConfigForm/productConfigForm.component.js +++ b/src/app/productConfig/productConfigForm/productConfigForm.component.js @@ -315,14 +315,7 @@ class ProductConfigFormController { const data = this.omitIrrelevantData(this.itemConfig) const comment = data.DONATION_SERVICES_COMMENTS const isTestingTransaction = comment ? comment.toLowerCase().includes('test') : false - const transformedAmount = this.transformAmountIfNecessary(data.AMOUNT) - if (transformedAmount === 'error') { - this.submittingGift = false - this.errorSavingGeneric = true - this.onStateChange({ state: 'errorSubmitting' }) - return - } - data.AMOUNT = transformedAmount + data.AMOUNT = this.transformAmountIfNecessary(data.AMOUNT) this.brandedAnalyticsFactory.saveTestingTransaction(isTestingTransaction) this.analyticsFactory.saveTestingTransaction(this.productData, isTestingTransaction) @@ -372,7 +365,7 @@ class ProductConfigFormController { transformedAmount = amount.replace('$', '') transformedAmount = parseFloat(transformedAmount) if (isNaN(transformedAmount)) { - return 'error' + return amount } } return transformedAmount diff --git a/src/app/productConfig/productConfigForm/productConfigForm.component.spec.js b/src/app/productConfig/productConfigForm/productConfigForm.component.spec.js index 1765d6751..ac9647f37 100644 --- a/src/app/productConfig/productConfigForm/productConfigForm.component.spec.js +++ b/src/app/productConfig/productConfigForm/productConfigForm.component.spec.js @@ -728,17 +728,6 @@ describe('product config form component', function () { expect($ctrl.errorAlreadyInCart).toEqual(false) expect($ctrl.errorSavingGeneric).toEqual(false) }) - - it('should fail if the amount is invalid', () => { - $ctrl.itemConfig.AMOUNT = 'test' - $ctrl.itemConfigForm.$dirty = true - $ctrl.saveGiftToCart() - - expect($ctrl.submittingGift).toEqual(false) - expect($ctrl.onStateChange).toHaveBeenCalledWith({ state: 'errorSubmitting' }) - expect($ctrl.errorAlreadyInCart).toEqual(false) - expect($ctrl.errorSavingGeneric).toEqual(true) - }) } }) @@ -803,9 +792,9 @@ describe('product config form component', function () { expect($ctrl.transformAmountIfNecessary(amount)).toEqual(50) }) - it('should return an error', () => { + it('should pass through the original amount', () => { const amount = 'test' - expect($ctrl.transformAmountIfNecessary(amount)).toEqual('error') + expect($ctrl.transformAmountIfNecessary(amount)).toEqual('test') }) }) })