Limit Sinon version to 5.0.7 at most #9627
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds a workaround for recent JavaScript unit test failures in Drone.
When using fake servers with Sinon.JS, the JavaScript test framework, the XHR objects are also fake. Both the fake XHR and server come from nise, which is a dependency and subproject from Sinon. In nise 1.3.3, which is used by Sinon.JS since 5.0.8,
setRequestHeaderof XMLHttpRequest was modified to normalize the header values (as requested by the spec), but since then only string values are accepted; null or integer values can no longer be passed tosetRequestHeader, as it expects thereplacefunction to be available in the object. However, in the tests null and integer values are passed tosetRequestHeader, which causes them to fail.Null values are passed due to
oc_requesttokenbeing null.oc_requesttokenis set to thedata-requesttokenattribute of theheadelement when js.js is loaded. However, in the unit tests, that attribute is not set anywhere, sooc_requesttokenends being null (and, in turn,OC.requestTokentoo, as it is set based onos_requesttokenalso when js.js is loaded).oc_requesttokenis passed as the value of the requesttoken header for every AJAX call that is not cross domain. In the unit tests some AJAX calls are seen as cross domain and others are not (if not explicitly given in the options of the call, whether an AJAX call is cross domain or not is automatically set by jQuery based on the URL; it seems that some of the URLs used in the tests are wrong, but that is a different issue); those tests that use an AJAX call that is not cross domain fail, asnormalizeHeaderValuein the fake XMLHttpRequest tries to callreplaceon a null object.Fixing that by initializing
oc_requesttokenin specHelper.js to an empty string before every test is run is not enough, though, as there are other places in the code in which non-string values are passed as the header value tosetRequestHeader.In the
propFindfunction of davclient.js, which is an external dependency, the value of the Depth header is passed as an integer tosetRequestHeader. The depth is a parameter of thepropFindfunction, so it could be passed as an integer to that function... but then it would not properly handle a depth of 0, as it makes an strict comparison against an integer.Both Firefox and Chromium accept passing non-string values to their
setRequestHeaderimplementation, and there is currently a pull request in nise to allow again non-string values to be passed tosetRequestHeader. It is not clear yet whether nise got too restrictive or the code callingsetRequestHeaderwas too loose. Given that davclient.js is an external dependency, as a temporary measure Sinon version is forced to be 5.0.7 at most until either Sinon or davclient.js are updated.@nextcloud/javascript