generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This does a few things: - Ensures the booking confirmation flow uses the arrival date and departure date submitted, rather than relying on filter start date and duration - Removes the `apType` parameter as it is not used - Updates the booking confirmation template to show relevent information - Refactors a lot of the flow to present occupancy view with retained filters where relevant
- Loading branch information
Showing
18 changed files
with
388 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,58 @@ | ||
import { ApType, PlacementDates, PlacementRequestDetail, Premises } from '@approved-premises/api' | ||
import { | ||
Cas1PremisesSummary, | ||
Cas1SpaceBookingCharacteristic, | ||
PlacementRequestDetail, | ||
Premises, | ||
} from '@approved-premises/api' | ||
import { differenceInDays } from 'date-fns' | ||
import Page from '../page' | ||
import paths from '../../../server/paths/match' | ||
import { createQueryString, sentenceCase } from '../../../server/utils/utils' | ||
import { DateFormats } from '../../../server/utils/dateUtils' | ||
import { | ||
filterOutAPTypes, | ||
placementDates, | ||
placementLength as placementLengthInDaysAndWeeks, | ||
} from '../../../server/utils/match' | ||
import { placementCriteriaLabels } from '../../../server/utils/placementCriteriaUtils' | ||
import { apTypeLabels } from '../../../server/utils/apTypeLabels' | ||
import { createQueryString } from '../../../server/utils/utils' | ||
import { DateFormats, daysToWeeksAndDays } from '../../../server/utils/dateUtils' | ||
import { requirementsHtmlString } from '../../../server/utils/match' | ||
import { allReleaseTypes } from '../../../server/utils/applications/releaseTypeUtils' | ||
|
||
export default class BookASpacePage extends Page { | ||
constructor(premisesName: string) { | ||
super(`Book space in ${premisesName}`) | ||
constructor() { | ||
super(`Confirm booking`) | ||
} | ||
|
||
static visit( | ||
placementRequest: PlacementRequestDetail, | ||
startDate: string, | ||
durationDays: PlacementDates['duration'], | ||
premisesName: Premises['name'], | ||
premisesId: Premises['id'], | ||
apType: ApType, | ||
arrivalDate: string, | ||
departureDate: string, | ||
criteria: Array<Cas1SpaceBookingCharacteristic>, | ||
) { | ||
const queryString = createQueryString({ startDate, durationDays, premisesName, premisesId, apType }) | ||
const path = `${paths.v2Match.placementRequests.spaceBookings.new({ id: placementRequest.id })}?${queryString}` | ||
const queryString = createQueryString({ arrivalDate, departureDate, criteria }) | ||
const path = `${paths.v2Match.placementRequests.spaceBookings.new({ | ||
id: placementRequest.id, | ||
premisesId, | ||
})}?${queryString}` | ||
|
||
cy.visit(path) | ||
return new BookASpacePage(premisesName) | ||
|
||
return new BookASpacePage() | ||
} | ||
|
||
shouldShowBookingDetails( | ||
placementRequest: PlacementRequestDetail, | ||
startDate: string, | ||
duration: PlacementDates['duration'], | ||
apType: ApType, | ||
premises: Cas1PremisesSummary, | ||
arrivalDate: string, | ||
departureDate: string, | ||
criteria: Array<Cas1SpaceBookingCharacteristic>, | ||
): void { | ||
const { endDate, placementLength } = placementDates(startDate, duration.toString()) | ||
cy.get('dd').contains(apTypeLabels[apType]) | ||
cy.get('dd').contains(DateFormats.isoDateToUIDate(startDate)) | ||
cy.get('dd').contains(DateFormats.isoDateToUIDate(endDate)) | ||
cy.get('dd').contains(placementLengthInDaysAndWeeks(placementLength)) | ||
cy.get('dd').contains(sentenceCase(placementRequest.gender)) | ||
filterOutAPTypes(placementRequest.essentialCriteria).forEach(requirement => { | ||
cy.get('li').contains(placementCriteriaLabels[requirement]) | ||
}) | ||
filterOutAPTypes(placementRequest.desirableCriteria).forEach(requirement => { | ||
cy.get('li').contains(placementCriteriaLabels[requirement]) | ||
}) | ||
this.shouldContainSummaryListItems([ | ||
{ key: { text: 'Approved Premises' }, value: { text: premises.name } }, | ||
// { key: { text: 'Address' }, value: { text: premises.fullAddress } }, | ||
{ key: { text: 'Space type' }, value: { html: requirementsHtmlString(criteria) } }, | ||
{ key: { text: 'Arrival date' }, value: { text: DateFormats.isoDateToUIDate(arrivalDate) } }, | ||
{ key: { text: 'Departure date' }, value: { text: DateFormats.isoDateToUIDate(departureDate) } }, | ||
{ | ||
key: { text: 'Length of stay' }, | ||
value: { text: DateFormats.formatDuration(daysToWeeksAndDays(differenceInDays(departureDate, arrivalDate))) }, | ||
}, | ||
{ key: { text: 'Release type' }, value: { text: allReleaseTypes[placementRequest.releaseType] } }, | ||
]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.