summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2017-11-19 22:41:28 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2017-11-23 13:32:13 +0100
commit3a1d8fa45f22503ba9841d71b7ea630d400b2ae5 (patch)
treefee9f7bc44b3c8903addfa00386d394951aa55b7 /core
parent4247936dd6d5ea2fa60586e0f4aa4acbc7d902f1 (diff)
downloadnextcloud-server-3a1d8fa45f22503ba9841d71b7ea630d400b2ae5.tar.gz
nextcloud-server-3a1d8fa45f22503ba9841d71b7ea630d400b2ae5.zip
adjust, fix and extend tests
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'core')
-rw-r--r--core/js/share.js22
-rw-r--r--core/js/tests/specs/shareSpec.js51
2 files changed, 48 insertions, 25 deletions
diff --git a/core/js/share.js b/core/js/share.js
index 281c414b900..86954b2ced2 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -197,24 +197,20 @@ OC.Share = _.extend(OC.Share || {}, {
delete OC.Share.statuses[itemSource];
}
},
- _formatRegularShare: function(shareWith, shareWithDisplayName, message) {
- // display avatar of the user
- var avatar = '<span class="avatar" data-username="' + escapeHTML(shareWith) + '" title="' + message + " " + escapeHTML(shareWithDisplayName) + '"></span>';
- var hidden = '<span class="hidden-visually">' + message + ' ' + escapeHTML(shareWithDisplayName) + '</span> ';
- return avatar + hidden;
- },
/**
* Format a remote address
*
- * @param {String} remoteAddress full remote share
+ * @param {String} shareWith userid, full remote share, or whatever
+ * @param {String} shareWithDisplayName
+ * @param {String} message
* @return {String} HTML code to display
*/
- _formatRemoteShare: function(remoteAddress, message) {
- var parts = this._REMOTE_OWNER_REGEXP.exec(remoteAddress);
+ _formatRemoteShare: function(shareWith, shareWithDisplayName, message) {
+ var parts = this._REMOTE_OWNER_REGEXP.exec(shareWith);
if (!parts) {
// display avatar of the user
- var avatar = '<span class="avatar" data-username="' + escapeHTML(remoteAddress) + '" title="' + message + " " + escapeHTML(remoteAddress) + '"></span>';
- var hidden = '<span class="hidden-visually">' + message + ' ' + escapeHTML(remoteAddress) + '</span> ';
+ var avatar = '<span class="avatar" data-username="' + escapeHTML(shareWith) + '" title="' + message + " " + escapeHTML(shareWithDisplayName) + '"></span>';
+ var hidden = '<span class="hidden-visually">' + message + ' ' + escapeHTML(shareWithDisplayName) + '</span> ';
return avatar + hidden;
}
@@ -250,7 +246,7 @@ OC.Share = _.extend(OC.Share || {}, {
_formatShareList: function(recipients) {
var _parent = this;
return $.map(recipients, function(shareWithDisplayName, shareWith) {
- return _parent._formatRegularShare(shareWith, shareWithDisplayName, t('core', 'Shared with'));
+ return _parent._formatRemoteShare(shareWith, shareWithDisplayName, t('core', 'Shared with'));
});
},
/**
@@ -304,7 +300,7 @@ OC.Share = _.extend(OC.Share || {}, {
// even if reshared, only show "Shared by"
if (ownerId) {
message = t('core', 'Shared by');
- avatars = this._formatRegularShare(ownerId, owner, message);
+ avatars = this._formatRemoteShare(ownerId, owner, message);
} else if (recipients) {
avatars = this._formatShareList(recipients);
}
diff --git a/core/js/tests/specs/shareSpec.js b/core/js/tests/specs/shareSpec.js
index 70c698c99a2..19e9a92ca9e 100644
--- a/core/js/tests/specs/shareSpec.js
+++ b/core/js/tests/specs/shareSpec.js
@@ -45,6 +45,7 @@ describe('OC.Share tests', function() {
var $action;
$file.attr('data-share-owner', input);
+ $file.attr('data-share-owner-id', input);
OC.Share.markFileAsShared($file);
$action = $file.find('.action-share>span').parent();
@@ -119,6 +120,7 @@ describe('OC.Share tests', function() {
it('shows a shared folder icon for folders shared with the current user', function() {
$file.attr('data-type', 'dir');
$file.attr('data-share-owner', 'someoneelse');
+ $file.attr('data-share-owner-id', 'someoneelse');
OC.Share.markFileAsShared($file);
checkIcon('filetypes/folder-shared');
@@ -155,7 +157,9 @@ describe('OC.Share tests', function() {
function checkRecipients(input, output, title) {
var $action;
- $file.attr('data-share-recipients', input);
+ var concatenated = _.values(input).join(', ');
+ $file.attr('data-share-recipients', concatenated);
+ $file.attr('data-share-recipient-data', JSON.stringify(input));
OC.Share.markFileAsShared($file, true);
$action = $file.find('.action-share>span').parent();
@@ -177,66 +181,89 @@ describe('OC.Share tests', function() {
}
it('displays the local share owner as is', function() {
- checkRecipients('User One', 'Shared with User One', null);
+ checkRecipients({'User One': 'User One'}, 'Shared with User One', null);
});
it('displays the user name part of a remote recipient', function() {
checkRecipients(
- 'User One@someserver.com',
+ {'User One@someserver.com': 'User One@someserver.com'},
'User One@…',
'Shared with User One@someserver.com'
);
checkRecipients(
- 'User One@someserver.com/',
+ '{User One@someserver.com/: User One@someserver.com/}',
'User One@…',
'Shared with User One@someserver.com'
);
checkRecipients(
- 'User One@someserver.com/root/of/owncloud',
+ {'User One@someserver.com/root/of/owncloud': 'User One@someserver.com/root/of/owncloud'},
'User One@…',
'Shared with User One@someserver.com'
);
});
it('displays the user name part with domain of a remote share owner', function() {
checkRecipients(
- 'User One@example.com@someserver.com',
+ {'User One@example.com@someserver.com': 'User One@example.com@someserver.com'},
'User One@example.com',
'Shared with User One@example.com@someserver.com'
);
checkRecipients(
- 'User One@example.com@someserver.com/',
+ {'User One@example.com@someserver.com/': 'User One@example.com@someserver.com/'},
'User One@example.com',
'Shared with User One@example.com@someserver.com'
);
checkRecipients(
- 'User One@example.com@someserver.com/root/of/owncloud',
+ {'User One@example.com@someserver.com/root/of/nextcloud': 'User One@example.com@someserver.com/root/of/nextcloud'},
'User One@example.com',
'Shared with User One@example.com@someserver.com'
);
});
it('display multiple remote recipients', function() {
checkRecipients(
- 'One@someserver.com, two@otherserver.com',
+ {
+ 'One@someserver.com': 'One@someserver.com',
+ 'two@otherserver.com': 'two@otherserver.com'
+ },
'One@… two@…',
['Shared with One@someserver.com', 'Shared with two@otherserver.com']
);
checkRecipients(
- 'One@someserver.com/, two@otherserver.com',
+ {
+ 'One@someserver.com/': 'One@someserver.com/',
+ 'two@otherserver.com': 'two@otherserver.com'
+ },
'One@… two@…',
['Shared with One@someserver.com', 'Shared with two@otherserver.com']
);
checkRecipients(
- 'One@someserver.com/root/of/owncloud, two@otherserver.com',
+ {
+ 'One@someserver.com/root/of/owncloud': 'One@someserver.com/root/of/owncloud',
+ 'two@otherserver.com': 'two@otherserver.com'
+ },
'One@… two@…',
['Shared with One@someserver.com', 'Shared with two@otherserver.com']
);
});
it('display mixed recipients', function() {
checkRecipients(
- 'One, two@otherserver.com',
+ {
+ 'One': 'One',
+ 'two@otherserver.com': 'two@otherserver.com'
+ },
'Shared with One two@…',
['Shared with two@otherserver.com']
);
});
+ it('display multiple with divergent displaynames', function() {
+ checkRecipients(
+ {
+ 'One': 'Yoko Ono',
+ 'two@otherserver.com': 'two@otherserver.com',
+ 'Three': 'Green, Mina'
+ },
+ 'Shared with Yoko Ono two@… Shared with Green, Mina',
+ ['Shared with two@otherserver.com']
+ );
+ });
});
});
});