File tree Expand file tree Collapse file tree 5 files changed +38
-12
lines changed
Braintree/view/frontend/web/js/view/payment/method-renderer
templates/catalog/product/attribute
ConfigurableProduct/view/adminhtml/web/js/variations
dev/tests/js/jasmine/tests/app/code/Magento/Braintree/frontend/js/view/payment/method-renderer Expand file tree Collapse file tree 5 files changed +38
-12
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ define(
7979 */
8080 onError : function ( response ) {
8181 braintree . showError ( $t ( 'Payment ' + this . getTitle ( ) + ' can\'t be initialized' ) ) ;
82+ this . isPlaceOrderActionAllowed ( true ) ;
8283 throw response . message ;
8384 } ,
8485
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ $stores = $block->getStoresSortedBySortOrder();
5757 <input type="hidden" id="option-count-check" value="" />
5858 </div>
5959 <script id="row-template" type="text/x-magento-template">
60- <tr>
60+ <tr <% if (data.rowClasses) { %>class="<%- data.rowClasses %>"<% } %> >
6161 <td class="col-draggable">
6262 <?php if (!$ block ->getReadOnly () && !$ block ->canManageOptionDefaultOnly ()): ?>
6363 <div data-role="draggable-handle" class="draggable-handle"
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ define([
2424 totalItems : 0 ,
2525 rendered : 0 ,
2626 template : mageTemplate ( '#row-template' ) ,
27+ newOptionClass : 'new-option' ,
2728 isReadOnly : config . isReadOnly ,
2829 add : function ( data , render ) {
2930 var isNewOption = false ,
@@ -32,7 +33,8 @@ define([
3233 if ( typeof data . id == 'undefined' ) {
3334 data = {
3435 'id' : 'option_' + this . itemCount ,
35- 'sort_order' : this . itemCount + 1
36+ 'sort_order' : this . itemCount + 1 ,
37+ 'rowClasses' : this . newOptionClass
3638 } ;
3739 isNewOption = true ;
3840 }
@@ -84,6 +86,10 @@ define([
8486 this . totalItems -- ;
8587 this . updateItemsCountField ( ) ;
8688 }
89+
90+ if ( element . hasClassName ( this . newOptionClass ) ) {
91+ element . remove ( ) ;
92+ }
8793 } ,
8894 updateItemsCountField : function ( ) {
8995 $ ( 'option-count-check' ) . value = this . totalItems > 0 ? '1' : '' ;
Original file line number Diff line number Diff line change @@ -357,12 +357,12 @@ define([
357357 var element ;
358358
359359 _ . each ( this . disabledAttributes , function ( attribute ) {
360- registry . get ( 'index = ' + attribute ) . disabled ( false ) ;
360+ registry . get ( 'code = ' + attribute , ' index = ' + attribute ) . disabled ( false ) ;
361361 } ) ;
362362 this . disabledAttributes = [ ] ;
363363
364364 _ . each ( attributes , function ( attribute ) {
365- element = registry . get ( 'index = ' + attribute . code ) ;
365+ element = registry . get ( 'code = ' + attribute . code , ' index = ' + attribute . code ) ;
366366
367367 if ( ! _ . isUndefined ( element ) ) {
368368 element . disabled ( true ) ;
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ define([
2727 ) ,
2828 'Magento_Braintree/js/view/payment/adapter' : jasmine . createSpyObj (
2929 'adapter' ,
30- [ 'setup' , 'setConfig' ]
30+ [ 'setup' , 'setConfig' , 'showError' ]
3131 )
3232 } ,
3333 braintreeCcForm ;
@@ -43,14 +43,17 @@ define([
4343 } ;
4444 injector . mock ( mocks ) ;
4545 injector . require ( [ 'Magento_Braintree/js/view/payment/method-renderer/cc-form' ] , function ( Constr ) {
46- braintreeCcForm = new Constr ( {
47- provider : 'provName' ,
48- name : 'test' ,
49- index : 'test'
50- } ) ;
51-
52- done ( ) ;
46+ braintreeCcForm = new Constr ( {
47+ provider : 'provName' ,
48+ name : 'test' ,
49+ index : 'test' ,
50+ item : {
51+ title : 'Braintree'
52+ }
5353 } ) ;
54+
55+ done ( ) ;
56+ } ) ;
5457 } ) ;
5558
5659 it ( 'Check if payment code and message container are restored after onActiveChange call.' , function ( ) {
@@ -65,5 +68,21 @@ define([
6568 expect ( braintreeCcForm . getCode ( ) ) . toEqual ( expectedCode ) ;
6669 expect ( braintreeCcForm . messageContainer ) . toEqual ( expectedMessageContainer ) ;
6770 } ) ;
71+
72+ it ( 'Check if form validation fails when "Place Order" button should be active.' , function ( ) {
73+ var errorMessage = 'Something went wrong.' ,
74+
75+ /**
76+ * Anonymous wrapper
77+ */
78+ func = function ( ) {
79+ braintreeCcForm . clientConfig . onError ( {
80+ 'message' : errorMessage
81+ } ) ;
82+ } ;
83+
84+ expect ( func ) . toThrow ( errorMessage ) ;
85+ expect ( braintreeCcForm . isPlaceOrderActionAllowed ( ) ) . toBeTruthy ( ) ;
86+ } ) ;
6887 } ) ;
6988} ) ;
You can’t perform that action at this time.
0 commit comments