Skip to content

Commit

Permalink
fix: community type disclaimer (#821)
Browse files Browse the repository at this point in the history
* feat: adding community type disclaimer fields (bloom-housing#4486)

* feat: adding community type disclaimer fields

* fix: updates per morgan

(cherry picked from commit baa2f43)

* fix: community type disclaimer frontend (bloom-housing#4496)

* fix: add community type disclaimer to public site

* fix: add community type disclaimer to partners

* fix: add partners tests

* fix: form type issue

* fix: failing build

* fix: allow reserved community disclaimer only when community type selected

* fix: tests

* fix: be tests

* fix: add translations with tests

(cherry picked from commit 2769691)

* chore: generate client

---------

Co-authored-by: Yazeed Loonat <[email protected]>
  • Loading branch information
KrissDrawing and YazeedLoonat authored Jan 6, 2025
1 parent 134909f commit a8ce13b
Show file tree
Hide file tree
Showing 19 changed files with 365 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- AlterTable
ALTER TABLE "listings" ADD COLUMN "community_disclaimer_description" TEXT,
ADD COLUMN "community_disclaimer_title" TEXT,
ADD COLUMN "include_community_disclaimer" BOOLEAN;
19 changes: 11 additions & 8 deletions api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,13 @@ model Demographics {
}

model FeatureFlags {
id String @id() @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(6)
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamp(6)
name String @unique()
description String
active Boolean @default(true)
jurisdictions Jurisdictions[]
id String @id() @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(6)
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamp(6)
name String @unique()
description String
active Boolean @default(true)
jurisdictions Jurisdictions[]
@@map("feature_flags")
}
Expand Down Expand Up @@ -572,6 +572,9 @@ model Listings {
resultId String? @map("result_id") @db.Uuid
featuresId String? @unique() @map("features_id") @db.Uuid
utilitiesId String? @unique() @map("utilities_id") @db.Uuid
includeCommunityDisclaimer Boolean? @map("include_community_disclaimer")
communityDisclaimerTitle String? @map("community_disclaimer_title")
communityDisclaimerDescription String? @map("community_disclaimer_description")
// START DETROIT SPECIFIC
hrdId String? @map("hrd_id")
ownerCompany String? @map("owner_company")
Expand Down Expand Up @@ -621,7 +624,7 @@ model Listings {
requestedChangesUser UserAccounts? @relation("requested_changes_user", fields: [requestedChangesUserId], references: [id], onDelete: NoAction, onUpdate: NoAction)
applicationLotteryPositions ApplicationLotteryPositions[]
applicationLotteryTotals ApplicationLotteryTotal[]
copyOf Listings? @relation("copy_of", fields: [copyOfId], references: [id])
copyOf Listings? @relation("copy_of", fields: [copyOfId], references: [id], onUpdate: NoAction)
Listings Listings[] @relation("copy_of")
@@index([jurisdictionId])
Expand Down
24 changes: 24 additions & 0 deletions api/src/dtos/listings/listing.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
IsUrl,
MaxLength,
Validate,
ValidateIf,
ValidateNested,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
Expand Down Expand Up @@ -613,6 +614,29 @@ class Listing extends AbstractDTO {
@Type(() => ApplicationLotteryTotal)
@ApiProperty({ type: ApplicationLotteryTotal, isArray: true })
applicationLotteryTotals: ApplicationLotteryTotal[];

@Expose()
@ApiPropertyOptional()
@IsBoolean({ groups: [ValidationsGroupsEnum.default] })
includeCommunityDisclaimer?: boolean;

@Expose()
@ApiPropertyOptional()
@ValidateIf((o) => o.includeCommunityDisclaimer, {
groups: [ValidationsGroupsEnum.default],
})
@IsDefined({ groups: [ValidationsGroupsEnum.default] })
@IsString({ groups: [ValidationsGroupsEnum.default] })
communityDisclaimerTitle?: string;

@Expose()
@ApiPropertyOptional()
@ValidateIf((o) => o.includeCommunityDisclaimer, {
groups: [ValidationsGroupsEnum.default],
})
@IsDefined({ groups: [ValidationsGroupsEnum.default] })
@IsString({ groups: [ValidationsGroupsEnum.default] })
communityDisclaimerDescription?: string;
}

export { Listing as default, Listing };
7 changes: 7 additions & 0 deletions api/src/services/translation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ export class TranslationService {
});
}

if (listing.includeCommunityDisclaimer) {
pathsToFilter[`communityDisclaimerTitle`] =
listing.communityDisclaimerTitle;
pathsToFilter[`communityDisclaimerDescription`] =
listing.communityDisclaimerDescription;
}

const persistedTranslationsFromDB = await this.getPersistedTranslatedValues(
listing,
language,
Expand Down
9 changes: 9 additions & 0 deletions api/test/integration/listing.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ describe('Listing Controller Tests', () => {
label: 'example asset label',
};

const shouldIncludeCommunityDisclaimer = Math.random() >= 0.5;

return {
id: listingId ?? undefined,
assets: [exampleAsset],
Expand Down Expand Up @@ -344,6 +346,13 @@ describe('Listing Controller Tests', () => {
phone: false,
internet: true,
},
includeCommunityDisclaimer: shouldIncludeCommunityDisclaimer,
communityDisclaimerTitle: shouldIncludeCommunityDisclaimer
? 'example title'
: undefined,
communityDisclaimerDescription: shouldIncludeCommunityDisclaimer
? 'example description'
: undefined,
};
};

Expand Down
12 changes: 12 additions & 0 deletions api/test/unit/services/translation.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ const mockListing = (): Listing => {
},
},
],
includeCommunityDisclaimer: true,
communityDisclaimerTitle: 'untranslated community disclaimer title',
communityDisclaimerDescription:
'untranslated community disclaimer description',
};
};

Expand Down Expand Up @@ -133,6 +137,8 @@ const translatedStrings = [
'translated multiselect description',
'translated multiselect subtext',
'translated multiselect opt out text',
'translated community disclaimer title',
'translated community disclaimer description',
];

describe('Testing translations service', () => {
Expand Down Expand Up @@ -395,4 +401,10 @@ const validateTranslatedFields = (listing: Listing) => {
expect(
listing.listingMultiselectQuestions[0].multiselectQuestions.optOutText,
).toEqual('translated multiselect opt out text');
expect(listing.communityDisclaimerTitle).toEqual(
'translated community disclaimer title',
);
expect(listing.communityDisclaimerDescription).toEqual(
'translated community disclaimer description',
);
};
27 changes: 27 additions & 0 deletions shared-helpers/src/types/backend-swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3653,6 +3653,15 @@ export interface Listing {

/** */
applicationLotteryTotals: ApplicationLotteryTotal[]

/** */
includeCommunityDisclaimer?: boolean

/** */
communityDisclaimerTitle?: string

/** */
communityDisclaimerDescription?: string
}

export interface PaginationMeta {
Expand Down Expand Up @@ -4115,6 +4124,15 @@ export interface ListingCreate {
/** */
lotteryOptIn?: boolean

/** */
includeCommunityDisclaimer?: boolean

/** */
communityDisclaimerTitle?: string

/** */
communityDisclaimerDescription?: string

/** */
listingMultiselectQuestions?: IdDTO[]

Expand Down Expand Up @@ -4389,6 +4407,15 @@ export interface ListingUpdate {
/** */
lotteryOptIn?: boolean

/** */
includeCommunityDisclaimer?: boolean

/** */
communityDisclaimerTitle?: string

/** */
communityDisclaimerDescription?: string

/** */
listingMultiselectQuestions?: IdDTO[]

Expand Down
10 changes: 10 additions & 0 deletions sites/partners/cypress/e2e/default/03-listing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ describe("Listing Management Tests", () => {
cy.contains("Listing Data")
// Try to publish a listing and should show errors for appropriate fields
cy.getByID("listingEditButton").contains("Edit").click()
cy.getByID("reservedCommunityTypes.id").select(1)
cy.getByID("includeCommunityDisclaimerYes").check()
cy.getByID("publishButton").contains("Publish").click()
cy.getByID("publishButtonConfirm").contains("Publish").click()
cy.contains("Please resolve any errors before saving or publishing your listing.")
Expand All @@ -42,6 +44,8 @@ describe("Listing Management Tests", () => {
expect($alertButtons[1]).to.have.id("addUnitsButton")
})
cy.getByID("units-error").contains("This field is required")
cy.getByID("communityDisclaimerTitle-error").contains("Enter title")
cy.get(".textarea-error-message").contains("Enter description")
cy.getByID("applicationProcessButton").contains("Application Process").click()
cy.getByID("leasingAgentName-error").contains("This field is required")
cy.getByID("leasingAgentEmail-error").contains("This field is required")
Expand Down Expand Up @@ -157,6 +161,9 @@ describe("Listing Management Tests", () => {
cy.get(".addressPopup").contains(listing["buildingAddress.street"])
cy.getByID("reservedCommunityTypes.id").select(listing["reservedCommunityType.id"])
cy.getByID("reservedCommunityDescription").type(listing["reservedCommunityDescription"])
cy.getByID("includeCommunityDisclaimerYes").check()
cy.getByID("communityDisclaimerTitle").type(listing["communityDisclaimerTitle"])
cy.getByID("communityDisclaimerDescription").type(listing["communityDisclaimerDescription"])
cy.getByTestId("unit-types").check()
cy.getByTestId("listingAvailability.availableUnits").check()
cy.getByID("addUnitsButton").contains("Add Unit").click()
Expand Down Expand Up @@ -292,6 +299,9 @@ describe("Listing Management Tests", () => {
cy.getByID("latitude").should("include.text", "37.7")
cy.getByID("reservedCommunityType").contains(listing["reservedCommunityType.id"])
cy.getByID("reservedCommunityDescription").contains(listing["reservedCommunityDescription"])
cy.getByID("includeCommunityDisclaimer").contains("Yes")
cy.getByID("communityDisclaimerTitle").contains(listing["communityDisclaimerTitle"])
cy.getByID("communityDisclaimerDescription").contains(listing["communityDisclaimerDescription"])
cy.getByTestId("unit-types-or-individual").contains("Unit Types")
cy.getByTestId("listing-availability-question").contains("Available Units")
cy.getByID("unitTable").contains(listing["number"])
Expand Down
3 changes: 3 additions & 0 deletions sites/partners/cypress/fixtures/listing.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"yearBuilt": "2021",
"reservedCommunityType.id": "Seniors",
"reservedCommunityDescription": "Basic Test Description",
"communityDisclaimerTitle": "Basic Test Title",
"communityDisclaimerDescription": "Basic Test Description",
"homeType": "Apartment",
"number": "2",
"unitType.id": "One Bedroom",
"numBathrooms": "2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import SectionWithGrid from "../../../shared/SectionWithGrid"
const DetailCommunityType = () => {
const listing = useContext(ListingContext)

const includeCommunityDisclaimer = listing.includeCommunityDisclaimer

return (
<SectionWithGrid heading={t("listings.sections.communityType")} inset>
<Grid.Row>
Expand All @@ -27,6 +29,33 @@ const DetailCommunityType = () => {
{getDetailFieldString(listing.reservedCommunityDescription)}
</FieldValue>
</Grid.Row>

<Grid.Row>
<FieldValue
id="includeCommunityDisclaimer"
label={t("listings.includeCommunityDisclaimer")}
>
{includeCommunityDisclaimer ? t("t.yes") : t("t.no")}
</FieldValue>
</Grid.Row>
{includeCommunityDisclaimer && (
<>
<Grid.Row>
<FieldValue
id="communityDisclaimerTitle"
label={t("listings.reservedCommunityDisclaimerTitle")}
>
{getDetailFieldString(listing.communityDisclaimerTitle)}
</FieldValue>
<FieldValue
id="communityDisclaimerDescription"
label={t("listings.reservedCommunityDisclaimer")}
>
{getDetailFieldString(listing.communityDisclaimerDescription)}
</FieldValue>
</Grid.Row>
</>
)}
</SectionWithGrid>
)
}
Expand Down
Loading

0 comments on commit a8ce13b

Please sign in to comment.