From b6988a2955fd8dc66e3a0fcd15ad46a37ae6a5c4 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 25 Nov 2024 13:25:06 -0500 Subject: [PATCH 01/29] start adding advnaced search text inputs --- __test__/helpers/searchHelpers.js | 2 ++ pages/search/advanced.tsx | 1 - src/server/api/search.ts | 2 -- src/types/searchTypes.ts | 6 +++- src/utils/advancedSearchUtils.ts | 4 +++ src/utils/searchUtils.ts | 44 ++++++++++++++---------- src/utils/utilsTests/searchUtils.test.ts | 2 +- 7 files changed, 37 insertions(+), 24 deletions(-) diff --git a/__test__/helpers/searchHelpers.js b/__test__/helpers/searchHelpers.js index 72dfcb908..356ff7c43 100644 --- a/__test__/helpers/searchHelpers.js +++ b/__test__/helpers/searchHelpers.js @@ -11,6 +11,8 @@ export const queryParamsEquality = (queryConstructor) => { const constructedQueries = queryConstructor(queryParamsToConstruct) .substring(1) .split("&") + console.log(constructedQueries) + console.log(testQueries) return ( testQueries.every((queryParam) => constructedQueries.includes(queryParam) diff --git a/pages/search/advanced.tsx b/pages/search/advanced.tsx index d1d4130aa..60945b4cb 100644 --- a/pages/search/advanced.tsx +++ b/pages/search/advanced.tsx @@ -85,7 +85,6 @@ export default function AdvancedSearch({ e.preventDefault() alert && setAlert(false) const target = e.target as HTMLInputElement - dispatch({ type: type, field: target.name, diff --git a/src/server/api/search.ts b/src/server/api/search.ts index 16a3d7bca..b9d475ecc 100644 --- a/src/server/api/search.ts +++ b/src/server/api/search.ts @@ -38,7 +38,6 @@ export async function fetchResults( ...journalParams, q: keywordsOrBibId, } - let queryString = getSearchQuery(modifiedSearchParams) // Fall back to a single "?" in the case of an empty query @@ -55,7 +54,6 @@ export async function fetchResults( // - drb results const client = await nyplApiClient({ apiName: DISCOVERY_API_NAME }) const drbClient = await nyplApiClient({ apiName: DRB_API_NAME }) - const [resultsResponse, aggregationsResponse, drbResultsResponse] = await Promise.allSettled([ client.get(`${DISCOVERY_API_SEARCH_ROUTE}${resultsQuery}`), diff --git a/src/types/searchTypes.ts b/src/types/searchTypes.ts index 2cf22674e..92ff5c8c5 100644 --- a/src/types/searchTypes.ts +++ b/src/types/searchTypes.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import type { DiscoveryBibResult } from "./bibTypes" import type { DRBResults } from "./drbTypes" import type { Aggregation } from "./filterTypes" @@ -38,10 +39,11 @@ export interface SearchParams { contributor?: string title?: string journalTitle?: string - standardNumber?: string + standard_number?: string subject?: string page?: number identifiers?: Identifiers + callnumber?: string } export type SortKey = "relevance" | "title" | "date" @@ -90,6 +92,8 @@ export interface SearchFormAction { export interface SearchQueryParams extends Identifiers { q?: string + callnumber?: string + standard_number?: string contributor?: string title?: string subject?: string diff --git a/src/utils/advancedSearchUtils.ts b/src/utils/advancedSearchUtils.ts index 0ab01474e..43eb57ff4 100644 --- a/src/utils/advancedSearchUtils.ts +++ b/src/utils/advancedSearchUtils.ts @@ -7,6 +7,8 @@ export const textInputFields: SearchFormInputField[] = [ { name: "title", label: "Title" }, { name: "contributor", label: "Author" }, { name: "subject", label: "Subject" }, + { name: "callnumber", label: "Call number" }, + { name: "standard_number", label: "Unique identifier" }, ] export const initialSearchFormState: SearchParams = { @@ -14,6 +16,8 @@ export const initialSearchFormState: SearchParams = { title: "", contributor: "", subject: "", + callnumber: "", + standard_number: "", filters: { language: "", dateBefore: "", diff --git a/src/utils/searchUtils.ts b/src/utils/searchUtils.ts index 1f2605b98..4623f4716 100644 --- a/src/utils/searchUtils.ts +++ b/src/utils/searchUtils.ts @@ -1,6 +1,9 @@ import { isArray, isEmpty, mapObject, forEach } from "underscore" -import { textInputFields as advSearchFields } from "./advancedSearchUtils" +import { + textInputFields as advSearchFields, + textInputFields, +} from "./advancedSearchUtils" import type { SearchParams, SearchQueryParams, @@ -190,18 +193,16 @@ function getFilterQuery(filters: SearchFilters) { * getSearchQuery * Builds a query string from a SearchParams object */ -export function getSearchQuery({ - sortBy = "relevance", - field = "all", - order, - filters = {}, - identifiers = {}, - q, - contributor, - title, - subject, - page = 1, -}: SearchParams): string { +export function getSearchQuery(params: SearchParams): string { + const { + sortBy = "relevance", + field = "all", + order, + filters = {}, + identifiers = {}, + q, + page = 1, + } = params const searchKeywordsQuery = encodeURIComponent(q) const sortQuery = getSortQuery(sortBy, order) @@ -210,21 +211,24 @@ export function getSearchQuery({ const identifierQuery = getIdentifierQuery(identifiers) const pageQuery = page !== 1 ? `&page=${page}` : "" - // advanced search query - const contributorQuery = contributor ? `&contributor=${contributor}` : "" - const titleQuery = title ? `&title=${title}` : "" - const subjectQuery = subject ? `&subject=${subject}` : "" + const advancedSearchQueryParams = textInputFields + .map(({ name: advancedSearchParam }) => { + if (advancedSearchParam === "q") return + return params[advancedSearchParam] + ? `&${advancedSearchParam}=${params[advancedSearchParam]}` + : "" + }) + .join("") // if a search_scope is "all", we want to clear the advanced search query params // and default to the q param const isAdvancedSearchOrAllFields = field.length && field === "all" const advancedQuery = isAdvancedSearchOrAllFields - ? `${contributorQuery}${titleQuery}${subjectQuery}` + ? advancedSearchQueryParams : "" const completeQuery = `${searchKeywordsQuery}${advancedQuery}${filterQuery}${sortQuery}${fieldQuery}${pageQuery}${identifierQuery}` - return completeQuery?.length ? `?q=${completeQuery}` : "" } @@ -303,6 +307,8 @@ export function mapQueryToSearchParams({ search_scope, sort_direction, page, + callnumber, + standard_number, contributor, title, subject, diff --git a/src/utils/utilsTests/searchUtils.test.ts b/src/utils/utilsTests/searchUtils.test.ts index f185499b9..6bb0cc9d7 100644 --- a/src/utils/utilsTests/searchUtils.test.ts +++ b/src/utils/utilsTests/searchUtils.test.ts @@ -50,7 +50,7 @@ describe("searchUtils", () => { }) ).toBe(true) }) - it("includes advanced search query params when field is set to 'all'", () => { + it.only("includes advanced search query params when field is set to 'all'", () => { const testQuery = "?q=shel%20silverstein&contributor=shel silverstein&title=the giving tree&subject=books" expect( From 10e45dc5191b354a1ad69afd19515aa92e3d4100 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 25 Nov 2024 13:44:55 -0500 Subject: [PATCH 02/29] add callnumber and standard number --- src/utils/searchUtils.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/searchUtils.ts b/src/utils/searchUtils.ts index 4623f4716..52db9e53d 100644 --- a/src/utils/searchUtils.ts +++ b/src/utils/searchUtils.ts @@ -326,6 +326,8 @@ export function mapQueryToSearchParams({ q, field: search_scope, page: page ? parseInt(page) : 1, + callnumber, + standard_number, contributor, title, subject, From 0268170509d1d42a7f1b02d0d798080f89d5ffd8 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 25 Nov 2024 15:53:54 -0500 Subject: [PATCH 03/29] update changelog --- CHANGELOG | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index f9bfe434a..af6af399a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,10 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +### Updated + +- add call number and standard numbers to advanced search ([SCC-4326](https://newyorkpubliclibrary.atlassian.net/browse/SCC-4326)) + ### [1.3.7] Hotfix 2024-11-21 - Fix analytics bug where routes without a query string do not emit the correct virtual page view event (SCC-4314) +## Prerelease + ## [1.3.6] 2024-11-6 ## Added From 4e270a4ada338abae67349d96369a59f1b2d5301 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 25 Nov 2024 15:57:03 -0500 Subject: [PATCH 04/29] rm console.logs --- __test__/helpers/searchHelpers.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/__test__/helpers/searchHelpers.js b/__test__/helpers/searchHelpers.js index 356ff7c43..72dfcb908 100644 --- a/__test__/helpers/searchHelpers.js +++ b/__test__/helpers/searchHelpers.js @@ -11,8 +11,6 @@ export const queryParamsEquality = (queryConstructor) => { const constructedQueries = queryConstructor(queryParamsToConstruct) .substring(1) .split("&") - console.log(constructedQueries) - console.log(testQueries) return ( testQueries.every((queryParam) => constructedQueries.includes(queryParam) From 0904d3e98ffc52a20619be7ac17aa45c3c4ad2b1 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 25 Nov 2024 16:02:30 -0500 Subject: [PATCH 05/29] extract advancedsearchquery type --- src/types/searchTypes.ts | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/src/types/searchTypes.ts b/src/types/searchTypes.ts index 92ff5c8c5..ee09e414d 100644 --- a/src/types/searchTypes.ts +++ b/src/types/searchTypes.ts @@ -30,27 +30,20 @@ export interface Identifiers { lccn?: string } -export interface SearchParams { +export interface SearchParams extends AdvancedSearchQueryParams { q?: string field?: string sortBy?: SortKey order?: SortOrder filters?: SearchFilters - contributor?: string - title?: string journalTitle?: string - standard_number?: string - subject?: string page?: number identifiers?: Identifiers - callnumber?: string } export type SortKey = "relevance" | "title" | "date" export type SortOrder = "asc" | "desc" -type SearchFormField = { value: string } - export interface SearchResultsResponse { results?: SearchResults aggregations?: AggregationResults @@ -88,29 +81,22 @@ export interface SearchFormAction { payload: SearchParams | SearchFilters | string | string[] } -/* eslint-disable @typescript-eslint/naming-convention */ - -export interface SearchQueryParams extends Identifiers { - q?: string +export interface AdvancedSearchQueryParams { callnumber?: string standard_number?: string contributor?: string title?: string subject?: string +} + +/* eslint-disable @typescript-eslint/naming-convention */ + +export interface SearchQueryParams + extends Identifiers, + AdvancedSearchQueryParams { + q?: string sort?: SortKey sort_direction?: SortOrder search_scope?: string page?: string } - -export interface SearchFormEvent { - q?: SearchFormField - search_scope?: SearchFormField - title?: SearchFormField - contributor?: SearchFormField - subject?: SearchFormField - language?: SearchFormField - dateBefore?: SearchFormField - dateAfter?: SearchFormField - materialType?: SearchFormField -} From 55c3d6015eb087be2a5e3197aaad3ee67b9e0959 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 25 Nov 2024 16:11:55 -0500 Subject: [PATCH 06/29] add todo --- src/utils/searchUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/searchUtils.ts b/src/utils/searchUtils.ts index 52db9e53d..841484e6e 100644 --- a/src/utils/searchUtils.ts +++ b/src/utils/searchUtils.ts @@ -321,7 +321,7 @@ export function mapQueryToSearchParams({ }: SearchQueryParams): SearchParams { const hasIdentifiers = issn || isbn || oclc || lccn const filters = collapseMultiValueQueryParams(queryFilters) - + //TODO: can we merge the SearchQueryParams and SearchParams types by renaming some params? e.g. search_scope, sort, sort_direction. Also maybe passing in identifiers so it maches this pattern. return { q, field: search_scope, From 8032b2a8dacc5baa6eb6fd1301d84b651a99e797 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 25 Nov 2024 16:14:08 -0500 Subject: [PATCH 07/29] rm only --- src/utils/utilsTests/searchUtils.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/utilsTests/searchUtils.test.ts b/src/utils/utilsTests/searchUtils.test.ts index 6bb0cc9d7..f185499b9 100644 --- a/src/utils/utilsTests/searchUtils.test.ts +++ b/src/utils/utilsTests/searchUtils.test.ts @@ -50,7 +50,7 @@ describe("searchUtils", () => { }) ).toBe(true) }) - it.only("includes advanced search query params when field is set to 'all'", () => { + it("includes advanced search query params when field is set to 'all'", () => { const testQuery = "?q=shel%20silverstein&contributor=shel silverstein&title=the giving tree&subject=books" expect( From 28281988811469c5d05a99db4163755cea5716a3 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Tue, 26 Nov 2024 09:59:17 -0500 Subject: [PATCH 08/29] add flex grow --- pages/search/advanced.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/search/advanced.tsx b/pages/search/advanced.tsx index 60945b4cb..f2f485035 100644 --- a/pages/search/advanced.tsx +++ b/pages/search/advanced.tsx @@ -163,7 +163,7 @@ export default function AdvancedSearch({ onSubmit={handleSubmit} > - + {textInputFields.map(({ name, label }) => { return ( @@ -200,7 +200,7 @@ export default function AdvancedSearch({ {} - + Date: Tue, 26 Nov 2024 10:00:42 -0500 Subject: [PATCH 09/29] rm extra es lint disable --- src/types/searchTypes.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/types/searchTypes.ts b/src/types/searchTypes.ts index ee09e414d..482c9d1ea 100644 --- a/src/types/searchTypes.ts +++ b/src/types/searchTypes.ts @@ -89,8 +89,6 @@ export interface AdvancedSearchQueryParams { subject?: string } -/* eslint-disable @typescript-eslint/naming-convention */ - export interface SearchQueryParams extends Identifiers, AdvancedSearchQueryParams { From 7b69392c168a17acf8595c2ef1069bceaba6d424 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Tue, 26 Nov 2024 13:42:33 -0500 Subject: [PATCH 10/29] test wip --- .../pages/search/advancedSearchForm.test.tsx | 52 ++++++++++--------- pages/search/advanced.tsx | 1 - 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/__test__/pages/search/advancedSearchForm.test.tsx b/__test__/pages/search/advancedSearchForm.test.tsx index b07ec4842..7b734925c 100644 --- a/__test__/pages/search/advancedSearchForm.test.tsx +++ b/__test__/pages/search/advancedSearchForm.test.tsx @@ -1,5 +1,10 @@ import React from "react" -import { fireEvent, render, screen } from "../../../src/utils/testUtils" +import { + fireEvent, + render, + screen, + waitFor, +} from "../../../src/utils/testUtils" import mockRouter from "next-router-mock" import userEvent from "@testing-library/user-event" @@ -31,30 +36,29 @@ describe("Advanced Search Form", () => { // this functionality works in the browser, but won't include // final input in output string in test. the broken test is // commented out below. - it.todo("can set keyword, contributor, title, subject") - // async () => { - // render() + it("can set keyword, contributor, title, subject", async () => { + render() + + const [keywordInput, contributorInput, titleInput, subjectInput] = [ + "Keyword", + "Title", + "Author", + "Subject", + "Call number", + "Unique identifier", + ].map((field) => screen.getByLabelText(field)) + fireEvent.change(subjectInput, { target: { value: "italian food" } }) + fireEvent.change(keywordInput, { target: { value: "spaghetti" } }) + fireEvent.change(contributorInput, { target: { value: "strega nonna" } }) + fireEvent.change(titleInput, { target: { value: "il amore di pasta" } }) + submit() + await waitFor(() => + expect(mockRouter.asPath).toBe( + "/search?q=spaghetti&contributor=il+amore+di+pasta&title=strega+nonna&subject=italian+food" + ) + ) + }) - // const [keywordInput, contributorInput, titleInput, subjectInput] = [ - // "Keywords", - // "Title", - // "Author", - // "Subject", - // ].map((field) => screen.getByLabelText(field)) - // await act(async () => { - // await userEvent.type(subjectInput, "italian food") - // await userEvent.type(keywordInput, "spaghetti") - // await userEvent.type(contributorInput, "strega nonna") - // await userEvent.type(titleInput, "il amore di pasta") - // // this set stimeout is to ad - // // eslint-disable-next-line @typescript-eslint/no-empty-function - // setTimeout(() => {}, 300) - // submit() - // expect(mockRouter.asPath).toBe( - // "/search?q=spaghetti&contributor=il+amore+di+pasta&title=strega+nonna&subject=italian+food" - // ) - // }) - // }) it("can select languages", async () => { render() diff --git a/pages/search/advanced.tsx b/pages/search/advanced.tsx index f2f485035..242084280 100644 --- a/pages/search/advanced.tsx +++ b/pages/search/advanced.tsx @@ -105,7 +105,6 @@ export default function AdvancedSearch({ e.preventDefault() if (!validateDateRange()) return const queryString = getSearchQuery(searchFormState as SearchParams) - if (!queryString.length) { setErrorMessage(defaultEmptySearchErrorMessage) setAlert(true) From a1ac63a42cd640fd976ba0e5eff2f6be81b74128 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Tue, 26 Nov 2024 14:02:31 -0500 Subject: [PATCH 11/29] update tests --- .../pages/search/advancedSearchForm.test.tsx | 65 +++++++++---------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/__test__/pages/search/advancedSearchForm.test.tsx b/__test__/pages/search/advancedSearchForm.test.tsx index 7b734925c..e54b80269 100644 --- a/__test__/pages/search/advancedSearchForm.test.tsx +++ b/__test__/pages/search/advancedSearchForm.test.tsx @@ -1,13 +1,9 @@ import React from "react" -import { - fireEvent, - render, - screen, - waitFor, -} from "../../../src/utils/testUtils" +import { fireEvent, render, screen } from "../../../src/utils/testUtils" import mockRouter from "next-router-mock" import userEvent from "@testing-library/user-event" +import { textInputFields } from "../../../src/utils/advancedSearchUtils" import AdvancedSearch, { defaultEmptySearchErrorMessage, } from "../../../pages/search/advanced" @@ -17,6 +13,9 @@ import { searchAggregations } from "../../../src/config/aggregations" jest.mock("next/router", () => jest.requireActual("next-router-mock")) describe("Advanced Search Form", () => { + beforeEach(async () => { + render() + }) const submit = () => { fireEvent( screen.getByTestId("submit-advanced-search-button"), @@ -27,8 +26,6 @@ describe("Advanced Search Form", () => { await userEvent.click(screen.getByText("Clear fields")) }) it("displays alert when no fields are submitted", () => { - render() - submit() screen.getByText(defaultEmptySearchErrorMessage) }) @@ -36,32 +33,37 @@ describe("Advanced Search Form", () => { // this functionality works in the browser, but won't include // final input in output string in test. the broken test is // commented out below. - it("can set keyword, contributor, title, subject", async () => { - render() + it.todo("can set keyword, contributor, title, subject") + // , async () => { + // - const [keywordInput, contributorInput, titleInput, subjectInput] = [ - "Keyword", - "Title", - "Author", - "Subject", - "Call number", - "Unique identifier", - ].map((field) => screen.getByLabelText(field)) - fireEvent.change(subjectInput, { target: { value: "italian food" } }) - fireEvent.change(keywordInput, { target: { value: "spaghetti" } }) - fireEvent.change(contributorInput, { target: { value: "strega nonna" } }) - fireEvent.change(titleInput, { target: { value: "il amore di pasta" } }) - submit() - await waitFor(() => - expect(mockRouter.asPath).toBe( - "/search?q=spaghetti&contributor=il+amore+di+pasta&title=strega+nonna&subject=italian+food" - ) - ) + // const [keywordInput, contributorInput, titleInput, subjectInput] = [ + // "Keyword", + // "Title", + // "Author", + // "Subject", + // "Call number", + // "Unique identifier", + // ].map((field) => screen.getByLabelText(field)) + // fireEvent.change(subjectInput, { target: { value: "italian food" } }) + // fireEvent.change(keywordInput, { target: { value: "spaghetti" } }) + // fireEvent.change(contributorInput, { target: { value: "strega nonna" } }) + // fireEvent.change(titleInput, { target: { value: "il amore di pasta" } }) + // submit() + // await waitFor(() => + // expect(mockRouter.asPath).toBe( + // "/search?q=spaghetti&contributor=il+amore+di+pasta&title=strega+nonna&subject=italian+food" + // ) + // ) + // }) + it("renders inputs for all text input fields", () => { + textInputFields.map(({ label }) => { + const input = screen.getByLabelText(label) + expect(input).toBeInTheDocument() + }) }) it("can select languages", async () => { - render() - const languageSelect = screen.getByLabelText("Language") await userEvent.selectOptions(languageSelect, "Azerbaijani") submit() @@ -71,7 +73,6 @@ describe("Advanced Search Form", () => { ) }) it("can check material checkboxes", async () => { - render() await userEvent.click(screen.getByLabelText("Notated music")) await userEvent.click(screen.getByLabelText("Cartographic")) submit() @@ -82,7 +83,6 @@ describe("Advanced Search Form", () => { ) }) it("can check location checkboxes", async () => { - render() const location = searchAggregations.buildingLocation[0] await userEvent.click(screen.getByLabelText(location.label as string)) submit() @@ -92,7 +92,6 @@ describe("Advanced Search Form", () => { }) it("can clear the form", async () => { - render() const notatedMusic = screen.getByLabelText("Notated music") await userEvent.click(notatedMusic) const cartographic = screen.getByLabelText("Cartographic") From 06b0a345c2ee015e9d09680ac247b87f441534d1 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 2 Dec 2024 13:33:57 -0500 Subject: [PATCH 12/29] rm extra textinputfields import --- src/utils/searchUtils.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/utils/searchUtils.ts b/src/utils/searchUtils.ts index 841484e6e..6b6f81a86 100644 --- a/src/utils/searchUtils.ts +++ b/src/utils/searchUtils.ts @@ -1,9 +1,6 @@ import { isArray, isEmpty, mapObject, forEach } from "underscore" -import { - textInputFields as advSearchFields, - textInputFields, -} from "./advancedSearchUtils" +import { textInputFields as advancedSearchFields } from "./advancedSearchUtils" import type { SearchParams, SearchQueryParams, @@ -69,7 +66,7 @@ export function getSearchResultsHeading( // Shows the final part of the search query string (e.g. "for keyword 'cats'") function buildQueryDisplayString(searchParams: SearchParams): string { - const searchFields = advSearchFields + const searchFields = advancedSearchFields // Lowercase the adv search field labels: .map((field) => ({ ...field, label: field.label.toLowerCase() })) .concat([ @@ -211,7 +208,7 @@ export function getSearchQuery(params: SearchParams): string { const identifierQuery = getIdentifierQuery(identifiers) const pageQuery = page !== 1 ? `&page=${page}` : "" - const advancedSearchQueryParams = textInputFields + const advancedSearchQueryParams = advancedSearchFields .map(({ name: advancedSearchParam }) => { if (advancedSearchParam === "q") return return params[advancedSearchParam] From e581ec688979316a964d2d5bd977407ac43b2235 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Fri, 22 Nov 2024 15:27:20 -0500 Subject: [PATCH 13/29] add owner to bib details --- src/models/BibDetails.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/models/BibDetails.ts b/src/models/BibDetails.ts index df6b05a3b..91ccf4e48 100644 --- a/src/models/BibDetails.ts +++ b/src/models/BibDetails.ts @@ -10,6 +10,7 @@ import type { AnyBibDetail, } from "../types/bibDetailsTypes" import { convertToSentenceCase } from "../utils/appUtils" +import type { JSONLDValue } from "../types/itemTypes" export default class BibDetails { bib: DiscoveryBibResult @@ -21,6 +22,7 @@ export default class BibDetails { supplementaryContent: LinkedBibDetail extent: BibDetail subjectHeadings: SubjectHeadingDetail + owner: JSONLDValue constructor( discoveryBibResult: DiscoveryBibResult, @@ -31,6 +33,7 @@ export default class BibDetails { this.supplementaryContent = this.buildSupplementaryContent() this.groupedNotes = this.buildGroupedNotes() this.extent = this.buildExtent() + this.owner = this.buildOwner() // If we can't retreive subject headings from the SHEP API, we'll use the subjectLiteral this.subjectHeadings = this.buildSubjectHeadings() || this.buildSubjectLiterals() @@ -43,6 +46,10 @@ export default class BibDetails { this.bottomDetails = this.buildBottomDetails() } + buildOwner() { + return this.bib.items?.[0]?.owner?.[0] + } + buildAnnotatedMarcDetails( annotatedMarc: AnnotatedMarcField[] ): AnyBibDetail[] { @@ -125,12 +132,12 @@ export default class BibDetails { else if (fieldMapping.field === "subjectLiteral") detail = this.subjectHeadings else if (fieldMapping.field === "extent") detail = this.extent - else if (fieldMapping.field === "owner") - detail = this.bib.owner && { + else if (fieldMapping.field === "owner") { + detail = this.owner && { label: convertToSentenceCase(fieldMapping.label), - value: [this.bib.owner?.prefLabel], + value: [this.owner.prefLabel], } - else detail = this.buildStandardDetail(fieldMapping) + } else detail = this.buildStandardDetail(fieldMapping) return detail }) .filter((f) => f) From af7dd785a765fca73930461d05b974c3ebd37946 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Fri, 22 Nov 2024 17:04:33 -0500 Subject: [PATCH 14/29] owner tests --- __test__/fixtures/bibFixtures.ts | 181 +++++++++++++++++++++++ src/models/BibDetails.ts | 17 ++- src/models/modelTests/BibDetails.test.ts | 15 ++ 3 files changed, 205 insertions(+), 8 deletions(-) diff --git a/__test__/fixtures/bibFixtures.ts b/__test__/fixtures/bibFixtures.ts index 294842e95..cc87cb2e6 100644 --- a/__test__/fixtures/bibFixtures.ts +++ b/__test__/fixtures/bibFixtures.ts @@ -1,3 +1,184 @@ +export const princetonRecord = { + "@context": + "http://discovery-api-qa.nypl.org/api/v0.1/discovery/context_all.jsonld", + "@type": ["nypl:Item", "nypl:Resource"], + "@id": "res:pb2608686", + buildingLocationIds: [], + carrierType: [ + { + "@id": "carriertypes:nc", + prefLabel: "volume", + }, + ], + contributorLiteral: ["Brown, David, journalist, joint author."], + createdString: ["1943"], + createdYear: 1943, + creatorLiteral: ["Wagg, Alfred."], + dateStartYear: 1943, + dateString: ["1943"], + dimensions: ["23 cm."], + extent: ["231 p."], + idLccn: [" 44003956 "], + identifier: [ + { + "@type": "nypl:Bnumber", + "@value": "2608686", + }, + { + "@type": "bf:Lccn", + "@value": " 44003956 ", + }, + { + "@type": "bf:Identifier", + "@value": "(OCoLC)ocm02088006", + }, + ], + issuance: [ + { + "@id": "urn:biblevel:m", + prefLabel: "monograph/item", + }, + ], + itemAggregations: [ + { + "@type": "nypl:Aggregation", + "@id": "res:location", + id: "location", + field: "location", + values: [], + }, + { + "@type": "nypl:Aggregation", + "@id": "res:format", + id: "format", + field: "format", + values: [], + }, + { + "@type": "nypl:Aggregation", + "@id": "res:status", + id: "status", + field: "status", + values: [ + { + value: "status:a", + count: 1, + label: "Available", + }, + ], + }, + ], + items: [ + { + "@id": "res:pi5153471", + accessMessage: [ + { + "@id": "accessMessage:1", + prefLabel: "Use in library", + }, + ], + catalogItemType: [ + { + "@id": "catalogItemType:1", + prefLabel: "non-circ", + }, + ], + eddFulfillment: { + "@id": "fulfillment:recap-edd", + }, + eddRequestable: true, + idBarcode: ["32101067443802"], + identifier: [ + { + "@type": "bf:ShelfMark", + "@value": "D763.I8 W3 1943", + }, + { + "@type": "bf:Barcode", + "@value": "32101067443802", + }, + ], + idNyplSourceId: { + "@type": "RecapPul", + "@value": "25791623", + }, + owner: [ + { + "@id": "orgs:0003", + prefLabel: "Princeton University Library", + }, + ], + physFulfillment: { + "@id": "fulfillment:recap-offsite", + }, + physRequestable: true, + requestable: [true], + shelfMark: ["D763.I8 W3 1943"], + specRequestable: false, + status: [ + { + "@id": "status:na", + prefLabel: "Not available", + }, + ], + uri: "pi5153471", + idNyplSourceId: { + "@type": "RecapPul", + "@value": "5153471", + }, + }, + ], + language: [ + { + "@id": "lang:eng", + prefLabel: "English", + }, + ], + lccClassification: ["D763.I8 W3"], + materialType: [ + { + "@id": "resourcetypes:txt", + prefLabel: "Text", + }, + ], + mediaType: [ + { + "@id": "mediatypes:n", + prefLabel: "unmediated", + }, + ], + note: [ + { + noteType: "Note", + "@type": "bf:Note", + prefLabel: '"First published in 1943."', + }, + ], + numAvailable: 1, + numItems: 1, + numItemsMatched: 1, + numItemsTotal: 1, + placeOfPublication: ["London,"], + publicationStatement: ["London, Nicholson & Watson [1943]"], + publisherLiteral: ["Nicholson & Watson"], + subjectLiteral: [ + "World War, 1939-1945 -- Campaigns -- Italy.", + "World War, 1939-1945 -- Naval operations.", + "World War, 1939-1945 -- Personal narratives.", + ], + title: ["No spaghetti for breakfast"], + titleDisplay: [ + "No spaghetti for breakfast [by] Alfred Wagg and David Brown.", + ], + type: ["nypl:Item"], + updatedAt: 1543536484228, + uri: "pb2608686", + updatedAtDate: "2018-11-30T00:08:04.228Z", + hasItemVolumes: false, + hasItemDates: false, + electronicResources: [], +} + export const bibWithItems = { resource: { "@context": diff --git a/src/models/BibDetails.ts b/src/models/BibDetails.ts index 91ccf4e48..1a3245e96 100644 --- a/src/models/BibDetails.ts +++ b/src/models/BibDetails.ts @@ -46,8 +46,14 @@ export default class BibDetails { this.bottomDetails = this.buildBottomDetails() } - buildOwner() { - return this.bib.items?.[0]?.owner?.[0] + buildOwner(): string { + if (!this.bib.items) return null + + const firstRecapItem = this.bib.items + // Only consider items with a Recap source id + .find((item) => /^Recap/.test(item?.idNyplSourceId?.["@type"])) + // Only consider items with an `owner` (should be all, in practice) + return firstRecapItem?.owner?.[0]?.prefLabel } buildAnnotatedMarcDetails( @@ -132,12 +138,7 @@ export default class BibDetails { else if (fieldMapping.field === "subjectLiteral") detail = this.subjectHeadings else if (fieldMapping.field === "extent") detail = this.extent - else if (fieldMapping.field === "owner") { - detail = this.owner && { - label: convertToSentenceCase(fieldMapping.label), - value: [this.owner.prefLabel], - } - } else detail = this.buildStandardDetail(fieldMapping) + else detail = this.buildStandardDetail(fieldMapping) return detail }) .filter((f) => f) diff --git a/src/models/modelTests/BibDetails.test.ts b/src/models/modelTests/BibDetails.test.ts index 773426c8a..bfd568da4 100644 --- a/src/models/modelTests/BibDetails.test.ts +++ b/src/models/modelTests/BibDetails.test.ts @@ -4,6 +4,8 @@ import { parallelsBib, yiddishBib, bibWithSubjectHeadings, + bibNoItems, + princetonRecord, } from "../../../__test__/fixtures/bibFixtures" import type { LinkedBibDetail } from "../../types/bibDetailsTypes" import BibDetailsModel from "../BibDetails" @@ -31,6 +33,19 @@ describe("Bib model", () => { bibWithSubjectHeadings.resource, bibWithSubjectHeadings.annotatedMarc ) + describe.only("owner", () => { + it("populates owner when owner is present", () => { + const partnerBib = new BibDetailsModel(princetonRecord) + expect(partnerBib.owner).toBe("Princeton University Library") + }) + it("does not populate owner if item is nypl", () => { + expect(bibWithRtlParallelsModel.owner).toBe(undefined) + }) + it("can handle no items", () => { + const noItemsBib = new BibDetailsModel(bibNoItems.resource) + expect(noItemsBib.owner).toBe(undefined) + }) + }) describe("note", () => { it("groups notes into an array of {label, value} details", () => { const model = bibWithParallelsModel From 44b8e8c625d2ccb9d76049247a7e6dda6a8605b2 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 25 Nov 2024 10:48:36 -0500 Subject: [PATCH 15/29] owner working --- pages/bib/[id]/index.tsx | 1 - src/components/BibPage/BibDetail.tsx | 1 - src/models/BibDetails.ts | 39 +++++++++++++----------- src/models/modelTests/BibDetails.test.ts | 18 +++++------ 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/pages/bib/[id]/index.tsx b/pages/bib/[id]/index.tsx index 26074b8ec..9132d1388 100644 --- a/pages/bib/[id]/index.tsx +++ b/pages/bib/[id]/index.tsx @@ -84,7 +84,6 @@ export default function BibPage({ discoveryBibResult, annotatedMarc ) - const displayLegacyCatalogLink = isNyplBibID(bib.id) const filtersAreApplied = areFiltersApplied(appliedFilters) diff --git a/src/components/BibPage/BibDetail.tsx b/src/components/BibPage/BibDetail.tsx index a8606b8b4..b6d271d22 100644 --- a/src/components/BibPage/BibDetail.tsx +++ b/src/components/BibPage/BibDetail.tsx @@ -14,7 +14,6 @@ import type { } from "../../types/bibDetailsTypes" import { rtlOrLtr, isItTheLastElement } from "../../utils/bibUtils" import type { ReactNode } from "react" -import { BASE_URL } from "../../config/constants" interface BibDetailsProps { details: AnyBibDetail[] diff --git a/src/models/BibDetails.ts b/src/models/BibDetails.ts index 1a3245e96..09494a5ba 100644 --- a/src/models/BibDetails.ts +++ b/src/models/BibDetails.ts @@ -10,7 +10,6 @@ import type { AnyBibDetail, } from "../types/bibDetailsTypes" import { convertToSentenceCase } from "../utils/appUtils" -import type { JSONLDValue } from "../types/itemTypes" export default class BibDetails { bib: DiscoveryBibResult @@ -20,9 +19,9 @@ export default class BibDetails { bottomDetails: AnyBibDetail[] groupedNotes: AnyBibDetail[] supplementaryContent: LinkedBibDetail - extent: BibDetail + extent: string[] subjectHeadings: SubjectHeadingDetail - owner: JSONLDValue + owner: string[] constructor( discoveryBibResult: DiscoveryBibResult, @@ -46,14 +45,15 @@ export default class BibDetails { this.bottomDetails = this.buildBottomDetails() } - buildOwner(): string { + buildOwner(): string[] { if (!this.bib.items) return null const firstRecapItem = this.bib.items // Only consider items with a Recap source id .find((item) => /^Recap/.test(item?.idNyplSourceId?.["@type"])) // Only consider items with an `owner` (should be all, in practice) - return firstRecapItem?.owner?.[0]?.prefLabel + const owner = firstRecapItem?.owner?.[0]?.prefLabel + if (owner) return [owner] } buildAnnotatedMarcDetails( @@ -101,11 +101,16 @@ export default class BibDetails { { field: "creatorLiteral", label: "Author" }, ] .map((fieldMapping) => { - if (fieldMapping.field === "supplementaryContent") - return this.supplementaryContent - else if (fieldMapping.field === "creatorLiteral") - return this.buildInternalLinkedDetail(fieldMapping) - else return this.buildStandardDetail(fieldMapping) + switch (fieldMapping.field) { + case "supplementaryContent": + return this.supplementaryContent + case "creatorLiteral": + return this.buildInternalLinkedDetail(fieldMapping) + case "owner": + return this.owner + default: + return this.buildStandardDetail(fieldMapping) + } }) .filter((f) => f) } @@ -137,12 +142,10 @@ export default class BibDetails { detail = this.buildInternalLinkedDetail(fieldMapping) else if (fieldMapping.field === "subjectLiteral") detail = this.subjectHeadings - else if (fieldMapping.field === "extent") detail = this.extent else detail = this.buildStandardDetail(fieldMapping) return detail }) .filter((f) => f) - const fieldsWithNotes = this.addNotes(resourceFields) const combinedFields = this.combineBibDetailsData( fieldsWithNotes, @@ -182,7 +185,9 @@ export default class BibDetails { } buildStandardDetail(fieldMapping: FieldMapping) { - const bibFieldValue = this.bib[fieldMapping.field] + const bibFieldValue = + this.bib[fieldMapping.field] || this[fieldMapping.field] + if (!bibFieldValue) return return this.buildDetail( convertToSentenceCase(fieldMapping.label), bibFieldValue @@ -334,7 +339,7 @@ export default class BibDetails { return Object.assign({}, bib, ...parallelFieldMatches) } - buildExtent(): BibDetail { + buildExtent(): string[] { let modifiedExtent: string[] const { extent, dimensions } = this.bib const removeSemiColon = (extent) => [extent[0].replace(/\s*;\s*$/, "")] @@ -350,10 +355,8 @@ export default class BibDetails { parts.push(dimensions[0]) modifiedExtent = [parts.join("; ")] } - return { - label: "Description", - value: modifiedExtent, - } + + return modifiedExtent } buildSupplementaryContent(): LinkedBibDetail { diff --git a/src/models/modelTests/BibDetails.test.ts b/src/models/modelTests/BibDetails.test.ts index bfd568da4..699bdc58a 100644 --- a/src/models/modelTests/BibDetails.test.ts +++ b/src/models/modelTests/BibDetails.test.ts @@ -33,10 +33,10 @@ describe("Bib model", () => { bibWithSubjectHeadings.resource, bibWithSubjectHeadings.annotatedMarc ) - describe.only("owner", () => { + describe("owner", () => { it("populates owner when owner is present", () => { const partnerBib = new BibDetailsModel(princetonRecord) - expect(partnerBib.owner).toBe("Princeton University Library") + expect(partnerBib.owner).toStrictEqual(["Princeton University Library"]) }) it("does not populate owner if item is nypl", () => { expect(bibWithRtlParallelsModel.owner).toBe(undefined) @@ -166,14 +166,14 @@ describe("Bib model", () => { ) }) }) - describe("extent", () => { + xdescribe("extent", () => { it("should add a semicolon after extent if there is not one already", () => { const bib = new BibDetailsModel({ identifier: [{ uri: "123456" }], extent: ["99 bottles of beer"], dimensions: ["99 x 99 cm"], }) - expect(bib.extent.value[0].includes("; ")) + expect(bib.extent[0].includes("; ")) }) it("should append dimensions to extent", () => { const bib = new BibDetailsModel({ @@ -181,7 +181,7 @@ describe("Bib model", () => { extent: ["99 bottles of beer"], dimensions: ["99 x 99 cm"], }) - expect(bib.extent.value[0]).toBe("99 bottles of beer; 99 x 99 cm") + expect(bib.extent[0]).toBe("99 bottles of beer; 99 x 99 cm") }) it("should not add semicolon if it already is in extent", () => { const bib = new BibDetailsModel({ @@ -189,7 +189,7 @@ describe("Bib model", () => { extent: ["700 sheets of woven gold; "], dimensions: ["1 x 1 in."], }) - expect(bib.extent.value[0]).toBe("700 sheets of woven gold; 1 x 1 in.") + expect(bib.extent[0]).toBe("700 sheets of woven gold; 1 x 1 in.") }) it("should remove semicolon if there is no dimensions", () => { const bib = new BibDetailsModel({ @@ -200,15 +200,15 @@ describe("Bib model", () => { identifier: [{ uri: "123456" }], extent: ["700 sheets of woven gold;"], }) - expect(bib.extent.value[0]).toBe("700 sheets of woven gold") - expect(anotherBib.extent.value[0]).toBe("700 sheets of woven gold") + expect(bib.extent[0]).toBe("700 sheets of woven gold") + expect(anotherBib.extent[0]).toBe("700 sheets of woven gold") }) it("should display dimensions if there are dimensions and no extent", () => { const bib = new BibDetailsModel({ identifier: [{ uri: "123456" }], dimensions: ["1,000,000mm x 7ft"], }) - expect(bib.extent.value[0]).toBe("1,000,000mm x 7ft") + expect(bib.extent[0]).toBe("1,000,000mm x 7ft") }) it("should do nothing if there are no dimensions or extent", () => { const bib = new BibDetailsModel({ identifier: [{ uri: "123456" }] }) From e8c6287a62f56c2dcce0083468466270b005e79f Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 25 Nov 2024 10:57:46 -0500 Subject: [PATCH 16/29] fix extent biz --- __test__/pages/bib/bibPage.test.tsx | 2 +- src/models/BibDetails.ts | 5 +---- src/models/modelTests/BibDetails.test.ts | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/__test__/pages/bib/bibPage.test.tsx b/__test__/pages/bib/bibPage.test.tsx index a18ae2b37..78e56184b 100644 --- a/__test__/pages/bib/bibPage.test.tsx +++ b/__test__/pages/bib/bibPage.test.tsx @@ -45,7 +45,7 @@ describe("Bib Page with items", () => { }) // TODO: Determine if this should be rendering twice - it("renders the bottom bib details", () => { + it.only("renders the bottom bib details", () => { expect(screen.getAllByTestId("publication-date")[0]).toHaveTextContent( "Vol. 1, issue 1-" ) diff --git a/src/models/BibDetails.ts b/src/models/BibDetails.ts index 09494a5ba..988f34bb5 100644 --- a/src/models/BibDetails.ts +++ b/src/models/BibDetails.ts @@ -106,8 +106,6 @@ export default class BibDetails { return this.supplementaryContent case "creatorLiteral": return this.buildInternalLinkedDetail(fieldMapping) - case "owner": - return this.owner default: return this.buildStandardDetail(fieldMapping) } @@ -186,7 +184,7 @@ export default class BibDetails { buildStandardDetail(fieldMapping: FieldMapping) { const bibFieldValue = - this.bib[fieldMapping.field] || this[fieldMapping.field] + this[fieldMapping.field] || this.bib[fieldMapping.field] if (!bibFieldValue) return return this.buildDetail( convertToSentenceCase(fieldMapping.label), @@ -355,7 +353,6 @@ export default class BibDetails { parts.push(dimensions[0]) modifiedExtent = [parts.join("; ")] } - return modifiedExtent } diff --git a/src/models/modelTests/BibDetails.test.ts b/src/models/modelTests/BibDetails.test.ts index 699bdc58a..dd9ea8bc0 100644 --- a/src/models/modelTests/BibDetails.test.ts +++ b/src/models/modelTests/BibDetails.test.ts @@ -166,7 +166,7 @@ describe("Bib model", () => { ) }) }) - xdescribe("extent", () => { + describe("extent", () => { it("should add a semicolon after extent if there is not one already", () => { const bib = new BibDetailsModel({ identifier: [{ uri: "123456" }], From a72d9bab77e793bc81bc18afd8523afe74efe482 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 25 Nov 2024 11:00:14 -0500 Subject: [PATCH 17/29] rm duplicated fixture property --- __test__/fixtures/bibFixtures.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/__test__/fixtures/bibFixtures.ts b/__test__/fixtures/bibFixtures.ts index cc87cb2e6..999a549b4 100644 --- a/__test__/fixtures/bibFixtures.ts +++ b/__test__/fixtures/bibFixtures.ts @@ -122,10 +122,6 @@ export const princetonRecord = { }, ], uri: "pi5153471", - idNyplSourceId: { - "@type": "RecapPul", - "@value": "5153471", - }, }, ], language: [ From a170f55e187866290f2fe5674072a4d0a81b8bd9 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 25 Nov 2024 11:05:41 -0500 Subject: [PATCH 18/29] update changelog --- CHANGELOG | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index af6af399a..14e076471 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,16 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Prerelease + ### Updated - add call number and standard numbers to advanced search ([SCC-4326](https://newyorkpubliclibrary.atlassian.net/browse/SCC-4326)) +- Pull in Owning institution from items to populate bib details ([SCC-4334](https://newyorkpubliclibrary.atlassian.net/browse/SCC-4334)) ### [1.3.7] Hotfix 2024-11-21 - Fix analytics bug where routes without a query string do not emit the correct virtual page view event (SCC-4314) -## Prerelease - ## [1.3.6] 2024-11-6 ## Added From 650f764b9cc2aafa73310a98bb2e85b3900eca10 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 25 Nov 2024 11:12:48 -0500 Subject: [PATCH 19/29] add comment --- src/models/BibDetails.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/models/BibDetails.ts b/src/models/BibDetails.ts index 988f34bb5..95d514118 100644 --- a/src/models/BibDetails.ts +++ b/src/models/BibDetails.ts @@ -136,6 +136,7 @@ export default class BibDetails { ] .map((fieldMapping: FieldMapping): AnyBibDetail => { let detail: AnyBibDetail + // TODO: standardize detail building by returning array of strings from all instance variables, so the detail can be returned from buildStandardDetail. That way, we won't be maintaining two different locations for labels. if (fieldMapping.field === "contributorLiteral") detail = this.buildInternalLinkedDetail(fieldMapping) else if (fieldMapping.field === "subjectLiteral") From ceb6d7194927c12f690f226e438d3050b5683e39 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 2 Dec 2024 11:56:56 -0500 Subject: [PATCH 20/29] zhuzh search results test --- __test__/pages/bib/bibPage.test.tsx | 2 +- __test__/pages/search/searchResults.test.tsx | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/__test__/pages/bib/bibPage.test.tsx b/__test__/pages/bib/bibPage.test.tsx index 78e56184b..a18ae2b37 100644 --- a/__test__/pages/bib/bibPage.test.tsx +++ b/__test__/pages/bib/bibPage.test.tsx @@ -45,7 +45,7 @@ describe("Bib Page with items", () => { }) // TODO: Determine if this should be rendering twice - it.only("renders the bottom bib details", () => { + it("renders the bottom bib details", () => { expect(screen.getAllByTestId("publication-date")[0]).toHaveTextContent( "Vol. 1, issue 1-" ) diff --git a/__test__/pages/search/searchResults.test.tsx b/__test__/pages/search/searchResults.test.tsx index b121f48b2..8969afa4f 100644 --- a/__test__/pages/search/searchResults.test.tsx +++ b/__test__/pages/search/searchResults.test.tsx @@ -1,6 +1,6 @@ import React from "react" import userEvent from "@testing-library/user-event" -import { render, screen } from "../../../src/utils/testUtils" +import { render, screen, waitFor } from "../../../src/utils/testUtils" import mockRouter from "next-router-mock" @@ -32,11 +32,10 @@ describe("Search Results page", () => { }) await userEvent.click(field) await userEvent.click(screen.getByText("Apply filters")) - // This was the only way to get this test to pass. waitFor was not in fact waiting, even with same timeout. - setTimeout(() => { + waitFor(() => { const resultsHeading = screen.getByTestId("search-results-heading") expect(resultsHeading).toHaveFocus() - }, 500) + }) }) it("focuses on search results heading after loading a keyword search", () => { mockRouter.push(`/search?q=${query}`) From e7c15e96fa905d9430ec5e7f303b0471acb5593c Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 2 Dec 2024 12:40:49 -0500 Subject: [PATCH 21/29] rename subjectheading and return only values --- src/models/BibDetails.ts | 25 ++-- src/models/modelTests/BibDetails.test.ts | 162 +++++++++++------------ 2 files changed, 86 insertions(+), 101 deletions(-) diff --git a/src/models/BibDetails.ts b/src/models/BibDetails.ts index 95d514118..ae304a08b 100644 --- a/src/models/BibDetails.ts +++ b/src/models/BibDetails.ts @@ -20,7 +20,7 @@ export default class BibDetails { groupedNotes: AnyBibDetail[] supplementaryContent: LinkedBibDetail extent: string[] - subjectHeadings: SubjectHeadingDetail + subjectLiteral: BibDetailURL[][] owner: string[] constructor( @@ -34,7 +34,7 @@ export default class BibDetails { this.extent = this.buildExtent() this.owner = this.buildOwner() // If we can't retreive subject headings from the SHEP API, we'll use the subjectLiteral - this.subjectHeadings = + this.subjectLiteral = this.buildSubjectHeadings() || this.buildSubjectLiterals() // these are the actual arrays of details that will be displayed this.annotatedMarcDetails = this.buildAnnotatedMarcDetails( @@ -136,11 +136,10 @@ export default class BibDetails { ] .map((fieldMapping: FieldMapping): AnyBibDetail => { let detail: AnyBibDetail - // TODO: standardize detail building by returning array of strings from all instance variables, so the detail can be returned from buildStandardDetail. That way, we won't be maintaining two different locations for labels. if (fieldMapping.field === "contributorLiteral") detail = this.buildInternalLinkedDetail(fieldMapping) - else if (fieldMapping.field === "subjectLiteral") - detail = this.subjectHeadings + // else if (fieldMapping.field === "subjectLiteral") + // detail = this.subjectHeadings else detail = this.buildStandardDetail(fieldMapping) return detail }) @@ -376,21 +375,16 @@ export default class BibDetails { return this.buildExternalLinkedDetail(convertToSentenceCase(label), values) } - buildSubjectHeadings(): SubjectHeadingDetail { + buildSubjectHeadings(): BibDetailURL[][] { if (!this.bib.subjectHeadings) return const subjectHeadingsUrls = this.bib.subjectHeadings.map((heading) => this.flattenSubjectHeadingUrls(heading) ) - return ( - subjectHeadingsUrls?.length && { - label: "Subject", - value: subjectHeadingsUrls, - } - ) + return subjectHeadingsUrls?.length && subjectHeadingsUrls } - buildSubjectLiterals(): SubjectHeadingDetail { + buildSubjectLiterals(): BibDetailURL[][] { if (!this.bib.subjectLiteral) return const subjectLiteralUrls = this.bib.subjectLiteral.map( (subject: string) => { @@ -412,10 +406,7 @@ export default class BibDetails { }) } ) - return { - label: "Subject", - value: subjectLiteralUrls, - } + return subjectLiteralUrls } constructSubjectLiteralsArray(subject: string) { diff --git a/src/models/modelTests/BibDetails.test.ts b/src/models/modelTests/BibDetails.test.ts index dd9ea8bc0..d91bd2514 100644 --- a/src/models/modelTests/BibDetails.test.ts +++ b/src/models/modelTests/BibDetails.test.ts @@ -73,96 +73,90 @@ describe("Bib model", () => { }) describe("subjectHeadings", () => { it("correctly formats the subjectHeading urls when the subjectHeadings are present in the bib result", () => { - const subjectHeadingsObject = { - label: "Subject", - value: [ - [ - { - url: "/subject_headings/cf347108-e1f2-4c0f-808a-ac4ace2f0765?label=Cortanze%2C%20G%C3%A9rard%20de", - urlLabel: "Cortanze, Gérard de", - }, - { - url: "/subject_headings/74746d11-638b-4cfb-a72a-9a2bd296e6fd?label=Cortanze%2C%20G%C3%A9rard%20de%20--%20Childhood%20and%20youth", - urlLabel: "Childhood and youth", - }, - ], - [ - { - url: "/subject_headings/5fd065df-b4e9-48cb-b13c-ea15f36b96b4?label=Authors%2C%20French", - urlLabel: "Authors, French", - }, - { - url: "/subject_headings/e43674a7-5f02-44f1-95cd-dbcc776331b7?label=Authors%2C%20French%20--%2020th%20century", - urlLabel: "20th century", - }, - { - url: "/subject_headings/9391bc26-e44c-44ac-98cc-e3800da51926?label=Authors%2C%20French%20--%2020th%20century%20--%20Biography", - urlLabel: "Biography", - }, - ], - [ - { - url: "/subject_headings/3a779ed6-8a07-4d27-80ef-e0c2b10fe78e?label=Autobiographical%20Narrative", - urlLabel: "Autobiographical Narrative", - }, - ], + const subjectHeadings = [ + [ + { + url: "/subject_headings/cf347108-e1f2-4c0f-808a-ac4ace2f0765?label=Cortanze%2C%20G%C3%A9rard%20de", + urlLabel: "Cortanze, Gérard de", + }, + { + url: "/subject_headings/74746d11-638b-4cfb-a72a-9a2bd296e6fd?label=Cortanze%2C%20G%C3%A9rard%20de%20--%20Childhood%20and%20youth", + urlLabel: "Childhood and youth", + }, + ], + [ + { + url: "/subject_headings/5fd065df-b4e9-48cb-b13c-ea15f36b96b4?label=Authors%2C%20French", + urlLabel: "Authors, French", + }, + { + url: "/subject_headings/e43674a7-5f02-44f1-95cd-dbcc776331b7?label=Authors%2C%20French%20--%2020th%20century", + urlLabel: "20th century", + }, + { + url: "/subject_headings/9391bc26-e44c-44ac-98cc-e3800da51926?label=Authors%2C%20French%20--%2020th%20century%20--%20Biography", + urlLabel: "Biography", + }, + ], + [ + { + url: "/subject_headings/3a779ed6-8a07-4d27-80ef-e0c2b10fe78e?label=Autobiographical%20Narrative", + urlLabel: "Autobiographical Narrative", + }, ], - } - expect(bibWithSubjectHeadingsModel.subjectHeadings).toMatchObject( - subjectHeadingsObject + ] + expect(bibWithSubjectHeadingsModel.subjectLiteral).toStrictEqual( + subjectHeadings ) }) it("falls back to subject literals when subject headings are absent in the bib and correctly formats the urls", () => { const filterQueryForSubjectLiteral = "/search?filters[subjectLiteral]=" - const subjectHeadingsObject = { - label: "Subject", - value: [ - [ - { - url: `${filterQueryForSubjectLiteral}${encodeURI( - "Authors, French" - )}`, - urlLabel: "Authors, French", - }, - { - url: `${filterQueryForSubjectLiteral}${encodeURI( - "Authors, French -- 20th century" - )}`, - urlLabel: "20th century", - }, - { - url: `${filterQueryForSubjectLiteral}${encodeURI( - "Authors, French -- 20th century -- Biography" - )}`, - urlLabel: "Biography", - }, - ], - [ - { - url: `${filterQueryForSubjectLiteral}${encodeURI( - "Autobiographical Narrative" - )}`, - urlLabel: "Autobiographical Narrative", - }, - ], - [ - { - url: `${filterQueryForSubjectLiteral}${encodeURI( - "Cortanze, Gérard de" - )}`, - urlLabel: "Cortanze, Gérard de", - }, - { - url: `${filterQueryForSubjectLiteral}${encodeURI( - "Cortanze, Gérard de -- Childhood and youth" - )}`, - urlLabel: "Childhood and youth", - }, - ], + const subjectHeadings = [ + [ + { + url: `${filterQueryForSubjectLiteral}${encodeURI( + "Authors, French" + )}`, + urlLabel: "Authors, French", + }, + { + url: `${filterQueryForSubjectLiteral}${encodeURI( + "Authors, French -- 20th century" + )}`, + urlLabel: "20th century", + }, + { + url: `${filterQueryForSubjectLiteral}${encodeURI( + "Authors, French -- 20th century -- Biography" + )}`, + urlLabel: "Biography", + }, + ], + [ + { + url: `${filterQueryForSubjectLiteral}${encodeURI( + "Autobiographical Narrative" + )}`, + urlLabel: "Autobiographical Narrative", + }, + ], + [ + { + url: `${filterQueryForSubjectLiteral}${encodeURI( + "Cortanze, Gérard de" + )}`, + urlLabel: "Cortanze, Gérard de", + }, + { + url: `${filterQueryForSubjectLiteral}${encodeURI( + "Cortanze, Gérard de -- Childhood and youth" + )}`, + urlLabel: "Childhood and youth", + }, ], - } - expect(bibWithNoParallelsModel.subjectHeadings).toMatchObject( - subjectHeadingsObject + ] + expect(bibWithNoParallelsModel.subjectLiteral).toStrictEqual( + subjectHeadings ) }) }) From 89a92a6e59850332517f94d86030bd12744d35ce Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 2 Dec 2024 12:45:34 -0500 Subject: [PATCH 22/29] change buildInternalLinkDetail name to buildSearchFilterUrl --- src/models/BibDetails.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/models/BibDetails.ts b/src/models/BibDetails.ts index ae304a08b..1cbbbe5fe 100644 --- a/src/models/BibDetails.ts +++ b/src/models/BibDetails.ts @@ -105,7 +105,7 @@ export default class BibDetails { case "supplementaryContent": return this.supplementaryContent case "creatorLiteral": - return this.buildInternalLinkedDetail(fieldMapping) + return this.buildSearchFilterUrl(fieldMapping) default: return this.buildStandardDetail(fieldMapping) } @@ -137,9 +137,7 @@ export default class BibDetails { .map((fieldMapping: FieldMapping): AnyBibDetail => { let detail: AnyBibDetail if (fieldMapping.field === "contributorLiteral") - detail = this.buildInternalLinkedDetail(fieldMapping) - // else if (fieldMapping.field === "subjectLiteral") - // detail = this.subjectHeadings + detail = this.buildSearchFilterUrl(fieldMapping) else detail = this.buildStandardDetail(fieldMapping) return detail }) @@ -201,7 +199,7 @@ export default class BibDetails { } } - buildInternalLinkedDetail(fieldMapping: { + buildSearchFilterUrl(fieldMapping: { label: string field: string }): LinkedBibDetail { From 16a540d477db94521056869650b7d81d4e142d73 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Thu, 5 Dec 2024 17:16:50 -0500 Subject: [PATCH 23/29] fix advanced search tests --- .../pages/search/advancedSearchForm.test.tsx | 61 +++++++++---------- pages/search/advanced.tsx | 1 + src/utils/testUtils.tsx | 4 +- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/__test__/pages/search/advancedSearchForm.test.tsx b/__test__/pages/search/advancedSearchForm.test.tsx index e54b80269..6319dfb8c 100644 --- a/__test__/pages/search/advancedSearchForm.test.tsx +++ b/__test__/pages/search/advancedSearchForm.test.tsx @@ -1,5 +1,11 @@ import React from "react" -import { fireEvent, render, screen } from "../../../src/utils/testUtils" +import { + fireEvent, + render, + screen, + waitFor, + delay, +} from "../../../src/utils/testUtils" import mockRouter from "next-router-mock" import userEvent from "@testing-library/user-event" @@ -17,10 +23,7 @@ describe("Advanced Search Form", () => { render() }) const submit = () => { - fireEvent( - screen.getByTestId("submit-advanced-search-button"), - new MouseEvent("click") - ) + fireEvent.click(screen.getByTestId("submit-advanced-search-button")) } afterEach(async () => { await userEvent.click(screen.getByText("Clear fields")) @@ -29,33 +32,29 @@ describe("Advanced Search Form", () => { submit() screen.getByText(defaultEmptySearchErrorMessage) }) - // this test is broken due to debounce/userEvent/timing weirdness. - // this functionality works in the browser, but won't include - // final input in output string in test. the broken test is - // commented out below. - it.todo("can set keyword, contributor, title, subject") - // , async () => { - // - // const [keywordInput, contributorInput, titleInput, subjectInput] = [ - // "Keyword", - // "Title", - // "Author", - // "Subject", - // "Call number", - // "Unique identifier", - // ].map((field) => screen.getByLabelText(field)) - // fireEvent.change(subjectInput, { target: { value: "italian food" } }) - // fireEvent.change(keywordInput, { target: { value: "spaghetti" } }) - // fireEvent.change(contributorInput, { target: { value: "strega nonna" } }) - // fireEvent.change(titleInput, { target: { value: "il amore di pasta" } }) - // submit() - // await waitFor(() => - // expect(mockRouter.asPath).toBe( - // "/search?q=spaghetti&contributor=il+amore+di+pasta&title=strega+nonna&subject=italian+food" - // ) - // ) - // }) + it("can set keyword, contributor, title, subject", async () => { + const [keywordInput, contributorInput, titleInput, subjectInput] = [ + "Keyword", + "Title", + "Author", + "Subject", + "Call number", + "Unique identifier", + ].map((field) => screen.getByLabelText(field)) + fireEvent.change(subjectInput, { target: { value: "italian food" } }) + fireEvent.change(keywordInput, { target: { value: "spaghetti" } }) + fireEvent.change(contributorInput, { target: { value: "strega nonna" } }) + fireEvent.change(titleInput, { target: { value: "il amore di pasta" } }) + // without this delay, the input is not updated until after submit is called. + await delay(50) + submit() + await waitFor(() => + expect(mockRouter.asPath).toBe( + "/search?q=spaghetti&title=strega+nonna&contributor=il+amore+di+pasta&subject=italian+food" + ) + ) + }) it("renders inputs for all text input fields", () => { textInputFields.map(({ label }) => { const input = screen.getByLabelText(label) diff --git a/pages/search/advanced.tsx b/pages/search/advanced.tsx index 242084280..f44cb1987 100644 --- a/pages/search/advanced.tsx +++ b/pages/search/advanced.tsx @@ -70,6 +70,7 @@ export default function AdvancedSearch({ searchFormReducer, initialSearchFormState ) + const { dateFormProps, validateDateRange, diff --git a/src/utils/testUtils.tsx b/src/utils/testUtils.tsx index 102d5299b..879254a56 100644 --- a/src/utils/testUtils.tsx +++ b/src/utils/testUtils.tsx @@ -11,5 +11,7 @@ const customRender = ( options?: Omit ) => render(ui, { wrapper: AllTheProviders, ...options }) +const delay = (ms) => new Promise((res) => setTimeout(res, ms)) + export * from "@testing-library/react" -export { customRender as render } +export { customRender as render, delay } From 92ad0337bf1941b3341fec5db81bd5e70aa3f22b Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Fri, 6 Dec 2024 11:38:59 -0500 Subject: [PATCH 24/29] change adv search input order --- src/utils/advancedSearchUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/advancedSearchUtils.ts b/src/utils/advancedSearchUtils.ts index 43eb57ff4..8ae98e8d8 100644 --- a/src/utils/advancedSearchUtils.ts +++ b/src/utils/advancedSearchUtils.ts @@ -6,9 +6,9 @@ export const textInputFields: SearchFormInputField[] = [ { name: "q", label: "Keyword" }, { name: "title", label: "Title" }, { name: "contributor", label: "Author" }, - { name: "subject", label: "Subject" }, { name: "callnumber", label: "Call number" }, { name: "standard_number", label: "Unique identifier" }, + { name: "subject", label: "Subject" }, ] export const initialSearchFormState: SearchParams = { From 340249710e4641c6f9e3ff6ad9cc636562831b07 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 9 Dec 2024 11:18:32 -0500 Subject: [PATCH 25/29] update advanced search form label and tests --- .../pages/search/advancedSearchForm.test.tsx | 62 ++++++++++++------- src/utils/advancedSearchUtils.ts | 2 +- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/__test__/pages/search/advancedSearchForm.test.tsx b/__test__/pages/search/advancedSearchForm.test.tsx index 6319dfb8c..de7cc0b54 100644 --- a/__test__/pages/search/advancedSearchForm.test.tsx +++ b/__test__/pages/search/advancedSearchForm.test.tsx @@ -25,19 +25,18 @@ describe("Advanced Search Form", () => { const submit = () => { fireEvent.click(screen.getByTestId("submit-advanced-search-button")) } - afterEach(async () => { - await userEvent.click(screen.getByText("Clear fields")) - }) - it("displays alert when no fields are submitted", () => { - submit() - screen.getByText(defaultEmptySearchErrorMessage) - }) - - it("can set keyword, contributor, title, subject", async () => { - const [keywordInput, contributorInput, titleInput, subjectInput] = [ + const updateAllFields = async () => { + const [ + keywordInput, + contributorInput, + titleInput, + subjectInput, + callNumberInput, + uniqueIdentifierInput, + ] = [ "Keyword", "Title", - "Author", + "Author/Contributor", "Subject", "Call number", "Unique identifier", @@ -46,13 +45,34 @@ describe("Advanced Search Form", () => { fireEvent.change(keywordInput, { target: { value: "spaghetti" } }) fireEvent.change(contributorInput, { target: { value: "strega nonna" } }) fireEvent.change(titleInput, { target: { value: "il amore di pasta" } }) + fireEvent.change(callNumberInput, { target: { value: "12345" } }) + fireEvent.change(uniqueIdentifierInput, { target: { value: "67890" } }) + // without this delay, the input is not updated until after submit is called. - await delay(50) + await delay(100) + return [ + keywordInput, + contributorInput, + titleInput, + subjectInput, + callNumberInput, + uniqueIdentifierInput, + ] + } + afterEach(async () => { + await userEvent.click(screen.getByText("Clear fields")) + }) + it("displays alert when no fields are submitted", () => { submit() - await waitFor(() => - expect(mockRouter.asPath).toBe( - "/search?q=spaghetti&title=strega+nonna&contributor=il+amore+di+pasta&subject=italian+food" - ) + screen.getByText(defaultEmptySearchErrorMessage) + }) + + it("can set keyword, contributor, title, subject", async () => { + await updateAllFields() + submit() + + expect(mockRouter.asPath).toBe( + "/search?q=spaghetti&title=strega+nonna&contributor=il+amore+di+pasta&callnumber=12345&standard_number=67890&subject=italian+food" ) }) it("renders inputs for all text input fields", () => { @@ -102,14 +122,8 @@ describe("Advanced Search Form", () => { }) await userEvent.click(schomburg) - const keywordInput = screen.getByLabelText("Keyword") - const titleInput = screen.getByLabelText("Title") - const contributorInput = screen.getByLabelText("Author") - const subjectInput = screen.getByLabelText("Subject") - await userEvent.type(keywordInput, "spaghetti") - await userEvent.type(contributorInput, "strega nonna") - await userEvent.type(titleInput, "il amore di pasta") - await userEvent.type(subjectInput, "italian food") + const [subjectInput, keywordInput, titleInput, contributorInput] = + await updateAllFields() await userEvent.click(screen.getByText("Clear fields")) ;[notatedMusic, cartographic, schomburg].forEach((input) => diff --git a/src/utils/advancedSearchUtils.ts b/src/utils/advancedSearchUtils.ts index 8ae98e8d8..b46224808 100644 --- a/src/utils/advancedSearchUtils.ts +++ b/src/utils/advancedSearchUtils.ts @@ -5,7 +5,7 @@ import { BASE_URL } from "../config/constants" export const textInputFields: SearchFormInputField[] = [ { name: "q", label: "Keyword" }, { name: "title", label: "Title" }, - { name: "contributor", label: "Author" }, + { name: "contributor", label: "Author/Contributor" }, { name: "callnumber", label: "Call number" }, { name: "standard_number", label: "Unique identifier" }, { name: "subject", label: "Subject" }, From 2381b7e9ebd05046cb8d9b5b55c3b434f988cddd Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 9 Dec 2024 12:20:17 -0500 Subject: [PATCH 26/29] update tests --- __test__/pages/search/advancedSearchForm.test.tsx | 4 ++-- src/utils/advancedSearchUtils.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/__test__/pages/search/advancedSearchForm.test.tsx b/__test__/pages/search/advancedSearchForm.test.tsx index de7cc0b54..69be2b364 100644 --- a/__test__/pages/search/advancedSearchForm.test.tsx +++ b/__test__/pages/search/advancedSearchForm.test.tsx @@ -36,7 +36,7 @@ describe("Advanced Search Form", () => { ] = [ "Keyword", "Title", - "Author/Contributor", + "Author/contributor", "Subject", "Call number", "Unique identifier", @@ -49,7 +49,7 @@ describe("Advanced Search Form", () => { fireEvent.change(uniqueIdentifierInput, { target: { value: "67890" } }) // without this delay, the input is not updated until after submit is called. - await delay(100) + await delay(500) return [ keywordInput, contributorInput, diff --git a/src/utils/advancedSearchUtils.ts b/src/utils/advancedSearchUtils.ts index b46224808..fa8f0947d 100644 --- a/src/utils/advancedSearchUtils.ts +++ b/src/utils/advancedSearchUtils.ts @@ -5,7 +5,7 @@ import { BASE_URL } from "../config/constants" export const textInputFields: SearchFormInputField[] = [ { name: "q", label: "Keyword" }, { name: "title", label: "Title" }, - { name: "contributor", label: "Author/Contributor" }, + { name: "contributor", label: "Author/contributor" }, { name: "callnumber", label: "Call number" }, { name: "standard_number", label: "Unique identifier" }, { name: "subject", label: "Subject" }, From 62c1b57845d5c34681fdccab3ec7d48541c852aa Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 9 Dec 2024 12:52:59 -0500 Subject: [PATCH 27/29] comment test --- __test__/pages/search/advancedSearchForm.test.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/__test__/pages/search/advancedSearchForm.test.tsx b/__test__/pages/search/advancedSearchForm.test.tsx index 69be2b364..c00fbfbfe 100644 --- a/__test__/pages/search/advancedSearchForm.test.tsx +++ b/__test__/pages/search/advancedSearchForm.test.tsx @@ -67,14 +67,15 @@ describe("Advanced Search Form", () => { screen.getByText(defaultEmptySearchErrorMessage) }) - it("can set keyword, contributor, title, subject", async () => { - await updateAllFields() - submit() + it.todo("can set keyword, contributor, title, subject") + // async () => { + // await updateAllFields() + // submit() - expect(mockRouter.asPath).toBe( - "/search?q=spaghetti&title=strega+nonna&contributor=il+amore+di+pasta&callnumber=12345&standard_number=67890&subject=italian+food" - ) - }) + // expect(mockRouter.asPath).toBe( + // "/search?q=spaghetti&title=strega+nonna&contributor=il+amore+di+pasta&callnumber=12345&standard_number=67890&subject=italian+food" + // ) + // }) it("renders inputs for all text input fields", () => { textInputFields.map(({ label }) => { const input = screen.getByLabelText(label) From 3bb6b9a9a286e7bf4f6df8a7b9ca8ca47e1871f1 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 9 Dec 2024 12:57:40 -0500 Subject: [PATCH 28/29] un comment tests --- __test__/pages/search/advancedSearchForm.test.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/__test__/pages/search/advancedSearchForm.test.tsx b/__test__/pages/search/advancedSearchForm.test.tsx index c00fbfbfe..69be2b364 100644 --- a/__test__/pages/search/advancedSearchForm.test.tsx +++ b/__test__/pages/search/advancedSearchForm.test.tsx @@ -67,15 +67,14 @@ describe("Advanced Search Form", () => { screen.getByText(defaultEmptySearchErrorMessage) }) - it.todo("can set keyword, contributor, title, subject") - // async () => { - // await updateAllFields() - // submit() + it("can set keyword, contributor, title, subject", async () => { + await updateAllFields() + submit() - // expect(mockRouter.asPath).toBe( - // "/search?q=spaghetti&title=strega+nonna&contributor=il+amore+di+pasta&callnumber=12345&standard_number=67890&subject=italian+food" - // ) - // }) + expect(mockRouter.asPath).toBe( + "/search?q=spaghetti&title=strega+nonna&contributor=il+amore+di+pasta&callnumber=12345&standard_number=67890&subject=italian+food" + ) + }) it("renders inputs for all text input fields", () => { textInputFields.map(({ label }) => { const input = screen.getByLabelText(label) From 831f476869c3a2a1a5c95c9dc21842b2444f57b6 Mon Sep 17 00:00:00 2001 From: Vera Kahn Date: Mon, 9 Dec 2024 13:17:43 -0500 Subject: [PATCH 29/29] update changelog --- CHANGELOG | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 14e076471..d2c91d4b0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,7 +5,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Prerelease +## [1.3.8] 2024-12-9 + +Note this release was not merged to main before deploying. ### Updated