diff --git a/src/corpus/ui/__snapshots__/ManuscriptPopover.test.tsx.snap b/src/corpus/ui/__snapshots__/ManuscriptPopover.test.tsx.snap index 2274020e1..b9e17f48c 100644 --- a/src/corpus/ui/__snapshots__/ManuscriptPopover.test.tsx.snap +++ b/src/corpus/ui/__snapshots__/ManuscriptPopover.test.tsx.snap @@ -14,7 +14,7 @@ exports[`Show manuscript line details 1`] = ` - Estrada & Wolfe, 2068: 7477711662481408-4847418310918144 + Estrada & Wolfe, 2069: 7477711662481408-4847418310918144 [ l. 4'.2., 3'. ] diff --git a/src/fragmentarium/domain/fragment.ts b/src/fragmentarium/domain/fragment.ts index a8eb7f141..644e1e363 100644 --- a/src/fragmentarium/domain/fragment.ts +++ b/src/fragmentarium/domain/fragment.ts @@ -78,6 +78,36 @@ export interface ScriptDto { export class Fragment { readonly [immerable] = true + museumKey: + | 'ISTANBUL_ARKEOLOJI_MUSEUM' + | 'THE_IRAQ_MUSEUM' + | 'PENN_MUSEUM' + | 'ASHMOLEAN_MUSEUM' + | 'PHYSICIANS_COLLEGE_PHILADELPHIA' + | 'COUVENT_SAINT_ETIENNE' + | 'REDPATH_MUSEUM' + | 'HILPRECHT_COLLECTION' + | 'HEARST_MUSEUM' + | 'RYLANDS_INSTITUTE' + | 'KELSEY_MUSEUM' + | 'KUNSTHISTORISCHES_MUSEUM' + | 'LOUVRE' + | 'MUSEE_D_ART' + | 'MUSEES_ROYAUX' + | 'NATIONALMUSEET' + | 'OAKLAND_MUSEUM' + | 'ANCIENT_CULTURES_CHICAGO' + | 'PIERPONT_MORGAN' + | 'PONTIFICAL_BIBLICAL_INSTITUTE' + | 'ROSICRUCIAN_EGYPTIAN_MUSEUM' + | 'THE_BRITISH_MUSEUM' + | 'TRINITY_COLLEGE_DUBLIN' + | 'VATICAN_MUSEUMS' + | 'VORDERASIATISCHES_MUSEUM' + | 'THE_WALTERS_ART_MUSEUM' + | 'YALE_PEABODY_COLLECTION' + | 'ECOLE_PRATIQUE_DES_HAUTES_ETUDES' + | 'UNKNOWN' constructor( readonly number: string, diff --git a/src/fragmentarium/domain/museum.test.ts b/src/fragmentarium/domain/museum.test.ts index 9a6756002..91fcfa191 100644 --- a/src/fragmentarium/domain/museum.test.ts +++ b/src/fragmentarium/domain/museum.test.ts @@ -1,8 +1,4 @@ import { Museums, MuseumKey } from './museum' -import { - externalNumbersFactory, - fragmentFactory, -} from 'test-support/fragment-fixtures' describe.each([ [ @@ -18,10 +14,10 @@ describe.each([ 'The Iraq Museum', 'Baghdad', 'IRQ', - '', + 'https://theiraqmuseum.com/', 'By Permission of the State Board of Antiquities and Heritage and The Iraq Museum', ], - ['Other Museum', '', '', '', '', ''], + ['UNKNOWN', '', '', '', '', ''], ] as [MuseumKey, string, string, string, string, string][])( '%s', ( @@ -33,7 +29,6 @@ describe.each([ expectedcopyright = '' ) => { const museum = Museums[key] - test('name', () => { expect(museum.name).toEqual(expectedName) }) @@ -55,89 +50,3 @@ describe.each([ }) } ) - -describe('BritishMuseum', () => { - const bmIdNumber = 'A 1234+43' - const link = { - name: 'The British Museum', - url: `https://www.britishmuseum.org/collection/object/${encodeURIComponent( - bmIdNumber - )}`, - label: `The British Museum object ${bmIdNumber}`, - } - const britishMuseum = Museums['THE_BRITISH_MUSEUM'] - - describe('hasFragmentLink', () => { - test('fragment has bmIdNumber', () => { - const fragment = fragmentFactory.build( - {}, - { - associations: { - externalNumbers: externalNumbersFactory.build({ bmIdNumber }), - }, - } - ) - expect(britishMuseum.hasFragmentLink(fragment)).toEqual(true) - }) - - test('fragment does not have bmIdNumber', () => { - const fragment = fragmentFactory.build( - {}, - { - associations: { - externalNumbers: externalNumbersFactory.build({ bmIdNumber: '' }), - }, - } - ) - expect(britishMuseum.hasFragmentLink(fragment)).toEqual(false) - }) - }) - - test('fragmentlink', () => { - const fragment = fragmentFactory.build( - {}, - { - associations: { - externalNumbers: externalNumbersFactory.build({ bmIdNumber }), - }, - } - ) - expect(britishMuseum.createLinkFor(fragment)).toEqual(link) - }) -}) - -describe('YaleBabylonianCollectionhMuseum', () => { - const accession = 'A 1234+4.3' - const expectedAccession = 'A 1234+4-3' - const link = { - name: 'Yale Babylonian Collection, Peabody Museum', - url: `https://collections.peabody.yale.edu/search/Record/YPM-${encodeURIComponent( - expectedAccession - )}`, - label: `Yale Babylonian Collection, Peabody Museum`, - } - const ybc = Museums['YALE_PEABODY_COLLECTION'] - - describe('hasFragmentLink', () => { - test('fragment has accession', () => { - const fragment = fragmentFactory.build({ - accession, - }) - expect(ybc.hasFragmentLink(fragment)).toEqual(true) - }) - - test('fragment does not have accession', () => { - const fragment = fragmentFactory.build({ - accession: '', - }) - expect(ybc.hasFragmentLink(fragment)).toEqual(false) - }) - }) - - test('fragmentlink', () => { - const fragment = fragmentFactory.build({ - accession, - }) - expect(ybc.createLinkFor(fragment)).toEqual(link) - }) -}) diff --git a/src/fragmentarium/ui/front-page/__snapshots__/LatestTransliterations.test.tsx.snap b/src/fragmentarium/ui/front-page/__snapshots__/LatestTransliterations.test.tsx.snap index d14edfa3a..cf2f15e6d 100644 --- a/src/fragmentarium/ui/front-page/__snapshots__/LatestTransliterations.test.tsx.snap +++ b/src/fragmentarium/ui/front-page/__snapshots__/LatestTransliterations.test.tsx.snap @@ -71,9 +71,9 @@ exports[`Snapshot 1`] = ` , ) @@ -108,7 +108,7 @@ exports[`Snapshot 1`] = ` - Fanti & Carr, 2036: 8970824935538688-3796097900216320 + Fanti & Carr, 2037: 8970824935538688-3796097900216320 [ l. 4'.2., 2. ] @@ -123,7 +123,7 @@ exports[`Snapshot 1`] = ` - Hall & Reid, 2089: 7020923936833536-4895425479835648 + Hall & Reid, 2090: 7020923936833536-4895425479835648 [ l. 4'.2., 3'. ] @@ -5906,7 +5906,7 @@ exports[`Snapshot 1`] = ` - White & Manca, 2070: 6525764484726784-1000123435843584 + White & Manca, 2071: 6525764484726784-1000123435843584 [ l. 3'., 2. ] @@ -5925,7 +5925,7 @@ exports[`Snapshot 1`] = ` - Martinez & Robin, 2112: 5946678584541184-5595938733162496 + Martinez & Robin, 2113: 5946678584541184-5595938733162496 [ l. 3'., 4'.2. ] diff --git a/src/fragmentarium/ui/info/Details.test.tsx b/src/fragmentarium/ui/info/Details.test.tsx index 43140d3b4..2cfe12426 100644 --- a/src/fragmentarium/ui/info/Details.test.tsx +++ b/src/fragmentarium/ui/info/Details.test.tsx @@ -64,7 +64,7 @@ describe('All details', () => { }, { associations: { - museum: Museums['The British Museum'], + museumKey: 'THE_BRITISH_MUSEUM', genres: new Genres([]), joins: [ [ @@ -86,14 +86,14 @@ describe('All details', () => { }) it('Renders museum', () => { - expect(screen.getByText(`${fragment.museum.name}`)).toBeInTheDocument() + const museum = Museums[fragment.museumKey] + expect(screen.getByText(museum.name)).toBeInTheDocument() }) - it('Links to museum home', () => - expect(screen.getByText(fragment.museum.name)).toHaveAttribute( - 'href', - 'https://britishmuseum.org/' - )) + it('Links to museum home', () => { + const museum = Museums[fragment.museumKey] + expect(screen.getByText(museum.name)).toHaveAttribute('href', museum.url) + }) it('Renders colection', () => { expect( @@ -192,22 +192,3 @@ describe('Missing details', () => { expect(screen.getByText('Accession: -')).toBeInTheDocument() }) }) - -describe('Unknown museum', () => { - beforeEach(async () => { - fragment = fragmentFactory.build( - {}, - { - associations: { - museum: Museums['UNKNOWN'], - }, - } - ) - await renderDetails() - }) - - it('Does not link museum', () => - expect(screen.queryByText(fragment.museum.name)).not.toHaveAttribute( - 'href' - )) -}) diff --git a/src/fragmentarium/ui/info/Details.tsx b/src/fragmentarium/ui/info/Details.tsx index 5b8511514..79cf2c62d 100644 --- a/src/fragmentarium/ui/info/Details.tsx +++ b/src/fragmentarium/ui/info/Details.tsx @@ -1,5 +1,5 @@ import React from 'react' - +import { Museums, MuseumKey } from 'fragmentarium/domain/museum' import _ from 'lodash' import { Fragment, Script } from 'fragmentarium/domain/fragment' import FragmentLink from 'fragmentarium/ui/FragmentLink' @@ -22,8 +22,13 @@ function Collection({ fragment: { collection } }: Props): JSX.Element { return <>{collection && `(${collection} Collection)`} } -function MuseumName({ fragment: { museum } }: Props): JSX.Element { - return museum.hasUrl ? ( +interface MuseumNameProps { + museumKey: MuseumKey +} + +const MuseumName: React.FC = ({ museumKey }) => { + const museum = Museums[museumKey] + return museum.url ? ( {museum.name} ) : ( <>{museum.name} @@ -107,7 +112,7 @@ function Details({ return (
  • - +
  • diff --git a/src/fragmentarium/ui/search/__snapshots__/FragmentariumSearch.test.tsx.snap b/src/fragmentarium/ui/search/__snapshots__/FragmentariumSearch.test.tsx.snap index 48d4a8c96..53ed16af9 100644 --- a/src/fragmentarium/ui/search/__snapshots__/FragmentariumSearch.test.tsx.snap +++ b/src/fragmentarium/ui/search/__snapshots__/FragmentariumSearch.test.tsx.snap @@ -773,7 +773,7 @@ exports[`Searching fragments by transliteration Displays corpus results when cli - Giles & Alvarez, 2086: 5582194326110208-1406653725409280 + Giles & Alvarez, 2087: 5582194326110208-1406653725409280 [ l. 1., 3'. ] @@ -792,7 +792,7 @@ exports[`Searching fragments by transliteration Displays corpus results when cli - Shaw & Robert, 2045: 6150545542742016-5917511180615680 + Shaw & Robert, 2046: 6150545542742016-5917511180615680 [ l. 2., 1. ] @@ -6565,7 +6565,7 @@ exports[`Searching fragments by transliteration Displays corpus results when cli - Harrison & Palmieri, 2028: 5188341634957312-4059361584349184 + Harrison & Palmieri, 2029: 5188341634957312-4059361584349184 [ l. 1., 2. ] @@ -6584,7 +6584,7 @@ exports[`Searching fragments by transliteration Displays corpus results when cli - Wise & Hudson, 2039: 1529496131862528-4383736143544320 + Wise & Hudson, 2040: 1529496131862528-4383736143544320 [ l. 4'.2., 2. ] diff --git a/src/transliteration/ui/__snapshots__/markup.test.tsx.snap b/src/transliteration/ui/__snapshots__/markup.test.tsx.snap index b3a8aa722..df48a0dc2 100644 --- a/src/transliteration/ui/__snapshots__/markup.test.tsx.snap +++ b/src/transliteration/ui/__snapshots__/markup.test.tsx.snap @@ -40,7 +40,7 @@ exports[`Markup 1`] = ` - Dickinson & Falciani, 2062: 6831522153758720-8434983175716864 + Dickinson & Falciani, 2063: 6831522153758720-8434983175716864 [ l. 4'.2., 1. ]