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 1
1
import React from "react" ;
2
- import { BrowserRouter as Router , Routes , Route } from "react-router-dom" ;
2
+ import { Routes , Route } from "react-router-dom" ;
3
3
import { Provider } from "react-redux" ;
4
4
import { GlobalStore } from "src/redux-state/index" ;
5
5
@@ -13,12 +13,10 @@ const App: React.FC = () => {
13
13
< div className = "App" >
14
14
< GlobalStyle />
15
15
< Provider store = { GlobalStore } >
16
- < Router >
17
16
< Routes >
18
17
< Route path = "/" element = { < Dashboard /> } />
19
18
< Route path = "/editor/:id" element = { < Editor /> } />
20
19
</ Routes >
21
- </ Router >
22
20
</ Provider >
23
21
</ div >
24
22
) ;
Original file line number Diff line number Diff line change @@ -3,20 +3,24 @@ import { Provider } from 'react-redux';
3
3
import { GlobalStore } from 'src/redux-state/index' ;
4
4
import { render , queries , RenderOptions } from '@testing-library/react'
5
5
import * as customQueries from './custom-queries'
6
+ import { BrowserRouter } from 'react-router-dom' ;
6
7
7
8
// with redux
8
9
const AllTheProviders : React . FC = ( { children } ) => {
9
10
return (
10
- < Provider store = { GlobalStore } >
11
- { children }
12
- </ Provider >
11
+ < BrowserRouter >
12
+ < Provider store = { GlobalStore } >
13
+ { children }
14
+ </ Provider >
15
+ </ BrowserRouter >
13
16
)
14
17
}
15
18
16
19
const customRender = (
17
20
ui : React . ReactElement ,
18
21
options ?: Omit < RenderOptions , 'queries' > ,
19
- ) => render ( ui , {
22
+ ) => render (
23
+ ui , {
20
24
queries : { ...queries , ...customQueries } ,
21
25
wrapper : AllTheProviders ,
22
26
...options
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import styled from 'styled-components' ;
3
3
import 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
+
4
8
5
9
const Container = styled . div `
6
10
height: 65px;
@@ -16,7 +20,7 @@ const HeaderFlex = styled.div`
16
20
display: flex;
17
21
flex-direction: row;
18
22
flex-wrap: nowrap;
19
- justify-content: flex-end ;
23
+ justify-content: space-between ;
20
24
align-items: center;
21
25
padding: 0.3rem 0.5rem;
22
26
`
@@ -37,13 +41,30 @@ const ButtonStyle = styled(Button)`
37
41
min-width: 2px;
38
42
}
39
43
`
44
+
45
+ const ButtonContainer = styled . div `
46
+ display: flex;
47
+ justify-content: flex-end;
48
+ flex-direction: row;
49
+ align-items: center;
50
+ `
51
+
40
52
/* Preview and text to be changed into a dropdown menu */
41
53
42
54
const EditorHeader : React . FC = ( props ) => {
55
+
56
+ const navigate = useNavigate ( ) ;
57
+
43
58
return (
44
59
< Container >
45
60
< 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 >
47
68
{ /* <ButtonGroup>
48
69
<ButtonStyle>
49
70
←
Original file line number Diff line number Diff line change @@ -2,11 +2,15 @@ import React from 'react';
2
2
import ReactDOM from 'react-dom' ;
3
3
import App from './App' ;
4
4
import reportWebVitals from './reportWebVitals' ;
5
+ import { BrowserRouter } from 'react-router-dom' ;
5
6
6
7
ReactDOM . render (
7
8
< React . StrictMode >
8
- < App />
9
+ < BrowserRouter >
10
+ < App />
11
+ </ BrowserRouter >
9
12
</ React . StrictMode > ,
13
+
10
14
document . getElementById ( 'root' )
11
15
) ;
12
16
Original file line number Diff line number Diff line change 1
1
import { render } from "src/cse-testing-lib" ;
2
2
import { queryByDataAnchor } from "src/cse-testing-lib/custom-queries" ;
3
3
import SideBar from "./SideBar" ;
4
- import { BrowserRouter as Router } from "react-router-dom" ;
5
4
import React from "react" ;
6
5
7
6
describe ( "Side bar tests" , ( ) => {
@@ -11,14 +10,12 @@ describe("Side bar tests", () => {
11
10
const mockSetModalState = jest . fn ( ) ;
12
11
const mockSelectedFileID = "5" ;
13
12
const { queryByDataAnchor } = render (
14
- < Router >
15
13
< SideBar
16
14
setModalState = { mockSetModalState }
17
15
selectedFile = { mockSelectedFileID }
18
16
isOpen = { true }
19
17
setOpen = { mockSetOpen }
20
18
/>
21
- </ Router >
22
19
) ;
23
20
24
21
expect ( queryByDataAnchor ( "NewPageButton" ) ) . toBeTruthy ( ) ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import EditorPage from "./index";
5
5
6
6
describe ( "Editor Block tests" , ( ) => {
7
7
it ( "On CreateContentBlockButton click should create content block" , ( ) => {
8
+
8
9
const { queryByDataAnchor, queryAllByDataAnchor } = render ( < EditorPage /> ) ;
9
10
const CreateContentBlockButton = queryByDataAnchor ( "CreateContentBlockButton" ) ;
10
11
You can’t perform that action at this time.
0 commit comments