Skip to content

Commit 04ec3f8

Browse files
Merge pull request #294 from oss-slu/FRONTEND-REFACTOR
Frontend refactor. Solves #179 and advances #249
2 parents 17170f2 + 8bbabb7 commit 04ec3f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+372
-3944
lines changed

frontend/.dockerignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,11 @@ Thumbs.db
1717
.gitignore
1818

1919
# Secrets
20-
.env
20+
.env
21+
22+
# Dev files
23+
cypress/
24+
.eslintrc.json
25+
.prettierrc
26+
craco.config.js
27+
cypress.config.js

frontend/DroneWorld

Lines changed: 0 additions & 1 deletion
This file was deleted.

frontend/babel.config.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

frontend/cypress.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = defineConfig({
1717
env: {
1818
BACKEND_URL: backendUrl,
1919
},
20-
setupNodeEvents(on, config) {
20+
setupNodeEvents(on) {
2121
on('task', {
2222
verifyLocalMockReportFromTimestamp({ uiTimestamp }) {
2323
const match = (uiTimestamp || '').match(

frontend/cypress/e2e/app.cy.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
// Cypress Test for E2E Frontend Flow
22
describe('DroneWorld Application Flow', () => {
3+
it('should handle direct /dashboard access without route state', () => {
4+
cy.visit('/dashboard');
5+
cy.contains('No Report Selected').should('be.visible');
6+
cy.contains('button', 'Go to Reports').click();
7+
cy.url().should('include', '/reports');
8+
});
9+
310
it('should complete the full scenario configuration flow', () => {
411
const backendUrl = Cypress.env('BACKEND_URL');
512
const finalBackendUrl = backendUrl || 'http://localhost:5000';
@@ -20,6 +27,7 @@ describe('DroneWorld Application Flow', () => {
2027
cy.intercept('GET', `${finalBackendUrl}/list-reports`).as('listReports');
2128
cy.intercept('GET', `${finalBackendUrl}/currentRunning`).as('getBackendStatus');
2229
cy.intercept('POST', `${finalBackendUrl}/addTask`).as('addTask');
30+
cy.intercept('POST', `${finalBackendUrl}/list-folder-contents/*`).as('listFolderContents');
2331

2432
// Step 1: Visit the landing page
2533
cy.visit('/');
@@ -109,5 +117,25 @@ describe('DroneWorld Application Flow', () => {
109117
cy.contains('[role="tooltip"]', 'Download report (.zip)').should('be.visible');
110118
cy.get('@downloadButton').click();
111119
cy.get('@windowOpen').should('have.been.called');
120+
121+
// Step 11: Preview the newest batch report and verify dashboard navigation/rendering
122+
cy.get('@latestBatchTitle')
123+
.closest('.MuiCard-root')
124+
.within(() => {
125+
cy.contains('button', 'Preview').should('be.visible').click();
126+
});
127+
128+
cy.wait('@listFolderContents').then(({ response }) => {
129+
expect(response, 'list-folder-contents response').to.exist;
130+
expect(response.statusCode).to.eq(200);
131+
});
132+
133+
cy.url().should('include', '/dashboard');
134+
cy.contains(/Detailed Report/, { timeout: 10000 }).should('be.visible');
135+
cy.contains('Interactable HTMLs').should('be.visible');
136+
137+
// Step 12: Use dashboard Back action and verify return to reports
138+
cy.contains('Back').should('be.visible').click();
139+
cy.url().should('include', '/reports');
112140
});
113141
});

frontend/package.json

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,25 @@
44
"private": true,
55
"dependencies": {
66
"@craco/craco": "^7.1.0",
7-
"@date-io/date-fns": "2.16.0",
87
"@emotion/react": "^11.10.5",
98
"@emotion/styled": "^11.10.5",
10-
"@mdi/js": "^7.4.47",
11-
"@mdi/react": "^1.6.1",
129
"@mui/icons-material": "^5.11.0",
1310
"@mui/lab": "5.0.0-alpha.118",
1411
"@mui/material": "^5.11.5",
1512
"@mui/styles": "^5.11.2",
1613
"@mui/system": "5.15.20",
1714
"@mui/x-date-pickers": "5.0.17",
1815
"@react-google-maps/api": "2.18.1",
19-
"@testing-library/jest-dom": "^5.16.5",
20-
"@testing-library/react": "^12.1.5",
21-
"@testing-library/user-event": "^13.5.0",
22-
"axios": "^1.2.3",
2316
"cesium": "^1.126.0",
2417
"craco-cesium": "^1.2.0",
25-
"date-fns": "2.29.3",
2618
"dayjs": "^1.11.7",
27-
"html-webpack-plugin": "^5.6.0",
28-
"install": "^0.13.0",
19+
"html-webpack-plugin": "^5.6.6",
20+
"prop-types": "^15.8.1",
2921
"react": "^18.2.0",
3022
"react-dom": "^18.2.0",
31-
"react-redux": "^8.0.5",
3223
"react-router-dom": "^6.8.1",
3324
"react-scripts": "5.0.1",
34-
"redux": "^4.2.0",
35-
"resium": "^1.17.3",
36-
"web-vitals": "^2.1.4"
25+
"resium": "^1.17.3"
3726
},
3827
"scripts": {
3928
"start": "craco start",
@@ -74,13 +63,13 @@
7463
]
7564
},
7665
"devDependencies": {
66+
"@testing-library/jest-dom": "^5.16.5",
7767
"@testing-library/react": "^16.1.0",
78-
"babel-jest": "^29.7.0",
7968
"cypress": "^15.5.0",
69+
"dotenv": "^10.0.0",
8070
"eslint": "^8.32.0",
8171
"eslint-config-prettier": "^8.6.0",
8272
"eslint-plugin-react": "^7.32.1",
83-
"jest": "^27.5.1",
8473
"prettier": "2.8.3"
8574
}
8675
}

frontend/src/App.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Home from './pages/Home';
55
import Wizard from './pages/Wizard';
66
import FuzzyDashboard from './components/FuzzyDashboard';
77
import ReportDashboard from './components/ReportDashboard';
8-
import LandingPage from './LandingPage';
8+
import LandingPage from './pages/LandingPage';
99
import AboutUs from './pages/AboutUs';
1010
import Stream from './pages/Stream';
1111
import NavigationBar from './pages/NavigationBar';
@@ -24,8 +24,6 @@ function App() {
2424
<Route exact path='/simulation' element={<Wizard />} />
2525
<Route exact path='/dashboard' element={<FuzzyDashboard />} />
2626
<Route exact path='/reports' element={<ReportDashboard />} />
27-
{/* Backwards compatibility for old deep links */}
28-
<Route exact path='/report-dashboard' element={<ReportDashboard />} />
2927
<Route exact path='/' element={<LandingPage />} />
3028
<Route exact path='/aboutus' element={<AboutUs />} />
3129
<Route exact path='/stream' element={<Stream />} />

frontend/src/components/AboutUs.jsx

Lines changed: 0 additions & 16 deletions
This file was deleted.

frontend/src/components/Configuration/DroneConfiguration.jsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default function DroneConfiguration(droneData) {
4040
const { mainJson, setMainJson } = useMainJson();
4141
const { name = "", id = "", droneObject = {}, resetName = () => {}, droneJson = () => {} } = droneData || {};
4242

43-
const [selectedLoc, setSelectedLoc] = React.useState('GeoLocation');
43+
const [selectedLoc] = React.useState('GeoLocation');
4444
const [selectedModel, setSelectedModel] = React.useState('');
4545
const [selectedDroneType, setselectedDroneType] = React.useState(droneTypes[1].value);
4646
const [snackBarState, setSnackBarState] = React.useState({ open: false });
@@ -68,7 +68,6 @@ export default function DroneConfiguration(droneData) {
6868
param: []
6969
}
7070
};
71-
//return { ...defaults, ...(droneData?.getDroneBasedOnIndex?.(id) || {}), ...droneObject };
7271
const mergedDrone = { ...defaults, ...(droneData?.getDroneBasedOnIndex?.(id) || {}), ...droneObject };
7372
if (mergedDrone.MissionValue == null) {
7473
mergedDrone.MissionValue = mergedDrone.Mission?.name ?? defaults.Mission.name;
@@ -133,8 +132,6 @@ export default function DroneConfiguration(droneData) {
133132

134133

135134
const handleMissionChange = (event) => {
136-
//setDrone(prevState => ({
137-
// ...prevState,
138135
const missionName = event.target.value;
139136
setDrone(prevState => {
140137
const updatedDrone = {
@@ -157,8 +154,6 @@ export default function DroneConfiguration(droneData) {
157154
...currentDrone,
158155
MissionValue: missionName,
159156
Mission: {
160-
//...prevState.Mission,
161-
//name: event.target.value
162157
...(currentDrone.Mission || {}),
163158
name: missionName,
164159
param: Array.isArray(currentDrone?.Mission?.param) ? currentDrone.Mission.param : []
@@ -337,4 +332,4 @@ export default function DroneConfiguration(droneData) {
337332
</Box>
338333
</div>
339334
);
340-
}
335+
}

0 commit comments

Comments
 (0)