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-3904: Advanced Search page A11y and VQA fixes #59

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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