From 3d970eb2d5f44f0bbf0cdd98e64b9a0b6176e42e Mon Sep 17 00:00:00 2001 From: Greg Hawkins Date: Wed, 18 Dec 2024 13:01:17 +0000 Subject: [PATCH] Occupancy View - Add AP Manager to matching details --- .../pages/match/occupancyViewPage.ts | 5 +++- integration_tests/tests/match/match.cy.ts | 24 +++++++++++++++---- .../occupancyViewController.test.ts | 1 + .../occupancyViewController.ts | 10 +++++--- .../factories/cas1PremisesSummary.ts | 3 ++- server/utils/match/index.test.ts | 15 ++++++++++-- server/utils/match/index.ts | 11 +++++++++ 7 files changed, 57 insertions(+), 12 deletions(-) diff --git a/integration_tests/pages/match/occupancyViewPage.ts b/integration_tests/pages/match/occupancyViewPage.ts index 93a3e37ea..f47de2866 100644 --- a/integration_tests/pages/match/occupancyViewPage.ts +++ b/integration_tests/pages/match/occupancyViewPage.ts @@ -33,9 +33,12 @@ export default class OccupancyViewPage extends Page { startDate: string, durationDays: number, placementRequest: PlacementRequest, + managerDetails: string, ) { cy.get('.govuk-details').within(() => { - this.shouldContainSummaryListItems(occupancyViewSummaryListForMatchingDetails(totalCapacity, placementRequest)) + this.shouldContainSummaryListItems( + occupancyViewSummaryListForMatchingDetails(totalCapacity, placementRequest, managerDetails), + ) }) cy.get('.govuk-heading-l') .contains( diff --git a/integration_tests/tests/match/match.cy.ts b/integration_tests/tests/match/match.cy.ts index 5cab7ec91..a8c7e7d11 100644 --- a/integration_tests/tests/match/match.cy.ts +++ b/integration_tests/tests/match/match.cy.ts @@ -149,6 +149,7 @@ context('Placement Requests', () => { const startDate = '2024-07-23' const endDate = '2024-08-07' const totalCapacity = 10 + const managerDetails = 'John Doe' // Given I am signed in as a cru_member signIn(['cru_member'], ['cas1_space_booking_create']) @@ -162,7 +163,7 @@ context('Placement Requests', () => { duration: durationDays, }) const premiseCapacity = cas1PremiseCapacityFactory.build({ - premise: { id: premises.id, bedCount: totalCapacity }, + premise: { id: premises.id, bedCount: totalCapacity, managerDetails }, startDate, endDate, }) @@ -175,7 +176,13 @@ context('Placement Requests', () => { const occupancyViewPage = OccupancyViewPage.visit(placementRequest, premises, apType) // Then I should see the details of the case I am matching - occupancyViewPage.shouldShowMatchingDetails(totalCapacity, startDate, durationDays, placementRequest) + occupancyViewPage.shouldShowMatchingDetails( + totalCapacity, + startDate, + durationDays, + placementRequest, + managerDetails, + ) return { occupancyViewPage, placementRequest, premiseCapacity, premises } } @@ -185,6 +192,7 @@ context('Placement Requests', () => { const startDate = '2024-07-23' const endDate = '2024-08-07' const totalCapacity = 10 + const managerDetails = 'John Doe' // Given I am signed in as a cru_member signIn(['cru_member'], ['cas1_space_booking_create']) @@ -198,7 +206,7 @@ context('Placement Requests', () => { duration: durationDays, }) const premiseCapacity = cas1PremiseCapacityFactory.build({ - premise: { id: premises.id, bedCount: totalCapacity }, + premise: { id: premises.id, bedCount: totalCapacity, managerDetails }, startDate, endDate, }) @@ -211,7 +219,13 @@ context('Placement Requests', () => { const occupancyViewPage = OccupancyViewPage.visit(placementRequest, premises, apType) // Then I should see the details of the case I am matching - occupancyViewPage.shouldShowMatchingDetails(totalCapacity, startDate, durationDays, placementRequest) + occupancyViewPage.shouldShowMatchingDetails( + totalCapacity, + startDate, + durationDays, + placementRequest, + managerDetails, + ) // And I should see the filter form with populated values occupancyViewPage.shouldShowFilters(startDate, 'Up to 6 weeks', []) @@ -236,7 +250,7 @@ context('Placement Requests', () => { const newDuration = 'Up to 1 week' const newCriteria = ['Wheelchair accessible', 'Step-free'] const newPremiseCapacity = cas1PremiseCapacityFactory.build({ - premise: { id: premises.id, bedCount: totalCapacity }, + premise: { id: premises.id, bedCount: totalCapacity, managerDetails }, startDate: newStartDate, endDate: newEndDate, }) diff --git a/server/controllers/match/placementRequests/occupancyViewController.test.ts b/server/controllers/match/placementRequests/occupancyViewController.test.ts index 8ec98159f..1e8eba787 100644 --- a/server/controllers/match/placementRequests/occupancyViewController.test.ts +++ b/server/controllers/match/placementRequests/occupancyViewController.test.ts @@ -108,6 +108,7 @@ describe('OccupancyViewController', () => { matchingDetailsSummaryList: occupancyViewSummaryListForMatchingDetails( premiseCapacity.premise.bedCount, placementRequestDetail, + premiseCapacity.premise.managerDetails, ), summary: occupancySummary(premiseCapacity.capacity), calendar: occupancyCalendar(premiseCapacity.capacity), diff --git a/server/controllers/match/placementRequests/occupancyViewController.ts b/server/controllers/match/placementRequests/occupancyViewController.ts index 53c7729f4..78f173ac0 100644 --- a/server/controllers/match/placementRequests/occupancyViewController.ts +++ b/server/controllers/match/placementRequests/occupancyViewController.ts @@ -100,10 +100,9 @@ export default class { const durationDays = filterDurationDays || placementRequest.duration const dateFieldValues = filterError ? filterUserInput : DateFormats.isoDateToDateInputs(startDate, 'startDate') - const matchingDetailsSummaryList = occupancyViewSummaryListForMatchingDetails(premises.bedCount, placementRequest) let summary: OccupancySummary let calendar: Calendar - + let managerDetails: string if (!errors.startDate) { const capacityDates = placementDates(startDate, durationDays) const capacity = await this.premisesService.getCapacity( @@ -115,6 +114,7 @@ export default class { summary = occupancySummary(capacity.capacity, filterCriteria) calendar = occupancyCalendar(capacity.capacity, filterCriteria) + managerDetails = capacity.premise.managerDetails } res.render('match/placementRequests/occupancyView/view', { @@ -128,7 +128,11 @@ export default class { durationOptions: durationSelectOptions(durationDays), criteriaOptions: convertKeyValuePairToCheckBoxItems(occupancyCriteriaMap, filterCriteria), criteria: filterCriteria, - matchingDetailsSummaryList, + matchingDetailsSummaryList: occupancyViewSummaryListForMatchingDetails( + premises.bedCount, + placementRequest, + managerDetails, + ), summary, calendar, errors, diff --git a/server/testutils/factories/cas1PremisesSummary.ts b/server/testutils/factories/cas1PremisesSummary.ts index 485340eb0..43a9fec26 100644 --- a/server/testutils/factories/cas1PremisesSummary.ts +++ b/server/testutils/factories/cas1PremisesSummary.ts @@ -6,7 +6,7 @@ import { apAreaFactory } from './referenceData' export default Factory.define(() => ({ id: faker.string.uuid(), - name: `${faker.word.adjective()} ${faker.word.adverb()} ${faker.word.noun()}`, + name: `${faker.person}`, postcode: faker.location.zipCode(), apCode: `${faker.string.alpha(2)}`, bedCount: 50, @@ -14,5 +14,6 @@ export default Factory.define(() => ({ outOfServiceBeds: faker.number.int({ min: 0, max: 50 }), apArea: apAreaFactory.build(), supportsSpaceBookings: true, + managerDetails: `${faker.person}`, overbookingSummary: [], })) diff --git a/server/utils/match/index.test.ts b/server/utils/match/index.test.ts index 3f3bb5555..5e69a135c 100644 --- a/server/utils/match/index.test.ts +++ b/server/utils/match/index.test.ts @@ -19,6 +19,7 @@ import { DateFormats } from '../dateUtils' import { InvalidSpaceSearchDataException, addressRow, + apManagerDetailsRow, apTypeLabelsForRadioInput, apTypeRow, arrivalDateRow, @@ -395,20 +396,22 @@ describe('matchUtils', () => { }) const dates = placementDates(placementRequest.expectedArrival, placementRequest.duration) const totalCapacity = 120 + const managerDetails = 'John Doe' it('should call the correct row functions', () => { - expect(occupancyViewSummaryListForMatchingDetails(totalCapacity, placementRequest)).toEqual([ + expect(occupancyViewSummaryListForMatchingDetails(totalCapacity, placementRequest, managerDetails)).toEqual([ arrivalDateRow(dates.startDate), departureDateRow(dates.endDate), placementLengthRow(dates.placementLength), releaseTypeRow(placementRequest), totalCapacityRow(totalCapacity), + apManagerDetailsRow(managerDetails), spaceRequirementsRow(filterOutAPTypes(placementRequest.essentialCriteria)), ]) }) it('should generate the expected matching details', () => { - expect(occupancyViewSummaryListForMatchingDetails(totalCapacity, placementRequest)).toEqual([ + expect(occupancyViewSummaryListForMatchingDetails(totalCapacity, placementRequest, managerDetails)).toEqual([ { key: { text: 'Expected arrival date', @@ -449,6 +452,14 @@ describe('matchUtils', () => { text: '120 spaces', }, }, + { + key: { + text: 'AP manager details', + }, + value: { + text: 'John Doe', + }, + }, { key: { text: 'Space requirements', diff --git a/server/utils/match/index.ts b/server/utils/match/index.ts index 27a8b2414..ec2851d72 100644 --- a/server/utils/match/index.ts +++ b/server/utils/match/index.ts @@ -175,6 +175,7 @@ export const spaceBookingPersonNeedsSummaryCardRows = ( export const occupancyViewSummaryListForMatchingDetails = ( totalCapacity: number, placementRequest: PlacementRequest, + managerDetails: string, ): Array => { const placementRequestDates = placementDates(placementRequest.expectedArrival, placementRequest.duration) const essentialCharacteristics = filterOutAPTypes(placementRequest.essentialCriteria) @@ -185,6 +186,7 @@ export const occupancyViewSummaryListForMatchingDetails = ( placementLengthRow(placementRequestDates.placementLength), releaseTypeRow(placementRequest), totalCapacityRow(totalCapacity), + apManagerDetailsRow(managerDetails), spaceRequirementsRow(essentialCharacteristics), ] } @@ -334,6 +336,15 @@ export const totalCapacityRow = (totalCapacity: number) => ({ }, }) +export const apManagerDetailsRow = (apManagerDetails: string) => ({ + key: { + text: 'AP manager details', + }, + value: { + text: apManagerDetails, + }, +}) + export const spaceRequirementsRow = (essentialCharacteristics: Array) => ({ key: { text: 'Space requirements',