|
8 | 8 | Listing, |
9 | 9 | RaceEthnicityConfiguration, |
10 | 10 | } from "@bloom-housing/shared-helpers/src/types/backend-swagger" |
| 11 | +import { t } from "@bloom-housing/ui-components" |
11 | 12 | import { defaultRaceEthnicityConfiguration } from "@bloom-housing/shared-helpers/__tests__/testHelpers" |
12 | 13 | import { mockNextRouter, render } from "../../../testUtils" |
13 | 14 | import ApplicationConductor from "../../../../src/lib/applications/ApplicationConductor" |
@@ -78,11 +79,55 @@ describe("Demographics", () => { |
78 | 79 | expect(screen.getByRole("checkbox", { name: "Other / Multiracial" })).toBeInTheDocument() |
79 | 80 | expect(screen.getByRole("checkbox", { name: "Decline to respond" })).toBeInTheDocument() |
80 | 81 | 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() |
81 | 111 | 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"), |
84 | 114 | }) |
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() |
86 | 131 | }) |
87 | 132 |
|
88 | 133 | it("should render sub demographics fields when parent is checked", () => { |
@@ -229,17 +274,55 @@ describe("Demographics", () => { |
229 | 274 | <ApplicationDemographics /> |
230 | 275 | </AppSubmissionContext.Provider> |
231 | 276 | ) |
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() |
243 | 326 | }) |
244 | 327 |
|
245 | 328 | it("should hide ethnicity field when disabledEthnicityQuestion flag is on", () => { |
@@ -280,19 +363,16 @@ describe("Demographics", () => { |
280 | 363 | options: [ |
281 | 364 | { |
282 | 365 | id: "blackAfricanAmerican", |
283 | | - hasSubOptions: false, |
284 | 366 | subOptions: [], |
285 | 367 | allowOtherText: false, |
286 | 368 | }, |
287 | 369 | { |
288 | 370 | id: "white", |
289 | | - hasSubOptions: false, |
290 | 371 | subOptions: [], |
291 | 372 | allowOtherText: false, |
292 | 373 | }, |
293 | 374 | { |
294 | 375 | id: "otherMultiracial", |
295 | | - hasSubOptions: false, |
296 | 376 | subOptions: [], |
297 | 377 | allowOtherText: true, |
298 | 378 | }, |
@@ -340,7 +420,6 @@ describe("Demographics", () => { |
340 | 420 | options: [ |
341 | 421 | { |
342 | 422 | id: "asian", |
343 | | - hasSubOptions: true, |
344 | 423 | subOptions: [ |
345 | 424 | { id: "chinese", allowOtherText: false }, |
346 | 425 | { id: "vietnamese", allowOtherText: false }, |
|
0 commit comments