Skip to content

Commit f094d90

Browse files
emilyjablonskiludtkemorgan
authored andcommitted
feat: preselect jurisdiction (bloom-housing#5582)
1 parent ba93809 commit f094d90

46 files changed

Lines changed: 1235 additions & 1148 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

shared-helpers/__tests__/testHelpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ export const listing: Listing = {
716716
},
717717
jurisdictions: {
718718
id: "id",
719-
name: "San Jose",
719+
name: "Bloomington",
720720
},
721721
depositMax: "",
722722
disableUnitsAccordion: false,

sites/partners/.jest/setup-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Future home of additional Jest config
2+
import "@testing-library/jest-dom"
23
import { addTranslation } from "@bloom-housing/ui-components"
34
import generalTranslations from "@bloom-housing/shared-helpers/src/locales/general.json"
45
import { serviceOptions } from "@bloom-housing/shared-helpers/src/types/backend-swagger"
5-
import "@testing-library/jest-dom"
66
import axios from "axios"
77
import general from "../page_content/locale_overrides/general.json"
88
addTranslation({ ...generalTranslations, ...general })
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import React from "react"
2+
import { render, screen } from "@testing-library/react"
3+
import { listing } from "@bloom-housing/shared-helpers/__tests__/testHelpers"
4+
import { ReviewOrderTypeEnum } from "@bloom-housing/shared-helpers/src/types/backend-swagger"
5+
import { ListingContext } from "../../../../../src/components/listings/ListingContext"
6+
import DetailListingData from "../../../../../src/components/listings/PaperListingDetails/sections/DetailListingData"
7+
8+
describe("DetailListingData", () => {
9+
it("should render all data", () => {
10+
render(
11+
<ListingContext.Provider
12+
value={{
13+
...listing,
14+
createdAt: new Date("2023-01-01T10:00:00Z"),
15+
jurisdictions: { name: "Bloomington", id: "1" },
16+
id: "1234",
17+
reviewOrderType: ReviewOrderTypeEnum.waitlist,
18+
units: [],
19+
}}
20+
>
21+
<DetailListingData showJurisdictionName={true} />
22+
</ListingContext.Provider>
23+
)
24+
expect(screen.getByRole("heading", { level: 2, name: "Listing data" })).toBeInTheDocument()
25+
expect(screen.getByText("Date created")).toBeInTheDocument()
26+
expect(screen.getByText("01/01/2023 at 10:00 AM")).toBeInTheDocument()
27+
expect(screen.getByText("Jurisdiction")).toBeInTheDocument()
28+
expect(screen.getByText("Bloomington")).toBeInTheDocument()
29+
expect(screen.getByText("Listing ID")).toBeInTheDocument()
30+
expect(screen.getByText("1234")).toBeInTheDocument()
31+
})
32+
33+
it("should hide jurisdiction", () => {
34+
render(
35+
<ListingContext.Provider
36+
value={{
37+
...listing,
38+
createdAt: new Date("2023-01-01T10:00:00Z"),
39+
jurisdictions: { name: "Bloomington", id: "1" },
40+
id: "1234",
41+
reviewOrderType: ReviewOrderTypeEnum.waitlist,
42+
units: [],
43+
}}
44+
>
45+
<DetailListingData showJurisdictionName={false} />
46+
</ListingContext.Provider>
47+
)
48+
expect(screen.getByRole("heading", { level: 2, name: "Listing data" })).toBeInTheDocument()
49+
expect(screen.getByText("Date created")).toBeInTheDocument()
50+
expect(screen.getByText("01/01/2023 at 10:00 AM")).toBeInTheDocument()
51+
expect(screen.queryByText("Jurisdiction")).not.toBeInTheDocument()
52+
expect(screen.queryByText("Bloomington")).not.toBeInTheDocument()
53+
expect(screen.getByText("Listing ID")).toBeInTheDocument()
54+
expect(screen.getByText("1234")).toBeInTheDocument()
55+
})
56+
})

sites/partners/__tests__/components/listings/PaperListingForm/index.test.tsx

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
jurisdiction,
88
mockBaseJurisdiction,
99
mockUser,
10-
user,
1110
} from "@bloom-housing/shared-helpers/__tests__/testHelpers"
1211
import {
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
/tell the applicant what to expect from the process/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",

sites/partners/__tests__/components/listings/PaperListingForm/sections/AdditionalDetails.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe("AdditionalDetails", () => {
4747
<FormComponent>
4848
<AdditionalDetails
4949
defaultText="This is a mock default text"
50-
exisistingDocumnets={{
50+
existingDocuments={{
5151
socialSecurityCard: true,
5252
currentLandlordReference: true,
5353
birthCertificate: true,
@@ -98,7 +98,7 @@ describe("AdditionalDetails", () => {
9898
>
9999
<AdditionalDetails
100100
defaultText="This is a mock default text"
101-
exisistingDocumnets={{
101+
existingDocuments={{
102102
socialSecurityCard: true,
103103
currentLandlordReference: true,
104104
birthCertificate: true,

sites/partners/__tests__/components/listings/PaperListingForm/sections/AdditionalFees.test.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
FeatureFlagEnum,
1313
} from "@bloom-housing/shared-helpers/src/types/backend-swagger"
1414
import userEvent from "@testing-library/user-event"
15+
import "@testing-library/jest-dom"
1516

1617
const FormComponent = ({ children, values }: { values?: Partial<FormListing>; children }) => {
1718
const formMethods = useForm<FormListing>({
@@ -46,6 +47,8 @@ describe("AdditionalFees", () => {
4647
>
4748
<FormComponent>
4849
<AdditionalFees
50+
enableNonRegulatedListings={false}
51+
enableUtilitiesIncluded={false}
4952
existingUtilities={{
5053
water: true,
5154
gas: true,
@@ -80,7 +83,7 @@ describe("AdditionalFees", () => {
8083
expect(screen.queryByRole("checkbox", { name: /^internet$/i })).not.toBeInTheDocument()
8184
})
8285

83-
it("should render the AdditionalFees section with utlities included", async () => {
86+
it("should render the AdditionalFees section with utilities included", async () => {
8487
render(
8588
<AuthContext.Provider
8689
value={{
@@ -91,6 +94,8 @@ describe("AdditionalFees", () => {
9194
>
9295
<FormComponent>
9396
<AdditionalFees
97+
enableNonRegulatedListings={false}
98+
enableUtilitiesIncluded={true}
9499
existingUtilities={{
95100
water: true,
96101
gas: true,
@@ -151,7 +156,12 @@ describe("AdditionalFees", () => {
151156
}}
152157
>
153158
<FormComponent values={{ listingType: EnumListingListingType.nonRegulated }}>
154-
<AdditionalFees existingUtilities={{}} requiredFields={[]} />
159+
<AdditionalFees
160+
existingUtilities={{}}
161+
requiredFields={[]}
162+
enableNonRegulatedListings={true}
163+
enableUtilitiesIncluded={false}
164+
/>
155165
</FormComponent>
156166
</AuthContext.Provider>
157167
)

0 commit comments

Comments
 (0)