Skip to content

Commit

Permalink
Merge pull request #56 from NYPL/SCC-3898/search-results-view-all-link
Browse files Browse the repository at this point in the history
SCC-0898 - Search Results View All Link
  • Loading branch information
dgcohen authored Dec 12, 2023
2 parents e7acb96 + 69808b4 commit 424f107
Show file tree
Hide file tree
Showing 4 changed files with 360 additions and 3 deletions.
323 changes: 323 additions & 0 deletions __test__/fixtures/searchResultManyPhysicalItems.ts
Original file line number Diff line number Diff line change
@@ -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,
}
6 changes: 5 additions & 1 deletion src/components/RCLink/RCLink.tsx
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -8,6 +11,7 @@ interface RCLinkProps {
children: ReactNode
className?: string
color?: string
type?: LinkTypes
hasWhiteFocusRing?: boolean
}

Expand Down
21 changes: 21 additions & 0 deletions src/components/SearchResult/SearchResult.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -26,6 +28,25 @@ describe("SearchResult with Physical Items", () => {
})
})

describe("SearchResult with Many Physical Items", () => {
beforeEach(() => {
const bib = new SearchResultsBib(
searchResultManyPhysicalItems as SearchResultType
)
render(<SearchResult bib={bib} />)
})

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)
Expand Down
Loading

0 comments on commit 424f107

Please sign in to comment.