Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCC-3897 - Search Results Electronic Resources Link #55

Merged
merged 9 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
240 changes: 239 additions & 1 deletion __test__/fixtures/searchResultElectronicResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const searchResultElectronicResources = {
electronicResources: [
{
title: "Access eNYPL",
url: "http://link.overdrive.com/?websiteId=37&titleId=5312492",
url: "https://link.overdrive.com/?websiteId=37&titleId=5312492",
prefLabel: "Access eNYPL",
},
],
Expand Down Expand Up @@ -114,3 +114,241 @@ export const searchResultElectronicResources = {
hasItemVolumes: false,
hasItemDates: false,
}

export const searchResultElectronicResourcesNoLabel = {
"@type": ["nypl:Item", "nypl:Resource"],
"@id": "res:b22133121",
carrierType: [
{
"@id": "carriertypes:nc",
prefLabel: "volume",
},
],
contributorLiteral: [
"Acosta, María",
"Gomez, Vanessa, 1984-",
"OverDrive, Inc.",
],
createdString: ["2019"],
createdYear: 2019,
creatorLiteral: ["Persico, Nicky"],
dateStartYear: 2019,
dateString: ["2019"],
description: [
"Un abogado en prácticas inexperto y un poco torpe se ve involucrado en la defensa de dos mujeres muy diferentes entre ellas por edad y clase social, unidas por el hecho de ser ambas víctimas de la violencia. A partir de aquí se desenmaraña, aderezado por intrigantes mezclas culinarias, un denso entramado de historias y personas que, entre el suspense y la gravedad, se adentra en el fenómeno del acoso y de la manipulación por medio de una sucesión de eventos destinados a revelar una realidad insospechable. En una encantadora Puglia, descripta de manera cuanto menos original, Nicky Persico guía al lector a través de un mundo de individuos peligrosos (enemigos invisibles ante los ojos de todo el mundo, y sin embargo envidiosos de la vida y la vitalidad de las víctimas que persiguen) proponiendo la receta que su protagonista ha ideado para transformar elementos triviales en filosofía de vida: los Spaghetti Paradiso.",
],
electronicResources: [
{
title: "Access eNYPL",
url: "https://link.overdrive.com/?websiteId=37&titleId=5312492",
},
],
extent: [
"1 online resource (1 sound file (06 hr., 55 min., 34 sec.)) : digital",
],
genreForm: ["Audiobooks.", "Fiction."],
idIsbn: ["9788835401155", "8835401151"],
idOclc: ["1144496190"],
identifier: [
{
"@type": "nypl:Bnumber",
"@value": "22133121",
},
{
"@type": "bf:Isbn",
"@value": "9788835401155",
},
{
"@type": "bf:Isbn",
"@value": "8835401151",
},
{
"@type": "nypl:Oclc",
"@value": "1144496190",
},
{
"@type": "nypl:Oclc",
"@value": "1144496190",
},
{
"@type": "bf:Identifier",
"@value": "(OCoLC)1144496190",
},
],
issuance: [
{
"@id": "urn:biblevel:m",
prefLabel: "monograph/item",
},
],
items: [],
language: [
{
"@id": "lang:spa",
prefLabel: "Spanish",
},
],
lccClassification: ["PQ4916.E778 S63 2019"],
materialType: [
{
"@id": "resourcetypes:aud",
prefLabel: "Audio",
},
],
mediaType: [
{
"@id": "mediatypes:n",
prefLabel: "unmediated",
},
],
numAvailable: 0,
numCheckinCardItems: 0,
numElectronicResources: 1,
numItemDatesParsed: 0,
numItemVolumesParsed: 0,
numItems: 0,
numItemsMatched: 0,
numItemsTotal: 0,
nyplSource: ["sierra-nypl"],
placeOfPublication: ["[Solon, Ohio]"],
publicationStatement: ["[Solon, Ohio] : Tektime, 2019."],
publisherLiteral: ["Tektime"],
subjectLiteral: [
"Sexual harassment of women -- Fiction.",
"Sexual harassment of women.",
"Puglia (Italy) -- Fiction.",
"Italy -- Puglia.",
],
title: ["Spaghetti paradiso"],
titleDisplay: [
"Spaghetti paradiso / Nicky Persico ; traducción por: María Acosta.",
],
type: ["nypl:Item"],
updatedAt: 1681346906709,
uri: "b22133121",
suppressed: false,
hasItemVolumes: false,
hasItemDates: false,
}

export const searchResultMultipleElectronicResources = {
"@type": ["nypl:Item", "nypl:Resource"],
"@id": "res:b22133121",
carrierType: [
{
"@id": "carriertypes:nc",
prefLabel: "volume",
},
],
contributorLiteral: [
"Acosta, María",
"Gomez, Vanessa, 1984-",
"OverDrive, Inc.",
],
createdString: ["2019"],
createdYear: 2019,
creatorLiteral: ["Persico, Nicky"],
dateStartYear: 2019,
dateString: ["2019"],
description: [
"Un abogado en prácticas inexperto y un poco torpe se ve involucrado en la defensa de dos mujeres muy diferentes entre ellas por edad y clase social, unidas por el hecho de ser ambas víctimas de la violencia. A partir de aquí se desenmaraña, aderezado por intrigantes mezclas culinarias, un denso entramado de historias y personas que, entre el suspense y la gravedad, se adentra en el fenómeno del acoso y de la manipulación por medio de una sucesión de eventos destinados a revelar una realidad insospechable. En una encantadora Puglia, descripta de manera cuanto menos original, Nicky Persico guía al lector a través de un mundo de individuos peligrosos (enemigos invisibles ante los ojos de todo el mundo, y sin embargo envidiosos de la vida y la vitalidad de las víctimas que persiguen) proponiendo la receta que su protagonista ha ideado para transformar elementos triviales en filosofía de vida: los Spaghetti Paradiso.",
],
electronicResources: [
{
title: "Electronic Resource 1",
url: "https://link.overdrive.com/?websiteId=37&titleId=5312493",
prefLabel: "Electronic Resource 1",
},
{
title: "Access eNYPL",
url: "https://link.overdrive.com/?websiteId=37&titleId=5312494",
prefLabel: "Electronic Resource 2",
},
],
extent: [
"1 online resource (1 sound file (06 hr., 55 min., 34 sec.)) : digital",
],
genreForm: ["Audiobooks.", "Fiction."],
idIsbn: ["9788835401155", "8835401151"],
idOclc: ["1144496190"],
identifier: [
{
"@type": "nypl:Bnumber",
"@value": "22133121",
},
{
"@type": "bf:Isbn",
"@value": "9788835401155",
},
{
"@type": "bf:Isbn",
"@value": "8835401151",
},
{
"@type": "nypl:Oclc",
"@value": "1144496190",
},
{
"@type": "nypl:Oclc",
"@value": "1144496190",
},
{
"@type": "bf:Identifier",
"@value": "(OCoLC)1144496190",
},
],
issuance: [
{
"@id": "urn:biblevel:m",
prefLabel: "monograph/item",
},
],
items: [],
language: [
{
"@id": "lang:spa",
prefLabel: "Spanish",
},
],
lccClassification: ["PQ4916.E778 S63 2019"],
materialType: [
{
"@id": "resourcetypes:aud",
prefLabel: "Audio",
},
],
mediaType: [
{
"@id": "mediatypes:n",
prefLabel: "unmediated",
},
],
numAvailable: 0,
numCheckinCardItems: 0,
numElectronicResources: 1,
numItemDatesParsed: 0,
numItemVolumesParsed: 0,
numItems: 0,
numItemsMatched: 0,
numItemsTotal: 0,
nyplSource: ["sierra-nypl"],
placeOfPublication: ["[Solon, Ohio]"],
publicationStatement: ["[Solon, Ohio] : Tektime, 2019."],
publisherLiteral: ["Tektime"],
subjectLiteral: [
"Sexual harassment of women -- Fiction.",
"Sexual harassment of women.",
"Puglia (Italy) -- Fiction.",
"Italy -- Puglia.",
],
title: ["Spaghetti paradiso"],
titleDisplay: [
"Spaghetti paradiso / Nicky Persico ; traducción por: María Acosta.",
],
type: ["nypl:Item"],
updatedAt: 1681346906709,
uri: "b22133121",
suppressed: false,
hasItemVolumes: false,
hasItemDates: false,
}
1 change: 1 addition & 0 deletions pages/search/advanced.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import type {
SearchFormActionType,
} from "../../src/types/searchTypes"
import { getQueryString } from "../../src/utils/searchUtils"
// import FieldsetDate from "../../src/components/SearchFilters/FieldsetDate"

/**
* The Advanced Search page is responsible for displaying the Advanced Search form fields and
Expand Down
7 changes: 1 addition & 6 deletions src/components/DRB/DRBCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,7 @@ const DRBCard = ({ drbResult }: DRBCardProps) => {
sx={{ display: "flex", alignItems: "center" }}
noSpace
>
<Icon
className="more-link"
name="download"
align="left"
size="small"
/>
<Icon name="download" align="left" size="small" />
Download {drbResult.downloadLink.mediaType || ""}
</Text>
</DSLink>
Expand Down
7 changes: 6 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,8 @@ interface RCLinkProps {
children: ReactNode
className?: string
color?: string
type?: LinkTypes
size?: string
}

/**
Expand Down
72 changes: 72 additions & 0 deletions src/components/SearchResult/ElectronicResourcesLink.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from "react"
import { render, screen } from "@testing-library/react"
import ElectronicResourcesLink from "./ElectronicResourcesLink"
import SearchResultsBib from "../../models/SearchResultsBib"
import {
searchResultElectronicResources,
searchResultElectronicResourcesNoLabel,
searchResultMultipleElectronicResources,
} from "../../../__test__/fixtures/searchResultElectronicResources"

describe("Electronic Resources Link with a single resource", () => {
beforeEach(() => {
const bib = new SearchResultsBib(searchResultElectronicResources)
render(
<ElectronicResourcesLink
bibUrl={bib.url}
electronicResources={bib.electronicResources}
/>
)
})

it("renders the correct heading", async () => {
expect(screen.getByRole("heading", { level: 4 })).toHaveTextContent(
"Available Online"
)
})
it("renders the correct link with the label as the text when only one electronic resource is available", async () => {
const link = screen.getByRole("link", {
name: "Access eNYPL",
})
expect(link).toHaveAttribute(
"href",
"https://link.overdrive.com/?websiteId=37&titleId=5312492"
)
})
})

describe("Electronic Resources Link with a single resource and no label", () => {
it("renders the correct link with the url as the text when prefLabel is not available", async () => {
const bib = new SearchResultsBib(searchResultElectronicResourcesNoLabel)
render(
<ElectronicResourcesLink
bibUrl={bib.url}
electronicResources={bib.electronicResources}
/>
)
const link = screen.getByRole("link", {
name: "https://link.overdrive.com/?websiteId=37&titleId=5312492",
})
expect(link).toHaveAttribute(
"href",
"https://link.overdrive.com/?websiteId=37&titleId=5312492"
)
})
})

describe("Electronic Resources Link with multiple resources", () => {
it("renders a link to the bib page when multiple resources are available", async () => {
const bib = new SearchResultsBib(searchResultMultipleElectronicResources)
render(
<ElectronicResourcesLink
bibUrl={bib.url}
electronicResources={bib.electronicResources}
/>
)

const link = screen.getByRole("link", {
name: "See All Available Online Resources",
})
expect(link).toHaveAttribute("href", "/bib/b22133121#electronic-resources")
})
})
Loading