diff --git a/cypress/fixtures/material/music-fbi-api.json b/cypress/fixtures/material/music-fbi-api.json new file mode 100644 index 0000000000..670880360b --- /dev/null +++ b/cypress/fixtures/material/music-fbi-api.json @@ -0,0 +1,834 @@ +{ + "data": { + "work": { + "workId": "work-of:870970-basis:137949814", + "titles": { + "full": [ + "Billion dollar babies" + ], + "original": [] + }, + "abstract": [], + "creators": [ + { + "display": "Alice Cooper", + "__typename": "Person" + } + ], + "series": [], + "seriesMembers": [], + "workYear": null, + "genreAndForm": [ + "rock", + "heavy rock", + "70'er rock" + ], + "manifestations": { + "all": [ + { + "pid": "775100-katalog:10343852", + "genreAndForm": [], + "source": [ + "Bibliotekskatalog" + ], + "languages": { + "main": [], + "notes": [] + }, + "titles": { + "main": [ + "Billion dollar babies" + ], + "original": [] + }, + "fictionNonfiction": { + "display": "vides ikke", + "code": "NOT_SPECIFIED" + }, + "materialTypes": [ + { + "materialTypeSpecific": { + "display": "musik (cd)" + } + } + ], + "creators": [ + { + "display": "Alice Cooper", + "__typename": "Person" + } + ], + "publisher": [ + "Warner Bros." + ], + "identifiers": [ + { + "value": "Warner Bros. 7599-27269-2" + } + ], + "contributors": [ + { + "display": "Michael Bruce", + "roles": [] + }, + { + "display": "Dennis Dunaway", + "roles": [] + }, + { + "display": "Neal Smith", + "roles": [] + }, + { + "display": "Glen Buxton", + "roles": [] + } + ], + "edition": null, + "dateFirstEdition": null, + "audience": { + "generalAudience": [], + "ages": [] + }, + "notes": [], + "physicalDescriptions": [ + { + "summary": "Stereo", + "numberOfPages": null, + "playingTime": null + } + ], + "hostPublication": null, + "manifestationParts": { + "parts": [ + { + "title": "Hello hooray" + }, + { + "title": "Raped and freezin'" + }, + { + "title": "Elected" + }, + { + "title": "Billion dollar babies" + }, + { + "title": "Unfinished sweet" + }, + { + "title": "No more Mr. Nice Guy" + }, + { + "title": "Generation landslide" + }, + { + "title": "Sick things" + }, + { + "title": "Mary Ann" + }, + { + "title": "I love the dead" + } + ] + }, + "accessTypes": [ + { + "code": "PHYSICAL" + } + ], + "access": [ + { + "__typename": "InterLibraryLoan", + "loanIsPossible": true + } + ], + "shelfmark": { + "postfix": "Cooper", + "shelfmark": "Rock" + }, + "workYear": null, + "catalogueCodes": { + "nationalBibliography": [], + "otherCatalogues": [] + } + }, + { + "pid": "870970-basis:137949814", + "genreAndForm": [ + "rock", + "heavy rock", + "70'er rock" + ], + "source": [ + "Bibliotekskatalog" + ], + "languages": { + "main": [ + { + "display": "engelsk", + "isoCode": "eng" + } + ], + "notes": [] + }, + "titles": { + "main": [ + "Billion dollar babies" + ], + "original": [] + }, + "fictionNonfiction": { + "display": "vides ikke", + "code": "NOT_SPECIFIED" + }, + "materialTypes": [ + { + "materialTypeSpecific": { + "display": "musik (cd)" + } + } + ], + "creators": [ + { + "display": "Alice Cooper", + "__typename": "Person" + } + ], + "publisher": [ + "Warner Records" + ], + "identifiers": [ + { + "value": "Warner Rhino 603497832415" + } + ], + "contributors": [ + { + "display": "Michael Bruce", + "roles": [] + }, + { + "display": "Glen Buxton", + "roles": [] + }, + { + "display": "Dennis Dunaway", + "roles": [] + }, + { + "display": "Neal Smith", + "roles": [] + } + ], + "edition": { + "summary": "50th-anniversary edition, ℗2024", + "publicationYear": { + "display": "℗2024" + } + }, + "dateFirstEdition": null, + "audience": { + "generalAudience": [], + "ages": [] + }, + "notes": [], + "physicalDescriptions": [ + { + "summary": "2 cd'er (1 kommentarbilag)", + "numberOfPages": null, + "playingTime": null + } + ], + "hostPublication": null, + "manifestationParts": { + "parts": [ + { + "title": "Hello Hooray" + }, + { + "title": "Raped and Freezin'" + }, + { + "title": "Elected" + }, + { + "title": "Billion Dollar Babies" + }, + { + "title": "Unfinished Sweet" + }, + { + "title": "No More Mr. Nice Guy" + }, + { + "title": "Generation Landslide" + }, + { + "title": "Sick Things" + }, + { + "title": "Mary Ann" + }, + { + "title": "I Love the Dead" + }, + { + "title": "Hello Hooray (Live)" + }, + { + "title": "Billion Dollar Babies (Live)" + }, + { + "title": "Elected (Live)" + }, + { + "title": "I'm Eighteen (Live, 1973)" + }, + { + "title": "Raped and Freezin' (Live)" + }, + { + "title": "No More Mr. Nice Guy (Live)" + }, + { + "title": "My Stars (Live)" + }, + { + "title": "Unfinished Sweet (Live)" + }, + { + "title": "Sick Things (Live)" + }, + { + "title": "Dead Babies (Live)" + }, + { + "title": "I Love the Dead (Live)" + }, + { + "title": "School's Out (Live 1973)" + }, + { + "title": "Under My Wheels (Live 1973)" + }, + { + "title": "Coal Black Model T (Outtake)" + }, + { + "title": "Son Of Billion Dollar Babies (Generation Landslide) (Outtake)" + }, + { + "title": "Hello Hooray (Single Version)" + }, + { + "title": "Billion Dollar Babies 8Single Version" + }, + { + "title": "Elected (Single Version)" + }, + { + "title": "Mary Ann (Single Version)" + }, + { + "title": "Slick Black Limousine" + } + ] + }, + "accessTypes": [ + { + "code": "PHYSICAL" + } + ], + "access": [ + { + "__typename": "InterLibraryLoan", + "loanIsPossible": true + } + ], + "shelfmark": { + "postfix": "Cooper", + "shelfmark": "Rock" + }, + "workYear": null, + "catalogueCodes": { + "nationalBibliography": [], + "otherCatalogues": [ + "ACM202407", + "BKM202415" + ] + } + } + ], + "latest": { + "pid": "870970-basis:137949814", + "genreAndForm": [ + "rock", + "heavy rock", + "70'er rock" + ], + "source": [ + "Bibliotekskatalog" + ], + "languages": { + "main": [ + { + "display": "engelsk", + "isoCode": "eng" + } + ], + "notes": [] + }, + "titles": { + "main": [ + "Billion dollar babies" + ], + "original": [] + }, + "fictionNonfiction": { + "display": "vides ikke", + "code": "NOT_SPECIFIED" + }, + "materialTypes": [ + { + "materialTypeSpecific": { + "display": "musik (cd)" + } + } + ], + "creators": [ + { + "display": "Alice Cooper", + "__typename": "Person" + } + ], + "publisher": [ + "Warner Records" + ], + "identifiers": [ + { + "value": "Warner Rhino 603497832415" + } + ], + "contributors": [ + { + "display": "Michael Bruce", + "roles": [] + }, + { + "display": "Glen Buxton", + "roles": [] + }, + { + "display": "Dennis Dunaway", + "roles": [] + }, + { + "display": "Neal Smith", + "roles": [] + } + ], + "edition": { + "summary": "50th-anniversary edition, ℗2024", + "publicationYear": { + "display": "℗2024" + } + }, + "dateFirstEdition": null, + "audience": { + "generalAudience": [], + "ages": [] + }, + "notes": [], + "physicalDescriptions": [ + { + "summary": "2 cd'er (1 kommentarbilag)", + "numberOfPages": null, + "playingTime": null + } + ], + "hostPublication": null, + "manifestationParts": { + "parts": [ + { + "title": "Hello Hooray" + }, + { + "title": "Raped and Freezin'" + }, + { + "title": "Elected" + }, + { + "title": "Billion Dollar Babies" + }, + { + "title": "Unfinished Sweet" + }, + { + "title": "No More Mr. Nice Guy" + }, + { + "title": "Generation Landslide" + }, + { + "title": "Sick Things" + }, + { + "title": "Mary Ann" + }, + { + "title": "I Love the Dead" + }, + { + "title": "Hello Hooray (Live)" + }, + { + "title": "Billion Dollar Babies (Live)" + }, + { + "title": "Elected (Live)" + }, + { + "title": "I'm Eighteen (Live, 1973)" + }, + { + "title": "Raped and Freezin' (Live)" + }, + { + "title": "No More Mr. Nice Guy (Live)" + }, + { + "title": "My Stars (Live)" + }, + { + "title": "Unfinished Sweet (Live)" + }, + { + "title": "Sick Things (Live)" + }, + { + "title": "Dead Babies (Live)" + }, + { + "title": "I Love the Dead (Live)" + }, + { + "title": "School's Out (Live 1973)" + }, + { + "title": "Under My Wheels (Live 1973)" + }, + { + "title": "Coal Black Model T (Outtake)" + }, + { + "title": "Son Of Billion Dollar Babies (Generation Landslide) (Outtake)" + }, + { + "title": "Hello Hooray (Single Version)" + }, + { + "title": "Billion Dollar Babies 8Single Version" + }, + { + "title": "Elected (Single Version)" + }, + { + "title": "Mary Ann (Single Version)" + }, + { + "title": "Slick Black Limousine" + } + ] + }, + "accessTypes": [ + { + "code": "PHYSICAL" + } + ], + "access": [ + { + "__typename": "InterLibraryLoan", + "loanIsPossible": true + } + ], + "shelfmark": { + "postfix": "Cooper", + "shelfmark": "Rock" + }, + "workYear": null, + "catalogueCodes": { + "nationalBibliography": [], + "otherCatalogues": [ + "ACM202407", + "BKM202415" + ] + } + }, + "bestRepresentation": { + "pid": "870970-basis:137949814", + "genreAndForm": [ + "rock", + "heavy rock", + "70'er rock" + ], + "source": [ + "Bibliotekskatalog" + ], + "languages": { + "main": [ + { + "display": "engelsk", + "isoCode": "eng" + } + ], + "notes": [] + }, + "titles": { + "main": [ + "Billion dollar babies" + ], + "original": [] + }, + "fictionNonfiction": { + "display": "vides ikke", + "code": "NOT_SPECIFIED" + }, + "materialTypes": [ + { + "materialTypeSpecific": { + "display": "musik (cd)" + } + } + ], + "creators": [ + { + "display": "Alice Cooper", + "__typename": "Person" + } + ], + "publisher": [ + "Warner Records" + ], + "identifiers": [ + { + "value": "Warner Rhino 603497832415" + } + ], + "contributors": [ + { + "display": "Michael Bruce", + "roles": [] + }, + { + "display": "Glen Buxton", + "roles": [] + }, + { + "display": "Dennis Dunaway", + "roles": [] + }, + { + "display": "Neal Smith", + "roles": [] + } + ], + "edition": { + "summary": "50th-anniversary edition, ℗2024", + "publicationYear": { + "display": "℗2024" + } + }, + "dateFirstEdition": null, + "audience": { + "generalAudience": [], + "ages": [] + }, + "notes": [], + "physicalDescriptions": [ + { + "summary": "2 cd'er (1 kommentarbilag)", + "numberOfPages": null, + "playingTime": null + } + ], + "hostPublication": null, + "manifestationParts": { + "parts": [ + { + "title": "Hello Hooray" + }, + { + "title": "Raped and Freezin'" + }, + { + "title": "Elected" + }, + { + "title": "Billion Dollar Babies" + }, + { + "title": "Unfinished Sweet" + }, + { + "title": "No More Mr. Nice Guy" + }, + { + "title": "Generation Landslide" + }, + { + "title": "Sick Things" + }, + { + "title": "Mary Ann" + }, + { + "title": "I Love the Dead" + }, + { + "title": "Hello Hooray (Live)" + }, + { + "title": "Billion Dollar Babies (Live)" + }, + { + "title": "Elected (Live)" + }, + { + "title": "I'm Eighteen (Live, 1973)" + }, + { + "title": "Raped and Freezin' (Live)" + }, + { + "title": "No More Mr. Nice Guy (Live)" + }, + { + "title": "My Stars (Live)" + }, + { + "title": "Unfinished Sweet (Live)" + }, + { + "title": "Sick Things (Live)" + }, + { + "title": "Dead Babies (Live)" + }, + { + "title": "I Love the Dead (Live)" + }, + { + "title": "School's Out (Live 1973)" + }, + { + "title": "Under My Wheels (Live 1973)" + }, + { + "title": "Coal Black Model T (Outtake)" + }, + { + "title": "Son Of Billion Dollar Babies (Generation Landslide) (Outtake)" + }, + { + "title": "Hello Hooray (Single Version)" + }, + { + "title": "Billion Dollar Babies 8Single Version" + }, + { + "title": "Elected (Single Version)" + }, + { + "title": "Mary Ann (Single Version)" + }, + { + "title": "Slick Black Limousine" + } + ] + }, + "accessTypes": [ + { + "code": "PHYSICAL" + } + ], + "access": [ + { + "__typename": "InterLibraryLoan", + "loanIsPossible": true + } + ], + "shelfmark": { + "postfix": "Cooper", + "shelfmark": "Rock" + }, + "workYear": null, + "catalogueCodes": { + "nationalBibliography": [], + "otherCatalogues": [ + "ACM202407", + "BKM202415" + ] + } + } + }, + "materialTypes": [ + { + "materialTypeSpecific": { + "display": "musik (cd)" + } + } + ], + "mainLanguages": [ + { + "display": "engelsk", + "isoCode": "eng" + } + ], + "subjects": { + "all": [ + { + "display": "vokal" + }, + { + "display": "USA" + }, + { + "display": "1970'erne" + } + ], + "dbcVerified": [ + { + "display": "vokal" + }, + { + "display": "USA" + }, + { + "display": "1970'erne" + } + ] + }, + "fictionNonfiction": { + "display": "vides ikke", + "code": "NOT_SPECIFIED" + }, + "dk5MainEntry": { + "display": "78.794:5 Rock'n roll. Rock. Folk" + }, + "relations": { + "hasReview": [ + { + "pid": "870971-anmeld:138074587" + }, + { + "pid": "870971-anmeld:23412608" + } + ], + "hasAdaptation": [] + } + } + } +} \ No newline at end of file diff --git a/src/apps/material/helper.ts b/src/apps/material/helper.ts index e3e3769fbf..608c0cb184 100644 --- a/src/apps/material/helper.ts +++ b/src/apps/material/helper.ts @@ -217,9 +217,9 @@ export const getManifestationHostPublication = ( }; export const getManifestationParts = ( manifestation: Manifestation -): string[] => { +): string[] | string => { return ( - manifestation.manifestationParts?.parts?.map((item) => item.title) || [] + manifestation.manifestationParts?.parts?.map((item) => item.title) || "" ); }; diff --git a/src/apps/material/material.test.ts b/src/apps/material/material.test.ts index c288422a59..3a0e8ed067 100644 --- a/src/apps/material/material.test.ts +++ b/src/apps/material/material.test.ts @@ -121,6 +121,274 @@ describe("Material", () => { cy.getBySel("material-details-disclosure").click(); }); + it("Renders the correct details for books", () => { + cy.interceptGraphql({ + operationName: "getMaterial", + fixtureFilePath: "material/fbi-api.json" + }); + + cy.visit("/iframe.html?id=apps-material--default&viewMode=story&type=bog"); + cy.wait("@getMaterial GraphQL operation"); + + cy.scrollTo("bottom"); + cy.getBySel("material-details-disclosure").click(); + + cy.get('[data-cy="list-description"]').within(() => { + // Verify "Language" field and its value + cy.get(".list-description__item") + .contains("Language") + .next() + .should("contain.text", "dansk"); + + // Verify "Edition" field and its value + cy.get(".list-description__item") + .contains("Edition") + .next() + .should("contain.text", "1. udgave, 2016"); + + // Verify "Genre" field and its value + cy.get(".list-description__item") + .contains("Genre") + .next() + .should("contain.text", "roman / slægtsromaner"); + + // Verify "Original title" field and its value + cy.get(".list-description__item") + .contains("Original title") + .next() + .should("contain.text", "The seven sisters"); + + // Verify "Publisher" field and its value + cy.get(".list-description__item") + .contains("Publisher") + .next() + .should("contain.text", "Cicero"); + + // Verify "Type" field and its value + cy.get(".list-description__item") + .contains("Type") + .next() + .should("contain.text", "bog"); + + // Verify "Contributors" field and its value + cy.get(".list-description__item") + .contains("Contributors") + .next() + .should("contain.text", "Ulla Lauridsen (oversætter)"); + + // Verify "Scope" field and its value + cy.get(".list-description__item") + .contains("Scope") + .next() + .should("contain.text", "523"); + + // Verify "Dimensions" field and its value + cy.get(".list-description__item") + .contains("Dimensions") + .next() + .should("contain.text", "523 sider"); + }); + + cy.getBySel("material-editions-disclosure").click(); + cy.get(".material-manifestation-item__details").first().click(); + + cy.get('[data-cy="list-description"]').within(() => { + // Verify "Type" field and its value + cy.get(".list-description__item") + .contains("Type") + .next() + .should("contain.text", "bog"); + + // Verify "Language" field and its value + cy.get(".list-description__item") + .contains("Language") + .next() + .should("contain.text", "dansk"); + + // Verify "Genre" field and its value + cy.get(".list-description__item") + .contains("Genre") + .next() + .should("contain.text", "roman / slægtsromaner"); + + // Verify "Contributors" field and its value + cy.get(".list-description__item") + .contains("Contributors") + .next() + .should("contain.text", "Ulla Lauridsen (oversætter)"); + + // Verify "Original title" field and its value + cy.get(".list-description__item") + .contains("Original title") + .next() + .should("contain.text", "The seven sisters"); + + // Verify "ISBN" field and its value + cy.get(".list-description__item") + .contains("ISBN") + .next() + .should("contain.text", "9788763844116"); + + // Verify "Edition" field and its value + cy.get(".list-description__item") + .contains("Edition") + .next() + .should("contain.text", "1. udgave, 2016"); + + // Verify "Scope" field and its value + cy.get(".list-description__item") + .contains("Scope") + .next() + .should("contain.text", "523"); + + // Verify "Publisher" field and its value + cy.get(".list-description__item") + .contains("Publisher") + .next() + .should("contain.text", "Cicero"); + + // Verify "Authors" field and its value + cy.get(".list-description__item") + .contains("Authors") + .next() + .should("contain.text", "Lucinda Riley"); + + // Verify "Dimensions" field and its value + cy.get(".list-description__item") + .contains("Dimensions") + .next() + .should("contain.text", "523 sider"); + + // Verify "Source" field and its value + cy.get(".list-description__item") + .contains("Source") + .next() + .should("contain.text", "Bibliotekskatalog"); + }); + }); + + it("Renders the correct details for infomedia", () => { + cy.interceptGraphql({ + operationName: "getMaterial", + fixtureFilePath: "material/infomedia-fbi-api.json" + }); + + cy.visit( + "/iframe.html?args=&id=apps-material--infomedia&viewMode=story&type=artikel" + ); + cy.wait("@getMaterial GraphQL operation"); + + cy.scrollTo("bottom"); + cy.getBySel("material-details-disclosure").click(); + + cy.get('[data-cy="list-description"]').within(() => { + // Verify "Language" field and its value + cy.get(".list-description__item") + .contains("Language") + .next() + .should("contain.text", "dansk"); + + // Verify "Edition" field and its value + cy.get(".list-description__item") + .contains("Edition") + .next() + .should("contain.text", "2013"); + + // Verify "Type" field and its value + cy.get(".list-description__item") + .contains("Type") + .next() + .should("contain.text", "artikel"); + + // Verify "Scope" field and its value + cy.get(".list-description__item") + .contains("Scope") + .next() + .should("contain.text", "2"); + + // Verify "Dimensions" field and its value + cy.get(".list-description__item") + .contains("Dimensions") + .next() + .should("contain.text", "Sektion 3, s. 6-7: ill."); + + // Verify "Host Publication" field and its value + cy.get(".list-description__item") + .contains("Host Publication") + .next() + .should("contain.text", "Politiken, 2013-09-19"); + }); + }); + + it("Renders the correct details for music", () => { + cy.interceptGraphql({ + operationName: "getMaterial", + fixtureFilePath: "material/music-fbi-api.json" + }); + + cy.visit( + "/iframe.html?args=&id=apps-material--default&viewMode=story&type=musik+%28cd%29" + ); + cy.wait("@getMaterial GraphQL operation"); + + cy.scrollTo("bottom"); + cy.getBySel("material-details-disclosure").click(); + cy.get('[data-cy="list-description"]').within(() => { + // Verify "Publisher" field and its value + cy.get(".list-description__item") + .contains("Publisher") + .next() + .should("contain.text", "Warner Bros."); + + // Verify "Type" field and its value + cy.get(".list-description__item") + .contains("Type") + .next() + .should("contain.text", "musik (cd)"); + + // Verify "Contributors" field and its value + cy.get(".list-description__item") + .contains("Contributors") + .next() + .should( + "contain.text", + "Michael Bruce / Dennis Dunaway / Neal Smith / Glen Buxton" + ); + + // Verify "Dimensions" field and its value + cy.get(".list-description__item") + .contains("Dimensions") + .next() + .should("contain.text", "Stereo"); + + // Verify "Contents" field and its list values + cy.get(".list-description__item") + .contains("Contents") + .next() + .within(() => { + // Validate each list item in "Contents" + const contents = [ + "Hello hooray", + "Raped and freezin'", + "Elected", + "Billion dollar babies", + "Unfinished sweet", + "No more Mr. Nice Guy", + "Generation landslide", + "Sick things", + "Mary Ann", + "I love the dead" + ]; + + contents.forEach((item, index) => { + cy.get(".list-description__value--list li") + .eq(index) + .should("have.text", item); + }); + }); + }); + }); + it("Renders editions with a reservation button", () => { cy.interceptGraphql({ operationName: "getMaterial", diff --git a/src/components/description-list/description-list.tsx b/src/components/description-list/description-list.tsx index 99d1e82a79..f760976482 100644 --- a/src/components/description-list/description-list.tsx +++ b/src/components/description-list/description-list.tsx @@ -12,7 +12,11 @@ const DescriptionList: React.FC = ({ id }) => { return ( -
+
{data.map((item) => { const { label, value } = item; return (