88 Listing ,
99 RaceEthnicityConfiguration ,
1010} from "@bloom-housing/shared-helpers/src/types/backend-swagger"
11+ import { t } from "@bloom-housing/ui-components"
1112import { defaultRaceEthnicityConfiguration } from "@bloom-housing/shared-helpers/__tests__/testHelpers"
1213import { mockNextRouter , render } from "../../../testUtils"
1314import 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 ( )
8196 expect (
82- screen . getAllByRole ( "checkbox" , {
83- name : / J u r i s d i c t i o n w e b s i t e | D e v e l o p e r w e b s i t e | F l y e r | E m a i l a l e r t | F r i e n d | H o u s i n g c o u n s e l o r | R a d i o a d | B u s a d | O t h e r / ,
97+ within ( howDidYouHearGroup ) . getByRole ( "checkbox" , {
98+ name : t ( "application.review.demographics.howDidYouHearOptions.friend" ) ,
8499 } )
85- ) . toHaveLength ( 11 )
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 ( )
111+ expect (
112+ within ( howDidYouHearGroup ) . getByRole ( "checkbox" , {
113+ name : t ( "application.review.demographics.howDidYouHearOptions.jurisdictionWebsite" ) ,
114+ } )
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" , ( ) => {
@@ -190,21 +235,6 @@ describe("Demographics", () => {
190235 } )
191236 } )
192237
193- it ( "should show full list of how did you hear fields" , ( ) => {
194- render ( < ApplicationDemographics /> )
195- expect ( screen . getByText ( "How did you hear about this listing?" ) ) . toBeInTheDocument ( )
196- expect ( screen . getByRole ( "checkbox" , { name : "Jurisdiction website" } ) ) . toBeInTheDocument ( )
197- expect ( screen . getByRole ( "checkbox" , { name : "Developer website" } ) ) . toBeInTheDocument ( )
198- expect ( screen . getByRole ( "checkbox" , { name : "Flyer" } ) ) . toBeInTheDocument ( )
199- expect ( screen . getByRole ( "checkbox" , { name : "Email alert" } ) ) . toBeInTheDocument ( )
200- expect ( screen . getByRole ( "checkbox" , { name : "Friend" } ) ) . toBeInTheDocument ( )
201- expect ( screen . getByRole ( "checkbox" , { name : "Friend" } ) ) . toBeInTheDocument ( )
202- expect ( screen . getByRole ( "checkbox" , { name : "Housing counselor" } ) ) . toBeInTheDocument ( )
203- expect ( screen . getByRole ( "checkbox" , { name : "Radio ad" } ) ) . toBeInTheDocument ( )
204- expect ( screen . getByRole ( "checkbox" , { name : "Bus ad" } ) ) . toBeInTheDocument ( )
205- expect ( screen . getByRole ( "checkbox" , { name : "Other" } ) ) . toBeInTheDocument ( )
206- } )
207-
208238 it ( "should show limited list of how did you hear fields when enableLimitedHowDidYouHear is on" , ( ) => {
209239 const conductor = new ApplicationConductor ( { } , { } )
210240 conductor . config . featureFlags = [
@@ -229,17 +259,55 @@ describe("Demographics", () => {
229259 < ApplicationDemographics />
230260 </ AppSubmissionContext . Provider >
231261 )
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 ( )
262+ const howDidYouHearGroup = screen . getByRole ( "group" , {
263+ name : "How did you hear about this listing?" ,
264+ } )
265+ expect ( within ( howDidYouHearGroup ) . getAllByRole ( "checkbox" ) ) . toHaveLength ( 7 )
266+ expect (
267+ within ( howDidYouHearGroup ) . getByRole ( "checkbox" , {
268+ name : t ( "application.review.demographics.howDidYouHearOptions.flyer" ) ,
269+ } )
270+ ) . toBeInTheDocument ( )
271+ expect (
272+ within ( howDidYouHearGroup ) . getByRole ( "checkbox" , {
273+ name : t ( "application.review.demographics.howDidYouHearOptions.emailAlert" ) ,
274+ } )
275+ ) . toBeInTheDocument ( )
276+ expect (
277+ within ( howDidYouHearGroup ) . getByRole ( "checkbox" , {
278+ name : t ( "application.review.demographics.howDidYouHearOptions.friend" ) ,
279+ } )
280+ ) . toBeInTheDocument ( )
281+ expect (
282+ within ( howDidYouHearGroup ) . getByRole ( "checkbox" , {
283+ name : t ( "application.review.demographics.howDidYouHearOptions.housingCounselor" ) ,
284+ } )
285+ ) . toBeInTheDocument ( )
286+ expect (
287+ within ( howDidYouHearGroup ) . getByRole ( "checkbox" , {
288+ name : t ( "application.review.demographics.howDidYouHearOptions.developerWebsite" ) ,
289+ } )
290+ ) . toBeInTheDocument ( )
291+ expect (
292+ within ( howDidYouHearGroup ) . getByRole ( "checkbox" , {
293+ name : t ( "application.review.demographics.howDidYouHearOptions.jurisdictionWebsite" ) ,
294+ } )
295+ ) . toBeInTheDocument ( )
296+ expect (
297+ within ( howDidYouHearGroup ) . queryByRole ( "checkbox" , {
298+ name : t ( "application.review.demographics.howDidYouHearOptions.busAd" ) ,
299+ } )
300+ ) . not . toBeInTheDocument ( )
301+ expect (
302+ within ( howDidYouHearGroup ) . queryByRole ( "checkbox" , {
303+ name : t ( "application.review.demographics.howDidYouHearOptions.radioAd" ) ,
304+ } )
305+ ) . not . toBeInTheDocument ( )
306+ expect (
307+ within ( howDidYouHearGroup ) . getByRole ( "checkbox" , {
308+ name : t ( "application.review.demographics.howDidYouHearOptions.other" ) ,
309+ } )
310+ ) . toBeInTheDocument ( )
243311 } )
244312
245313 it ( "should hide ethnicity field when disabledEthnicityQuestion flag is on" , ( ) => {
@@ -280,19 +348,16 @@ describe("Demographics", () => {
280348 options : [
281349 {
282350 id : "blackAfricanAmerican" ,
283- hasSubOptions : false ,
284351 subOptions : [ ] ,
285352 allowOtherText : false ,
286353 } ,
287354 {
288355 id : "white" ,
289- hasSubOptions : false ,
290356 subOptions : [ ] ,
291357 allowOtherText : false ,
292358 } ,
293359 {
294360 id : "otherMultiracial" ,
295- hasSubOptions : false ,
296361 subOptions : [ ] ,
297362 allowOtherText : true ,
298363 } ,
@@ -340,7 +405,6 @@ describe("Demographics", () => {
340405 options : [
341406 {
342407 id : "asian" ,
343- hasSubOptions : true ,
344408 subOptions : [
345409 { id : "chinese" , allowOtherText : false } ,
346410 { id : "vietnamese" , allowOtherText : false } ,
0 commit comments