Skip to content

Commit

Permalink
Merge pull request #430 from NYPL/SCC-4142/spec-coll-no-findin
Browse files Browse the repository at this point in the history
Scc 4142/spec coll no findin
  • Loading branch information
charmingduchess authored Jan 3, 2025
2 parents eba37fa + 20c16f5 commit 311be0b
Show file tree
Hide file tree
Showing 17 changed files with 709 additions and 141 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Ticket:

- JIRA ticket [xxx](url)
- JIRA ticket [xxx](https://newyorkpubliclibrary.atlassian.net/browse/SCC-{fill in the ticket number})

## This PR does the following:

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## Added

- ItemAvailability class and updated access messaging

### Updated

- Updated phone, email, notification preference and home library to be individually editable in Account Settings (SCC-4337, SCC-4254, SCC-4253)
Expand Down
1 change: 1 addition & 0 deletions __test__/fixtures/itemFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const itemPhysicallyRequestable = {
prefLabel: "Use in library",
},
],
specialCollections: true,
aeonUrl: [
"https://specialcollections.nypl.org/aeon/Aeon.dll?Action=10&Form=30&Title=Spaghetti+westerns.&Site=LPAMRAMI&CallNumber=*LDC+14245&ItemPlace=[New+York?]+:&ItemPublisher=DRG+Records+Inc.,&Date=p1995.&ItemInfo3=https://catalog.nypl.org/record=b19028235&ReferenceNumber=b190282356&ItemInfo1=USE+IN+LIBRARY&ItemNumber=33433085319782&ItemISxN=i265238791&Genre=Music+CD&Location=Performing+Arts+Music+Division",
],
Expand Down
164 changes: 156 additions & 8 deletions src/components/ItemTable/ItemAvailability.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from "react"
import { render, screen } from "../../utils/testUtils"
import userEvent from "@testing-library/user-event"

import ItemAvailabilityModel from "../../models/ItemAvailability"

import ItemAvailability from "./ItemAvailability"
import Item from "../../models/Item"
import SearchResultsBib from "../../models/SearchResultsBib"
Expand All @@ -17,6 +19,160 @@ import { searchResultPhysicalItems } from "../../../__test__/fixtures/searchResu
const parentBib = new SearchResultsBib(searchResultPhysicalItems)

describe("ItemAvailability", () => {
describe("special collections", () => {
it("edge case", () => {
const item = new Item(itemPhysicallyRequestable, parentBib)
item.availability.key = "edgeCase"
render(<ItemAvailability item={item} />)
expect(screen.getByText("contact a librarian")).toBeInTheDocument()
expect(
screen.queryByText("Available by appointment")
).not.toBeInTheDocument()
expect(screen.queryByRole("link")).not.toBeInTheDocument()
expect(
screen.queryByText("Schwarzman Building - Main Reading Room 315")
).not.toBeInTheDocument()
})
it("onsite YES aeon YES finding aid", () => {
const item = new Item(itemPhysicallyRequestable, parentBib)
item.availability = new ItemAvailabilityModel({
isAvailable: true,
isReCAP: false,
aeonUrl: "spaghetti.com",
findingAid: "meatballs.com",
isSpecRequestable: true,
})
render(<ItemAvailability item={item} />)
expect(screen.getByText("Available by appointment")).toBeInTheDocument()
expect(screen.getByRole("link")).toHaveTextContent(
"Schwarzman Building - Main Reading Room 315"
)
})
it("recap YES aeon YES finding aid", () => {
const item = new Item(itemPhysicallyRequestable, parentBib)
item.availability = new ItemAvailabilityModel({
isAvailable: true,
isReCAP: true,
aeonUrl: "spaghetti.com",
findingAid: "meatballs.com",
isSpecRequestable: true,
})
render(<ItemAvailability item={item} />)
expect(screen.getByText("Available by appointment.")).toBeInTheDocument()
expect(screen.queryByRole("link")).not.toBeInTheDocument()
expect(
screen.queryByText("Schwarzman Building - Main Reading Room 315")
).not.toBeInTheDocument()
})
it("recap YES aeon NO finding aid", () => {
const item = new Item(itemPhysicallyRequestable, parentBib)
item.availability = new ItemAvailabilityModel({
isAvailable: true,
isReCAP: true,
aeonUrl: "spaghetti.com",
findingAid: null,
isSpecRequestable: true,
})
render(<ItemAvailability item={item} />)
expect(screen.getByText("Available by appointment.")).toBeInTheDocument()
expect(screen.queryByRole("link")).not.toBeInTheDocument()
expect(
screen.queryByText("Schwarzman Building - Main Reading Room 315")
).not.toBeInTheDocument()
})
it("onsite YES aeon NO finding aid", () => {
const item = new Item(itemPhysicallyRequestable, parentBib)
item.availability = new ItemAvailabilityModel({
isAvailable: true,
isReCAP: false,
aeonUrl: "spaghetti.com",
findingAid: null,
isSpecRequestable: true,
})
render(<ItemAvailability item={item} />)
expect(screen.getByText("Available by appointment")).toBeInTheDocument()
expect(screen.queryByRole("link")).not.toBeInTheDocument()
expect(
screen.getByText("at Schwarzman Building - Main Reading Room 315.")
).toBeInTheDocument()
})
it("onsite NO aeon YES finding aid", () => {
const item = new Item(itemPhysicallyRequestable, parentBib)
item.availability = new ItemAvailabilityModel({
isAvailable: true,
isReCAP: false,
aeonUrl: null,
findingAid: "meatballs.com",
isSpecRequestable: true,
})
render(<ItemAvailability item={item} />)
expect(screen.getByText("Available by appointment")).toBeInTheDocument()
expect(screen.queryByRole("link")).toHaveTextContent("finding aid")
expect(
screen.getByText(
"at Schwarzman Building - Main Reading Room 315. See the ",
{ exact: false }
)
).toBeInTheDocument()
})
it("recap NO aeon YES finding aid", () => {
const item = new Item(itemPhysicallyRequestable, parentBib)
item.availability = new ItemAvailabilityModel({
isAvailable: true,
isReCAP: true,
aeonUrl: null,
findingAid: "meatballs.com",
isSpecRequestable: true,
})
render(<ItemAvailability item={item} />)
expect(screen.getByText("Available by appointment.")).toBeInTheDocument()
expect(screen.queryByRole("link")).toHaveTextContent("finding aid")
expect(
screen.queryByText("Schwarzman Building - Main Reading Room 315", {
exact: false,
})
).not.toBeInTheDocument()
})
it("recap NO aeon NO finding aid", () => {
const item = new Item(itemPhysicallyRequestable, parentBib)
item.availability = new ItemAvailabilityModel({
isAvailable: true,
isReCAP: true,
aeonUrl: null,
findingAid: null,
isSpecRequestable: true,
})
render(<ItemAvailability item={item} />)
expect(screen.getByText("Available by appointment.")).toBeInTheDocument()
expect(screen.queryByRole("link")).not.toBeInTheDocument()
expect(
screen.queryByText("Schwarzman Building - Main Reading Room 315", {
exact: false,
})
).not.toBeInTheDocument()
expect(screen.getByText("contact a librarian")).toBeInTheDocument()
})
it("onsite NO aeon NO finding aid", () => {
const item = new Item(itemPhysicallyRequestable, parentBib)
item.availability = new ItemAvailabilityModel({
isAvailable: true,
isReCAP: false,
aeonUrl: null,
findingAid: null,
isSpecRequestable: true,
})
render(<ItemAvailability item={item} />)
expect(screen.getByText("Available by appointment")).toBeInTheDocument()
expect(screen.queryByRole("link")).not.toBeInTheDocument()
expect(
screen.queryByText("Schwarzman Building - Main Reading Room 315.", {
exact: false,
})
).toBeInTheDocument()
expect(screen.getByText("contact a librarian")).toBeInTheDocument()
})
})

it("renders the correct link when item is available, is reCAP, and does not have an aeon url", async () => {
const item = new Item(itemNYPLReCAP, parentBib)
render(<ItemAvailability item={item} />)
Expand All @@ -27,14 +183,6 @@ describe("ItemAvailability", () => {
"https://www.nypl.org/help/request-research-materials"
)
})
it("renders the correct text when item is available, has an aeon url, and has a location endpoint", async () => {
const item = new Item(itemPhysicallyRequestable, parentBib)
render(<ItemAvailability item={item} />)
expect(screen.getByText("Available by appointment")).toBeInTheDocument()
expect(
screen.getByText("Schwarzman Building - Main Reading Room 315")
).toHaveAttribute("href", "https://www.nypl.org/locations/schwarzman")
})
it("renders the correct text for an available onsite item", async () => {
const item = new Item(itemAvailableOnsite, parentBib)
render(<ItemAvailability item={item} />)
Expand Down
Loading

0 comments on commit 311be0b

Please sign in to comment.