Skip to content

Commit 5f3ce67

Browse files
fix: partner tests
1 parent b13ba5e commit 5f3ce67

File tree

2 files changed

+100
-45
lines changed

2 files changed

+100
-45
lines changed

sites/partners/__tests__/components/applications/PaperApplicationForm/sections/FormDemographics.test.tsx

Lines changed: 100 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
import { FormDemographics } from "../../../../../src/components/applications/PaperApplicationForm/sections/FormDemographics"
2-
import { mockNextRouter, render, screen, FormProviderWrapper } from "../../../../testUtils"
2+
import { mockNextRouter, render, screen, FormProviderWrapper, within } from "../../../../testUtils"
33
import React from "react"
44
import userEvent from "@testing-library/user-event"
55
import { RaceEthnicityConfiguration } from "@bloom-housing/shared-helpers/src/types/backend-swagger"
66
import { defaultRaceEthnicityConfiguration } from "@bloom-housing/shared-helpers/__tests__/testHelpers"
7+
import { t } from "@bloom-housing/ui-components"
78

89
const customConfig: RaceEthnicityConfiguration = {
910
options: [
1011
{
1112
id: "blackAfricanAmerican",
12-
hasSubOptions: false,
1313
subOptions: [],
1414
allowOtherText: false,
1515
},
1616
{
1717
id: "white",
18-
hasSubOptions: false,
1918
subOptions: [],
2019
allowOtherText: false,
2120
},
2221

2322
{
2423
id: "otherMultiracial",
25-
hasSubOptions: false,
2624
subOptions: [],
2725
allowOtherText: true,
2826
},
@@ -73,18 +71,55 @@ describe("<FormDemographics>", () => {
7371

7472
expect(screen.getByLabelText(/ethnicity/i)).toBeInTheDocument()
7573

76-
expect(screen.getByText(/how did you hear about us/i))
77-
expect(screen.getByLabelText(/bus ad/i)).toBeInTheDocument()
78-
expect(screen.getByLabelText(/developer website/i)).toBeInTheDocument()
79-
expect(screen.getByLabelText(/email alert/i)).toBeInTheDocument()
80-
expect(screen.getByLabelText(/flyer/i)).toBeInTheDocument()
81-
expect(screen.getByLabelText(/friend/i)).toBeInTheDocument()
82-
expect(screen.getByLabelText(/housing counselor/i)).toBeInTheDocument()
83-
expect(screen.getByLabelText(/^other$/i)).toBeInTheDocument()
84-
expect(screen.getByLabelText(/radio ad/i)).toBeInTheDocument()
85-
expect(screen.getByLabelText(/jurisdiction website/i)).toBeInTheDocument()
86-
expect(screen.queryByLabelText(/government website/i)).not.toBeInTheDocument()
87-
expect(screen.queryByLabelText(/property website/i)).not.toBeInTheDocument()
74+
const howDidYouHearGroup = screen.getByRole("group", {
75+
name: "How did you hear about us?",
76+
})
77+
expect(within(howDidYouHearGroup).getAllByRole("checkbox")).toHaveLength(9)
78+
expect(
79+
within(howDidYouHearGroup).getByRole("checkbox", {
80+
name: t("application.review.demographics.howDidYouHearOptions.flyer"),
81+
})
82+
).toBeInTheDocument()
83+
expect(
84+
within(howDidYouHearGroup).getByRole("checkbox", {
85+
name: t("application.review.demographics.howDidYouHearOptions.emailAlert"),
86+
})
87+
).toBeInTheDocument()
88+
expect(
89+
within(howDidYouHearGroup).getByRole("checkbox", {
90+
name: t("application.review.demographics.howDidYouHearOptions.friend"),
91+
})
92+
).toBeInTheDocument()
93+
expect(
94+
within(howDidYouHearGroup).getByRole("checkbox", {
95+
name: t("application.review.demographics.howDidYouHearOptions.housingCounselor"),
96+
})
97+
).toBeInTheDocument()
98+
expect(
99+
within(howDidYouHearGroup).getByRole("checkbox", {
100+
name: t("application.review.demographics.howDidYouHearOptions.developerWebsite"),
101+
})
102+
).toBeInTheDocument()
103+
expect(
104+
within(howDidYouHearGroup).getByRole("checkbox", {
105+
name: t("application.review.demographics.howDidYouHearOptions.jurisdictionWebsite"),
106+
})
107+
).toBeInTheDocument()
108+
expect(
109+
within(howDidYouHearGroup).getByRole("checkbox", {
110+
name: t("application.review.demographics.howDidYouHearOptions.busAd"),
111+
})
112+
).toBeInTheDocument()
113+
expect(
114+
within(howDidYouHearGroup).getByRole("checkbox", {
115+
name: t("application.review.demographics.howDidYouHearOptions.radioAd"),
116+
})
117+
).toBeInTheDocument()
118+
expect(
119+
within(howDidYouHearGroup).getByRole("checkbox", {
120+
name: t("application.review.demographics.howDidYouHearOptions.other"),
121+
})
122+
).toBeInTheDocument()
88123
})
89124

90125
it("renders the form with limited how did you hear options when flag is enabled", () => {
@@ -107,18 +142,55 @@ describe("<FormDemographics>", () => {
107142

108143
expect(screen.getByLabelText(/ethnicity/i)).toBeInTheDocument()
109144

110-
expect(screen.getByText(/how did you hear about us/i))
111-
expect(screen.queryByLabelText(/bus ad/i)).not.toBeInTheDocument()
112-
expect(screen.getByLabelText(/developer website/i)).toBeInTheDocument()
113-
expect(screen.getByLabelText(/email alert/i)).toBeInTheDocument()
114-
expect(screen.getByLabelText(/flyer/i)).toBeInTheDocument()
115-
expect(screen.getByLabelText(/friend/i)).toBeInTheDocument()
116-
expect(screen.getByLabelText(/housing counselor/i)).toBeInTheDocument()
117-
expect(screen.getByLabelText(/^other$/i)).toBeInTheDocument()
118-
expect(screen.queryByLabelText(/radio ad/i)).not.toBeInTheDocument()
119-
expect(screen.getByLabelText(/jurisdiction website/i)).toBeInTheDocument()
120-
expect(screen.queryByLabelText(/government website/i)).not.toBeInTheDocument()
121-
expect(screen.queryByLabelText(/property website/i)).not.toBeInTheDocument()
145+
const howDidYouHearGroup = screen.getByRole("group", {
146+
name: "How did you hear about us?",
147+
})
148+
expect(within(howDidYouHearGroup).getAllByRole("checkbox")).toHaveLength(7)
149+
expect(
150+
within(howDidYouHearGroup).getByRole("checkbox", {
151+
name: t("application.review.demographics.howDidYouHearOptions.flyer"),
152+
})
153+
).toBeInTheDocument()
154+
expect(
155+
within(howDidYouHearGroup).getByRole("checkbox", {
156+
name: t("application.review.demographics.howDidYouHearOptions.emailAlert"),
157+
})
158+
).toBeInTheDocument()
159+
expect(
160+
within(howDidYouHearGroup).getByRole("checkbox", {
161+
name: t("application.review.demographics.howDidYouHearOptions.friend"),
162+
})
163+
).toBeInTheDocument()
164+
expect(
165+
within(howDidYouHearGroup).getByRole("checkbox", {
166+
name: t("application.review.demographics.howDidYouHearOptions.housingCounselor"),
167+
})
168+
).toBeInTheDocument()
169+
expect(
170+
within(howDidYouHearGroup).getByRole("checkbox", {
171+
name: t("application.review.demographics.howDidYouHearOptions.developerWebsite"),
172+
})
173+
).toBeInTheDocument()
174+
expect(
175+
within(howDidYouHearGroup).getByRole("checkbox", {
176+
name: t("application.review.demographics.howDidYouHearOptions.jurisdictionWebsite"),
177+
})
178+
).toBeInTheDocument()
179+
expect(
180+
within(howDidYouHearGroup).queryByRole("checkbox", {
181+
name: t("application.review.demographics.howDidYouHearOptions.busAd"),
182+
})
183+
).not.toBeInTheDocument()
184+
expect(
185+
within(howDidYouHearGroup).queryByRole("checkbox", {
186+
name: t("application.review.demographics.howDidYouHearOptions.radioAd"),
187+
})
188+
).not.toBeInTheDocument()
189+
expect(
190+
within(howDidYouHearGroup).getByRole("checkbox", {
191+
name: t("application.review.demographics.howDidYouHearOptions.other"),
192+
})
193+
).toBeInTheDocument()
122194
})
123195

124196
it("should expand suboptions when main key is checked", async () => {
@@ -233,7 +305,6 @@ describe("<FormDemographics>", () => {
233305
options: [
234306
{
235307
id: "asian",
236-
hasSubOptions: true,
237308
subOptions: [
238309
{ id: "chinese", allowOtherText: false },
239310
{ id: "vietnamese", allowOtherText: false },
@@ -242,7 +313,6 @@ describe("<FormDemographics>", () => {
242313
},
243314
{
244315
id: "otherMultiracial",
245-
hasSubOptions: false,
246316
subOptions: [],
247317
allowOtherText: true,
248318
},

sites/public/__tests__/pages/applications/review/demographics.test.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -235,21 +235,6 @@ describe("Demographics", () => {
235235
})
236236
})
237237

238-
it("should show full list of how did you hear fields", () => {
239-
render(<ApplicationDemographics />)
240-
expect(screen.getByText("How did you hear about this listing?")).toBeInTheDocument()
241-
expect(screen.getByRole("checkbox", { name: "Jurisdiction website" })).toBeInTheDocument()
242-
expect(screen.getByRole("checkbox", { name: "Developer website" })).toBeInTheDocument()
243-
expect(screen.getByRole("checkbox", { name: "Flyer" })).toBeInTheDocument()
244-
expect(screen.getByRole("checkbox", { name: "Email alert" })).toBeInTheDocument()
245-
expect(screen.getByRole("checkbox", { name: "Friend" })).toBeInTheDocument()
246-
expect(screen.getByRole("checkbox", { name: "Friend" })).toBeInTheDocument()
247-
expect(screen.getByRole("checkbox", { name: "Housing counselor" })).toBeInTheDocument()
248-
expect(screen.getByRole("checkbox", { name: "Radio ad" })).toBeInTheDocument()
249-
expect(screen.getByRole("checkbox", { name: "Bus ad" })).toBeInTheDocument()
250-
expect(screen.getByRole("checkbox", { name: "Other" })).toBeInTheDocument()
251-
})
252-
253238
it("should show limited list of how did you hear fields when enableLimitedHowDidYouHear is on", () => {
254239
const conductor = new ApplicationConductor({}, {})
255240
conductor.config.featureFlags = [

0 commit comments

Comments
 (0)