-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 404 page added * add 404 for subpages/subroutes * Add `exact` attribute to Fragmentarium Routes * refactoring routes * Add tests for fragmentarium 404 routes * add all tests for routes --------- Co-authored-by: Ilya Khait <[email protected]>
- Loading branch information
1 parent
12c96bb
commit 7d0e2b3
Showing
11 changed files
with
279 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react' | ||
|
||
const NotFoundPage: React.FC = () => ( | ||
<div style={{ textAlign: 'center', marginTop: '50px' }}> | ||
<h1>404 - Not Found</h1> | ||
<p>The page you are looking for does not exist.</p> | ||
</div> | ||
) | ||
|
||
export default NotFoundPage |
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
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,177 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
import { Router, Switch } from 'react-router-dom' | ||
import { getServices } from 'test-support/AppDriver' | ||
import { createMemoryHistory } from 'history' | ||
import AboutRoutes from './aboutRoutes' | ||
import FragmentariumRoutes from './fragmentariumRoutes' | ||
import BibliographyRoutes from './bibliographyRoutes' | ||
import CorpusRoutes from './corpusRoutes' | ||
import DictionaryRoutes from './dictionaryRoutes' | ||
import SignRoutes from './signRoutes' | ||
import ToolsRoutes from './toolsRoutes' | ||
|
||
describe('NotFoundPage rendering in FragmentariumRoutes', () => { | ||
const nonExistentRoutes = [ | ||
'/fragmentarium/search/non-existent', | ||
'/fragmentarium/Fragment.12345/match/non-existent', | ||
'/fragmentarium/Fragment.12345/annotate/non-existent', | ||
'/fragmentarium/Fragment.12345/non-existent', | ||
] | ||
nonExistentRoutes.forEach((path) => { | ||
const history = createMemoryHistory({ initialEntries: [path] }) | ||
test(`renders NotFoundPage for "${path}"`, () => { | ||
render( | ||
<Router history={history}> | ||
<Switch> | ||
{[...FragmentariumRoutes({ ...getServices(), sitemap: false })]} | ||
</Switch> | ||
</Router> | ||
) | ||
expect( | ||
screen.getByText(/The page you are looking for does not exist./i) | ||
).toBeInTheDocument() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('NotFoundPage rendering in AboutRoutes', () => { | ||
const nonExistentAboutRoutes = [ | ||
'/about/non-existent-page', | ||
'/about/invalid-section', | ||
'/about/undefined-route', | ||
] | ||
nonExistentAboutRoutes.forEach((path) => { | ||
const history = createMemoryHistory({ initialEntries: [path] }) | ||
test(`renders NotFoundPage for "${path}"`, () => { | ||
render( | ||
<Router history={history}> | ||
<Switch> | ||
{[...AboutRoutes({ ...getServices(), sitemap: false })]} | ||
</Switch> | ||
</Router> | ||
) | ||
expect( | ||
screen.getByText(/The page you are looking for does not exist./i) | ||
).toBeInTheDocument() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('NotFoundPage rendering in BibliographyRoutes', () => { | ||
const nonExistentAboutRoutes = [ | ||
'/bibliography/search/non-existent', | ||
'/bibliography/afo-register/non-existent-page', | ||
'/bibliography/afo-register/invalid-section', | ||
'/bibliography/afo-register/undefined-route', | ||
] | ||
nonExistentAboutRoutes.forEach((path) => { | ||
const history = createMemoryHistory({ initialEntries: [path] }) | ||
test(`renders NotFoundPage for "${path}"`, () => { | ||
render( | ||
<Router history={history}> | ||
<Switch> | ||
{[...BibliographyRoutes({ ...getServices(), sitemap: false })]} | ||
</Switch> | ||
</Router> | ||
) | ||
expect( | ||
screen.getByText(/The page you are looking for does not exist./i) | ||
).toBeInTheDocument() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('NotFoundPage rendering in CorpusRoutes', () => { | ||
const nonExistentAboutRoutes = [ | ||
'/corpus/Corpus.12345/non-existent-page', | ||
'/corpus/Corpus.12345/invalid-section', | ||
'/corpus/Corpus.12345/undefined-route', | ||
] | ||
nonExistentAboutRoutes.forEach((path) => { | ||
const history = createMemoryHistory({ initialEntries: [path] }) | ||
test(`renders NotFoundPage for "${path}"`, () => { | ||
render( | ||
<Router history={history}> | ||
<Switch> | ||
{[...CorpusRoutes({ ...getServices(), sitemap: false })]} | ||
</Switch> | ||
</Router> | ||
) | ||
expect( | ||
screen.getByText(/The page you are looking for does not exist./i) | ||
).toBeInTheDocument() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('NotFoundPage rendering in DictionaryRoutes', () => { | ||
const nonExistentAboutRoutes = [ | ||
'/dictionary/search/non-existent', | ||
'/dictionary/Dictionary.12345/non-existent-page', | ||
'/dictionary/Dictionary.12345/invalid-section', | ||
'/dictionary/Dictionary.12345/undefined-route', | ||
] | ||
nonExistentAboutRoutes.forEach((path) => { | ||
const history = createMemoryHistory({ initialEntries: [path] }) | ||
test(`renders NotFoundPage for "${path}"`, () => { | ||
render( | ||
<Router history={history}> | ||
<Switch> | ||
{[...DictionaryRoutes({ ...getServices(), sitemap: false })]} | ||
</Switch> | ||
</Router> | ||
) | ||
expect( | ||
screen.getByText(/The page you are looking for does not exist./i) | ||
).toBeInTheDocument() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('NotFoundPage rendering in SignRoutes', () => { | ||
const nonExistentAboutRoutes = [ | ||
'/signs/search/non-existent', | ||
'/signs/Signs.12345/non-existent-page', | ||
'/signs/Signs.12345/invalid-section', | ||
'/signs/Signs.12345/undefined-route', | ||
] | ||
nonExistentAboutRoutes.forEach((path) => { | ||
const history = createMemoryHistory({ initialEntries: [path] }) | ||
test(`renders NotFoundPage for "${path}"`, () => { | ||
render( | ||
<Router history={history}> | ||
<Switch> | ||
{[...SignRoutes({ ...getServices(), sitemap: false })]} | ||
</Switch> | ||
</Router> | ||
) | ||
expect( | ||
screen.getByText(/The page you are looking for does not exist./i) | ||
).toBeInTheDocument() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('NotFoundPage rendering in ToolsRoutes', () => { | ||
const nonExistentAboutRoutes = [ | ||
'/tools/date-converter/non-existent-page', | ||
'/tools/date-converter/invalid-section', | ||
'/tools/date-converter/undefined-route', | ||
] | ||
nonExistentAboutRoutes.forEach((path) => { | ||
const history = createMemoryHistory({ initialEntries: [path] }) | ||
test(`renders NotFoundPage for "${path}"`, () => { | ||
render( | ||
<Router history={history}> | ||
<Switch> | ||
{[...ToolsRoutes({ ...getServices(), sitemap: false })]} | ||
</Switch> | ||
</Router> | ||
) | ||
expect( | ||
screen.getByText(/The page you are looking for does not exist./i) | ||
).toBeInTheDocument() | ||
}) | ||
}) | ||
}) |
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
Oops, something went wrong.