diff --git a/__test__/fixtures/searchResultManyPhysicalItems.ts b/__test__/fixtures/searchResultManyPhysicalItems.ts new file mode 100644 index 000000000..0d7ac0a19 --- /dev/null +++ b/__test__/fixtures/searchResultManyPhysicalItems.ts @@ -0,0 +1,323 @@ +export const searchResultManyPhysicalItems = { + "@type": ["nypl:Item", "nypl:Resource"], + "@id": "res:b14753192", + carrierType: [ + { + "@id": "carriertypes:nc", + prefLabel: "volume", + }, + ], + createdString: ["190"], + createdYear: 190, + dateStartYear: 190, + dateString: ["190"], + dimensions: ["20 cm."], + electronicResources: [], + extent: ["18 p. : col. ill. ;"], + identifier: [ + { + "@type": "bf:ShelfMark", + "@value": "*ZO-*OSH p.v. 3, no. 2", + }, + { + "@type": "nypl:Bnumber", + "@value": "14753192", + }, + { + "@type": "bf:Identifier", + "@value": "(WaOLN)R310002230", + }, + ], + issuance: [ + { + "@id": "urn:biblevel:m", + prefLabel: "monograph/item", + }, + ], + items: [ + { + "@id": "res:i14507546", + accessMessage: [ + { + "@id": "accessMessage:4", + prefLabel: "Restricted use", + }, + ], + catalogItemType: [ + { + "@id": "catalogItemType:2", + prefLabel: "book non-circ", + }, + ], + eddRequestable: false, + holdingLocation: [ + { + "@id": "loc:macc2", + prefLabel: "Schwarzman Building - Arents Collection Room 328", + endpoint: "schwarzman", + }, + ], + identifier: [ + { + "@type": "bf:ShelfMark", + "@value": "Arents BIP (Hearn. Japanese) AL 04-11 [Text]", + }, + ], + owner: [ + { + "@id": "orgs:1109", + prefLabel: "George Arents Collection", + }, + ], + physRequestable: false, + physicalLocation: ["Arents BIP (Hearn. Japanese) AL 04-11 [Text]"], + requestable: [false], + shelfMark: ["Arents BIP (Hearn. Japanese) AL 04-11 [Text]"], + specRequestable: false, + status: [ + { + "@id": "status:a", + prefLabel: "Available", + }, + ], + uri: "i14507546", + idNyplSourceId: { + "@type": "SierraNypl", + "@value": "14507546", + }, + }, + { + "@id": "res:i14507545", + accessMessage: [ + { + "@id": "accessMessage:p", + prefLabel: "Permit needed", + }, + ], + catalogItemType: [ + { + "@id": "catalogItemType:6", + prefLabel: "microfilm service copy", + }, + ], + eddRequestable: false, + holdingLocation: [ + { + "@id": "loc:mai82", + prefLabel: "Schwarzman Building M1 - Microforms Room 315", + endpoint: "schwarzman", + }, + ], + identifier: [ + { + "@type": "bf:ShelfMark", + "@value": "*ZO-*OSH p.v. 3, no. 2", + }, + ], + owner: [ + { + "@id": "orgs:1101", + prefLabel: "General Research Division", + }, + ], + physRequestable: false, + physicalLocation: ["*ZO-*OSH p.v. 3, no. 2"], + requestable: [false], + shelfMark: ["*ZO-*OSH p.v. 3, no. 2"], + specRequestable: false, + status: [ + { + "@id": "status:a", + prefLabel: "Available", + }, + ], + uri: "i14507545", + idNyplSourceId: { + "@type": "SierraNypl", + "@value": "14507545", + }, + }, + { + "@id": "res:i14507543", + accessMessage: [ + { + "@id": "accessMessage:p", + prefLabel: "Permit needed", + }, + ], + catalogItemType: [ + { + "@id": "catalogItemType:6", + prefLabel: "microfilm service copy", + }, + ], + eddRequestable: true, + holdingLocation: [ + { + "@id": "loc:rcmi2", + prefLabel: "Offsite", + }, + ], + idBarcode: ["33433105668333"], + identifier: [ + { + "@type": "bf:ShelfMark", + "@value": "*ZO-*OSH p.v. 3, no. 1", + }, + { + "@type": "bf:Barcode", + "@value": "33433105668333", + }, + ], + owner: [ + { + "@id": "orgs:1000", + prefLabel: "Stephen A. Schwarzman Building", + }, + ], + physRequestable: true, + physicalLocation: ["*ZO-*OSH p.v. 3, no. 1"], + recapCustomerCode: ["NA"], + requestable: [true], + shelfMark: ["*ZO-*OSH p.v. 3, no. 1"], + specRequestable: false, + status: [ + { + "@id": "status:a", + prefLabel: "Available", + }, + ], + uri: "i14507543", + idNyplSourceId: { + "@type": "SierraNypl", + "@value": "14507543", + }, + }, + { + "@id": "res:i30068374", + accessMessage: [ + { + "@id": "accessMessage:2", + prefLabel: "Request in advance", + }, + ], + catalogItemType: [ + { + "@id": "catalogItemType:6", + prefLabel: "microfilm service copy", + }, + ], + eddRequestable: true, + enumerationChronology: ["*OSH p.v. 1-2"], + holdingLocation: [ + { + "@id": "loc:rcmi2", + prefLabel: "Offsite", + }, + ], + idBarcode: ["33433105668325"], + identifier: [ + { + "@type": "bf:ShelfMark", + "@value": "*ZO-*OSH p.v. 1, no. 1 *OSH p.v. 1-2", + }, + { + "@type": "bf:Barcode", + "@value": "33433105668325", + }, + ], + owner: [ + { + "@id": "orgs:1000", + prefLabel: "Stephen A. Schwarzman Building", + }, + ], + physRequestable: true, + physicalLocation: ["*ZO-*OSH p.v. 1, no. 1"], + recapCustomerCode: ["NA"], + requestable: [true], + shelfMark: ["*ZO-*OSH p.v. 1, no. 1 *OSH p.v. 1-2"], + specRequestable: false, + status: [ + { + "@id": "status:a", + prefLabel: "Available", + }, + ], + uri: "i30068374", + idNyplSourceId: { + "@type": "SierraNypl", + "@value": "30068374", + }, + }, + ], + language: [ + { + "@id": "lang:eng", + prefLabel: "English", + }, + ], + materialType: [ + { + "@id": "resourcetypes:txt", + prefLabel: "Text", + }, + ], + mediaType: [ + { + "@id": "mediatypes:n", + prefLabel: "unmediated", + }, + ], + note: [ + { + noteType: "Note", + "@type": "bf:Note", + prefLabel: "Cover title.", + }, + { + noteType: "Note", + "@type": "bf:Note", + prefLabel: "Printed on double leaves folded in Japanese fashion.", + }, + { + noteType: "Note", + "@type": "bf:Note", + prefLabel: "Name of second publisher from stamp on t.p. verso.", + }, + { + noteType: "Indexed In", + "@type": "bf:Note", + prefLabel: "BAL", + }, + { + noteType: "Reproduction", + "@type": "bf:Note", + prefLabel: "Microfilm.", + }, + ], + numAvailable: 4, + numElectronicResources: 0, + numItems: 4, + numItemsMatched: 4, + numItemsTotal: 4, + nyplSource: ["sierra-nypl"], + placeOfPublication: ["Tokyo : [London] :"], + publicationStatement: [ + "Tokyo : T. Hasegawa ; [London] : Martin Hopkinson & Co., [190-?]", + ], + publisherLiteral: ["T. Hasegawa ; Martin Hopkinson & Co.,"], + shelfMark: ["*ZO-*OSH p.v. 3, no. 2"], + subjectLiteral: ["Fairy tales -- Japan."], + title: ["The boy who drew cats [microform]"], + titleAlt: ["Japanese fairy tale"], + titleDisplay: [ + "The boy who drew cats [microform] / rendered into English, by Lafcadio Hearn.", + ], + type: ["nypl:Item"], + updatedAt: 1636582835709, + uri: "b14753192", + suppressed: false, + hasItemVolumes: false, + hasItemDates: false, +} diff --git a/src/components/RCLink/RCLink.tsx b/src/components/RCLink/RCLink.tsx index 0cfb2817e..25eb57222 100644 --- a/src/components/RCLink/RCLink.tsx +++ b/src/components/RCLink/RCLink.tsx @@ -1,4 +1,7 @@ -import { Link as DSLink } from "@nypl/design-system-react-components" +import { + Link as DSLink, + type LinkTypes, +} from "@nypl/design-system-react-components" import Link from "next/link" import { type ReactNode } from "react" @@ -8,6 +11,7 @@ interface RCLinkProps { children: ReactNode className?: string color?: string + type?: LinkTypes hasWhiteFocusRing?: boolean } diff --git a/src/components/SearchResult/SearchResult.test.tsx b/src/components/SearchResult/SearchResult.test.tsx index 7aa4f3de4..e72db6202 100644 --- a/src/components/SearchResult/SearchResult.test.tsx +++ b/src/components/SearchResult/SearchResult.test.tsx @@ -3,7 +3,9 @@ import { render, screen } from "@testing-library/react" import SearchResult from "./SearchResult" import SearchResultsBib from "../../models/SearchResultsBib" import { searchResultPhysicalItems } from "../../../__test__/fixtures/searchResultPhysicalItems" +import { searchResultManyPhysicalItems } from "../../../__test__/fixtures/searchResultManyPhysicalItems" import { searchResultElectronicResources } from "../../../__test__/fixtures/searchResultElectronicResources" +import type { SearchResult as SearchResultType } from "../../types/searchTypes" describe("SearchResult with Physical Items", () => { beforeEach(() => { @@ -26,6 +28,25 @@ describe("SearchResult with Physical Items", () => { }) }) +describe("SearchResult with Many Physical Items", () => { + beforeEach(() => { + const bib = new SearchResultsBib( + searchResultManyPhysicalItems as SearchResultType + ) + render() + }) + + it("renders a link to the bib page with the correct text when there are more than the set limit of items per search result", async () => { + const resultTitleLink = screen.getByRole("link", { + name: "View All 4 Items", + }) + expect(resultTitleLink).toHaveAttribute( + "href", + "/bib/b14753192#items-table" + ) + }) +}) + describe("SearchResult with Electronic Resources", () => { it("renders the correct item message for bib with electronic resources", async () => { const bib = new SearchResultsBib(searchResultElectronicResources) diff --git a/src/components/SearchResult/SearchResult.tsx b/src/components/SearchResult/SearchResult.tsx index 0d5fbe2a5..78bd28fe4 100644 --- a/src/components/SearchResult/SearchResult.tsx +++ b/src/components/SearchResult/SearchResult.tsx @@ -4,11 +4,12 @@ import { CardHeading, Box, Text, + CardActions, } from "@nypl/design-system-react-components" import RCLink from "../RCLink/RCLink" import type SearchResultsBib from "../../models/SearchResultsBib" -import { PATHS } from "../../config/constants" +import { PATHS, ITEMS_PER_SEARCH_RESULT } from "../../config/constants" interface SearchResultProps { bib: SearchResultsBib @@ -29,12 +30,20 @@ const SearchResult = ({ bib }: SearchResultProps) => { {bib.title} - + {bib.materialType && {bib.materialType}} {bib.publicationStatement && {bib.publicationStatement}} {bib.yearPublished && {bib.yearPublished}} {bib.itemMessage} + {/* Move the code block below to the conditional for rendering the Item Table */} + {bib.numPhysicalItems > ITEMS_PER_SEARCH_RESULT && ( + + + {`View All ${bib.itemMessage} `} + + + )} )