@museumwnf/viewer-layout 3.79.0 → 3.80.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@museumwnf/viewer-layout",
3
- "version": "3.79.0",
3
+ "version": "3.80.1",
4
4
  "description": "Page structure for MWNF websites: PageShell composing seven optional, token-styled sections, the content components a page is made of, and the composed views a website names instead of writing a page.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -46,12 +46,12 @@
46
46
  "test": "vitest run"
47
47
  },
48
48
  "peerDependencies": {
49
- "@museumwnf/viewer-core": "^2.23.0",
49
+ "@museumwnf/viewer-core": "^2.24.0",
50
50
  "vue": "^3.5.0",
51
51
  "vue-router": "^4.5.0 || ^5.0.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@museumwnf/viewer-core": "^2.23.0",
54
+ "@museumwnf/viewer-core": "^2.24.0",
55
55
  "@vitejs/plugin-vue": "^6.0.10",
56
56
  "@vue/test-utils": "^2.5.1",
57
57
  "jsdom": "^30.1.3",
@@ -678,11 +678,16 @@ export function describeExhibitionSmoke({
678
678
  }) {
679
679
  const { messages, mountSite } = mounter(config, sharedTexts, ownTexts)
680
680
  const loadItems = async () => (await loadEntities(['exhibition', 'items']))[1]
681
+ // The site's own hidden partners when its config lists them, else the
682
+ // package's (inventory-app#2727).
681
683
  const visiblePartners = async () => {
682
684
  const [exhibition, partners] = await loadEntities(['exhibition', 'partners'])
683
- const hidden = new Set(exhibition.hidden_partner_ids ?? [])
685
+ const hidden = new Set(config.exhibition?.hiddenPartners ?? exhibition.hidden_partner_ids ?? [])
684
686
  return partners.filter((p) => !hidden.has(p.id))
685
687
  }
688
+ // A site that never had legacy addresses leaves the redirects out
689
+ // (`legacyRoutes: false`).
690
+ const hasLegacyRoutes = (config.legacyRoutes ?? []).length > 0
686
691
  const datedItem = async () => (await loadItems()).find((i) => Number.isFinite(i.start_date) && i.country_id)
687
692
 
688
693
  describe('exhibition smoke test', () => {
@@ -750,9 +755,11 @@ export function describeExhibitionSmoke({
750
755
  expect(!!host.querySelector(`a[href="${drawnAs(project.related_database_url)}"]`)).toBe(!!project.related_database_url)
751
756
  expect(!!host.querySelector(`a[href="${drawnAs(project.artistic_introduction_url)}"]`)).toBe(!!project.artistic_introduction_url)
752
757
  expect(!!host.querySelector('.mwnf-sheet-notice')).toBe(noticeProjects.includes(item.project_id))
753
- // Every project needs its chip colour, or the chip falls back to the
754
- // layout's default swatch.
755
- expect(config.projectColors[item.project_id]).toBeTruthy()
758
+ // Every project the package places needs its chip colour, or the chip
759
+ // falls back to the layout's default swatch. A project the package
760
+ // cannot place (no `home_site`, inventory-app#2727) gets one only from
761
+ // the site's own `projectColors`.
762
+ if ('home_site' in project) expect(config.projectColors[item.project_id]).toBeTruthy()
756
763
  app.unmount()
757
764
  }
758
765
  }, 120000)
@@ -784,13 +791,20 @@ export function describeExhibitionSmoke({
784
791
  }, 30000)
785
792
 
786
793
  it('renders a partner profile on the composed record view', async () => {
787
- const partner = (await visiblePartners()).find((p) => p.type !== 'institution' && partnerNames[p.id]?.name)
794
+ const named = (await visiblePartners()).filter((p) => partnerNames[p.id]?.name)
795
+ // A museum when there is one; an exhibition of institutions only (publishers,
796
+ // archives) shows one of those.
797
+ const museums = named.filter((p) => p.type !== 'institution')
798
+ const pool = museums.length > 0 ? museums : named
799
+ // The map needs the partner's coordinates: one that has them, if any.
800
+ const located = (p) => Number.isFinite(p.latitude) && Number.isFinite(p.longitude)
801
+ const partner = pool.find(located) ?? pool[0]
788
802
  const { app, host } = await mountSite(`#/partner/${partner.id}`)
789
803
  await vi.waitFor(() => expect(host.querySelector('.mwnf-record')).not.toBeNull(), WAIT)
790
804
  await vi.waitFor(() => expect(host.querySelector('.mwnf-record').textContent.trim().length).toBeGreaterThan(0), WAIT)
791
805
  // The tab strip and the map are the page's own slots.
792
806
  expect(host.querySelector('[role="tablist"], .mwnf-dxa-profile-links')).not.toBeNull()
793
- expect(host.querySelector('.mwnf-partner-map')).not.toBeNull()
807
+ if (located(partner)) expect(host.querySelector('.mwnf-partner-map')).not.toBeNull()
794
808
  app.unmount()
795
809
  }, 30000)
796
810
 
@@ -852,8 +866,13 @@ export function describeExhibitionSmoke({
852
866
  app.unmount()
853
867
  }, 30000)
854
868
 
869
+ // The first theme that has pictures, its sub-themes' or (a theme with no
870
+ // sub-themes) its own.
855
871
  it("renders a theme's gallery on legacy's grid", async () => {
856
- const { app, host } = await mountSite('#/theme-gallery/1')
872
+ const [themes] = await loadEntities(['themes'])
873
+ const pictured = (node) => (node.sub_themes?.length ? node.sub_themes : [node]).some((sub) => sub.pictures?.length)
874
+ const theme = themes.filter((t) => t.display_order > 1).sort((a, b) => a.display_order - b.display_order).find(pictured)
875
+ const { app, host } = await mountSite(`#/theme-gallery/${theme ? theme.display_order - 1 : 1}`)
857
876
  await vi.waitFor(() => expect(host.querySelector(TILE)).not.toBeNull(), WAIT)
858
877
  expect(host.querySelector('.mwnf-dxa-theme-gallery-page')).not.toBeNull()
859
878
  app.unmount()
@@ -952,49 +971,58 @@ export function describeExhibitionSmoke({
952
971
  'institution', 'institution-monuments', 'related', 'timeline', 'timeline-results',
953
972
  'timeline-gallery', 'credits',
954
973
  ],
955
- legacyPaths: [
956
- '/database-item/:uid(.*)/:language',
957
- '/partner/:country/:id/:language',
958
- '/partner-objects/:country/:id/:page',
959
- '/institution/:country/:id/:language',
960
- '/institution-monuments/:country/:id/:page',
961
- '/timeline-gallery/:country/:start/:end/:page',
962
- ],
974
+ legacyPaths: hasLegacyRoutes
975
+ ? [
976
+ '/database-item/:uid(.*)/:language',
977
+ '/partner/:country/:id/:language',
978
+ '/partner-objects/:country/:id/:page',
979
+ '/institution/:country/:id/:language',
980
+ '/institution-monuments/:country/:id/:page',
981
+ '/timeline-gallery/:country/:start/:end/:page',
982
+ ]
983
+ : [],
963
984
  })
964
985
 
965
- it('maps a legacy address onto the canonical route', async () => {
986
+ it.skipIf(!hasLegacyRoutes)('maps a legacy address onto the canonical route', async () => {
966
987
  const [, items, partners] = await loadEntities(['exhibition', 'items', 'partners'])
967
988
  const [itemFor, partnerFor, objectsFor, institutionFor, monumentsFor, galleryFor] = config.legacyRoutes
968
989
 
990
+ // A package built from the inventory's own data carries no legacy key
991
+ // (inventory-app#2727): the item and partner shapes are then proven on
992
+ // nothing, the timeline gallery's still are.
969
993
  const item = items.find((i) => i.backward_compatibility)
970
- expect(await itemFor.resolve({ uid: item.backward_compatibility.split(':').join('/') })).toEqual({
971
- name: 'item',
972
- params: { id: item.id },
973
- })
994
+ if (item) {
995
+ expect(await itemFor.resolve({ uid: item.backward_compatibility.split(':').join('/') })).toEqual({
996
+ name: 'item',
997
+ params: { id: item.id },
998
+ })
999
+ }
974
1000
  expect(await itemFor.resolve({ uid: 'mwnf3/objects/NOPE/xx/Mus00/0' })).toBeNull()
975
1001
 
976
1002
  const museum = partners.find((p) => p.type !== 'institution' && (p.backward_compatibility ?? '').split(':').length >= 4)
977
- const [, , museumId, museumCountry] = museum.backward_compatibility.split(':')
978
- expect(await partnerFor.resolve({ country: museumCountry, id: museumId })).toEqual({
979
- name: 'partner',
980
- params: { id: museum.id },
981
- })
982
- expect(await objectsFor.resolve({ country: museumCountry, id: museumId, page: '3' })).toEqual({
983
- name: 'partner-objects',
984
- params: { id: museum.id },
985
- query: { page: '3' },
986
- })
987
- // An institution reaches the institution pages, the same component
988
- // under another name.
989
- expect(await institutionFor.resolve({ country: museumCountry, id: museumId })).toEqual({
990
- name: 'institution',
991
- params: { id: museum.id },
992
- })
993
- expect(await monumentsFor.resolve({ country: museumCountry, id: museumId, page: '1' })).toEqual({
994
- name: 'institution-monuments',
995
- params: { id: museum.id },
996
- query: {},
997
- })
1003
+ const [, , museumId, museumCountry] = museum?.backward_compatibility.split(':') ?? []
1004
+ if (museum) {
1005
+ expect(await partnerFor.resolve({ country: museumCountry, id: museumId })).toEqual({
1006
+ name: 'partner',
1007
+ params: { id: museum.id },
1008
+ })
1009
+ expect(await objectsFor.resolve({ country: museumCountry, id: museumId, page: '3' })).toEqual({
1010
+ name: 'partner-objects',
1011
+ params: { id: museum.id },
1012
+ query: { page: '3' },
1013
+ })
1014
+ // An institution reaches the institution pages, the same component
1015
+ // under another name.
1016
+ expect(await institutionFor.resolve({ country: museumCountry, id: museumId })).toEqual({
1017
+ name: 'institution',
1018
+ params: { id: museum.id },
1019
+ })
1020
+ expect(await monumentsFor.resolve({ country: museumCountry, id: museumId, page: '1' })).toEqual({
1021
+ name: 'institution-monuments',
1022
+ params: { id: museum.id },
1023
+ query: {},
1024
+ })
1025
+ }
998
1026
  // The page number and the period leave the path for the query; an open
999
1027
  // bound stops being the literal 'any', and `start` becomes `begin`.
1000
1028
  expect(galleryFor.resolve({ country: 'uk', start: 'any', end: '1500', page: '2' })).toEqual({