Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shared-helpers/__tests__/testHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ export const listing: Listing = {
applicationLotteryTotals: [],
jurisdictions: {
id: "id",
name: "San Jose",
name: "Bloomington",
},
depositMax: "",
disableUnitsAccordion: false,
Expand Down
2 changes: 1 addition & 1 deletion sites/partners/.jest/setup-tests.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Future home of additional Jest config
import "@testing-library/jest-dom"
import { addTranslation } from "@bloom-housing/ui-components"
import generalTranslations from "@bloom-housing/shared-helpers/src/locales/general.json"
import { serviceOptions } from "@bloom-housing/shared-helpers/src/types/backend-swagger"
import "@testing-library/jest-dom"
import axios from "axios"
import general from "../page_content/locale_overrides/general.json"
addTranslation({ ...generalTranslations, ...general })
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from "react"
import { render, screen } from "@testing-library/react"
import { listing } from "@bloom-housing/shared-helpers/__tests__/testHelpers"
import { ReviewOrderTypeEnum } from "@bloom-housing/shared-helpers/src/types/backend-swagger"
import { ListingContext } from "../../../../../src/components/listings/ListingContext"
import DetailListingData from "../../../../../src/components/listings/PaperListingDetails/sections/DetailListingData"

describe("DetailListingData", () => {
it("should render all data", () => {
render(
<ListingContext.Provider
value={{
...listing,
createdAt: new Date("2023-01-01T10:00:00Z"),
jurisdictions: { name: "Bloomington", id: "1" },
id: "1234",
reviewOrderType: ReviewOrderTypeEnum.waitlist,
units: [],
}}
>
<DetailListingData showJurisdictionName={true} />
</ListingContext.Provider>
)
expect(screen.getByRole("heading", { level: 2, name: "Listing data" })).toBeInTheDocument()
expect(screen.getByText("Date created")).toBeInTheDocument()
expect(screen.getByText("01/01/2023 at 10:00 AM")).toBeInTheDocument()
expect(screen.getByText("Jurisdiction")).toBeInTheDocument()
expect(screen.getByText("Bloomington")).toBeInTheDocument()
expect(screen.getByText("Listing ID")).toBeInTheDocument()
expect(screen.getByText("1234")).toBeInTheDocument()
})

it("should hide jurisdiction", () => {
render(
<ListingContext.Provider
value={{
...listing,
createdAt: new Date("2023-01-01T10:00:00Z"),
jurisdictions: { name: "Bloomington", id: "1" },
id: "1234",
reviewOrderType: ReviewOrderTypeEnum.waitlist,
units: [],
}}
>
<DetailListingData showJurisdictionName={false} />
</ListingContext.Provider>
)
expect(screen.getByRole("heading", { level: 2, name: "Listing data" })).toBeInTheDocument()
expect(screen.getByText("Date created")).toBeInTheDocument()
expect(screen.getByText("01/01/2023 at 10:00 AM")).toBeInTheDocument()
expect(screen.queryByText("Jurisdiction")).not.toBeInTheDocument()
expect(screen.queryByText("Bloomington")).not.toBeInTheDocument()
expect(screen.getByText("Listing ID")).toBeInTheDocument()
expect(screen.getByText("1234")).toBeInTheDocument()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
jurisdiction,
mockBaseJurisdiction,
mockUser,
user,
} from "@bloom-housing/shared-helpers/__tests__/testHelpers"
import {
FeatureFlag,
Expand All @@ -30,7 +29,9 @@ const jurisdictions = [
{ name: FeatureFlagEnum.enableRegions, active: true } as FeatureFlag,
{ name: FeatureFlagEnum.enableHomeType, active: true } as FeatureFlag,
{ name: FeatureFlagEnum.enableCompanyWebsite, active: true } as FeatureFlag,
{ name: FeatureFlagEnum.enableWhatToExpectAdditionalField, active: true } as FeatureFlag,
],
whatToExpect: "Here's what you might expect from the process.",
requiredListingFields: [
"listingsBuildingAddress",
"name",
Expand Down Expand Up @@ -126,9 +127,10 @@ describe("add listing", () => {
return false
}
},
getJurisdictionLanguages: () => [],
}}
>
<ListingForm />
<ListingForm jurisdictionId={"Bloomington"} />
</AuthContext.Provider>
)

Expand Down Expand Up @@ -181,29 +183,41 @@ describe("add listing", () => {
return res(ctx.json([]))
})
)

const mockRetrieve = jest.fn().mockResolvedValue({})

render(
<AuthContext.Provider
value={{
profile: {
...user,
listings: [],
jurisdictions: [jurisdiction],
},
getJurisdictionLanguages: () => [],
jurisdictionsService: new JurisdictionsService(),
doJurisdictionsHaveFeatureFlagOn: (featureFlag: FeatureFlagEnum) => {
switch (featureFlag) {
case FeatureFlagEnum.swapCommunityTypeWithPrograms:
return false
case FeatureFlagEnum.enableRegions:
return true
case FeatureFlagEnum.enableHomeType:
return true
case FeatureFlagEnum.enableCompanyWebsite:
return true
case FeatureFlagEnum.enableWhatToExpectAdditionalField:
return true
default:
return false
}
},
getJurisdictionLanguages,
profile: {
...mockUser,
listings: [],
jurisdictions: jurisdictions as Jurisdiction[],
userRoles: {
isAdmin: true,
},
},
jurisdictionsService: {
retrieve: mockRetrieve,
} as unknown as JurisdictionsService,
}}
>
<ListingForm />
<ListingForm jurisdictionId={"Bloomington"} />
</AuthContext.Provider>
)

Expand All @@ -213,18 +227,11 @@ describe("add listing", () => {
/tell the applicant what to expect from the process/i
)
expect(whatToExpectEditorLabel).toBeInTheDocument()
const whatToExpectEditorWrapper = whatToExpectEditorLabel.parentElement.parentElement
const whatToExpectEditorWrapper =
whatToExpectEditorLabel.parentElement.parentElement.parentElement

expect(
await within(whatToExpectEditorWrapper).findByText(
"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."
)
).toBeInTheDocument()
expect(
within(whatToExpectEditorWrapper).getByText("You have 451 characters remaining")
).toBeInTheDocument()
expect(
within(whatToExpectEditorWrapper).getByRole("menuitem", { name: "Bold" })
await within(whatToExpectEditorWrapper).findByRole("menuitem", { name: "Bold" })
).toBeInTheDocument()
expect(
within(whatToExpectEditorWrapper).getByRole("menuitem", { name: "Bullet list" })
Expand All @@ -241,6 +248,15 @@ describe("add listing", () => {
expect(
within(whatToExpectEditorWrapper).getByRole("menuitem", { name: "Unlink" })
).toBeInTheDocument()

expect(
within(whatToExpectEditorWrapper).getByText("Here's what you might expect from the process.")
).toBeInTheDocument()

expect(
within(whatToExpectEditorWrapper).getByText("You have 954 characters remaining")
).toBeInTheDocument()

// Query issue: https://github.com/ueberdosis/tiptap/discussions/4008#discussioncomment-7623655
const editor = screen.getByTestId("whatToExpect").firstElementChild.querySelector("p")
act(() => {
Expand All @@ -260,15 +276,7 @@ describe("add listing", () => {
whatToExpectAdditonalTextEditorLabel.parentElement.parentElement

expect(
await within(whatToExpectAdditonalTextEditorWrapper).findByText(
"Property staff should walk you through the process to get on their waitlist."
)
).toBeInTheDocument()
expect(
within(whatToExpectAdditonalTextEditorWrapper).getByText("You have 924 characters remaining")
).toBeInTheDocument()
expect(
within(whatToExpectAdditonalTextEditorWrapper).getByRole("menuitem", { name: "Bold" })
await within(whatToExpectAdditonalTextEditorWrapper).findByRole("menuitem", { name: "Bold" })
).toBeInTheDocument()
expect(
within(whatToExpectAdditonalTextEditorWrapper).getByRole("menuitem", { name: "Bullet list" })
Expand All @@ -287,6 +295,17 @@ describe("add listing", () => {
expect(
within(whatToExpectAdditonalTextEditorWrapper).getByRole("menuitem", { name: "Unlink" })
).toBeInTheDocument()

expect(
within(whatToExpectAdditonalTextEditorWrapper).getByText(
"Property staff should walk you through the process to get on their waitlist."
)
).toBeInTheDocument()

expect(
within(whatToExpectAdditonalTextEditorWrapper).getByText("You have 473 characters remaining")
).toBeInTheDocument()

// Query issue: https://github.com/ueberdosis/tiptap/discussions/4008#discussioncomment-7623655
const whatToExpectAdditonalTextEditor = screen
.getByTestId("whatToExpectAdditionalText")
Expand Down Expand Up @@ -358,11 +377,11 @@ describe("add listing", () => {
} as unknown as JurisdictionsService,
}}
>
<ListingForm />
<ListingForm jurisdictionId={"Bloomington"} />
</AuthContext.Provider>
)

const requiredFields = ["Listing name", "Jurisdiction"]
const requiredFields = ["Listing name"]

const unrequiredFields = [
"Housing developer",
Expand Down Expand Up @@ -473,13 +492,12 @@ describe("add listing", () => {
} as unknown as JurisdictionsService,
}}
>
<ListingForm />
<ListingForm jurisdictionId={"Bloomington"} />
</AuthContext.Provider>
)

const possibleRequiredFields = [
"Listing name",
"Jurisdiction",
"Housing developer",
"Photos",
"Street address",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("AdditionalDetails", () => {
<FormComponent>
<AdditionalDetails
defaultText="This is a mock default text"
exisistingDocumnets={{
existingDocuments={{
socialSecurityCard: true,
currentLandlordReference: true,
birthCertificate: true,
Expand Down Expand Up @@ -98,7 +98,7 @@ describe("AdditionalDetails", () => {
>
<AdditionalDetails
defaultText="This is a mock default text"
exisistingDocumnets={{
existingDocuments={{
socialSecurityCard: true,
currentLandlordReference: true,
birthCertificate: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
FeatureFlagEnum,
} from "@bloom-housing/shared-helpers/src/types/backend-swagger"
import userEvent from "@testing-library/user-event"
import "@testing-library/jest-dom"

const FormComponent = ({ children, values }: { values?: Partial<FormListing>; children }) => {
const formMethods = useForm<FormListing>({
Expand Down Expand Up @@ -46,6 +47,8 @@ describe("AdditionalFees", () => {
>
<FormComponent>
<AdditionalFees
enableNonRegulatedListings={false}
enableUtilitiesIncluded={false}
existingUtilities={{
water: true,
gas: true,
Expand Down Expand Up @@ -80,7 +83,7 @@ describe("AdditionalFees", () => {
expect(screen.queryByRole("checkbox", { name: /^internet$/i })).not.toBeInTheDocument()
})

it("should render the AdditionalFees section with utlities included", async () => {
it("should render the AdditionalFees section with utilities included", async () => {
render(
<AuthContext.Provider
value={{
Expand All @@ -91,6 +94,8 @@ describe("AdditionalFees", () => {
>
<FormComponent>
<AdditionalFees
enableNonRegulatedListings={false}
enableUtilitiesIncluded={true}
existingUtilities={{
water: true,
gas: true,
Expand Down Expand Up @@ -151,7 +156,12 @@ describe("AdditionalFees", () => {
}}
>
<FormComponent values={{ listingType: EnumListingListingType.nonRegulated }}>
<AdditionalFees existingUtilities={{}} requiredFields={[]} />
<AdditionalFees
existingUtilities={{}}
requiredFields={[]}
enableNonRegulatedListings={true}
enableUtilitiesIncluded={false}
/>
</FormComponent>
</AuthContext.Provider>
)
Expand Down
Loading
Loading