Skip to content

Commit

Permalink
Merge branch 'main' into qa
Browse files Browse the repository at this point in the history
* main:
  Updates based on feedback for the Advanced Search page
  • Loading branch information
EdwinGuzman committed Dec 21, 2023
2 parents 695acbd + 4614937 commit c7da6aa
Show file tree
Hide file tree
Showing 4 changed files with 269 additions and 216 deletions.
27 changes: 20 additions & 7 deletions __test__/pages/search/advancedSearchForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { fireEvent, render, screen, act } from "@testing-library/react"
import mockRouter from "next-router-mock"
import userEvent from "@testing-library/user-event"

import AdvancedSearch from "../../../pages/search/advanced"
import AdvancedSearch, {
badDateErrorMessage,
defaultEmptySearchErrorMessage,
} from "../../../pages/search/advanced"

// Mock next router
jest.mock("next/router", () => jest.requireActual("next-router-mock"))
Expand All @@ -24,9 +27,7 @@ describe("Advanced Search Form", () => {
render(<AdvancedSearch />)

submit()
screen.getByText(
"Please enter at least one field to submit an advanced search."
)
screen.getByText(defaultEmptySearchErrorMessage)
})
// this test is broken due to debounce/userEvent/timing weirdness.
// this functionality works in the browser, but won't include
Expand Down Expand Up @@ -82,6 +83,18 @@ describe("Advanced Search Form", () => {
)
})
})
it("should throw an error when the date from is bigger than the date to", async () => {
render(<AdvancedSearch />)
await act(async () => {
const dateFromInput = screen.getByLabelText("From")
const dateToInput = screen.getByLabelText("To")
await userEvent.type(dateFromInput, "1999")
await userEvent.type(dateToInput, "1900")
submit()

expect(screen.getByText(badDateErrorMessage)).toBeInTheDocument()
})
})
it("can clear the form", async () => {
render(<AdvancedSearch />)

Expand All @@ -107,9 +120,9 @@ describe("Advanced Search Form", () => {
expect(notatedMusic).not.toBeChecked()
submit()
// presence of alert means the form was cleared before hitting submit
screen.getByText(
"Please enter at least one field to submit an advanced search."
)
expect(
screen.getByText(defaultEmptySearchErrorMessage)
).toBeInTheDocument()
})
})
})
150 changes: 75 additions & 75 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"coverage": "jest --coverage"
},
"dependencies": {
"@nypl/design-system-react-components": "^2.1.0",
"@nypl/design-system-react-components": "2.1.3",
"@nypl/nypl-data-api-client": "1.0.5",
"@types/node": "20.3.1",
"@types/react": "18.2.13",
Expand Down
Loading

0 comments on commit c7da6aa

Please sign in to comment.