Skip to content

Commit

Permalink
⏫ Forwardport of #12902 to 2.3-develop branch
Browse files Browse the repository at this point in the history
Applied pull request patch https://github.com/magento/magento2/pull/12902.patch (created by @joni-jones) based on commit(s):
  1. 0c5cb6a

Fixed GitHub Issues in 2.3-develop branch:
  - #12900: Braintree "Place Order" button is disabled after failed validation (reported by @ifekaj)
  • Loading branch information
magento-engcom-team committed Jan 24, 2018
1 parent 8e77e2f commit 4cfc07e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ define(
*/
onError: function (response) {
braintree.showError($t('Payment ' + this.getTitle() + ' can\'t be initialized'));
this.isPlaceOrderActionAllowed(true);
throw response.message;
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ define([
),
'Magento_Braintree/js/view/payment/adapter': jasmine.createSpyObj(
'adapter',
['setup', 'setConfig']
['setup', 'setConfig', 'showError']
)
},
braintreeCcForm;
Expand All @@ -43,14 +43,17 @@ define([
};
injector.mock(mocks);
injector.require(['Magento_Braintree/js/view/payment/method-renderer/cc-form'], function (Constr) {
braintreeCcForm = new Constr({
provider: 'provName',
name: 'test',
index: 'test'
});

done();
braintreeCcForm = new Constr({
provider: 'provName',
name: 'test',
index: 'test',
item: {
title: 'Braintree'
}
});

done();
});
});

it('Check if payment code and message container are restored after onActiveChange call.', function () {
Expand All @@ -65,5 +68,21 @@ define([
expect(braintreeCcForm.getCode()).toEqual(expectedCode);
expect(braintreeCcForm.messageContainer).toEqual(expectedMessageContainer);
});

it('Check if form validation fails when "Place Order" button should be active.', function () {
var errorMessage = 'Something went wrong.',

/**
* Anonymous wrapper
*/
func = function () {
braintreeCcForm.clientConfig.onError({
'message': errorMessage
});
};

expect(func).toThrow(errorMessage);
expect(braintreeCcForm.isPlaceOrderActionAllowed()).toBeTruthy();
});
});
});

0 comments on commit 4cfc07e

Please sign in to comment.