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>
This commit is contained in:
Ilja Neumann 2017-01-17 14:35:22 +01:00 committed by Morris Jobke
parent 39afcbd49f
commit 31fa2f73d4
No known key found for this signature in database
GPG key ID: 9CE5ED29E7FCD38A
2 changed files with 77 additions and 0 deletions

View file

@ -260,6 +260,9 @@
var suggestions = users.concat(groups).concat(remotes).concat(emails).concat(lookup); var suggestions = users.concat(groups).concat(remotes).concat(emails).concat(lookup);
if (suggestions.length > 0) { if (suggestions.length > 0) {
suggestions.sort(function (a, b) {
return OC.Util.naturalSortCompare(a.label, b.label);
});
$shareWithField $shareWithField
.autocomplete("option", "autoFocus", true); .autocomplete("option", "autoFocus", true);

View file

@ -490,6 +490,80 @@ describe('OC.Share.ShareDialogView', function() {
}); });
}); });
describe('autocompletion of users', 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 () { it('triggers autocomplete display and focus with data when ajax search succeeds', function () {
dialog.render(); dialog.render();
var response = sinon.stub(); var response = sinon.stub();