summaryrefslogtreecommitdiffstats
path: root/apps/files_external/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-03-16 14:07:53 +0100
committerVincent Petry <pvince81@owncloud.com>2015-03-26 11:21:03 +0100
commitca6b715b31bbfea7724dd8659e2a1e61098a31a5 (patch)
tree322cde35082f830855ab023c969ce093eb0bc325 /apps/files_external/tests
parent69f14f974b2acd385809b508f22aa5c15e70d801 (diff)
downloadnextcloud-server-ca6b715b31bbfea7724dd8659e2a1e61098a31a5.tar.gz
nextcloud-server-ca6b715b31bbfea7724dd8659e2a1e61098a31a5.zip
Added ext storage mount options GUI
Added option to disable autoscan of external storages Mount option file system scan is now an int Move priority field to avoid undefined field in storage options All input elements inside the storage options block get parsed into storage options. Moving the priority field outside prevents it to appear in the storage config, as expected. It is still parsed by special code.
Diffstat (limited to 'apps/files_external/tests')
-rw-r--r--apps/files_external/tests/js/settingsSpec.js88
1 files changed, 81 insertions, 7 deletions
diff --git a/apps/files_external/tests/js/settingsSpec.js b/apps/files_external/tests/js/settingsSpec.js
index 5a3ee2cb5f1..f030965835a 100644
--- a/apps/files_external/tests/js/settingsSpec.js
+++ b/apps/files_external/tests/js/settingsSpec.js
@@ -43,6 +43,7 @@ describe('OCA.External.Settings tests', function() {
'<td class="applicable">' +
'<input type="hidden" class="applicableUsers">' +
'</td>' +
+ '<td class="mountOptionsToggle"><input type="hidden" class="mountOptions"/><img class="svg action"/></td>' +
'<td><img alt="Delete" title="Delete" class="svg action"/></td>' +
'</tr>' +
'</tbody>' +
@@ -116,30 +117,57 @@ describe('OCA.External.Settings tests', function() {
// TODO: test suggested mount point logic
});
describe('saving storages', function() {
- it('saves storage after editing config', function() {
- var $tr = view.$el.find('tr:first');
- selectBackend('\\OC\\TestBackend');
+ var $tr;
+ beforeEach(function() {
+ $tr = view.$el.find('tr:first');
+ selectBackend('\\OC\\TestBackend');
+ });
+ it('saves storage after editing config', function() {
var $field1 = $tr.find('input[data-parameter=field1]');
expect($field1.length).toEqual(1);
$field1.val('test');
$field1.trigger(new $.Event('keyup', {keyCode: 97}));
+ var $mountOptionsField = $tr.find('input.mountOptions');
+ expect($mountOptionsField.length).toEqual(1);
+ $mountOptionsField.val(JSON.stringify({previews:true}));
+
clock.tick(4000);
expect(fakeServer.requests.length).toEqual(1);
var request = fakeServer.requests[0];
expect(request.url).toEqual(OC.webroot + '/index.php/apps/files_external/globalstorages');
- expect(OC.parseQueryString(request.requestBody)).toEqual({
+ expect(JSON.parse(request.requestBody)).toEqual({
backendClass: '\\OC\\TestBackend',
- 'backendOptions[field1]': 'test',
- 'backendOptions[field2]': '',
+ backendOptions: {
+ 'field1': 'test',
+ 'field2': ''
+ },
mountPoint: 'TestBackend',
- priority: '11'
+ priority: 11,
+ applicableUsers: [],
+ applicableGroups: [],
+ mountOptions: {
+ 'previews': true
+ }
});
// TODO: respond and check data-id
});
+ it('saves storage after closing mount options dropdown', function() {
+ $tr.find('.mountOptionsToggle img').click();
+ $tr.find('[name=previews]').trigger(new $.Event('keyup', {keyCode: 97}));
+ $tr.find('input[data-parameter=field1]').val('test');
+
+ // does not save inside the dropdown
+ expect(fakeServer.requests.length).toEqual(0);
+
+ $('body').mouseup();
+
+ // but after closing the dropdown
+ expect(fakeServer.requests.length).toEqual(1);
+ });
// TODO: tests with "applicableUsers" and "applicableGroups"
// TODO: test with non-optional config parameters
// TODO: test with missing mount point value
@@ -157,6 +185,52 @@ describe('OCA.External.Settings tests', function() {
describe('recheck storages', function() {
// TODO
});
+ describe('mount options dropdown', function() {
+ var $tr;
+ var $td;
+
+ beforeEach(function() {
+ $tr = view.$el.find('tr:first');
+ $td = $tr.find('.mountOptionsToggle');
+ selectBackend('\\OC\\TestBackend');
+ });
+
+ it('shows dropdown when clicking on toggle button, hides when clicking outside', function() {
+ $td.find('img').click();
+
+ expect($td.find('.dropdown').length).toEqual(1);
+
+ $('body').mouseup();
+
+ expect($td.find('.dropdown').length).toEqual(0);
+ });
+
+ it('reads config from mountOptions field', function() {
+ $tr.find('input.mountOptions').val(JSON.stringify({previews:false}));
+
+ $td.find('img').click();
+ expect($td.find('.dropdown [name=previews]').prop('checked')).toEqual(false);
+ $('body').mouseup();
+
+ $tr.find('input.mountOptions').val(JSON.stringify({previews:true}));
+ $td.find('img').click();
+ expect($td.find('.dropdown [name=previews]').prop('checked')).toEqual(true);
+ });
+
+ it('writes config into mountOptions field', function() {
+ $td.find('img').click();
+ // defaults to true
+ var $field = $td.find('.dropdown [name=previews]');
+ expect($field.prop('checked')).toEqual(true);
+ $td.find('.dropdown [name=filesystem_check_changes]').val(2);
+ $('body').mouseup();
+
+ expect(JSON.parse($tr.find('input.mountOptions').val())).toEqual({
+ previews: true,
+ filesystem_check_changes: 2
+ });
+ });
+ });
});
describe('applicable user list', function() {
// TODO: test select2 retrieval logic