From 1e8725f0fb163fef3fa4dd7c515b1815f8dc383e Mon Sep 17 00:00:00 2001 From: Kartik Paliwal Date: Mon, 5 Feb 2024 13:29:17 +0000 Subject: [PATCH 1/7] 404 page added --- src/NotFoundPage.tsx | 10 ++++++++++ src/router/router.tsx | 2 ++ 2 files changed, 12 insertions(+) create mode 100644 src/NotFoundPage.tsx diff --git a/src/NotFoundPage.tsx b/src/NotFoundPage.tsx new file mode 100644 index 000000000..be2754c69 --- /dev/null +++ b/src/NotFoundPage.tsx @@ -0,0 +1,10 @@ +import React from 'react' + +const NotFoundPage: React.FC = () => ( +
+

404 - Not Found

+

The page you are looking for does not exist.

+
+) + +export default NotFoundPage diff --git a/src/router/router.tsx b/src/router/router.tsx index 2577bcb17..cbcb5b1fe 100644 --- a/src/router/router.tsx +++ b/src/router/router.tsx @@ -24,6 +24,7 @@ import ToolsRoutes from 'router/toolsRoutes' import Sitemap, { sitemapDefaults, Slugs } from 'router/sitemap' import Header from 'Header' +import NotFoundPage from 'NotFoundPage' import { helmetContext } from 'router/head' import { HelmetProvider } from 'react-helmet-async' import { FindspotService } from 'fragmentarium/application/FindspotService' @@ -51,6 +52,7 @@ export default function Router(services: Services): JSX.Element { {WebsiteRoutes(services, false)} + ) From e46f13a25c7308219d92d849314d6c6b21faa0a7 Mon Sep 17 00:00:00 2001 From: Kartik Paliwal Date: Sun, 25 Feb 2024 12:06:41 +0000 Subject: [PATCH 2/7] add 404 for subpages/subroutes --- src/router/aboutRoutes.tsx | 6 ++++++ src/router/bibliographyRoutes.tsx | 6 ++++++ src/router/corpusRoutes.tsx | 7 ++++++- src/router/fragmentariumRoutes.tsx | 7 ++++++- src/router/toolsRoutes.tsx | 6 ++++++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/router/aboutRoutes.tsx b/src/router/aboutRoutes.tsx index 9eed869b7..731dfa066 100644 --- a/src/router/aboutRoutes.tsx +++ b/src/router/aboutRoutes.tsx @@ -4,6 +4,7 @@ import About, { TabId, tabIds } from 'about/ui/about' import { CachedMarkupService } from 'markup/application/MarkupService' import { sitemapDefaults } from 'router/sitemap' import { HeadTagsService } from 'router/head' +import NotFoundPage from 'NotFoundPage' // ToDo: // - Test change of url on click at about @@ -34,6 +35,11 @@ export default function AboutRoutes({ )} {...(sitemap && sitemapDefaults)} />, + } + />, , + } + />, , + } + />, ] } diff --git a/src/router/fragmentariumRoutes.tsx b/src/router/fragmentariumRoutes.tsx index 5ee436e67..2915c52b7 100644 --- a/src/router/fragmentariumRoutes.tsx +++ b/src/router/fragmentariumRoutes.tsx @@ -22,7 +22,7 @@ import { HeadTagsService } from 'router/head' import BibliographyService from 'bibliography/application/BibliographyService' import { FindspotService } from 'fragmentarium/application/FindspotService' import AfoRegisterService from 'afo-register/application/AfoRegisterService' - +import NotFoundPage from 'NotFoundPage' function parseStringParam(location: Location, param: string): string | null { const value = parse(location.search)[param] return _.isArray(value) ? value.join('') : value @@ -176,5 +176,10 @@ export default function FragmentariumRoutes({ )} {...(sitemap && sitemapDefaults)} />, + } + />, ] } diff --git a/src/router/toolsRoutes.tsx b/src/router/toolsRoutes.tsx index 77798f5e4..d461eaf0d 100644 --- a/src/router/toolsRoutes.tsx +++ b/src/router/toolsRoutes.tsx @@ -17,6 +17,7 @@ import DateConverterForm, { import AboutListOfKings from 'chronology/ui/BrinkmanKingsTable' import _ from 'lodash' import 'about/ui/about.sass' +import NotFoundPage from 'NotFoundPage' const tabIds = ['date-converter', 'list-of-kings'] as const type TabId = typeof tabIds[number] @@ -86,6 +87,11 @@ export default function ToolsRoutes({ )} {...(sitemap && sitemapDefaults)} />, + } + />, Date: Tue, 27 Feb 2024 11:16:16 +0000 Subject: [PATCH 3/7] Add `exact` attribute to Fragmentarium Routes --- src/router/fragmentariumRoutes.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/router/fragmentariumRoutes.tsx b/src/router/fragmentariumRoutes.tsx index 2915c52b7..9d65f8d97 100644 --- a/src/router/fragmentariumRoutes.tsx +++ b/src/router/fragmentariumRoutes.tsx @@ -78,6 +78,7 @@ export default function FragmentariumRoutes({ ( ( ( ( {(session) => ( @@ -157,6 +161,7 @@ export default function FragmentariumRoutes({ ( , } />, From cefe006647c1693f179d6b54ce91307420ef3d3f Mon Sep 17 00:00:00 2001 From: Kartik Paliwal Date: Wed, 28 Feb 2024 17:05:44 +0000 Subject: [PATCH 4/7] refactoring routes --- src/router/bibliographyRoutes.tsx | 6 +++++- src/router/corpusRoutes.tsx | 2 +- src/router/dictionaryRoutes.tsx | 9 +++++++++ src/router/signRoutes.tsx | 8 ++++++++ src/router/toolsRoutes.tsx | 3 ++- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/router/bibliographyRoutes.tsx b/src/router/bibliographyRoutes.tsx index ec96b6fb8..f1213e1e1 100644 --- a/src/router/bibliographyRoutes.tsx +++ b/src/router/bibliographyRoutes.tsx @@ -26,6 +26,7 @@ export default function BibliographyRoutes({ ( ( ( ( , } />, diff --git a/src/router/corpusRoutes.tsx b/src/router/corpusRoutes.tsx index 742d0696e..33bf91df4 100644 --- a/src/router/corpusRoutes.tsx +++ b/src/router/corpusRoutes.tsx @@ -150,7 +150,7 @@ export default function CorpusRoutes({ })} />, } />, diff --git a/src/router/dictionaryRoutes.tsx b/src/router/dictionaryRoutes.tsx index b4995d33e..71ab629a2 100644 --- a/src/router/dictionaryRoutes.tsx +++ b/src/router/dictionaryRoutes.tsx @@ -9,6 +9,7 @@ import { Route } from 'react-router-dom' import SignService from 'signs/application/SignService' import { DictionarySlugs, sitemapDefaults } from 'router/sitemap' import { HeadTagsService } from 'router/head' +import NotFoundPage from 'NotFoundPage' export default function DictionaryRoutes({ sitemap, @@ -29,6 +30,7 @@ export default function DictionaryRoutes({ ( ( ( , + } + />, ] } diff --git a/src/router/signRoutes.tsx b/src/router/signRoutes.tsx index 99f2125f1..8ef01723d 100644 --- a/src/router/signRoutes.tsx +++ b/src/router/signRoutes.tsx @@ -6,6 +6,7 @@ import SignDisplay from 'signs/ui/display/SignDisplay' import Signs from 'signs/ui/search/Signs' import { SignSlugs, sitemapDefaults } from 'router/sitemap' import { HeadTagsService } from 'router/head' +import NotFoundPage from 'NotFoundPage' export default function SignRoutes({ sitemap, @@ -22,6 +23,7 @@ export default function SignRoutes({ ( ( , + } + />, ] } diff --git a/src/router/toolsRoutes.tsx b/src/router/toolsRoutes.tsx index bdd052c60..cb536e412 100644 --- a/src/router/toolsRoutes.tsx +++ b/src/router/toolsRoutes.tsx @@ -72,8 +72,8 @@ export default function ToolsRoutes({ return [ ): ReactNode => ( } />, Date: Wed, 28 Feb 2024 19:07:10 +0000 Subject: [PATCH 5/7] Add tests for fragmentarium 404 routes --- src/router/notFoundRoutes.test.tsx | 30 +++++++++++++++++++ src/test-support/AppDriver.tsx | 48 ++++++++++++++++++++---------- 2 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 src/router/notFoundRoutes.test.tsx diff --git a/src/router/notFoundRoutes.test.tsx b/src/router/notFoundRoutes.test.tsx new file mode 100644 index 000000000..4819c6d6c --- /dev/null +++ b/src/router/notFoundRoutes.test.tsx @@ -0,0 +1,30 @@ +import React from 'react' +import { render, screen } from '@testing-library/react' +import { Router, Switch } from 'react-router-dom' +import FragmentariumRoutes from './fragmentariumRoutes' +import { getServices } from 'test-support/AppDriver' +import { createMemoryHistory } from 'history' + +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( + + + {[...FragmentariumRoutes({ ...getServices(), sitemap: false })]} + + + ) + expect( + screen.getByText(/The page you are looking for does not exist./i) + ).toBeInTheDocument() + }) + }) +}) diff --git a/src/test-support/AppDriver.tsx b/src/test-support/AppDriver.tsx index 30d04625a..dc04e688c 100644 --- a/src/test-support/AppDriver.tsx +++ b/src/test-support/AppDriver.tsx @@ -34,8 +34,22 @@ import AfoRegisterRepository from 'afo-register/infrastructure/AfoRegisterReposi import AfoRegisterService from 'afo-register/application/AfoRegisterService' import { FindspotService } from 'fragmentarium/application/FindspotService' import { ApiFindspotRepository } from 'fragmentarium/infrastructure/FindspotRepository' - -function createApp(api): JSX.Element { +import FakeApi from 'test-support/FakeApi' + +export function getServices( + api: any = FakeApi +): { + signService: SignService + wordService: WordService + fragmentService: FragmentService + fragmentSearchService: FragmentSearchService + bibliographyService: BibliographyService + textService: TextService + markupService: MarkupService + cachedMarkupService: CachedMarkupService + afoRegisterService: AfoRegisterService + findspotService: FindspotService +} { const wordRepository = new WordRepository(api) const fragmentRepository = new FragmentRepository(api) const imageRepository = new ApiImageRepository(api) @@ -64,20 +78,22 @@ function createApp(api): JSX.Element { const cachedMarkupService = new CachedMarkupService(api, bibliographyService) const afoRegisterService = new AfoRegisterService(afoRegisterRepository) const findspotService = new FindspotService(findspotRepository) - return ( - - ) + return { + signService, + wordService, + fragmentService, + fragmentSearchService, + bibliographyService, + textService, + markupService, + cachedMarkupService, + afoRegisterService, + findspotService, + } +} + +function createApp(api): JSX.Element { + return } const breadcrumbs = { From 26c49110d4af98524f74cda5ae2accd2c96dfd79 Mon Sep 17 00:00:00 2001 From: Kartik Paliwal Date: Sat, 2 Mar 2024 10:43:36 +0000 Subject: [PATCH 6/7] add tests --- src/router/aboutRoutes.tsx | 2 +- src/router/notFoundRoutes.test.tsx | 149 ++++++++++++++++++++++++++++- src/router/toolsRoutes.tsx | 2 +- 3 files changed, 150 insertions(+), 3 deletions(-) diff --git a/src/router/aboutRoutes.tsx b/src/router/aboutRoutes.tsx index fffb6c076..d0859656c 100644 --- a/src/router/aboutRoutes.tsx +++ b/src/router/aboutRoutes.tsx @@ -46,7 +46,7 @@ export default function AboutRoutes({ {...(sitemap && sitemapDefaults)} />, } />, diff --git a/src/router/notFoundRoutes.test.tsx b/src/router/notFoundRoutes.test.tsx index 4819c6d6c..aa7019f18 100644 --- a/src/router/notFoundRoutes.test.tsx +++ b/src/router/notFoundRoutes.test.tsx @@ -1,9 +1,15 @@ import React from 'react' import { render, screen } from '@testing-library/react' import { Router, Switch } from 'react-router-dom' -import FragmentariumRoutes from './fragmentariumRoutes' 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 = [ @@ -28,3 +34,144 @@ describe('NotFoundPage rendering in FragmentariumRoutes', () => { }) }) }) + +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( + + + {[...AboutRoutes({ ...getServices(), sitemap: false })]} + + + ) + 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( + + + {[...BibliographyRoutes({ ...getServices(), sitemap: false })]} + + + ) + 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( + + + {[...CorpusRoutes({ ...getServices(), sitemap: false })]} + + + ) + 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( + + + {[...DictionaryRoutes({ ...getServices(), sitemap: false })]} + + + ) + 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( + + + {[...SignRoutes({ ...getServices(), sitemap: false })]} + + + ) + 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( + + + {[...ToolsRoutes({ ...getServices(), sitemap: false })]} + + + ) + expect( + screen.getByText(/The page you are looking for does not exist./i) + ).toBeInTheDocument() + }) + }) +}) diff --git a/src/router/toolsRoutes.tsx b/src/router/toolsRoutes.tsx index cb536e412..9896cd978 100644 --- a/src/router/toolsRoutes.tsx +++ b/src/router/toolsRoutes.tsx @@ -88,7 +88,7 @@ export default function ToolsRoutes({ {...(sitemap && sitemapDefaults)} />, } From 40fa18bd26eb9190a1d723f55c6d7bc0a8b9c650 Mon Sep 17 00:00:00 2001 From: Kartik Paliwal Date: Mon, 4 Mar 2024 21:41:25 +0000 Subject: [PATCH 7/7] allignment of sign edit and project image --- src/fragmentarium/ui/info/ResearchProjects.sass | 2 ++ src/fragmentarium/ui/info/ResearchProjects.tsx | 8 ++++---- src/fragmentarium/ui/info/ScriptSelection.sass | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/fragmentarium/ui/info/ResearchProjects.sass b/src/fragmentarium/ui/info/ResearchProjects.sass index 6f2644833..1ebaa76cc 100644 --- a/src/fragmentarium/ui/info/ResearchProjects.sass +++ b/src/fragmentarium/ui/info/ResearchProjects.sass @@ -1,6 +1,8 @@ .ResultList ul padding: 0 + margin: 0 + li list-style: none padding-bottom: .5rem diff --git a/src/fragmentarium/ui/info/ResearchProjects.tsx b/src/fragmentarium/ui/info/ResearchProjects.tsx index f3fe70dcd..982ad2a7e 100644 --- a/src/fragmentarium/ui/info/ResearchProjects.tsx +++ b/src/fragmentarium/ui/info/ResearchProjects.tsx @@ -9,9 +9,9 @@ export function ProjectList({ projects: readonly ResearchProject[] }): JSX.Element { return ( -
    +
    {projects.map((project, index) => ( -
  • +
    -
  • +
    ))} -
+ ) } diff --git a/src/fragmentarium/ui/info/ScriptSelection.sass b/src/fragmentarium/ui/info/ScriptSelection.sass index 2e2f51908..f4162c64a 100644 --- a/src/fragmentarium/ui/info/ScriptSelection.sass +++ b/src/fragmentarium/ui/info/ScriptSelection.sass @@ -2,7 +2,7 @@ &__button-wrapper display: flex align-items: flex-start - justify-content: space-between + justify-content: flex-end button margin-left: .5em