[Pkg-owncloud-commits] [owncloud] 111/123: Reset share dialog values so we start out clean

David Prévot taffit at moszumanska.debian.org
Tue May 19 23:55:25 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit b090a32d233631305f050b7235eb4bedc91417ad
Author: Roeland Jago Douma <roeland at famdouma.nl>
Date:   Fri Apr 24 16:14:08 2015 +0200

    Reset share dialog values so we start out clean
    
    * Unit test
---
 core/js/share.js                 |   5 ++
 core/js/tests/specs/shareSpec.js | 106 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 111 insertions(+)

diff --git a/core/js/share.js b/core/js/share.js
index 6723b82..aa90790 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -986,6 +986,11 @@ $(document).ready(function() {
 			$('#linkPassText').attr('placeholder', t('core', 'Choose a password for the public link'));
 			// Reset link
 			$('#linkText').val('');
+			$('#showPassword').prop('checked', false);
+			$('#linkPass').hide();
+			$('#sharingDialogAllowPublicUpload').prop('checked', false);
+			$('#expirationCheckbox').prop('checked', false);
+			$('#expirationDate').hide();
 			var expireDateString = '';
 			if (oc_appconfig.core.defaultExpireDateEnabled) {
 				var date = new Date().getTime();
diff --git a/core/js/tests/specs/shareSpec.js b/core/js/tests/specs/shareSpec.js
index 3e9a0b2..5ae2b55 100644
--- a/core/js/tests/specs/shareSpec.js
+++ b/core/js/tests/specs/shareSpec.js
@@ -228,6 +228,112 @@ describe('OC.Share tests', function() {
 
 				oc_appconfig.core.enforcePasswordForPublicLink = old;
 			});
+			it('reset password on toggle of share', function() {
+				$('#allowShareWithLink').val('yes');
+				OC.Share.showDropDown(
+					'file',
+					123,
+					$container,
+					true,
+					31,
+					'shared_file_name.txt'
+				);
+				$('#dropdown [name=linkCheckbox]').click();
+				fakeServer.requests[0].respond(
+					200,
+					{ 'Content-Type': 'application/json' },
+					JSON.stringify({data: {token: 'xyz'}, status: 'success'})
+				);
+
+				//Password protection should be unchecked and password field not visible
+				expect($('#dropdown [name=showPassword]').prop('checked')).toEqual(false);
+				expect($('#dropdown #linkPass').is(":visible")).toEqual(false);
+
+				// Toggle and set password
+				$('#dropdown [name=showPassword]').click();
+				$('#dropdown #linkPassText').val('foo');
+				$('#dropdown #linkPassText').trigger(new $.Event('keyup', {keyCode: 13}));
+				fakeServer.requests[1].respond(
+					200,
+					{ 'Content-Type': 'application/json' },
+					JSON.stringify({data: {token: 'xyz2'}, status: 'success'})
+				);
+
+				// Unshare
+				$('#dropdown [name=linkCheckbox]').click();
+				fakeServer.requests[2].respond(
+					200,
+					{ 'Content-Type': 'application/json' },
+					JSON.stringify({status: 'success'})
+				);
+
+				// Toggle share again
+				$('#dropdown [name=linkCheckbox]').click();
+				fakeServer.requests[3].respond(
+					200,
+					{ 'Content-Type': 'application/json' },
+					JSON.stringify({data: {token: 'xyz3'}, status: 'success'})
+				);
+
+
+				// Password checkbox should be unchecked
+				expect($('#dropdown [name=showPassword]').prop('checked')).toEqual(false);
+				expect($('#dropdown #linkPass').is(":visible")).toEqual(false);
+			});
+			it('reset expiration on toggle of share', function() {
+				$('#allowShareWithLink').val('yes');
+				OC.Share.showDropDown(
+					'file',
+					123,
+					$container,
+					true,
+					31,
+					'shared_file_name.txt'
+				);
+				$('#dropdown [name=linkCheckbox]').click();
+				fakeServer.requests[0].respond(
+					200,
+					{ 'Content-Type': 'application/json' },
+					JSON.stringify({data: {token: 'xyz'}, status: 'success'})
+				);
+
+				//Expiration should be unchecked and expiration field not visible
+				expect($('#dropdown [name=expirationCheckbox]').prop('checked')).toEqual(false);
+				expect($('#dropdown #expirationDate').is(":visible")).toEqual(false);
+
+				// Toggle and set password
+				$('#dropdown [name=expirationCheckbox]').click();
+				d = new Date();
+				d.setDate(d.getDate() + 1);
+				date=d.getDate() + '-' + (d.getMonth()+1) + '-' + d.getFullYear();
+				$('#dropdown #expirationDate').val(date);
+				$('#dropdown #expirationDate').change();
+				fakeServer.requests[1].respond(
+					200,
+					{ 'Content-Type': 'application/json' },
+					JSON.stringify({data: {token: 'xyz2'}, status: 'success'})
+				);
+
+				// Unshare
+				$('#dropdown [name=linkCheckbox]').click();
+				fakeServer.requests[2].respond(
+					200,
+					{ 'Content-Type': 'application/json' },
+					JSON.stringify({status: 'success'})
+				);
+
+				// Toggle share again
+				$('#dropdown [name=linkCheckbox]').click();
+				fakeServer.requests[3].respond(
+					200,
+					{ 'Content-Type': 'application/json' },
+					JSON.stringify({data: {token: 'xyz3'}, status: 'success'})
+				);
+
+				// Recheck expire visibility
+				expect($('#dropdown [name=expirationCheckbox]').prop('checked')).toEqual(false);
+				expect($('#dropdown #expirationDate').is(":visible")).toEqual(false);
+			});
 			it('shows populated link share when a link share exists', function() {
 				loadItemStub.returns({
 					reshare: [],

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list