From f956e8f9f74f157260385506305c7fb542c53336 Mon Sep 17 00:00:00 2001
From: Antoine Detailleur <detailleur@fortiss.org>
Date: Wed, 3 Feb 2021 16:22:08 +0100
Subject: [PATCH] [NRRPLT-8094] import experiment added in experiment overview
instead of experiment list
---
.../experiment-list/experiment-list.css | 5 -----
.../experiment-list/experiment-list.js | 4 ----
.../experiment-overview.js | 2 ++
.../experiment-storage-service.test.js | 22 ++++++++++++-------
4 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/src/components/experiment-list/experiment-list.css b/src/components/experiment-list/experiment-list.css
index ae50ee0..be1ab3c 100644
--- a/src/components/experiment-list/experiment-list.css
+++ b/src/components/experiment-list/experiment-list.css
@@ -8,7 +8,6 @@ li.nostyle {
grid-template-rows: auto;
grid-template-columns: auto;
grid-template-areas:
- "import-experiments"
"experiments";
}
@@ -19,10 +18,6 @@ li.nostyle {
background-color: white;
}
-.import-experiments {
- grid-area: import-experiments;
-}
-
.no-items-notification {
margin: 10px;
font-size: 1.5em;
diff --git a/src/components/experiment-list/experiment-list.js b/src/components/experiment-list/experiment-list.js
index b165746..8ff9165 100644
--- a/src/components/experiment-list/experiment-list.js
+++ b/src/components/experiment-list/experiment-list.js
@@ -1,6 +1,5 @@
import React from 'react';
-import ImportExperimentButtons from '../experiment-list/import-experiment-buttons.js';
import ExperimentListElement from './experiment-list-element.js';
import './experiment-list.css';
@@ -9,9 +8,6 @@ export default class ExperimentList extends React.Component {
render() {
return (
<div className='experiment-list-wrapper'>
- <div className='import-experiment'>
- <ImportExperimentButtons />
- </div>
<div className='experiment-list'>
{this.props.experiments.length === 0 ?
<div className='no-items-notification'>List is currently empty ...</div> :
diff --git a/src/components/experiment-overview/experiment-overview.js b/src/components/experiment-overview/experiment-overview.js
index 6b67ad2..42dda8d 100644
--- a/src/components/experiment-overview/experiment-overview.js
+++ b/src/components/experiment-overview/experiment-overview.js
@@ -6,6 +6,7 @@ import ExperimentStorageService from '../../services/experiments/storage/experim
import ExperimentServerService from '../../services/experiments/execution/server-resources-service.js';
import ExperimentExecutionService from '../../services/experiments/execution/experiment-execution-service.js';
+import ImportExperimentButtons from '../experiment-list/import-experiment-buttons.js';
import ExperimentList from '../experiment-list/experiment-list.js';
import NrpHeader from '../nrp-header/nrp-header.js';
@@ -104,6 +105,7 @@ export default class ExperimentOverview extends React.Component {
</TabList>
<TabPanel>
+ <ImportExperimentButtons />
<ExperimentList experiments={this.state.experiments}
availableServers={this.state.availableServers}
startingExperiment={this.state.startingExperiment} />
diff --git a/src/services/experiments/storage/__tests__/experiment-storage-service.test.js b/src/services/experiments/storage/__tests__/experiment-storage-service.test.js
index e4c5049..8f67834 100644
--- a/src/services/experiments/storage/__tests__/experiment-storage-service.test.js
+++ b/src/services/experiments/storage/__tests__/experiment-storage-service.test.js
@@ -13,13 +13,19 @@ jest.mock('../../../authentication-service');
const proxyEndpoint = endpoints.proxy;
const experimentsUrl = `${config.api.proxy.url}${proxyEndpoint.storage.experiments.url}`;
-test('fetches the list of experiments', async () => {
- jest.spyOn(ExperimentStorageService.instance, 'performRequest');
- const experiments = await ExperimentStorageService.instance.getExperiments();
- expect(ExperimentStorageService.instance.performRequest)
- .toHaveBeenCalledWith(experimentsUrl, ExperimentStorageService.instance.GETOptions);
- expect(experiments[0].name).toBe('braitenberg_husky_holodeck_1_0_0');
- expect(experiments[1].configuration.maturity).toBe('production');
+jest.setTimeout(3 * ExperimentStorageService.CONSTANTS.INTERVAL_POLL_EXPERIMENTS);
+
+let onWindowBeforeUnloadCb = undefined;
+beforeEach(() => {
+ jest.spyOn(window, 'addEventListener').mockImplementation((event, cb) => {
+ if (event === 'beforeunload') {
+ onWindowBeforeUnloadCb = cb;
+ }
+ });
+});
+
+afterEach(() => {
+ jest.restoreAllMocks();
});
test('makes sure that invoking the constructor fails with the right message', () => {
@@ -42,7 +48,7 @@ test('fetches the list of experiments', async () => {
const experiments = await ExperimentStorageService.instance.getExperiments();
expect(ExperimentStorageService.instance.performRequest)
- .toHaveBeenCalledWith(experimentsUrl, ExperimentStorageService.instance.options);
+ .toHaveBeenCalledWith(experimentsUrl, ExperimentStorageService.instance.GETOptions);
expect(experiments[0].name).toBe('braitenberg_husky_holodeck_1_0_0');
expect(experiments[1].configuration.maturity).toBe('production');
--
GitLab