From 4537ffa3ae9a9f216390ccdea42a10d0e4d48e8c Mon Sep 17 00:00:00 2001 From: Bestin B Thomas Date: Tue, 30 Mar 2021 20:53:46 +0530 Subject: [PATCH 1/3] fix(deployment): fix server deployment bugs --- Dockerfile | 2 +- __tests__/app/containers/SideBar.test.tsx | 2 + .../__snapshots__/SideBar.test.tsx.snap | 287 +++++++++++------- package.json | 1 + server/app.js | 2 +- src/app/components/Dashboard.tsx | 2 - src/app/components/Leaderboard/index.tsx | 2 - src/app/components/SideBar.tsx | 19 +- src/app/components/SocketHandlerWrapper.tsx | 8 + src/app/containers/SocketHandlerWrapper.ts | 13 + src/app/index.tsx | 26 +- 11 files changed, 221 insertions(+), 143 deletions(-) create mode 100644 src/app/components/SocketHandlerWrapper.tsx create mode 100644 src/app/containers/SocketHandlerWrapper.ts diff --git a/Dockerfile b/Dockerfile index c401382b..aa5e788d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ COPY src/config/config.example.ts src/config/config.ts COPY . . -RUN npm run build +RUN mkdir -p build && npm run build WORKDIR /usr/src/app/server diff --git a/__tests__/app/containers/SideBar.test.tsx b/__tests__/app/containers/SideBar.test.tsx index 94e1c099..481b14ad 100644 --- a/__tests__/app/containers/SideBar.test.tsx +++ b/__tests__/app/containers/SideBar.test.tsx @@ -5,6 +5,7 @@ import { SidePanelTab } from 'app/reducers/Dashboard'; import { configureStore } from 'app/store'; import { mount } from 'enzyme'; import * as React from 'react'; +import { BrowserRouter } from 'react-router-dom'; describe('SideBar Container', () => { const { store } = configureStore(); @@ -17,6 +18,7 @@ describe('SideBar Container', () => { context: { store, }, + wrappingComponent: BrowserRouter, }, ); diff --git a/__tests__/app/containers/__snapshots__/SideBar.test.tsx.snap b/__tests__/app/containers/__snapshots__/SideBar.test.tsx.snap index 1924aa9b..692801f7 100644 --- a/__tests__/app/containers/__snapshots__/SideBar.test.tsx.snap +++ b/__tests__/app/containers/__snapshots__/SideBar.test.tsx.snap @@ -491,10 +491,9 @@ exports[`SideBar Container Should render 1`] = ` placement="right" title="Leaderboard" > - - - - - + + + + + + @@ -765,15 +796,9 @@ exports[`SideBar Container Should render 1`] = ` placement="right" title="Login" > - + + @@ -930,10 +954,9 @@ exports[`SideBar Container Should render 1`] = ` placement="right" title="Home" > - - - - - + + + + + + { }); app.listen(5000); -console.log('Server is listening on http://localhost:5000'); \ No newline at end of file +console.log('Server is listening on http://localhost:5000'); diff --git a/src/app/components/Dashboard.tsx b/src/app/components/Dashboard.tsx index d12e4074..ef70bb8e 100644 --- a/src/app/components/Dashboard.tsx +++ b/src/app/components/Dashboard.tsx @@ -6,7 +6,6 @@ import GameLog from 'app/containers/GameLog'; import Renderer from 'app/containers/Renderer'; import SideBar from 'app/containers/SideBar'; import SidePanel from 'app/containers/SidePanel'; -import SocketHandler from 'app/containers/SocketHandler'; import SubmitBar from 'app/containers/SubmitBar'; import { Routes } from 'app/routes'; import * as style from 'app/styles/Dashboard.css'; @@ -118,7 +117,6 @@ export class Dashboard extends React.Component< {isLoggedIn && isReactTourActive && !isWelcomeModalOpen ? ( ) : null} - {isLoggedIn ? : null} - {isLoggedIn ? : null} { public render() { @@ -84,8 +85,8 @@ export class Sidebar extends React.Component { - { onClick={() => clearAllLogs()} > - + {isLoggedIn ? ( @@ -145,8 +146,8 @@ export class Sidebar extends React.Component { - + {isLoggedIn ? ( @@ -175,17 +176,17 @@ export class Sidebar extends React.Component { ) : null} - clearAllLogs()} > - + - -
- - -
- { - this.setState({ - currentUserType: LeaderboardInterfaces.UserType.STUDENT, - }); - }} - className={ - this.state.currentUserType === LeaderboardInterfaces.UserType.STUDENT - ? classnames(styles.dropDownMenuActive, styles.dropDownMenuActive) - : classnames(styles.dropDownMenu) - } - > - {LeaderboardInterfaces.UserTypeName.STUDENT} - - { - this.setState({ - currentUserType: LeaderboardInterfaces.UserType.PROFESSIONAL, - }); - }} - className={ - this.state.currentUserType === LeaderboardInterfaces.UserType.PROFESSIONAL - ? classnames(styles.dropDownMenuActive, styles.dropDownMenuActive) - : classnames(styles.dropDownMenu) - } - > - {LeaderboardInterfaces.UserTypeName.PROFESSIONAL} - - { - this.setState({ currentUserType: LeaderboardInterfaces.UserType.ALL }); - }} - className={ - this.state.currentUserType === LeaderboardInterfaces.UserType.ALL - ? classnames(styles.dropDownMenuActive, styles.dropDownMenuActive) - : classnames(styles.dropDownMenu) - } - > - {LeaderboardInterfaces.UserTypeName.All} - -
-
-