-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update select.js #9475
Update select.js #9475
Conversation
Fixed a bug where options.reduce was not available in case options was generated by an array with non-numeric or missing numeric keys in PHP.
@@ -55,6 +55,10 @@ define([ | |||
flatOptions: function (options) { | |||
var self = this; | |||
|
|||
if (!Array.isArray(options)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, use _.isArray function to check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you cover this with unit test? Test already created(dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/select.test.js), but this case did not covered.
Used `_.isArray` instead of `Array.isArray` as requested
Used `_.isArray` instead of `Array.isArray` as requested
Added a scenario where options are loaded as an object instead of an array. Options are generated in PHP. This is the case when the option array in PHP has non-numeric keys or has numeric keys but misses some numeric keys. I noticed the opts test was deleted by someone in an earlier commit, but I think this is too important to remove from the test, so I added it again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@omiroshnichenko I made the changes and covered it in the test file.
Wanted to add the note that the opt test is still present in the 2.1-develop branch, so I think it may be removed by mistake.
@redelschaap Travis CI did not execute tests on this PR due to the error: We will execute tests on this PR in the internal CICD, however you may want to contact Travis CI support to figure out what is wrong. |
Okay great. I guess they gave that error because I committed 4 or 5 times within half an hour. Is there anything I need to do now? |
@redelschaap It's ok on our side. We will let you know if there is anything specific found by internal CICD jobs. |
@redelschaap
I suggest you talking to Travis CI support to fix builds, so you could fix the errors. |
Fix for jasmine tests
@ishakhsuvarov I can't get grunt to work with jasmine tests, but when analyzing |
Changed file to re-run Travis test
Fixed style issues
@ishakhsuvarov Travis CI is working again on my account. Travis' tests for select.js succeeded, but two integration tests for PHP failed on some tests in Magento_Sales, but I did not change anything about that. In Build #4295 you can see those integration tests succeeded, so I think Travis failed in the last build. |
@redelschaap We are currently experiencing some issues with integration test failures. I've restarted build jobs, hope it's green this time. |
@ishakhsuvarov It did :) |
[EngCom] Public Pull Requests - MAGETWO-69573: Adding logo in media folder #9797 - MAGETWO-69555: Allow for referenceBlock to include template argument #9772 - MAGETWO-69540: Fix for #5897: getIdentities relies on uninitialized collection #9777 - MAGETWO-69533: [BUGFIX][6244] Fix Issue with code label display in cart checkout. #9721 - MAGETWO-69499: Update select.js #9475 - MAGETWO-69451: Replace Zend_Json in the configurable product block test #9753 - MAGETWO-69373: Customer with unique attribute can't be saved #7844 #9712 - MAGETWO-69369: Replace the direct usage of Zend_Json with a call to the Json Help class #9344 - MAGETWO-69085: Do not hardcode product link types #9600 - MAGETWO-69554: Patch to allow multiple filter_url_params to function #9723
@redelschaap thank you for your contribution |
You're welcome, happy to help! |
Description
Fixed a bug where
options.reduce
was not available in case options was generated by an array with non-numeric or missing numeric keys in PHP. In that case a TypeError get thrown, becauseoptions.reduce
is not a function of an object.Uncaught TypeError: Unable to process binding "text: function (){return $col.getLabel($row()) }"
Message: options.reduce is not a function
Manual testing scenarios