Skip to content

Commit

Permalink
Add new space search premises summary properties
Browse files Browse the repository at this point in the history
This updates the factory for a Space Search Premises Summary, which is
renamed to match the new namespace and prevent confusion.
  • Loading branch information
froddd committed Jan 6, 2025
1 parent bce8f88 commit 2b40c7e
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
placementRequestDetailFactory,
} from '../../../testutils/factories'
import { encodeSpaceSearchResult, placementDates } from '../../../utils/match'
import { NewBookingNotMade } from '../../../@types/shared'
import { NewBookingNotMade, type Cas1SpaceSearchResult as SpaceSearchResult } from '../../../@types/shared'

import matchPaths from '../../../paths/match'
import adminPaths from '../../../paths/admin'
Expand Down Expand Up @@ -41,7 +41,7 @@ describe('BookingsController', () => {
placementRequestService.getPlacementRequest.mockResolvedValue(placementRequestDetail)

const query = {
bedSearchResult: encodeSpaceSearchResult(bedSearchResult),
bedSearchResult: encodeSpaceSearchResult(bedSearchResult as unknown as SpaceSearchResult),
startDate: '2022-01-01',
duration: '4',
}
Expand Down
65 changes: 65 additions & 0 deletions server/testutils/factories/cas1PremisesSearchResultSummary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { Factory } from 'fishery'
import { faker } from '@faker-js/faker/locale/en_GB'

import type { Cas1PremisesSearchResultSummary, Cas1SpaceCharacteristic } from '@approved-premises/api'
import namedIdFactory from './namedId'
import { sentenceCase } from '../../utils/utils'
import { apCharacteristicPairFactory } from './bedSearchResult'

const characteristics: ReadonlyArray<Cas1SpaceCharacteristic> = [
'acceptsChildSexOffenders',
'acceptsHateCrimeOffenders',
'acceptsNonSexualChildOffenders',
'acceptsSexOffenders',
'hasArsonInsuranceConditions',
'hasBrailleSignage',
'hasCallForAssistance',
'hasCrib7Bedding',
'hasEnSuite',
'hasFixedMobilityAids',
'hasHearingLoop',
'hasLift',
'hasNearbySprinkler',
'hasSmokeDetector',
'hasStepFreeAccess',
'hasStepFreeAccessToCommunalAreas',
'hasTactileFlooring',
'hasTurningSpace',
'hasWheelChairAccessibleBathrooms',
'hasWideAccessToCommunalAreas',
'hasWideDoor',
'hasWideStepFreeAccess',
'isArsonDesignated',
'isArsonSuitable',
'isCatered',
'isFullyFm',
'isGroundFloor',
'isGroundFloorNrOffice',
'isIAP',
'isSingle',
'isStepFreeDesignated',
'isSuitableForVulnerable',
'isSuitedForSexOffenders',
'isTopFloorVulnerable',
'isWheelchairAccessible',
'isWheelchairDesignated',
]

export default Factory.define<Cas1PremisesSearchResultSummary>(() => {
return {
id: faker.string.uuid(),
apCode: faker.string.alphanumeric(5),
deliusQCode: faker.string.alphanumeric(5),
apType: faker.helpers.arrayElement(['normal', 'pipe', 'esap', 'rfap', 'mhapStJosephs', 'mhapElliottHouse']),
name: `${sentenceCase(faker.lorem.word({}))} ${faker.helpers.arrayElement(['House', 'Lodge', 'Cottage', 'Court', 'Place', 'Hall', 'Manor', 'Mansion'])}`,
addressLine1: faker.location.streetAddress(),
addressLine2: faker.location.county(),
town: faker.location.city(),
postcode: faker.location.zipCode(),
apArea: namedIdFactory.build(),
totalSpaceCount: faker.number.int({ min: 5, max: 50 }),
fullAddress: `${faker.location.streetAddress()}, ${faker.location.county()}, ${faker.location.city()}`,
premisesCharacteristics: apCharacteristicPairFactory.buildList(5),
characteristics: faker.helpers.arrayElements(characteristics),
}
})
4 changes: 2 additions & 2 deletions server/testutils/factories/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import bookingPremisesSummaryFactory from './bookingPremisesSummary'
import withdrawableFactory from './withdrawableFactory'
import cancellationReasonFactory from './cancellationReason'
import newSpaceBookingFactory from './newSpaceBooking'
import premisesSearchResultSummaryFactory from './premisesSearchResultSummary'
import cas1PremisesSearchResultSummaryFactory from './cas1PremisesSearchResultSummary'
import spaceBookingRequirementsFactory from './spaceBookingRequirements'
import spaceCategoryAvailabilityFactory from './spaceAvailability'
import spaceSearchParametersFactory, { spaceSearchParametersUiFactory } from './spaceSearchParameters'
Expand Down Expand Up @@ -191,7 +191,7 @@ export {
withdrawableFactory,
cancellationReasonFactory,
newSpaceBookingFactory,
premisesSearchResultSummaryFactory,
cas1PremisesSearchResultSummaryFactory,
spaceBookingRequirementsFactory,
spaceCategoryAvailabilityFactory,
spaceSearchParametersFactory,
Expand Down
24 changes: 0 additions & 24 deletions server/testutils/factories/premisesSearchResultSummary.ts

This file was deleted.

2 changes: 1 addition & 1 deletion server/testutils/factories/spaceSearchResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Factory } from 'fishery'
import { faker } from '@faker-js/faker/locale/en_GB'

import type { Cas1SpaceSearchResult } from '@approved-premises/api'
import premisesSearchResultSummary from './premisesSearchResultSummary'
import premisesSearchResultSummary from './cas1PremisesSearchResultSummary'
import spaceCategoryAvailability from './spaceAvailability'

export default Factory.define<Cas1SpaceSearchResult>(() => {
Expand Down

0 comments on commit 2b40c7e

Please sign in to comment.