Skip to content

Commit b13ba5e

Browse files
fix: how did you hear test labels
1 parent a2b0f87 commit b13ba5e

File tree

1 file changed

+97
-18
lines changed

1 file changed

+97
-18
lines changed

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

Lines changed: 97 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
Listing,
99
RaceEthnicityConfiguration,
1010
} from "@bloom-housing/shared-helpers/src/types/backend-swagger"
11+
import { t } from "@bloom-housing/ui-components"
1112
import { defaultRaceEthnicityConfiguration } from "@bloom-housing/shared-helpers/__tests__/testHelpers"
1213
import { mockNextRouter, render } from "../../../testUtils"
1314
import ApplicationConductor from "../../../../src/lib/applications/ApplicationConductor"
@@ -78,11 +79,55 @@ describe("Demographics", () => {
7879
expect(screen.getByRole("checkbox", { name: "Other / Multiracial" })).toBeInTheDocument()
7980
expect(screen.getByRole("checkbox", { name: "Decline to respond" })).toBeInTheDocument()
8081
expect(screen.getByLabelText("Which best describes your ethnicity?")).toBeInTheDocument()
82+
const howDidYouHearGroup = screen.getByRole("group", {
83+
name: "How did you hear about this listing?",
84+
})
85+
expect(within(howDidYouHearGroup).getAllByRole("checkbox")).toHaveLength(9)
86+
expect(
87+
within(howDidYouHearGroup).getByRole("checkbox", {
88+
name: t("application.review.demographics.howDidYouHearOptions.flyer"),
89+
})
90+
).toBeInTheDocument()
91+
expect(
92+
within(howDidYouHearGroup).getByRole("checkbox", {
93+
name: t("application.review.demographics.howDidYouHearOptions.emailAlert"),
94+
})
95+
).toBeInTheDocument()
96+
expect(
97+
within(howDidYouHearGroup).getByRole("checkbox", {
98+
name: t("application.review.demographics.howDidYouHearOptions.friend"),
99+
})
100+
).toBeInTheDocument()
101+
expect(
102+
within(howDidYouHearGroup).getByRole("checkbox", {
103+
name: t("application.review.demographics.howDidYouHearOptions.housingCounselor"),
104+
})
105+
).toBeInTheDocument()
106+
expect(
107+
within(howDidYouHearGroup).getByRole("checkbox", {
108+
name: t("application.review.demographics.howDidYouHearOptions.developerWebsite"),
109+
})
110+
).toBeInTheDocument()
81111
expect(
82-
screen.getAllByRole("checkbox", {
83-
name: /Jurisdiction website|Developer website|Flyer|Email alert|Friend|Housing counselor|Radio ad|Bus ad|Other/,
112+
within(howDidYouHearGroup).getByRole("checkbox", {
113+
name: t("application.review.demographics.howDidYouHearOptions.jurisdictionWebsite"),
84114
})
85-
).toHaveLength(11)
115+
).toBeInTheDocument()
116+
expect(
117+
within(howDidYouHearGroup).getByRole("checkbox", {
118+
name: t("application.review.demographics.howDidYouHearOptions.busAd"),
119+
})
120+
).toBeInTheDocument()
121+
expect(
122+
within(howDidYouHearGroup).getByRole("checkbox", {
123+
name: t("application.review.demographics.howDidYouHearOptions.radioAd"),
124+
})
125+
).toBeInTheDocument()
126+
expect(
127+
within(howDidYouHearGroup).getByRole("checkbox", {
128+
name: t("application.review.demographics.howDidYouHearOptions.other"),
129+
})
130+
).toBeInTheDocument()
86131
})
87132

88133
it("should render sub demographics fields when parent is checked", () => {
@@ -229,17 +274,55 @@ describe("Demographics", () => {
229274
<ApplicationDemographics />
230275
</AppSubmissionContext.Provider>
231276
)
232-
expect(screen.getByText("How did you hear about this listing?")).toBeInTheDocument()
233-
expect(screen.getByRole("checkbox", { name: "Jurisdiction website" })).toBeInTheDocument()
234-
expect(screen.getByRole("checkbox", { name: "Developer website" })).toBeInTheDocument()
235-
expect(screen.getByRole("checkbox", { name: "Flyer" })).toBeInTheDocument()
236-
expect(screen.getByRole("checkbox", { name: "Email alert" })).toBeInTheDocument()
237-
expect(screen.getByRole("checkbox", { name: "Friend" })).toBeInTheDocument()
238-
expect(screen.getByRole("checkbox", { name: "Friend" })).toBeInTheDocument()
239-
expect(screen.getByRole("checkbox", { name: "Housing counselor" })).toBeInTheDocument()
240-
expect(screen.queryByRole("checkbox", { name: "Radio ad" })).not.toBeInTheDocument()
241-
expect(screen.queryByRole("checkbox", { name: "Bus ad" })).not.toBeInTheDocument()
242-
expect(screen.getByRole("checkbox", { name: "Other" })).toBeInTheDocument()
277+
const howDidYouHearGroup = screen.getByRole("group", {
278+
name: "How did you hear about this listing?",
279+
})
280+
expect(within(howDidYouHearGroup).getAllByRole("checkbox")).toHaveLength(7)
281+
expect(
282+
within(howDidYouHearGroup).getByRole("checkbox", {
283+
name: t("application.review.demographics.howDidYouHearOptions.flyer"),
284+
})
285+
).toBeInTheDocument()
286+
expect(
287+
within(howDidYouHearGroup).getByRole("checkbox", {
288+
name: t("application.review.demographics.howDidYouHearOptions.emailAlert"),
289+
})
290+
).toBeInTheDocument()
291+
expect(
292+
within(howDidYouHearGroup).getByRole("checkbox", {
293+
name: t("application.review.demographics.howDidYouHearOptions.friend"),
294+
})
295+
).toBeInTheDocument()
296+
expect(
297+
within(howDidYouHearGroup).getByRole("checkbox", {
298+
name: t("application.review.demographics.howDidYouHearOptions.housingCounselor"),
299+
})
300+
).toBeInTheDocument()
301+
expect(
302+
within(howDidYouHearGroup).getByRole("checkbox", {
303+
name: t("application.review.demographics.howDidYouHearOptions.developerWebsite"),
304+
})
305+
).toBeInTheDocument()
306+
expect(
307+
within(howDidYouHearGroup).getByRole("checkbox", {
308+
name: t("application.review.demographics.howDidYouHearOptions.jurisdictionWebsite"),
309+
})
310+
).toBeInTheDocument()
311+
expect(
312+
within(howDidYouHearGroup).queryByRole("checkbox", {
313+
name: t("application.review.demographics.howDidYouHearOptions.busAd"),
314+
})
315+
).not.toBeInTheDocument()
316+
expect(
317+
within(howDidYouHearGroup).queryByRole("checkbox", {
318+
name: t("application.review.demographics.howDidYouHearOptions.radioAd"),
319+
})
320+
).not.toBeInTheDocument()
321+
expect(
322+
within(howDidYouHearGroup).getByRole("checkbox", {
323+
name: t("application.review.demographics.howDidYouHearOptions.other"),
324+
})
325+
).toBeInTheDocument()
243326
})
244327

245328
it("should hide ethnicity field when disabledEthnicityQuestion flag is on", () => {
@@ -280,19 +363,16 @@ describe("Demographics", () => {
280363
options: [
281364
{
282365
id: "blackAfricanAmerican",
283-
hasSubOptions: false,
284366
subOptions: [],
285367
allowOtherText: false,
286368
},
287369
{
288370
id: "white",
289-
hasSubOptions: false,
290371
subOptions: [],
291372
allowOtherText: false,
292373
},
293374
{
294375
id: "otherMultiracial",
295-
hasSubOptions: false,
296376
subOptions: [],
297377
allowOtherText: true,
298378
},
@@ -340,7 +420,6 @@ describe("Demographics", () => {
340420
options: [
341421
{
342422
id: "asian",
343-
hasSubOptions: true,
344423
subOptions: [
345424
{ id: "chinese", allowOtherText: false },
346425
{ id: "vietnamese", allowOtherText: false },

0 commit comments

Comments
 (0)