Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor placement-request page information #2280

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gregkhawkins
Copy link
Contributor

Context

  • Related JIRA: https://dsdmoj.atlassian.net/browse/APS-1693
  • This PR makes changes to the Summary information on the Placement request page in the Find and Book flow. This includes removing the data that overlaps with thre blue banner and moving the rest of the data to a summary list.

Changes in this PR

Screenshots of UI changes

Before

placement_request_before

After

placement_request_after

})
export const licenceExpiryDateRow = (placementRequest: PlacementRequestDetail) => {
let licenceExpiryDate: string | undefined
if (placementRequest.application && 'licenceExpiryDate' in placementRequest.application) {
Copy link
Contributor Author

@gregkhawkins gregkhawkins Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the integration tests saved my neck here as the isParole test case does not have an application associated with the placementRequest (in the test data setup). I assume that the data setup in that test reflects reality. Anyway, this means we need the if (placementRequest.application) check for sure or a runtime exception would occur for the isParole scenario.
I also added the if ('licenceExpiryDate' in placementRequest.application) check as I was growing increasingly paranoid that a placementRequest.application would not be of type ApprovedPremisesApplication. I did check this in the backend previously (when Bob flagged it on previous PR) and it seemed for the occupancy-view page it always would be, however with recent work on offline applications etc I wondered whether we could end up with an application that does not meet this type leading to a runtime exception related to that when we try to access the licenseExpiryDate field (specific to ApprovedPremisesApplication only).
Let me know if this is too defensive or if you can think of a more graceful way to do it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, a placementRequest without an application_id is news to me! In the placement, there is a secondary id offline_application_id with a foreign key to the offline application and constraints to make sure exactly one is populated. It sounds like these kind of checks do not exist for placementRequests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a type in the Application which I guess indicates the type that it may be cast into. That type is not, in itself typed so I don't know that the values are sensible in the test data though.

).toEqual(expectedMatchingDetailsSummaryListItems(''))
})

it(`should generate the expected matching details when placement-request's application is not of type ApprovedPremisesApplication`, () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

justification for this test case is in a comment in the index.ts file of this PR

Copy link
Contributor

@bobmeredith bobmeredith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!
Looks good to me.
Just a couple a minor comments (one is a tiny query on the content/design).

})
export const licenceExpiryDateRow = (placementRequest: PlacementRequestDetail) => {
let licenceExpiryDate: string | undefined
if (placementRequest.application && 'licenceExpiryDate' in placementRequest.application) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, a placementRequest without an application_id is news to me! In the placement, there is a secondary id offline_application_id with a foreign key to the offline application and constraints to make sure exactly one is populated. It sounds like these kind of checks do not exist for placementRequests.

})
export const licenceExpiryDateRow = (placementRequest: PlacementRequestDetail) => {
let licenceExpiryDate: string | undefined
if (placementRequest.application && 'licenceExpiryDate' in placementRequest.application) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a type in the Application which I guess indicates the type that it may be cast into. That type is not, in itself typed so I don't know that the values are sensible in the test data though.

`)
})

it('should return Not Found if the person is unknown person', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice - I see these tests are replicated in personUtils.test.ts


it('should generate the expected summary list', () => {
expect(placementRequestSummaryList(placementRequest).rows).toEqual(
expectedSummaryListItems(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The long list of parameters is a little hard to follow. Perhaps consider passing an args object so that each parameter is named

@@ -8,7 +8,7 @@ export const preferredApsRow = (placementRequest: PlacementRequestDetail): Summa
if (premises.length) {
const apList = premises.map(p => `<li>${p.name}</li>`)
return {
key: { text: 'Preferred APs' },
key: { text: 'Preferred AP' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check this with Stevie or Amber. It seems a bit odd to change to singular when clearly it's a list. Maybe it's a typo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants