Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
241ed17d
Commit
241ed17d
authored
9 years ago
by
Robin McCorkell
Browse files
Options
Downloads
Patches
Plain Diff
Add storage validation JS unit tests
parent
405e2d9b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/files_external/tests/js/settingsSpec.js
+75
-1
75 additions, 1 deletion
apps/files_external/tests/js/settingsSpec.js
with
75 additions
and
1 deletion
apps/files_external/tests/js/settingsSpec.js
+
75
−
1
View file @
241ed17d
...
@@ -37,6 +37,7 @@ describe('OCA.External.Settings tests', function() {
...
@@ -37,6 +37,7 @@ describe('OCA.External.Settings tests', function() {
'
<option disable selected>Add storage</option>
'
+
'
<option disable selected>Add storage</option>
'
+
'
<option value="
\\
OC
\\
TestBackend">Test Backend</option>
'
+
'
<option value="
\\
OC
\\
TestBackend">Test Backend</option>
'
+
'
<option value="
\\
OC
\\
AnotherTestBackend">Another Test Backend</option>
'
+
'
<option value="
\\
OC
\\
AnotherTestBackend">Another Test Backend</option>
'
+
'
<option value="
\\
OC
\\
InputsTestBackend">Inputs test backend</option>
'
+
'
</select>
'
+
'
</select>
'
+
'
</td>
'
+
'
</td>
'
+
'
<td class="authentication"></td>
'
+
'
<td class="authentication"></td>
'
+
...
@@ -76,6 +77,22 @@ describe('OCA.External.Settings tests', function() {
...
@@ -76,6 +77,22 @@ describe('OCA.External.Settings tests', function() {
'
builtin
'
:
true
,
'
builtin
'
:
true
,
},
},
'
priority
'
:
12
'
priority
'
:
12
},
'
\\
OC
\\
InputsTestBackend
'
:
{
'
identifier
'
:
'
\\
OC
\\
InputsTestBackend
'
,
'
name
'
:
'
Inputs test backend
'
,
'
configuration
'
:
{
'
field_text
'
:
'
Text field
'
,
'
field_password
'
:
'
*Password field
'
,
'
field_bool
'
:
'
!Boolean field
'
,
'
field_hidden
'
:
'
#Hidden field
'
,
'
field_text_optional
'
:
'
&Text field optional
'
,
'
field_password_optional
'
:
'
&*Password field optional
'
},
'
authSchemes
'
:
{
'
builtin
'
:
true
,
},
'
priority
'
:
13
}
}
}
}
);
);
...
@@ -190,13 +207,70 @@ describe('OCA.External.Settings tests', function() {
...
@@ -190,13 +207,70 @@ describe('OCA.External.Settings tests', function() {
expect
(
fakeServer
.
requests
.
length
).
toEqual
(
1
);
expect
(
fakeServer
.
requests
.
length
).
toEqual
(
1
);
});
});
// TODO: tests with "applicableUsers" and "applicableGroups"
// TODO: tests with "applicableUsers" and "applicableGroups"
// TODO: test with non-optional config parameters
// TODO: test with missing mount point value
// TODO: test with missing mount point value
// TODO: test with personal mounts (no applicable fields)
// TODO: test with personal mounts (no applicable fields)
// TODO: test save triggers: paste, keyup, checkbox
// TODO: test save triggers: paste, keyup, checkbox
// TODO: test "custom" field with addScript
// TODO: test "custom" field with addScript
// TODO: status indicator
// TODO: status indicator
});
});
describe
(
'
validate storage configuration
'
,
function
()
{
var
$tr
;
beforeEach
(
function
()
{
$tr
=
view
.
$el
.
find
(
'
tr:first
'
);
selectBackend
(
'
\\
OC
\\
InputsTestBackend
'
);
});
it
(
'
lists missing fields in storage errors
'
,
function
()
{
var
storage
=
view
.
getStorageConfig
(
$tr
);
expect
(
storage
.
errors
).
toEqual
({
backendOptions
:
[
'
field_text
'
,
'
field_password
'
]
});
});
it
(
'
highlights missing non-optional fields
'
,
function
()
{
_
.
each
([
'
field_text
'
,
'
field_password
'
],
function
(
param
)
{
expect
(
$tr
.
find
(
'
input[data-parameter=
'
+
param
+
'
]
'
).
hasClass
(
'
warning-input
'
)).
toBe
(
true
);
});
_
.
each
([
'
field_bool
'
,
'
field_hidden
'
,
'
field_text_optional
'
,
'
field_password_optional
'
],
function
(
param
)
{
expect
(
$tr
.
find
(
'
input[data-parameter=
'
+
param
+
'
]
'
).
hasClass
(
'
warning-input
'
)).
toBe
(
false
);
});
});
it
(
'
validates correct storage
'
,
function
()
{
$tr
.
find
(
'
[name=mountPoint]
'
).
val
(
'
mountpoint
'
);
$tr
.
find
(
'
input[data-parameter=field_text]
'
).
val
(
'
foo
'
);
$tr
.
find
(
'
input[data-parameter=field_password]
'
).
val
(
'
bar
'
);
$tr
.
find
(
'
input[data-parameter=field_text_optional]
'
).
val
(
'
foobar
'
);
// don't set field_password_optional
$tr
.
find
(
'
input[data-parameter=field_hidden]
'
).
val
(
'
baz
'
);
var
storage
=
view
.
getStorageConfig
(
$tr
);
expect
(
storage
.
validate
()).
toBe
(
true
);
});
it
(
'
checks missing mount point
'
,
function
()
{
$tr
.
find
(
'
[name=mountPoint]
'
).
val
(
''
);
$tr
.
find
(
'
input[data-parameter=field_text]
'
).
val
(
'
foo
'
);
$tr
.
find
(
'
input[data-parameter=field_password]
'
).
val
(
'
bar
'
);
var
storage
=
view
.
getStorageConfig
(
$tr
);
expect
(
storage
.
validate
()).
toBe
(
false
);
});
});
describe
(
'
update storage
'
,
function
()
{
describe
(
'
update storage
'
,
function
()
{
// TODO
// TODO
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment