Skip to content

Commit

Permalink
Merge pull request #2241 from ministryofjustice/feature/APS-1654_spac…
Browse files Browse the repository at this point in the history
…e_search_filter

APS-1654: Add applicationId to Space Search Parameters
  • Loading branch information
RobBoothMOJ authored Dec 9, 2024
2 parents 158b821 + 98db0be commit e5e7aa5
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions integration_tests/tests/match/match.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ context('Placement Requests', () => {

// And the first request to the API should contain the criteria from the placement request
expect(initialSearchRequestBody).to.deep.equal({
applicationId: placementRequest.applicationId,
durationInDays: placementRequest.duration,
startDate: placementRequest.expectedArrival,
targetPostcodeDistrict: placementRequest.location,
Expand All @@ -91,6 +92,7 @@ context('Placement Requests', () => {
// And the second request to the API should contain the new criteria I submitted

expect(secondSearchRequestBody).to.contain({
applicationId: placementRequest.applicationId,
durationInDays: placementRequest.duration,
startDate: newSearchParameters.startDate,
targetPostcodeDistrict: newSearchParameters.targetPostcodeDistrict,
Expand Down
4 changes: 4 additions & 0 deletions server/@types/shared/models/Cas1SpaceSearchParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
/* eslint-disable */
import type { Cas1SpaceSearchRequirements } from './Cas1SpaceSearchRequirements';
export type Cas1SpaceSearchParameters = {
/**
* The id of the application the space search is for
*/
applicationId?: string;
/**
* The date the space is required from
*/
Expand Down
1 change: 1 addition & 0 deletions server/@types/ui/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ type ContingencyPlanQuestion = {
export type ContingencyPlanQuestionsRecord = Record<ContingencyPlanQuestionId, ContingencyPlanQuestion>

export interface SpaceSearchParametersUi {
applicationId: string
startDate: string
targetPostcodeDistrict: string
durationInDays: string
Expand Down
2 changes: 2 additions & 0 deletions server/controllers/match/search/spaceSearchController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('spaceSearchController', () => {
spaceSearchResults,
placementRequest: placementRequestDetail,
tier: placementRequestDetail.risks.tier.value.level,
applicationId: placementRequestDetail.applicationId,
startDate: placementRequestDetail.expectedArrival,
formPath,
...query,
Expand All @@ -80,6 +81,7 @@ describe('spaceSearchController', () => {
spaceSearchResults,
placementRequest: placementRequestDetail,
tier: placementRequestDetail.risks.tier.value.level,
applicationId: placementRequestDetail.applicationId,
startDate: placementRequestDetail.expectedArrival,
formPath,
...query,
Expand Down
1 change: 1 addition & 0 deletions server/testutils/factories/spaceSearchParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default Factory.define<Cas1SpaceSearchParameters>(() => {
export const spaceSearchParametersUiFactory = Factory.define<SpaceSearchParametersUi>(() => {
const startDateInputsValues = DateFormats.dateObjectToDateInputs(faker.date.soon(), 'startDate')
return {
applicationId: faker.string.uuid(),
startDate: startDateInputsValues.startDate,
targetPostcodeDistrict: faker.helpers.arrayElement(postcodeAreas),
durationInDays: faker.number.int({ max: 100, min: 1 }).toString(),
Expand Down
1 change: 1 addition & 0 deletions server/utils/match/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ describe('matchUtils', () => {
genders: [uiParams.requirements.gender],
spaceCharacteristics: uiParams.requirements.spaceCharacteristics,
},
applicationId: uiParams.applicationId,
startDate: uiParams.startDate,
targetPostcodeDistrict: uiParams.targetPostcodeDistrict,
})
Expand Down
1 change: 1 addition & 0 deletions server/utils/match/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type SearchFilterCategories = 'apType' | 'offenceAndRisk' | 'placementReq

export const mapUiParamsForApi = (query: SpaceSearchParametersUi): SpaceSearchParameters => {
return {
applicationId: query.applicationId,
startDate: query.startDate,
targetPostcodeDistrict: query.targetPostcodeDistrict,
requirements: {
Expand Down
1 change: 1 addition & 0 deletions server/utils/placementRequests/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('utils', () => {
})

expect(mapPlacementRequestToSpaceSearchParams(placementRequest)).toEqual({
applicationId: placementRequest.applicationId,
durationInDays: placementRequest.duration.toString(),
startDate: placementRequest.expectedArrival,
targetPostcodeDistrict: placementRequest.location,
Expand Down
2 changes: 2 additions & 0 deletions server/utils/placementRequests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { DateFormats } from '../dateUtils'
import { TabItem } from '../tasks/listTable'

export const mapPlacementRequestToSpaceSearchParams = ({
applicationId,
duration,
expectedArrival,
location,
Expand All @@ -20,6 +21,7 @@ export const mapPlacementRequestToSpaceSearchParams = ({
gender,
}: PlacementRequest): SpaceSearchParametersUi => {
return {
applicationId,
startDate: expectedArrival,
targetPostcodeDistrict: location,
durationInDays: duration.toString(),
Expand Down

0 comments on commit e5e7aa5

Please sign in to comment.