Skip to content

Commit

Permalink
VB-3340 Booker management: add/edit a prisoner's registered prison (#202
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tpmcgowan authored Dec 18, 2024
1 parent 13c28e8 commit 1cea641
Show file tree
Hide file tree
Showing 21 changed files with 792 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ context('Booker management', () => {
cy.task('reset')
cy.task('stubSignIn')
cy.task('stubManageUser')
cy.task('stubGetAllPrisons')
cy.task('stubPrisonNames')
cy.signIn()
})

Expand Down Expand Up @@ -55,6 +57,7 @@ context('Booker management', () => {
bookerDetailsPage.addPrisoner()
const addPrisonerPage = Page.verifyOnPage(AddPrisonerPage)
addPrisonerPage.enterPrisonerNumber(prisoner.prisonerId)
addPrisonerPage.selectPrison(prisoner.prisonCode)
cy.task('stubCreateBookerPrisoner', { booker, prisoner })
cy.task('stubGetBookerByEmail', bookerWithPrisoner)
cy.task('stubGetSocialContacts', { prisonerId: prisoner.prisonerId, contacts: [contact], approvedOnly: false })
Expand All @@ -63,6 +66,7 @@ context('Booker management', () => {
// Booker details - prisoner added
bookerDetailsPage.checkOnPage()
bookerDetailsPage.prisonerNumber().contains(prisoner.prisonerId)
bookerDetailsPage.prisonName().contains('Hewell (HMP)')

// Add visitor
cy.task('stubGetSocialContacts', { prisonerId: prisoner.prisonerId, contacts: [contact], approvedOnly: true })
Expand Down
1 change: 1 addition & 0 deletions integration_tests/mockApis/bookerRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default {
equalToJson: {
prisonerId: prisoner.prisonerId,
active: true,
prisonCode: prisoner.prisonCode,
},
},
],
Expand Down
4 changes: 4 additions & 0 deletions integration_tests/pages/bookers/addPrisoner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export default class AddPrisonerPage extends Page {
cy.get('#prisonerNumber').type(prisonerNumber)
}

selectPrison = (prisonCode: string): void => {
cy.get('#prisonCode').select(prisonCode)
}

addPrisoner = (): void => {
cy.get('[data-test="add-prisoner"]').click()
}
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/pages/bookers/bookerDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export default class BookerDetailsPage extends Page {

prisonerNumber = (): PageElement => cy.get('[data-test="prisoner-number"]')

prisonName = (): PageElement => cy.get('[data-test="registered-prison-name"]')

addPrisoner = (): void => {
cy.get('[data-test="add-prisoner"]').click()
}
Expand Down
92 changes: 92 additions & 0 deletions server/@types/booker-registry-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,26 @@ export interface paths {
patch?: never
trace?: never
}
'/public/booker/{bookerReference}/permitted/prisoners/{prisonerId}/validate': {
parameters: {
query?: never
header?: never
path?: never
cookie?: never
}
/**
* Validates a prisoner for whom the booker is about to book a visit
* @description Validates a prisoner for whom the booker is about to book a visit
*/
get: operations['validatePrisoner']
put?: never
post?: never
delete?: never
options?: never
head?: never
patch?: never
trace?: never
}
'/public/booker/{bookerReference}/permitted/prisoners/{prisonerId}/permitted/visitors': {
parameters: {
query?: never
Expand Down Expand Up @@ -308,6 +328,11 @@ export interface components {
* @example true
*/
active: boolean
/**
* @description prison code
* @example MDI
*/
prisonCode: string
/** @description Permitted visitors */
permittedVisitors: components['schemas']['PermittedVisitorDto'][]
}
Expand All @@ -332,6 +357,11 @@ export interface components {
* @example A1234AA
*/
prisonerId: string
/**
* @description prison code
* @example MDI
*/
prisonCode: string
/**
* @description Active / Inactive permitted prisoner
* @example true
Expand All @@ -352,6 +382,16 @@ export interface components {
*/
active: boolean
}
BookerPrisonerValidationErrorResponse: {
validationError: string
/** Format: int32 */
status: number
/** Format: int32 */
errorCode?: number
userMessage?: string
developerMessage?: string
moreInfo?: string
}
}
responses: never
parameters: never
Expand Down Expand Up @@ -867,6 +907,58 @@ export interface operations {
}
}
}
validatePrisoner: {
parameters: {
query?: never
header?: never
path: {
bookerReference: string
/**
* @description Prisoner Id for that needs to be validated.
* @example A12345DC
*/
prisonerId: string
}
cookie?: never
}
requestBody?: never
responses: {
/** @description Validation passed */
200: {
headers: {
[name: string]: unknown
}
content?: never
}
/** @description Incorrect request to get permitted visitors for a prisoner associated with that booker */
400: {
headers: {
[name: string]: unknown
}
content: {
'application/json': components['schemas']['ErrorResponse']
}
}
/** @description Incorrect permissions for this action */
403: {
headers: {
[name: string]: unknown
}
content: {
'application/json': components['schemas']['ErrorResponse']
}
}
/** @description Prisoner validation failed */
422: {
headers: {
[name: string]: unknown
}
content: {
'application/json': components['schemas']['BookerPrisonerValidationErrorResponse']
}
}
}
}
getPermittedVisitorsForPrisoner: {
parameters: {
query?: {
Expand Down
26 changes: 24 additions & 2 deletions server/@types/prison-register-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export interface paths {
cookie?: never
}
/**
* Get prison names
* Get prison name(s)
* @description prison id and full name
*/
get: operations['getPrisonNames']
Expand Down Expand Up @@ -370,6 +370,8 @@ export interface components {
female: boolean
/** @description If this is a contracted prison */
contracted: boolean
/** @description If this prison is part of the long term high security estate */
lthse: boolean
/** @description Set of types for this prison */
prisonTypes: ('HMP' | 'YOI' | 'IRC' | 'STC' | 'YCS')[]
/** @description Set of categories for this prison */
Expand Down Expand Up @@ -434,6 +436,8 @@ export interface components {
female: boolean
/** @description Whether the prison is contracted */
contracted: boolean
/** @description Whether the prison is part of long term high security estate */
lthse: boolean
/** @description List of types for this prison */
types: components['schemas']['PrisonTypeDto'][]
/** @description List of the categories for this prison */
Expand Down Expand Up @@ -522,6 +526,8 @@ export interface components {
female: boolean
/** @description If this is a contracted prison */
contracted: boolean
/** @description If this prison is part of the long term high security estate */
lthse: boolean
/**
* @description Set of types for this prison
* @example HMP
Expand Down Expand Up @@ -1435,6 +1441,11 @@ export interface operations {
* @example true
*/
active?: boolean
/**
* @description Long Term High Security Estate
* @example true
*/
lthse?: boolean
/**
* @description Text search
* @example Sheffield
Expand Down Expand Up @@ -1470,7 +1481,18 @@ export interface operations {
}
getPrisonNames: {
parameters: {
query?: never
query?: {
/**
* @description If active is not set, return all prisons, otherwise return only the active or inactive ones based on the value
* @example true
*/
active?: boolean
/**
* @description If parameter prisonId is not set, return the names of all prisons, otherwise return only the one corresponding to the prisonId code. Filtering on active still applies
* @example WDI
*/
prison_id?: string
}
header?: never
path?: never
cookie?: never
Expand Down
Loading

0 comments on commit 1cea641

Please sign in to comment.