77 jurisdiction ,
88 mockBaseJurisdiction ,
99 mockUser ,
10- user ,
1110} from "@bloom-housing/shared-helpers/__tests__/testHelpers"
1211import {
1312 FeatureFlag ,
@@ -30,7 +29,9 @@ const jurisdictions = [
3029 { name : FeatureFlagEnum . enableRegions , active : true } as FeatureFlag ,
3130 { name : FeatureFlagEnum . enableHomeType , active : true } as FeatureFlag ,
3231 { name : FeatureFlagEnum . enableCompanyWebsite , active : true } as FeatureFlag ,
32+ { name : FeatureFlagEnum . enableWhatToExpectAdditionalField , active : true } as FeatureFlag ,
3333 ] ,
34+ whatToExpect : "Here's what you might expect from the process." ,
3435 requiredListingFields : [
3536 "listingsBuildingAddress" ,
3637 "name" ,
@@ -126,9 +127,10 @@ describe("add listing", () => {
126127 return false
127128 }
128129 } ,
130+ getJurisdictionLanguages : ( ) => [ ] ,
129131 } }
130132 >
131- < ListingForm />
133+ < ListingForm jurisdictionId = { "Bloomington" } />
132134 </ AuthContext . Provider >
133135 )
134136
@@ -181,29 +183,41 @@ describe("add listing", () => {
181183 return res ( ctx . json ( [ ] ) )
182184 } )
183185 )
186+
187+ const mockRetrieve = jest . fn ( ) . mockResolvedValue ( { } )
188+
184189 render (
185190 < AuthContext . Provider
186191 value = { {
187- profile : {
188- ...user ,
189- listings : [ ] ,
190- jurisdictions : [ jurisdiction ] ,
191- } ,
192- getJurisdictionLanguages : ( ) => [ ] ,
193- jurisdictionsService : new JurisdictionsService ( ) ,
194192 doJurisdictionsHaveFeatureFlagOn : ( featureFlag : FeatureFlagEnum ) => {
195193 switch ( featureFlag ) {
196- case FeatureFlagEnum . swapCommunityTypeWithPrograms :
197- return false
194+ case FeatureFlagEnum . enableRegions :
195+ return true
196+ case FeatureFlagEnum . enableHomeType :
197+ return true
198+ case FeatureFlagEnum . enableCompanyWebsite :
199+ return true
198200 case FeatureFlagEnum . enableWhatToExpectAdditionalField :
199201 return true
200202 default :
201203 return false
202204 }
203205 } ,
206+ getJurisdictionLanguages,
207+ profile : {
208+ ...mockUser ,
209+ listings : [ ] ,
210+ jurisdictions : jurisdictions as Jurisdiction [ ] ,
211+ userRoles : {
212+ isAdmin : true ,
213+ } ,
214+ } ,
215+ jurisdictionsService : {
216+ retrieve : mockRetrieve ,
217+ } as unknown as JurisdictionsService ,
204218 } }
205219 >
206- < ListingForm />
220+ < ListingForm jurisdictionId = { "Bloomington" } />
207221 </ AuthContext . Provider >
208222 )
209223
@@ -213,18 +227,11 @@ describe("add listing", () => {
213227 / t e l l t h e a p p l i c a n t w h a t t o e x p e c t f r o m t h e p r o c e s s / i
214228 )
215229 expect ( whatToExpectEditorLabel ) . toBeInTheDocument ( )
216- const whatToExpectEditorWrapper = whatToExpectEditorLabel . parentElement . parentElement
230+ const whatToExpectEditorWrapper =
231+ whatToExpectEditorLabel . parentElement . parentElement . parentElement
217232
218233 expect (
219- await within ( whatToExpectEditorWrapper ) . findByText (
220- "Applicants will be contacted by the property agent in rank order until vacancies are filled. All of the information that you have provided will be verified and your eligibility confirmed. Your application will be removed from the waitlist if you have made any fraudulent statements. If we cannot verify a housing preference that you have claimed, you will not receive the preference but will not be otherwise penalized. Should your application be chosen, be prepared to fill out a more detailed application and provide required supporting documents."
221- )
222- ) . toBeInTheDocument ( )
223- expect (
224- within ( whatToExpectEditorWrapper ) . getByText ( "You have 451 characters remaining" )
225- ) . toBeInTheDocument ( )
226- expect (
227- within ( whatToExpectEditorWrapper ) . getByRole ( "menuitem" , { name : "Bold" } )
234+ await within ( whatToExpectEditorWrapper ) . findByRole ( "menuitem" , { name : "Bold" } )
228235 ) . toBeInTheDocument ( )
229236 expect (
230237 within ( whatToExpectEditorWrapper ) . getByRole ( "menuitem" , { name : "Bullet list" } )
@@ -241,6 +248,15 @@ describe("add listing", () => {
241248 expect (
242249 within ( whatToExpectEditorWrapper ) . getByRole ( "menuitem" , { name : "Unlink" } )
243250 ) . toBeInTheDocument ( )
251+
252+ expect (
253+ within ( whatToExpectEditorWrapper ) . getByText ( "Here's what you might expect from the process." )
254+ ) . toBeInTheDocument ( )
255+
256+ expect (
257+ within ( whatToExpectEditorWrapper ) . getByText ( "You have 954 characters remaining" )
258+ ) . toBeInTheDocument ( )
259+
244260 // Query issue: https://github.com/ueberdosis/tiptap/discussions/4008#discussioncomment-7623655
245261 const editor = screen . getByTestId ( "whatToExpect" ) . firstElementChild . querySelector ( "p" )
246262 act ( ( ) => {
@@ -260,15 +276,7 @@ describe("add listing", () => {
260276 whatToExpectAdditonalTextEditorLabel . parentElement . parentElement
261277
262278 expect (
263- await within ( whatToExpectAdditonalTextEditorWrapper ) . findByText (
264- "Property staff should walk you through the process to get on their waitlist."
265- )
266- ) . toBeInTheDocument ( )
267- expect (
268- within ( whatToExpectAdditonalTextEditorWrapper ) . getByText ( "You have 924 characters remaining" )
269- ) . toBeInTheDocument ( )
270- expect (
271- within ( whatToExpectAdditonalTextEditorWrapper ) . getByRole ( "menuitem" , { name : "Bold" } )
279+ await within ( whatToExpectAdditonalTextEditorWrapper ) . findByRole ( "menuitem" , { name : "Bold" } )
272280 ) . toBeInTheDocument ( )
273281 expect (
274282 within ( whatToExpectAdditonalTextEditorWrapper ) . getByRole ( "menuitem" , { name : "Bullet list" } )
@@ -287,6 +295,17 @@ describe("add listing", () => {
287295 expect (
288296 within ( whatToExpectAdditonalTextEditorWrapper ) . getByRole ( "menuitem" , { name : "Unlink" } )
289297 ) . toBeInTheDocument ( )
298+
299+ expect (
300+ within ( whatToExpectAdditonalTextEditorWrapper ) . getByText (
301+ "Property staff should walk you through the process to get on their waitlist."
302+ )
303+ ) . toBeInTheDocument ( )
304+
305+ expect (
306+ within ( whatToExpectAdditonalTextEditorWrapper ) . getByText ( "You have 473 characters remaining" )
307+ ) . toBeInTheDocument ( )
308+
290309 // Query issue: https://github.com/ueberdosis/tiptap/discussions/4008#discussioncomment-7623655
291310 const whatToExpectAdditonalTextEditor = screen
292311 . getByTestId ( "whatToExpectAdditionalText" )
@@ -358,11 +377,11 @@ describe("add listing", () => {
358377 } as unknown as JurisdictionsService ,
359378 } }
360379 >
361- < ListingForm />
380+ < ListingForm jurisdictionId = { "Bloomington" } />
362381 </ AuthContext . Provider >
363382 )
364383
365- const requiredFields = [ "Listing name" , "Jurisdiction" ]
384+ const requiredFields = [ "Listing name" ]
366385
367386 const unrequiredFields = [
368387 "Housing developer" ,
@@ -474,13 +493,12 @@ describe("add listing", () => {
474493 } as unknown as JurisdictionsService ,
475494 } }
476495 >
477- < ListingForm />
496+ < ListingForm jurisdictionId = { "Bloomington" } />
478497 </ AuthContext . Provider >
479498 )
480499
481500 const possibleRequiredFields = [
482501 "Listing name" ,
483- "Jurisdiction" ,
484502 "Housing developer" ,
485503 "Photos" ,
486504 "Street address" ,
0 commit comments