File tree Expand file tree Collapse file tree 6 files changed +38
-13
lines changed
deprecated/components/Editor Expand file tree Collapse file tree 6 files changed +38
-13
lines changed Original file line number Diff line number Diff line change 11import React from "react" ;
2- import { BrowserRouter as Router , Routes , Route } from "react-router-dom" ;
2+ import { Routes , Route } from "react-router-dom" ;
33import { Provider } from "react-redux" ;
44import { GlobalStore } from "src/redux-state/index" ;
55
@@ -13,12 +13,10 @@ const App: React.FC = () => {
1313 < div className = "App" >
1414 < GlobalStyle />
1515 < Provider store = { GlobalStore } >
16- < Router >
1716 < Routes >
1817 < Route path = "/" element = { < Dashboard /> } />
1918 < Route path = "/editor/:id" element = { < Editor /> } />
2019 </ Routes >
21- </ Router >
2220 </ Provider >
2321 </ div >
2422 ) ;
Original file line number Diff line number Diff line change @@ -3,20 +3,24 @@ import { Provider } from 'react-redux';
33import { GlobalStore } from 'src/redux-state/index' ;
44import { render , queries , RenderOptions } from '@testing-library/react'
55import * as customQueries from './custom-queries'
6+ import { BrowserRouter } from 'react-router-dom' ;
67
78// with redux
89const AllTheProviders : React . FC = ( { children } ) => {
910 return (
10- < Provider store = { GlobalStore } >
11- { children }
12- </ Provider >
11+ < BrowserRouter >
12+ < Provider store = { GlobalStore } >
13+ { children }
14+ </ Provider >
15+ </ BrowserRouter >
1316 )
1417}
1518
1619const customRender = (
1720 ui : React . ReactElement ,
1821 options ?: Omit < RenderOptions , 'queries' > ,
19- ) => render ( ui , {
22+ ) => render (
23+ ui , {
2024 queries : { ...queries , ...customQueries } ,
2125 wrapper : AllTheProviders ,
2226 ...options
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import styled from 'styled-components' ;
33import Button from '@mui/material/Button' ;
4+ import IconButton from "@mui/material/IconButton" ;
5+ import ArrowBackIcon from "@mui/icons-material/ArrowBack" ;
6+ import { useNavigate } from 'react-router-dom' ;
7+
48
59const Container = styled . div `
610 height: 65px;
@@ -16,7 +20,7 @@ const HeaderFlex = styled.div`
1620display: flex;
1721flex-direction: row;
1822flex-wrap: nowrap;
19- justify-content: flex-end ;
23+ justify-content: space-between ;
2024align-items: center;
2125padding: 0.3rem 0.5rem;
2226`
@@ -37,13 +41,30 @@ const ButtonStyle = styled(Button)`
3741 min-width: 2px;
3842}
3943`
44+
45+ const ButtonContainer = styled . div `
46+ display: flex;
47+ justify-content: flex-end;
48+ flex-direction: row;
49+ align-items: center;
50+ `
51+
4052/* Preview and text to be changed into a dropdown menu */
4153
4254const EditorHeader : React . FC = ( props ) => {
55+
56+ const navigate = useNavigate ( ) ;
57+
4358 return (
4459 < Container >
4560 < HeaderFlex >
46- { props . children }
61+
62+ < IconButton aria-label = "back" onClick = { ( ) => navigate ( - 1 ) } >
63+ < ArrowBackIcon fontSize = "inherit" />
64+ </ IconButton >
65+ < ButtonContainer >
66+ { props . children }
67+ </ ButtonContainer >
4768 { /* <ButtonGroup>
4869 <ButtonStyle>
4970 ←
Original file line number Diff line number Diff line change @@ -2,11 +2,15 @@ import React from 'react';
22import ReactDOM from 'react-dom' ;
33import App from './App' ;
44import reportWebVitals from './reportWebVitals' ;
5+ import { BrowserRouter } from 'react-router-dom' ;
56
67ReactDOM . render (
78 < React . StrictMode >
8- < App />
9+ < BrowserRouter >
10+ < App />
11+ </ BrowserRouter >
912 </ React . StrictMode > ,
13+
1014 document . getElementById ( 'root' )
1115) ;
1216
Original file line number Diff line number Diff line change 11import { render } from "src/cse-testing-lib" ;
22import { queryByDataAnchor } from "src/cse-testing-lib/custom-queries" ;
33import SideBar from "./SideBar" ;
4- import { BrowserRouter as Router } from "react-router-dom" ;
54import React from "react" ;
65
76describe ( "Side bar tests" , ( ) => {
@@ -11,14 +10,12 @@ describe("Side bar tests", () => {
1110 const mockSetModalState = jest . fn ( ) ;
1211 const mockSelectedFileID = "5" ;
1312 const { queryByDataAnchor } = render (
14- < Router >
1513 < SideBar
1614 setModalState = { mockSetModalState }
1715 selectedFile = { mockSelectedFileID }
1816 isOpen = { true }
1917 setOpen = { mockSetOpen }
2018 />
21- </ Router >
2219 ) ;
2320
2421 expect ( queryByDataAnchor ( "NewPageButton" ) ) . toBeTruthy ( ) ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import EditorPage from "./index";
55
66describe ( "Editor Block tests" , ( ) => {
77 it ( "On CreateContentBlockButton click should create content block" , ( ) => {
8+
89 const { queryByDataAnchor, queryAllByDataAnchor } = render ( < EditorPage /> ) ;
910 const CreateContentBlockButton = queryByDataAnchor ( "CreateContentBlockButton" ) ;
1011
You can’t perform that action at this time.
0 commit comments