aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlja Neumann <ineumann@owncloud.com>2017-01-17 14:35:22 +0100
committerMorris Jobke <hey@morrisjobke.de>2017-03-17 00:06:05 -0600
commit31fa2f73d4089630b158d23f765db3a675b77683 (patch)
tree3d5b554b62bba1ab5dcbda43c12f7ba65b71036a
parent39afcbd49feb4ba333746762fe7c9d4701db9860 (diff)
downloadnextcloud-server-31fa2f73d4089630b158d23f765db3a675b77683.tar.gz
nextcloud-server-31fa2f73d4089630b158d23f765db3a675b77683.zip
Sharing dialog: Names sorting is case sensitive #25971
Sharing dialog: Names sorting is case sensitive: adding tests #25971 Signed-off-by: Morris Jobke <hey@morrisjobke.de>
-rw-r--r--core/js/sharedialogview.js3
-rw-r--r--core/js/tests/specs/sharedialogviewSpec.js74
2 files changed, 77 insertions, 0 deletions
diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js
index a63960da2b8..78168336bb7 100644
--- a/core/js/sharedialogview.js
+++ b/core/js/sharedialogview.js
@@ -260,6 +260,9 @@
var suggestions = users.concat(groups).concat(remotes).concat(emails).concat(lookup);
if (suggestions.length > 0) {
+ suggestions.sort(function (a, b) {
+ return OC.Util.naturalSortCompare(a.label, b.label);
+ });
$shareWithField
.autocomplete("option", "autoFocus", true);
diff --git a/core/js/tests/specs/sharedialogviewSpec.js b/core/js/tests/specs/sharedialogviewSpec.js
index 307adea85ff..7e3232f86e1 100644
--- a/core/js/tests/specs/sharedialogviewSpec.js
+++ b/core/js/tests/specs/sharedialogviewSpec.js
@@ -490,6 +490,80 @@ describe('OC.Share.ShareDialogView', function() {
});
});
describe('autocompletion of users', function() {
+ it('is sorted naturally', function () {
+ dialog.render();
+ var response = sinon.stub();
+ dialog.autocompleteHandler({term: 'p'}, response);
+ var jsonData = JSON.stringify({
+ 'ocs' : {
+ 'meta' : {
+ 'status' : 'success',
+ 'statuscode' : 100,
+ 'message' : null
+ },
+ 'data' : {
+ 'exact' : {
+ 'users' : [],
+ 'groups' : [],
+ 'remotes': []
+ },
+ 'users' : [{
+ "label": "Peter A.",
+ "value": {
+ "shareType": 0,
+ "shareWith": "Peter A."
+ }
+ },
+ {
+ "label": "Petra",
+ "value": {
+ "shareType": 0,
+ "shareWith": "Petra"
+ }
+ },
+ {
+ "label": "peter B.",
+ "value": {
+ "shareType": 0,
+ "shareWith": "peter B."
+ }
+ }],
+ 'groups' : [],
+ 'remotes': []
+ }
+ }
+ });
+
+ fakeServer.requests[0].respond(
+ 200,
+ {'Content-Type': 'application/json'},
+ jsonData
+ );
+
+ expect(response.calledWithExactly([
+ {
+ "label": "Peter A.",
+ "value": {
+ "shareType": 0,
+ "shareWith": "Peter A."
+ }
+ },
+ {
+ "label": "peter B.",
+ "value": {
+ "shareType": 0,
+ "shareWith": "peter B."
+ }
+ },
+ {
+ "label": "Petra",
+ "value": {
+ "shareType": 0,
+ "shareWith": "Petra"
+ }
+ }
+ ])).toEqual(true);
+ });
it('triggers autocomplete display and focus with data when ajax search succeeds', function () {
dialog.render();
var response = sinon.stub();