Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
form-generator
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
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
Coscine
frontend
libraries
form-generator
Commits
ce38bebf
Commit
ce38bebf
authored
2 years ago
by
Benedikt Heinrichs
Browse files
Options
Downloads
Patches
Plain Diff
Fix: No Validation on Empty Metadata (coscine/issues#2417)
parent
c99b2bd3
Branches
Hotfix/2417-emptyMetadataValidation
No related tags found
1 merge request
!119
Fix: No Validation on Empty Metadata
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/FormGenerator.spec.ts
+40
-0
40 additions, 0 deletions
src/FormGenerator.spec.ts
src/base/LinkedDataHandler.ts
+4
-0
4 additions, 0 deletions
src/base/LinkedDataHandler.ts
with
44 additions
and
0 deletions
src/FormGenerator.spec.ts
+
40
−
0
View file @
ce38bebf
...
@@ -10,6 +10,7 @@ import FormGenerator from '@/FormGenerator.vue';
...
@@ -10,6 +10,7 @@ import FormGenerator from '@/FormGenerator.vue';
import
{
listApplicationProfile
}
from
'
@/data/example/applicationProfile
'
;
import
{
listApplicationProfile
}
from
'
@/data/example/applicationProfile
'
;
import
{
listFixedValues
}
from
'
@/data/example/fixedValues
'
;
import
{
listFixedValues
}
from
'
@/data/example/fixedValues
'
;
import
{
listMetadata
}
from
'
@/data/example/metadata
'
;
import
{
listMetadata
}
from
'
@/data/example/metadata
'
;
import
factory
from
'
rdf-ext
'
;
function
sleep
(
ms
:
number
)
{
function
sleep
(
ms
:
number
)
{
return
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
ms
));
return
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
ms
));
...
@@ -138,4 +139,43 @@ describe('FormGenerator.vue', () => {
...
@@ -138,4 +139,43 @@ describe('FormGenerator.vue', () => {
'
Banana
'
'
Banana
'
);
);
});
});
/* Checks for correct functionality of empty metadatasets */
test
(
'
listWithEmptyMetadataFixedValues
'
,
async
()
=>
{
const
wrapper
=
mount
(
FormGenerator
,
{
propsData
:
{
fixedValues
:
{},
formData
:
factory
.
dataset
(),
selectedShape
:
'
https://aims-projekt.de/ap/agent/
'
,
shapes
:
listApplicationProfile
,
shapesMimeType
:
'
text/turtle
'
,
userReceiver
:
()
=>
{
return
{
displayName
:
defaultDisplayName
,
};
},
},
});
await
wrapper
.
vm
.
$nextTick
();
// Wait for 1 second until everything is set up
await
sleep
(
1000
);
expect
(
wrapper
.
emitted
(
'
isValid
'
)).
toBeFalsy
();
const
allTextFields
=
wrapper
.
findAllComponents
({
name
:
'
InputTextField
'
});
expect
(
allTextFields
.
length
).
toBe
(
1
);
await
allTextFields
.
wrappers
[
0
].
setValue
(
'
example@example.org
'
);
// Wait for validation debounce
await
sleep
(
1000
);
expect
(
wrapper
.
emitted
(
'
isValid
'
)).
toBeTruthy
();
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
expect
(
wrapper
.
emitted
(
'
isValid
'
)
!
.
length
).
toBe
(
1
);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
expect
(
wrapper
.
emitted
(
'
isValid
'
)
!
[
0
][
0
].
conforms
).
toBeTruthy
();
});
});
});
This diff is collapsed.
Click to expand it.
src/base/LinkedDataHandler.ts
+
4
−
0
View file @
ce38bebf
...
@@ -82,6 +82,10 @@ export default defineComponent({
...
@@ -82,6 +82,10 @@ export default defineComponent({
if
(
this
.
timeOuts
[
validationContext
])
{
if
(
this
.
timeOuts
[
validationContext
])
{
clearTimeout
(
this
.
timeOuts
[
validationContext
]);
clearTimeout
(
this
.
timeOuts
[
validationContext
]);
}
}
// Do not try to validate empty metadata sets
if
(
metadata
.
size
===
0
)
{
return
;
}
const
clonedMetadata
=
factory
.
dataset
(
const
clonedMetadata
=
factory
.
dataset
(
Array
.
from
(
metadata
)
Array
.
from
(
metadata
)
)
as
unknown
as
Dataset
;
)
as
unknown
as
Dataset
;
...
...
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