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 4142/spec coll no findin #430

Merged
merged 44 commits into from
Jan 3, 2025

Conversation

charmingduchess
Copy link
Contributor

@charmingduchess charmingduchess commented Jan 2, 2025

Ticket:

This PR does the following:

  • Add special collections messaging to the item tables
  • create new item Availability model to handle logic

How has this been tested?

unit tests and visual verification

Accessibility concerns or updates

Checklist:

  • I updated the CHANGELOG with the appropriate information and JIRA ticket number (if applicable).
  • I have added relevant accessibility documentation for this pull request.
  • All new and existing tests passed.

Copy link

vercel bot commented Jan 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
research-catalog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 3, 2025 8:48pm

@charmingduchess charmingduchess changed the base branch from main to special-collections January 2, 2025 16:27
@@ -1,6 +1,7 @@
## Ticket:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm down with this change, but did you mean to put this outside the parens?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't push up the final update to this! yes it should be

case RECAP_AEON:
case RECAP_AEON_FINDING_AID:
message = (
<>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nit: fragment isn't needed here

case EDGE_CASE:
message = <ContactALibrarian item={itemMetadata} />
break
case RECAP_AEON:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this case meant to be blank?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not blank, it is combined with the one after it


const AvailableByAppointment = ({ displayPeriod = false }) => {
return (
<>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nit: fragment isn't needed here

@@ -134,3 +134,22 @@ export const NYPL_LOCATIONS = {
address: "476 Fifth Avenue (42nd St and Fifth Ave)",
},
}

export const availabilityKeys = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very small nit: I know we haven't settled on naming conventions yet but can you rename to AVAILABILITY_KEYS to match the other constants?

@dgcohen
Copy link
Contributor

dgcohen commented Jan 2, 2025

will re-review once the last test is fixed, but looks good! just added some small nitpicky comments.

Copy link
Member

@EdwinGuzman EdwinGuzman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a few questions/comments.

@@ -13,10 +15,153 @@ import {
itemUnavailable,
} from "../../../__test__/fixtures/itemFixtures"
import { searchResultPhysicalItems } from "../../../__test__/fixtures/searchResultPhysicalItems"
import { notDeepEqual } from "assert"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used, remove it.

screen.queryByText("Schwarzman Building - Main Reading Room 315")
).not.toBeInTheDocument()
})
it("recap aeon", () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a "NO finding aid" in the next test. This test also doesn't have a finding aid, right? If that's right add the same text here.

})
render(<ItemAvailability item={item} />)
expect(screen.getByText("Available by appointment")).toBeInTheDocument()
expect(screen.getByRole("link")).toHaveTextContent(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the example for this case: https://research-catalog-git-scc-4142-spec-coll-messaging-nypl.vercel.app/research/research-catalog/bib/b17058276 (row 8 of spreadsheet). There should be no link but this test does have a link and it passes. Or am I missing something?

import { appConfig } from "../../../config/config"
import ExternalLink from "../../Links/ExternalLink/ExternalLink"

const AvailableByAppointment = ({ displayPeriod = false }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice way of solving sentence structure through react components.


const AvailableAt = ({ location }) => {
if (!location?.endpoint) return null
else return <> {` at ${location.prefLabel}. `}</>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you don't need a return since it will always go to this case if the statement above fails.

const ContactALibrarian = ({
item,
}: {
item: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary but just showing another way to type this. This is derived from the Item class when it's used as a class. You should be able to do Pick<Item, "id" | "barcode" | "callNumber" | "bibId">.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also reuse it in NotAvailable if you give this its own name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats a good pattern to keep in mind! i kept going back and forth between passing the whole item and just the needed properties. Pick would have been useful.


export const availabilityKeys = {
// anything not covered by the cases below is EDGE_CASE
EDGE_CASE: "edgeCase",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for this?

Copy link
Contributor Author

@charmingduchess charmingduchess Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't actually know that this case is possible, so I contrived it in the test as item.availability.key = "edgeCase"

describe("special collections", () => {
it("onsite aeon finding aid", () => {
const item = new Item(itemPhysicallyRequestable, parentBib)
item.availability = new ItemAvailabilityModel({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets called automatically in Item when it's initialized. Are you doing it here just for the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea I put in in here so it would be explicit per test exactly what case was being tested. i find it messy and hard to maintain specific actual fixtures for all these different cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose I could have just updated item.availabilty.key explicitly for each one.

screen.queryByText("Schwarzman Building - Main Reading Room 315")
).not.toBeInTheDocument()
})
it("recap YES aeon NO finding ait", () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: typo "ait"

@charmingduchess charmingduchess merged commit 311be0b into special-collections Jan 3, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants