-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Upgrade to use react router 7 - remove password from the mock data - add pageNotFound
- Loading branch information
1 parent
cbcf0a2
commit ebe97d0
Showing
9 changed files
with
217 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/pageNotFound/__snapshots__/pageNotFound.component.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Page Not Found Component > renders the basic 404 page 1`] = ` | ||
<body> | ||
<div> | ||
<div> | ||
<div | ||
class="MuiBox-root css-d8r78j" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-1wffj3i-MuiSvgIcon-root" | ||
data-testid="BugReportIcon" | ||
focusable="false" | ||
viewBox="0 0 24 24" | ||
> | ||
<path | ||
d="M20 8h-2.81c-.45-.78-1.07-1.45-1.82-1.96L17 4.41 15.59 3l-2.17 2.17C12.96 5.06 12.49 5 12 5c-.49 0-.96.06-1.41.17L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20zm-6 8h-4v-2h4zm0-4h-4v-2h4z" | ||
/> | ||
</svg> | ||
<p | ||
class="MuiTypography-root MuiTypography-body1 css-1fjbu-MuiTypography-root" | ||
> | ||
404 | ||
</p> | ||
</div> | ||
<div | ||
class="MuiBox-root css-sg7ujc" | ||
> | ||
<h2 | ||
class="MuiTypography-root MuiTypography-h2 css-18ft2kn-MuiTypography-root" | ||
> | ||
Page not found | ||
</h2> | ||
<p | ||
class="MuiTypography-root MuiTypography-body1 css-n3u125-MuiTypography-root" | ||
> | ||
We're sorry, the page you requested was not found on the server. If you entered the URL manually please check your spelling and try again. Otherwise, return to the | ||
<a | ||
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways css-17fxp5y-MuiTypography-root-MuiLink-root" | ||
data-discover="true" | ||
href="/" | ||
> | ||
home page | ||
</a> | ||
. | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { act } from 'react'; | ||
import { createBrowserRouter, RouterProvider } from 'react-router'; | ||
import { renderComponentWithProviders } from '../testUtils'; | ||
import PageNotFoundComponent from './pageNotFound.component'; | ||
|
||
describe('Page Not Found Component', () => { | ||
const createView = () => { | ||
const router = createBrowserRouter([ | ||
{ path: '*', Component: PageNotFoundComponent }, | ||
]); | ||
return renderComponentWithProviders(<RouterProvider router={router} />); | ||
}; | ||
|
||
it('renders the basic 404 page', async () => { | ||
let baseElement; | ||
await act(async () => { | ||
baseElement = createView().baseElement; | ||
}); | ||
expect(baseElement).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import BugReportIcon from '@mui/icons-material/BugReport'; | ||
import { Box, Link as MuiLink, Theme } from '@mui/material'; | ||
import Typography from '@mui/material/Typography'; | ||
import { Link } from 'react-router'; | ||
|
||
const PageNotFoundComponent = () => { | ||
return ( | ||
<div> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
backgroundColor: 'background.default', | ||
}} | ||
> | ||
<BugReportIcon | ||
sx={{ | ||
width: '10vw', | ||
height: '10vw', | ||
color: (theme: Theme) => theme.colours?.blue, | ||
}} | ||
/> | ||
<Typography | ||
sx={{ | ||
fontWeight: 'bold', | ||
fontSize: '10vw', | ||
color: (theme: Theme) => theme.colours?.blue, | ||
}} | ||
> | ||
404 | ||
</Typography> | ||
</Box> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
backgroundColor: 'background.default', | ||
}} | ||
> | ||
<Typography variant="h2" sx={{ color: 'text.primary' }}> | ||
Page not found | ||
</Typography> | ||
<Typography | ||
variant="body1" | ||
sx={{ | ||
padding: '15px', | ||
maxWidth: '600px', | ||
textAlign: 'center', | ||
color: 'text.secondary', | ||
}} | ||
> | ||
We're sorry, the page you requested was not found on the server. | ||
If you entered the URL manually please check your spelling and try | ||
again. Otherwise, return to the{' '} | ||
<MuiLink | ||
component={Link} | ||
sx={{ color: (theme: Theme) => theme.palette.text.primary }} | ||
to="/" | ||
> | ||
home page | ||
</MuiLink>{' '} | ||
. | ||
</Typography> | ||
</Box> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PageNotFoundComponent; |
Oops, something went wrong.