11import { 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"
33import React from "react"
44import userEvent from "@testing-library/user-event"
55import { RaceEthnicityConfiguration } from "@bloom-housing/shared-helpers/src/types/backend-swagger"
66import { defaultRaceEthnicityConfiguration } from "@bloom-housing/shared-helpers/__tests__/testHelpers"
7+ import { t } from "@bloom-housing/ui-components"
78
89const 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 ( / e t h n i c i t y / i) ) . toBeInTheDocument ( )
7573
76- expect ( screen . getByText ( / h o w d i d y o u h e a r a b o u t u s / i) )
77- expect ( screen . getByLabelText ( / b u s a d / i) ) . toBeInTheDocument ( )
78- expect ( screen . getByLabelText ( / d e v e l o p e r w e b s i t e / i) ) . toBeInTheDocument ( )
79- expect ( screen . getByLabelText ( / e m a i l a l e r t / i) ) . toBeInTheDocument ( )
80- expect ( screen . getByLabelText ( / f l y e r / i) ) . toBeInTheDocument ( )
81- expect ( screen . getByLabelText ( / f r i e n d / i) ) . toBeInTheDocument ( )
82- expect ( screen . getByLabelText ( / h o u s i n g c o u n s e l o r / i) ) . toBeInTheDocument ( )
83- expect ( screen . getByLabelText ( / ^ o t h e r $ / i) ) . toBeInTheDocument ( )
84- expect ( screen . getByLabelText ( / r a d i o a d / i) ) . toBeInTheDocument ( )
85- expect ( screen . getByLabelText ( / j u r i s d i c t i o n w e b s i t e / i) ) . toBeInTheDocument ( )
86- expect ( screen . queryByLabelText ( / g o v e r n m e n t w e b s i t e / i) ) . not . toBeInTheDocument ( )
87- expect ( screen . queryByLabelText ( / p r o p e r t y w e b s i t e / 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 ( / e t h n i c i t y / i) ) . toBeInTheDocument ( )
109144
110- expect ( screen . getByText ( / h o w d i d y o u h e a r a b o u t u s / i) )
111- expect ( screen . queryByLabelText ( / b u s a d / i) ) . not . toBeInTheDocument ( )
112- expect ( screen . getByLabelText ( / d e v e l o p e r w e b s i t e / i) ) . toBeInTheDocument ( )
113- expect ( screen . getByLabelText ( / e m a i l a l e r t / i) ) . toBeInTheDocument ( )
114- expect ( screen . getByLabelText ( / f l y e r / i) ) . toBeInTheDocument ( )
115- expect ( screen . getByLabelText ( / f r i e n d / i) ) . toBeInTheDocument ( )
116- expect ( screen . getByLabelText ( / h o u s i n g c o u n s e l o r / i) ) . toBeInTheDocument ( )
117- expect ( screen . getByLabelText ( / ^ o t h e r $ / i) ) . toBeInTheDocument ( )
118- expect ( screen . queryByLabelText ( / r a d i o a d / i) ) . not . toBeInTheDocument ( )
119- expect ( screen . getByLabelText ( / j u r i s d i c t i o n w e b s i t e / i) ) . toBeInTheDocument ( )
120- expect ( screen . queryByLabelText ( / g o v e r n m e n t w e b s i t e / i) ) . not . toBeInTheDocument ( )
121- expect ( screen . queryByLabelText ( / p r o p e r t y w e b s i t e / 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 } ,
0 commit comments