forked from bloom-housing/bloom
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #741 from CityOfDetroit/feature/add-eligibility-di…
…sclaimer Feature/add eligibility disclaimer
- Loading branch information
Showing
17 changed files
with
163 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
sites/public/__tests__/eligibility_questionnaire/EligibilityDisclaimer.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { render, fireEvent, screen } from "@testing-library/react" | ||
import EligibilityIncome from "../../pages/eligibility/income" | ||
import React from "react" | ||
import { act } from "react-dom/test-utils" | ||
import userEvent from "@testing-library/user-event" | ||
import EligibilityDisclaimer from "../../pages/eligibility/disclaimer" | ||
|
||
const mockRouter = { | ||
push: jest.fn(), | ||
} | ||
jest.mock("next/router", () => ({ | ||
useRouter() { | ||
return mockRouter | ||
}, | ||
})) | ||
|
||
describe("<EligibilityDisclaimer>", () => { | ||
it("Renders Disclaimer page of eligibility questionnaire", () => { | ||
act(() => { | ||
render(<EligibilityDisclaimer />) | ||
}) | ||
expect(screen.getByRole("heading", { name: "Disclaimer" })).toBeInTheDocument() | ||
expect(screen.getByRole("button", { name: "View Listings" })).toBeInTheDocument() | ||
}) | ||
|
||
it("Clicks the Finish button", async () => { | ||
await act(async () => { | ||
render(<EligibilityDisclaimer />) | ||
fireEvent.click(screen.getByRole("button", { name: "View Listings" })) | ||
}) | ||
|
||
expect(mockRouter.push.mock.calls.length).toBe(1) | ||
expect(mockRouter.push.mock.calls[0][0]).toContain("/listings") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export const DATE_FORMAT = "MMMM D, YYYY" | ||
export const ELIGIBILITY_SECTIONS = ["welcome", "household", "age", "disability", "income"] | ||
export const ELIGIBILITY_ROUTE = "eligibility" | ||
export const ELIGIBILITY_DISCLAIMER_ROUTE = `/${ELIGIBILITY_ROUTE}/disclaimer` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
Eligibility Disclaimer | ||
Disclaimer about filtering and waitlists. | ||
*/ | ||
import { AppearanceStyleType, Button, FormCard, t, Form } from "@bloom-housing/ui-components" | ||
import FormsLayout from "../../layouts/forms" | ||
import { useForm } from "react-hook-form" | ||
import React, { useContext } from "react" | ||
import { useRouter } from "next/router" | ||
import { EligibilityContext } from "../../lib/EligibilityContext" | ||
import { getFilterUrlLink } from "../../lib/filterUrlLink" | ||
|
||
const EligibilityDisclaimer = () => { | ||
const router = useRouter() | ||
const { eligibilityRequirements } = useContext(EligibilityContext) | ||
|
||
/* Form Handler */ | ||
const { handleSubmit } = useForm() | ||
const onSubmit = async (data) => { | ||
await router.push(getFilterUrlLink(eligibilityRequirements)) | ||
} | ||
|
||
return ( | ||
<FormsLayout> | ||
<header className="eligibility-disclaimer-header"> | ||
<h1 className="form-card__header_title">{t("eligibility.progress.sections.disclaimer")}</h1> | ||
</header> | ||
<div className="form-card__pager-row px-16"> | ||
<p className="field-note py-2">{t("eligibility.disclaimer.description")}</p> | ||
</div> | ||
<Form className="eligibility-disclaimer-submit-container" onSubmit={handleSubmit(onSubmit)}> | ||
<Button styleType={AppearanceStyleType.primary}>{t("t.viewListings")}</Button> | ||
</Form> | ||
</FormsLayout> | ||
) | ||
} | ||
|
||
export default EligibilityDisclaimer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.