Tests fixes and design bump
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
e302cadae2
commit
58debbe42c
|
@ -121,6 +121,7 @@ nbproject
|
|||
/build/jsdocs/
|
||||
/npm-debug.log
|
||||
/PhantomJS_*
|
||||
/build/package-lock.json
|
||||
|
||||
# puphpet
|
||||
puphpet
|
||||
|
|
|
@ -94,7 +94,8 @@
|
|||
@include icon-color('star-dark', 'files', $color-black, 2, true);
|
||||
}
|
||||
.nav-icon-sharingin,
|
||||
.nav-icon-sharingout {
|
||||
.nav-icon-sharingout,
|
||||
.nav-icon-shareoverview {
|
||||
@include icon-color('share', 'files', $color-black);
|
||||
}
|
||||
.nav-icon-sharinglinks {
|
||||
|
|
|
@ -135,10 +135,16 @@
|
|||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
// share note on the sidebar
|
||||
.share-note {
|
||||
border-radius: var(--border-radius);
|
||||
margin-bottom: 10px;
|
||||
margin-left: 37px;
|
||||
}
|
||||
}
|
||||
|
||||
// Sharing tab users list
|
||||
#shareWithList {
|
||||
.shareWithList {
|
||||
list-style-type: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
@ -218,4 +224,18 @@
|
|||
left: 8px;
|
||||
right: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.reshare,
|
||||
#link label,
|
||||
#expiration label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
.avatar {
|
||||
margin-right: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.resharerInfoView.subView {
|
||||
position: relative;
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
var TEMPLATE =
|
||||
'{{#if shareAllowed}}' +
|
||||
'<ul id="shareWithList" class="shareWithList">' +
|
||||
'<ul id="shareLink" class="shareWithList">' +
|
||||
' <li data-share-id="{{cid}}">' +
|
||||
' <div class="avatar icon-public-white"></div><span class="username" title="{{linkShareLabel}}">{{linkShareLabel}}</span>' +
|
||||
' <span class="sharingOptionsGroup">' +
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
'<span class="reshare">' +
|
||||
' <div class="avatar" data-userName="{{reshareOwner}}"></div>' +
|
||||
' {{sharedByText}}' +
|
||||
'</span><br/>'
|
||||
'</span>' +
|
||||
'{{#if hasShareNote}}<div class="share-note">{{shareNote}}</div>{{/if}}'
|
||||
;
|
||||
|
||||
/**
|
||||
|
@ -72,7 +73,10 @@
|
|||
|
||||
var reshareTemplate = this.template();
|
||||
var ownerDisplayName = this.model.getReshareOwnerDisplayname();
|
||||
var shareNote = this.model.getReshareNote();
|
||||
|
||||
var sharedByText = '';
|
||||
|
||||
if (this.model.getReshareType() === OC.Share.SHARE_TYPE_GROUP) {
|
||||
sharedByText = t(
|
||||
'core',
|
||||
|
@ -105,9 +109,13 @@
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.$el.html(reshareTemplate({
|
||||
reshareOwner: this.model.getReshareOwner(),
|
||||
sharedByText: sharedByText
|
||||
sharedByText: sharedByText,
|
||||
shareNote: shareNote,
|
||||
hasShareNote: shareNote !== ''
|
||||
}));
|
||||
|
||||
this.$el.find('.avatar').each(function() {
|
||||
|
|
|
@ -340,6 +340,13 @@
|
|||
return this.get('reshare').displayname_owner;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
getReshareNote: function() {
|
||||
return this.get('reshare').note;
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
|
|
|
@ -92,7 +92,7 @@ describe('OC.Share.ShareDialogLinkShareView', function () {
|
|||
|
||||
var $passwordDiv = view.$el.find('#linkPass');
|
||||
$passwordText = view.$el.find('.linkPassText');
|
||||
$workingIcon = view.$el.find('.linkPass .icon-loading-small');
|
||||
$workingIcon = view.$el.find('.linkPassMenu .icon-loading-small');
|
||||
|
||||
sinon.stub(shareModel, 'saveLinkShare');
|
||||
|
||||
|
|
|
@ -214,188 +214,6 @@ describe('OC.Share.ShareDialogView', function() {
|
|||
focusStub.restore();
|
||||
selectStub.restore();
|
||||
});
|
||||
describe('password', function() {
|
||||
var slideToggleStub;
|
||||
|
||||
beforeEach(function() {
|
||||
$('#allowShareWithLink').val('yes');
|
||||
configModel.set({
|
||||
enforcePasswordForPublicLink: false
|
||||
});
|
||||
|
||||
slideToggleStub = sinon.stub($.fn, 'slideToggle');
|
||||
});
|
||||
afterEach(function() {
|
||||
slideToggleStub.restore();
|
||||
});
|
||||
|
||||
it('enforced but toggled does not fire request', function() {
|
||||
configModel.set('enforcePasswordForPublicLink', true);
|
||||
dialog.render();
|
||||
|
||||
dialog.$el.find('.linkCheckbox').click();
|
||||
|
||||
// The password linkPass field is shown (slideToggle is called).
|
||||
// No request is made yet
|
||||
expect(slideToggleStub.callCount).toEqual(1);
|
||||
expect(slideToggleStub.getCall(0).thisValue.eq(0).attr('id')).toEqual('linkPass');
|
||||
expect(fakeServer.requests.length).toEqual(0);
|
||||
|
||||
// Now untoggle share by link
|
||||
dialog.$el.find('.linkCheckbox').click();
|
||||
dialog.render();
|
||||
|
||||
// Password field disappears and no ajax requests have been made
|
||||
expect(fakeServer.requests.length).toEqual(0);
|
||||
expect(slideToggleStub.callCount).toEqual(2);
|
||||
expect(slideToggleStub.getCall(1).thisValue.eq(0).attr('id')).toEqual('linkPass');
|
||||
});
|
||||
});
|
||||
describe('expiration date', function() {
|
||||
var shareData;
|
||||
var shareItem;
|
||||
var clock;
|
||||
var expectedMinDate;
|
||||
|
||||
beforeEach(function() {
|
||||
// pick a fake date
|
||||
clock = sinon.useFakeTimers(new Date(2014, 0, 20, 14, 0, 0).getTime());
|
||||
expectedMinDate = new Date(2014, 0, 21, 14, 0, 0);
|
||||
|
||||
configModel.set({
|
||||
enforcePasswordForPublicLink: false,
|
||||
isDefaultExpireDateEnabled: false,
|
||||
isDefaultExpireDateEnforced: false,
|
||||
defaultExpireDate: 7
|
||||
});
|
||||
|
||||
shareModel.set('linkShare', {
|
||||
isLinkShare: true,
|
||||
token: 'tehtoken',
|
||||
permissions: OC.PERMISSION_READ,
|
||||
expiration: null
|
||||
});
|
||||
});
|
||||
afterEach(function() {
|
||||
clock.restore();
|
||||
});
|
||||
|
||||
it('does not check expiration date checkbox when no date was set', function() {
|
||||
shareModel.get('linkShare').expiration = null;
|
||||
dialog.render();
|
||||
|
||||
expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(false);
|
||||
expect(dialog.$el.find('.datepicker').val()).toEqual('');
|
||||
});
|
||||
it('does not check expiration date checkbox for new share', function() {
|
||||
dialog.render();
|
||||
|
||||
expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(false);
|
||||
expect(dialog.$el.find('.datepicker').val()).toEqual('');
|
||||
});
|
||||
it('checks expiration date checkbox and populates field when expiration date was set', function() {
|
||||
shareModel.get('linkShare').expiration = '2014-02-01 00:00:00';
|
||||
dialog.render();
|
||||
expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(true);
|
||||
expect(dialog.$el.find('.datepicker').val()).toEqual('01-02-2014');
|
||||
});
|
||||
it('sets default date when default date setting is enabled', function() {
|
||||
configModel.set('isDefaultExpireDateEnabled', true);
|
||||
dialog.render();
|
||||
dialog.$el.find('.linkCheckbox').click();
|
||||
// here fetch would be called and the server returns the expiration date
|
||||
shareModel.get('linkShare').expiration = '2014-1-27 00:00:00';
|
||||
dialog.render();
|
||||
|
||||
// enabled by default
|
||||
expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(true);
|
||||
expect(dialog.$el.find('.datepicker').val()).toEqual('27-01-2014');
|
||||
|
||||
// disabling is allowed
|
||||
dialog.$el.find('[name=expirationCheckbox]').click();
|
||||
expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(false);
|
||||
});
|
||||
it('enforces default date when enforced date setting is enabled', function() {
|
||||
configModel.set({
|
||||
isDefaultExpireDateEnabled: true,
|
||||
isDefaultExpireDateEnforced: true
|
||||
});
|
||||
dialog.render();
|
||||
dialog.$el.find('.linkCheckbox').click();
|
||||
// here fetch would be called and the server returns the expiration date
|
||||
shareModel.get('linkShare').expiration = '2014-1-27 00:00:00';
|
||||
dialog.render();
|
||||
|
||||
expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(true);
|
||||
expect(dialog.$el.find('.datepicker').val()).toEqual('27-01-2014');
|
||||
|
||||
// disabling is not allowed
|
||||
expect(dialog.$el.find('[name=expirationCheckbox]').prop('disabled')).toEqual(true);
|
||||
dialog.$el.find('[name=expirationCheckbox]').click();
|
||||
expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(true);
|
||||
});
|
||||
it('enforces default date when enforced date setting is enabled and password is enforced', function() {
|
||||
configModel.set({
|
||||
enforcePasswordForPublicLink: true,
|
||||
isDefaultExpireDateEnabled: true,
|
||||
isDefaultExpireDateEnforced: true
|
||||
});
|
||||
dialog.render();
|
||||
dialog.$el.find('.linkCheckbox').click();
|
||||
// here fetch would be called and the server returns the expiration date
|
||||
shareModel.get('linkShare').expiration = '2014-1-27 00:00:00';
|
||||
dialog.render();
|
||||
|
||||
//Enter password
|
||||
dialog.$el.find('.linkPassText').val('foo');
|
||||
dialog.$el.find('.linkPassText').trigger(new $.Event('keyup', {keyCode: 13}));
|
||||
fakeServer.requests[0].respond(
|
||||
200,
|
||||
{ 'Content-Type': 'application/json' },
|
||||
JSON.stringify({data: {token: 'xyz'}, status: 'success'})
|
||||
);
|
||||
|
||||
expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(true);
|
||||
expect(dialog.$el.find('.datepicker').val()).toEqual('27-01-2014');
|
||||
|
||||
// disabling is not allowed
|
||||
expect(dialog.$el.find('[name=expirationCheckbox]').prop('disabled')).toEqual(true);
|
||||
dialog.$el.find('[name=expirationCheckbox]').click();
|
||||
expect(dialog.$el.find('[name=expirationCheckbox]').prop('checked')).toEqual(true);
|
||||
});
|
||||
it('sets picker minDate to today and no maxDate by default', function() {
|
||||
dialog.render();
|
||||
dialog.$el.find('.linkCheckbox').click();
|
||||
dialog.$el.find('[name=expirationCheckbox]').click();
|
||||
expect($.datepicker._defaults.minDate).toEqual(expectedMinDate);
|
||||
expect($.datepicker._defaults.maxDate).toEqual(null);
|
||||
});
|
||||
it('limits the date range to X days after share time when enforced', function() {
|
||||
configModel.set({
|
||||
isDefaultExpireDateEnabled: true,
|
||||
isDefaultExpireDateEnforced: true
|
||||
});
|
||||
dialog.render();
|
||||
dialog.$el.find('.linkCheckbox').click();
|
||||
expect($.datepicker._defaults.minDate).toEqual(expectedMinDate);
|
||||
expect($.datepicker._defaults.maxDate).toEqual(new Date(2014, 0, 27, 0, 0, 0, 0));
|
||||
});
|
||||
it('limits the date range to X days after share time when enforced, even when redisplayed the next days', function() {
|
||||
// item exists, was created two days ago
|
||||
var shareItem = shareModel.get('linkShare');
|
||||
shareItem.expiration = '2014-1-27';
|
||||
// share time has time component but must be stripped later
|
||||
shareItem.stime = new Date(2014, 0, 20, 11, 0, 25).getTime() / 1000;
|
||||
configModel.set({
|
||||
isDefaultExpireDateEnabled: true,
|
||||
isDefaultExpireDateEnforced: true
|
||||
});
|
||||
dialog.render();
|
||||
expect($.datepicker._defaults.minDate).toEqual(expectedMinDate);
|
||||
expect($.datepicker._defaults.maxDate).toEqual(new Date(2014, 0, 27, 0, 0, 0, 0));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
describe('check for avatar', function() {
|
||||
beforeEach(function() {
|
||||
|
@ -455,8 +273,8 @@ describe('OC.Share.ShareDialogView', function() {
|
|||
it('test correct function calls', function() {
|
||||
expect(avatarStub.calledThrice).toEqual(true);
|
||||
expect(placeholderStub.callCount).toEqual(4);
|
||||
expect(dialog.$('.shareWithList').children().length).toEqual(5);
|
||||
expect(dialog.$('.avatar').length).toEqual(6);
|
||||
expect(dialog.$('.shareWithList').children().length).toEqual(6);
|
||||
expect(dialog.$('.avatar').length).toEqual(7);
|
||||
});
|
||||
|
||||
it('test avatar owner', function() {
|
||||
|
|
|
@ -86,7 +86,6 @@ class Share extends Constants {
|
|||
);
|
||||
if(count(self::$backendTypes) === 1) {
|
||||
Util::addScript('core', 'merged-share-backend');
|
||||
\OC_Util::addStyle('core', 'share');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue