Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nrp-frontend
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Neurorobotics Platform
nrp-frontend
Commits
1132444e
Commit
1132444e
authored
3 years ago
by
Detailleur
Browse files
Options
Downloads
Patches
Plain Diff
[NRRPLT-8288]test error and import experiment
parent
ffbc0486
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/services/__tests__/import-experiment-service.test.js
+54
-0
54 additions, 0 deletions
src/services/__tests__/import-experiment-service.test.js
src/services/experiments/files/import-experiment-service.js
+11
-0
11 additions, 0 deletions
src/services/experiments/files/import-experiment-service.js
with
65 additions
and
0 deletions
src/services/__tests__/import-experiment-service.test.js
0 → 100644
+
54
−
0
View file @
1132444e
/**
* @jest-environment jsdom
*/
import
'
@testing-library/jest-dom
'
;
import
'
jest-fetch-mock
'
;
import
ErrorHandlerService
from
'
../error-handler-service
'
;
test
(
'
makes sure that invoking the constructor fails with the right message
'
,
()
=>
{
expect
(()
=>
{
new
ErrorHandlerService
();
}).
toThrow
(
Error
);
expect
(()
=>
{
new
ErrorHandlerService
();
}).
toThrowError
(
Error
(
'
Use ErrorHandlerService.instance
'
));
});
test
(
'
the experiments service instance always refers to the same object
'
,
()
=>
{
const
instance1
=
ErrorHandlerService
.
instance
;
const
instance2
=
ErrorHandlerService
.
instance
;
expect
(
instance1
).
toBe
(
instance2
);
});
test
(
'
should emit an event on network error
'
,
()
=>
{
jest
.
spyOn
(
ErrorHandlerService
.
instance
,
'
networkError
'
).
mockImplementation
(()
=>
{
return
Promise
.
resolve
();
});
let
NetworkError
=
MockNetworkError
;
ErrorHandlerService
.
instance
.
addListener
(
ErrorHandlerService
.
EVENTS
.
Error
,
confirmStartingExperiment
);
await
ErrorHandlerService
.
instance
.
networkError
(
NetworkError
);
ErrorHandlerService
.
instance
.
removeListener
(
ErrorHandlerService
.
EVENTS
.
Error
,
confirmStartingExperiment
);
});
test
(
'
should emit an event on data error
'
,
()
=>
{
jest
.
spyOn
(
ErrorHandlerService
.
instance
,
'
dataError
'
).
mockImplementation
(()
=>
{
return
Promise
.
resolve
();
});
let
DataError
=
DataNetworkError
;
ErrorHandlerService
.
instance
.
addListener
(
ErrorHandlerService
.
EVENTS
.
ERROR
,
confirmStartingExperiment
);
await
ErrorHandlerService
.
instance
.
dataError
(
NetworkError
);
ErrorHandlerService
.
instance
.
removeListener
(
ErrorHandlerService
.
EVENTS
.
ERROR
,
confirmStartingExperiment
);
});
This diff is collapsed.
Click to expand it.
src/services/experiments/files/import-experiment-service.js
+
11
−
0
View file @
1132444e
...
...
@@ -7,8 +7,19 @@ import ErrorHandlerService from '../../error-handler-service.js';
const
importExperimentURL
=
`
${
config
.
api
.
proxy
.
url
}${
endpoints
.
proxy
.
storage
.
importExperiment
.
url
}
`
;
const
scanStorageURL
=
`
${
config
.
api
.
proxy
.
url
}${
endpoints
.
proxy
.
storage
.
scanStorage
.
url
}
`
;
/**
* The Import Experiment Service performs the requests (Extract),
* processes data such as zip or folder (Transform),
* and passes them to the Import Experiment Component (Load).
* Errors are handled by communicating witht he Error Handler Service.
*/
let
_instance
=
null
;
const
SINGLETON_ENFORCER
=
Symbol
();
/**
* Non-default options (content type) for the POST request
*/
const
options
=
{
mode
:
'
cors
'
,
// no-cors, *cors, same-origin
cache
:
'
no-cache
'
,
// *default, no-cache, reload, force-cache, only-if-cached
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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