Skip to content

Commit

Permalink
feat: operation creator now uses sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
mbetancurt committed Jun 15, 2020
1 parent 978a692 commit 663f346
Show file tree
Hide file tree
Showing 31 changed files with 79 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: cypress-io/github-action@v1
with:
build: npm run build
start: npm run start
start: npm run start-dev
wait-on: http://localhost:2000
- name: Upload coverage
uses: codecov/codecov-action@v1
Expand Down
61 changes: 35 additions & 26 deletions cypress/integration/map_createnewoperation.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,45 @@ describe('Use Case 01A: Create New Operation (valid)', function () {
cy.setCookie('user', 'admin');
cy.setCookie('jwt', response.body);
});
cy.server(); // enable response stubbing
cy.route({
method: 'POST', // Route all GET requests
url: '/operation',
response: {},
status: 200
}).as('postOperation');
});
/*
it('Find created operation and clean-up', function () {
cy.visit('http://localhost:2000/dashboard/operations');
cy.contains('CreateNewOp#01')
.should('exist')
.click();
cy.get('[data-test-id="dash#selected#gufi"]').then(($value) => {
const gufi = $value.text();
cy.getCookie('jwt').then(cookie => {
cy.request({url: API + 'operation/' + gufi, method: 'DELETE', headers: {'auth': cookie.value}})
.then((response) => {
expect(response.isOkStatusCode).to.be.true;
});
});
});
});
*/
it('Finds button and starts use case', function () {
cy.visit('http://localhost:2000/');
cy.get('[data-test-id="mapButtonMenu"]').click();
cy.contains('contextualmenu_createnewop').click();
});
it('Define Polygon', function () {
cy.contains('editor.step.definevolumes').click();
cy.get('.rightAreaCloser').click();
cy.get('[data-test-id="map"]').click('topLeft');
cy.get('[data-test-id="map"]').click('topRight');
cy.get('[data-test-id="map"]').click('bottomLeft');
});
it('Define Volume Info', function () {
cy.get('[data-test-id="map"]').click(150,150);
cy.contains('editor.volume.editingvolume_count').get('[data-test-id="mapEditorVolumeInfoMinAltitude"]').clear().type('-1');
cy.get('.rightAreaOpener').click();
cy.get('[data-test-id="map#editor#volume#info#min_altitude"]').clear().type('-1');
cy.get('[data-test-id="map#editor#volume#info#max_altitude"]').clear().type('50');
cy.get('[data-test-id="map#editor#volume#info#near_structure"]').check({force: true});
cy.get('[data-test-id="map#editor#volume#info#bvlos"]').check({force: true});
Expand All @@ -38,45 +61,31 @@ describe('Use Case 01A: Create New Operation (valid)', function () {
.not('.DayPicker-Day--selected')
.not('.DayPicker-Day--today')
.first().click();
cy.contains('editor.volume.closecalendar').click();
cy.get('[data-test-id="map#editor#volume#info#effective_time_end"]').click();
cy.get('.DayPicker-Day')
.last()
.not('.DayPicker-Day--disabled')
.not('.DayPicker-Day--selected')
.not('.DayPicker-Day--today')
.first().click();
cy.contains('editor.volume.closecalendar').click();
cy.get('.bp3-dialog-close-button').click(); // TODO: Change this line if we don't use blueprint3js dialog anymore.
});
it('Complete Volume information', function () {
cy.get('.rightAreaOpener').click();
cy.contains('editor.step.defineoperationinfo').click();
cy.get('[data-test-id="mapInputEditorName"]')
.clear()
.type('CreateNewOp#01');
//cy.get('[data-test-id="mapInputEditorVolumeDescr"]').
cy.get('[data-test-id="mapInputEditorFlightNumber"]')
.clear()
.type('123');
cy.get('[data-test-id="map#editor#operation#info#contact"]')
.clear()
.type('E2E Testing');
cy.get('[data-test-id="map#editor#operation#info#contact_phone"]')
.clear()
.type('09123456');
});
it('Finish and post', function () {
cy.get('.bp3-dialog-close-button').click(); // TODO: Change this line if we don't use blueprint3js dialog anymore.
cy.contains('editor.step.finish').click();
cy.wait(3000);
cy.contains('finish').click();
cy.wait('@postOperation');
});
/*it('Find created operation and clean-up', function () {
cy.visit('http://localhost:2000/dashboard/operations');
cy.contains('CreateNewOp#01')
.should('exist')
.click();
cy.get('[data-test-id="dash#selected#gufi"]').then(($value) => {
const gufi = $value.text();
cy.getCookie('jwt').then(cookie => {
cy.request({url: API + 'operation/' + gufi, method: 'DELETE', headers: {'auth': cookie.value}})
.then((response) => {
expect(response.isOkStatusCode).to.be.true;
});
});
});
});*/
});
8 changes: 2 additions & 6 deletions cypress/integration/sp_login.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ describe('UseCase 05. Login', function() {
cy.visit('http://localhost:2000/');
cy.get('#login-user').type('admin');
cy.get('#login-password').type('admin');
cy.contains('app.changelanguage').click();
cy.contains('Español').click();
cy.contains('Iniciar sesión').click();
cy.contains('login.login').click();
/*cy.get('.loginError').then(($el) =>
expect($el).to.contain('Please wait')
);*/
Expand All @@ -17,9 +15,7 @@ describe('UseCase 05. Login', function() {
cy.visit('http://localhost:2000/');
cy.get('#login-user').type('admin');
cy.get('#login-password').type('wrongpassword');
cy.contains('Español').click();
cy.contains('English').click();
cy.contains('Log in').click();
cy.contains('login.login').click();
/*cy.get('.loginError').then(($el) =>
expect($el).to.contain('Please wait')
);*/
Expand Down
1 change: 0 additions & 1 deletion cypress/integration/sp_registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@ describe('SPx: (Registration)', function () {
cy.get( '#input-repeat-password').type('1234');
cy.contains('login.register').click();
cy.contains('OK').click();
cy.contains('app.changelanguage').click();
});
});
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/videos/dsh_list_users.js.mp4
Binary file not shown.
Binary file modified cypress/videos/dsh_newvehicle.js.mp4
Binary file not shown.
Binary file modified cypress/videos/dsh_sidemenu.js.mp4
Binary file not shown.
Binary file modified cypress/videos/map_createnewoperation.js.mp4
Binary file not shown.
Binary file modified cypress/videos/map_layers.js.mp4
Binary file not shown.
Binary file modified cypress/videos/map_operations.js.mp4
Binary file not shown.
Binary file modified cypress/videos/map_quickfly.js.mp4
Binary file not shown.
Binary file modified cypress/videos/sp_login.js.mp4
Binary file not shown.
Binary file modified cypress/videos/sp_registration.js.mp4
Binary file not shown.
Binary file modified cypress/videos/sp_simulator.js.mp4
Binary file not shown.
Binary file added cypress/videos/sp_verify.js.mp4
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Ades.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function Ades() {
bc.onmessage = (event) => setAlertUtmMessage(event.data);*/

/* Auth */
const [cookies, setCookie, removeCookie] = useCookies(['jwt']);
const [cookies, setCookie, removeCookie] = useCookies(['jwt', 'lang']);
const [isLoggedIn, setLoggedIn] = useState(true);
const [role, setRole] = useState('none');

Expand Down
2 changes: 1 addition & 1 deletion src/LoginScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function LoginScreen() {
i18n.changeLanguage('en');
}
}
}, []);
}, []); // eslint-disable-line react-hooks/exhaustive-deps

return (
<form onSubmit={login} className="centeredScreen texturedBackground">
Expand Down
2 changes: 1 addition & 1 deletion src/RegistrationScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const RegistrationScreen = () => {
i18n.changeLanguage('en');
}
}
}, []);
}, []); // eslint-disable-line react-hooks/exhaustive-deps

//----------------------------------------------------------------------------------
//--------------------------------- AUX FUNCTIONS ---------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/VerificationScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function VerificationScreen() {
i18n.changeLanguage('en');
}
}
}, []);
}, []); // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
Axios
Expand All @@ -50,7 +50,7 @@ function VerificationScreen() {
setLoading(false);
setError(true);
});
}, [username, token]);
}, [username, token]); // eslint-disable-line react-hooks/exhaustive-deps

return (
<div className="centeredScreen texturedBackground">
Expand Down
8 changes: 3 additions & 5 deletions src/map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import QuickFly from './actions/QuickFly';
import DroneMarker from './elements/DroneMarker';
import OperationPolygon from './elements/OperationPolygon';
import OperationInfoEditor from './editor/OperationInfoEditor';
import OperationVolumeInfoEditor from './editor/OperationVolumeInfoEditor';
import RestrictedFlightVolume from './elements/RestrictedFlightVolume';
import SelectedOperation from './viewer/SelectedOperation';
import SimulatorPanel from './actions/SimulatorPanel';
Expand All @@ -30,7 +29,6 @@ import OperationEditMarker from './elements/OperationEditMarker';
/* Hooks */
import useOperationFilter from './hooks/useOperationFilter';
import useAdesState from '../state/AdesState';
import useEditorStepText from './hooks/useEditorStepText';
import useEditorLogic from './hooks/useEditorLogic';
import useSimulatorLogic from './hooks/useSimulatorLogic';

Expand Down Expand Up @@ -64,13 +62,12 @@ function Map({ mode }) {
/* Editor state */
const isEditor = S.isJust(mode) && fM(mode) === 'new';

const [isOperationInfoPopupOpen, setOperationInfoPopupOpen] = useState(false);
const [operationInfo, setOperationInfo, volume, setVolumeInfo, polygons, setPolygons, saveOperation, setErrorOnSaveCallback] = useEditorLogic(refMapOnClick, mapInitialized && isEditor);
const [operationInfo, setOperationInfo, volume, setVolumeInfo, polygons, setPolygons, saveOperation, ] = useEditorLogic(refMapOnClick, mapInitialized && isEditor);

/*const [stepsToDefineOperation, , stepsDisabled] =
useEditorStepText(setOperationInfo, setOperationInfoPopupOpen, saveOperation, setErrorOnSaveCallback);*/

const [maybeEditingOpVolume, setEditingOperationVolume] = useState(S.Maybe.Nothing);
const [, setEditingOperationVolume] = useState(S.Maybe.Nothing);
//const notifications = useNotificationStore();
//const statusOverMapNotifs =
// notifications.state.all.size > 0
Expand Down Expand Up @@ -329,6 +326,7 @@ function Map({ mode }) {
{/* Editor Panels */}
{isEditor &&
<>
<EditorPanel />
<OperationInfoEditor
info={operationInfo}
setInfo={setOperationInfo}
Expand Down
2 changes: 1 addition & 1 deletion src/map/actions/EditorPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import RightAreaButton from '../RightAreaButton';
import {useTranslation} from 'react-i18next';
import useAdesState from '../../state/AdesState';

const EditorPanel = ({steps, stepsDisabled}) => {
const EditorPanel = () => {
const {t} = useTranslation();
const [state, actions] = useAdesState();
return (
Expand Down
7 changes: 3 additions & 4 deletions src/map/editor/OperationInfoEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import React from 'react';
/*
UI
*/
import {Button, Dialog, FormGroup, InputGroup} from '@blueprintjs/core';
import {Button, FormGroup, InputGroup} from '@blueprintjs/core';
/*
Helpers
*/
import PropTypes from 'prop-types';
import {Just, maybeToNullable, Maybe} from 'sanctuary';
import _, {maybeShow} from '../../libs/SaferSanctuary';
import {useTranslation} from 'react-i18next';
import RightAreaButton from '../RightAreaButton';
import OperationVolumeInfoEditor from './OperationVolumeInfoEditor';
Expand Down Expand Up @@ -67,7 +66,7 @@ function OperationInfoEditor({info, setInfo, volumeInfo, setVolumeInfo, saveOper
>
<InputGroup
id="contact"
data-test-id="mapInputEditorContact"
data-test-id="map#editor#operation#info#contact"
value={info.contact}
onChange={(evt) => editInfo('contact', evt.target.value)}
/>
Expand All @@ -80,7 +79,7 @@ function OperationInfoEditor({info, setInfo, volumeInfo, setVolumeInfo, saveOper
>
<InputGroup
id="contact_phone"
data-test-id="mapInputEditorContactPhone"
data-test-id="map#editor#operation#info#contact_phone"
value={info.contact_phone}
onChange={(evt) => editInfo('contact_phone', evt.target.value)}
/>
Expand Down
53 changes: 28 additions & 25 deletions src/map/editor/OperationVolumeInfoEditor.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import React, {useState} from 'react';
import {Alignment, Button, Checkbox, Dialog, Divider, FormGroup, InputGroup, Intent} from '@blueprintjs/core';
import S from 'sanctuary';
import {DateInput, DatePicker, TimePicker, TimePrecision} from '@blueprintjs/datetime';
import React from 'react';
import {Alignment, Checkbox, FormGroup, InputGroup} from '@blueprintjs/core';
import {DateInput, TimePrecision} from '@blueprintjs/datetime';
import {useTranslation} from 'react-i18next';

function OperationVolumeInfoEditor(props) {
const { t, } = useTranslation();
const [beginCalendarOpen, setBeginCalendarOpen] = useState(false);
const [endCalendarOpen, setEndCalendarOpen] = useState(false);
const {info, setInfo} = props;
const editInfo = (property, newValue) =>
setInfo(volume => {
Expand Down Expand Up @@ -64,15 +61,18 @@ function OperationVolumeInfoEditor(props) {
<p className="centerHorizontally">
{t('volume.effective_time_begin')}
</p>
<DateInput
data-test-id="map#editor#volume#info#effective_time_begin"
formatDate={date => date.toLocaleString()}
parseDate={str => new Date(str)}
placeholder="DD/MM/YYYY"
value={info.effective_time_begin}
timePrecision={TimePrecision.SECOND}
onChange={value => editInfo('effective_time_begin', value)}
/>
<div data-test-id="map#editor#volume#info#effective_time_begin">
<DateInput
canClearSelection={false}
minDate={new Date()}
formatDate={date => date.toLocaleString()}
parseDate={str => new Date(str)}
placeholder="DD/MM/YYYY"
value={info.effective_time_begin}
timePrecision={TimePrecision.SECOND}
onChange={value => editInfo('effective_time_begin', value)}
/>
</div>
</div>
{/*
effective_time_end* string($date-time)
Expand All @@ -84,15 +84,18 @@ function OperationVolumeInfoEditor(props) {
<p className="centerHorizontally">
{t('volume.effective_time_end')}
</p>
<DateInput
data-test-id="map#editor#volume#info#effective_time_end"
formatDate={date => date.toLocaleString()}
parseDate={str => new Date(str)}
placeholder="DD/MM/YYYY"
value={info.effective_time_end}
timePrecision={TimePrecision.SECOND}
onChange={value => editInfo('effective_time_end', value)}
/>
<div data-test-id="map#editor#volume#info#effective_time_end">
<DateInput
canClearSelection={false}
minDate={new Date()}
formatDate={date => date.toLocaleString()}
parseDate={str => new Date(str)}
placeholder="DD/MM/YYYY"
value={info.effective_time_end}
timePrecision={TimePrecision.SECOND}
onChange={value => editInfo('effective_time_end', value)}
/>
</div>
</div>
{/*
min_altitude* in meters. Good luck NASA!
Expand All @@ -101,7 +104,7 @@ function OperationVolumeInfoEditor(props) {
<FormGroup className="rightAreaButtonText" label={t('volume.min_altitude')} labelFor="min_altitude">
<InputGroup
id="min_altitude"
data-test-id="mapEditorVolumeInfoMinAltitude"
data-test-id="map#editor#volume#info#min_altitude"
value={info.min_altitude}
onChange={evt => editInfo('min_altitude', evt.target.value)}
/>
Expand Down
5 changes: 0 additions & 5 deletions src/map/hooks/useEditorLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ function UseEditorLogic(refMapOnClick, mapInitialized) {
}
}, [mapInitialized]); // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
console.log('Updated OperationInfo', S.maybeToNullable(operationInfo));
}, [operationInfo]);


const saveOperation = () => {
actions.map.onClicksDisabled(false);
refMapOnClick.current = () => {};
Expand Down
2 changes: 1 addition & 1 deletion src/state/AdesState.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function addVehicle(store, data) {
/* RFV */

function addRFV(store, data) {
const dataObtained = [(Array.from(data))[0]];
const dataObtained = Array.from(data);
const pairs = S.justs(dataObtained.map((rfv) => {
return S.Just(S.Pair(rfv.id)(convertCoordinatesRFV(rfv)));
}));
Expand Down

0 comments on commit 663f346

Please sign in to comment.