Skip to content

Commit

Permalink
Merge pull request #2192 from ministryofjustice/feature/APS-1458-rest…
Browse files Browse the repository at this point in the history
…rict-we-types-of-AP

APS-1458: restrict types of AP for Women's Estate
  • Loading branch information
froddd authored Nov 4, 2024
2 parents d942611 + 0dadc09 commit 7057d29
Show file tree
Hide file tree
Showing 22 changed files with 385 additions and 175 deletions.
19 changes: 12 additions & 7 deletions integration_tests/fixtures/applicationData.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,18 @@
},
"type-of-ap": {
"ap-type": {
"type": "rfap"
},
"rfap-details": {
"motivation": "Some motivation",
"continuedRecovery": "Some work",
"receivingTreatment": "yes",
"receivingTreatmentDetail": "Some details here"
"type": "pipe"
},
"pipe-referral": {
"opdPathway": "yes",
"opdPathwayDate-year": "2024",
"opdPathwayDate-month": "9",
"opdPathwayDate-day": "9",
"opdPathwayDate": "2024-09-09"
},
"pipe-opd-screening": {
"pipeReferral": "yes",
"pipeReferralMoreDetail": "Details"
}
},
"oasys-import": {
Expand Down
35 changes: 27 additions & 8 deletions integration_tests/fixtures/assessmentData.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"review-application": { "review": { "reviewed": "yes" } },
"sufficient-information": { "sufficient-information": { "sufficientInformation": "yes", "query": "" } },
"review-application": {
"review": {
"reviewed": "yes"
}
},
"sufficient-information": {
"sufficient-information": {
"sufficientInformation": "yes",
"query": ""
}
},
"suitability-assessment": {
"suitability-assessment": {
"riskFactors": "yes",
Expand All @@ -12,10 +21,11 @@
"moveOnPlan": "yes",
"moveOnPlanComments": "Some move on comments"
},
"rfap-suitability": {
"rfapIdentifiedAsSuitable": "no",
"unsuitabilityForRfapRationale": "Some RFAP comments",
"noDetail": "some detail"
"pipe-suitability": {
"pipeIdentifiedAsSuitable": "yes",
"unsuitabilityForPipeRationale": "Details",
"yesDetail": "Details about suitability",
"noDetail": ""
},
"contingency-plan-suitability": {
"contingencyPlanSufficient": "yes",
Expand All @@ -39,7 +49,12 @@
"outlineOfDiscussion": "Some discussion"
}
},
"make-a-decision": { "make-a-decision": { "decision": "accept", "decisionRationale": "some rejected comment" } },
"make-a-decision": {
"make-a-decision": {
"decision": "accept",
"decisionRationale": "some rejected comment"
}
},
"matching-information": {
"matching-information": {
"apType": "normal",
Expand All @@ -62,5 +77,9 @@
"isArsonSuitable": "notRelevant"
}
},
"check-your-answers": { "check-your-answers": { "reviewed": "1" } }
"check-your-answers": {
"check-your-answers": {
"reviewed": "1"
}
}
}
17 changes: 12 additions & 5 deletions integration_tests/helpers/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,14 +577,21 @@ export default class ApplyHelper {
apTypePage.completeForm()
apTypePage.clickSubmit()

// Given I am on the RFAP details page
const rfapDetailsPage = new ApplyPages.RfapDetailsPage(this.application)
// Given I am on the PIPE referral page
const pipeDetailsPage = new ApplyPages.PipeReferralPage(this.application)

// When I complete the form and click submit
rfapDetailsPage.completeForm()
rfapDetailsPage.clickSubmit()
pipeDetailsPage.completeForm()
pipeDetailsPage.clickSubmit()

this.pages.typeOfAp = [apTypePage, rfapDetailsPage]
// Given I am on the PIPE OPD screening page
const pipeOpdScreeningPage = new ApplyPages.PipeOpdScreening(this.application)

// When I complete the form and click submit
pipeOpdScreeningPage.completeForm()
pipeOpdScreeningPage.clickSubmit()

this.pages.typeOfAp = [apTypePage, pipeDetailsPage, pipeOpdScreeningPage]

// Then I should be redirected to the task list
const tasklistPage = Page.verifyOnPage(ApplyPages.TaskListPage)
Expand Down
10 changes: 5 additions & 5 deletions integration_tests/helpers/assess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
import Page from '../pages/page'
import AssessPage from '../pages/assess/assessPage'
import { assessmentSummaryFactory, personFactory } from '../../server/testutils/factories'
import RfapSuitabilityPage from '../pages/assess/rfapSuitability'
import PipeSuitabilityPage from '../pages/assess/pipeSuitability'
import ContingencyPlanSuitabilityPage from '../pages/assess/contingencyPlanSuitability'

import { awaitingAssessmentStatuses } from '../../server/utils/assessments/utils'
Expand Down Expand Up @@ -208,11 +208,11 @@ export default class AseessHelper {
suitabilityAssessmentPage.completeForm()
suitabilityAssessmentPage.clickSubmit()

const rfapSuitabilityPage = new RfapSuitabilityPage(this.assessment)
rfapSuitabilityPage.completeForm()
rfapSuitabilityPage.clickSubmit()
const pipeSuitabilityPage = new PipeSuitabilityPage(this.assessment)
pipeSuitabilityPage.completeForm()
pipeSuitabilityPage.clickSubmit()

this.pages.assessSuitability = [suitabilityAssessmentPage, rfapSuitabilityPage]
this.pages.assessSuitability = [suitabilityAssessmentPage, pipeSuitabilityPage]

if (!options.isShortNoticeApplication) {
const contingencyPlanSuitabilityPage = new ContingencyPlanSuitabilityPage(this.assessment)
Expand Down
6 changes: 4 additions & 2 deletions integration_tests/pages/apply/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ import ReasonForShortNoticePage from './reasonForShortNoticePage'
import RehabilitativeInterventions from './rehabilitativeInterventions'
import ReleaseDatePage from './releaseDate'
import RelocationRegionPage from './relocationRegion'
import RfapDetailsPage from './rfapDetails'
import PipeOpdScreening from './pipeOpdScreening'
import PipeReferralPage from './pipeReferral'
import RiskManagementFeatures from './riskManagementFeatures'
import RiskManagementPlanPage from './riskManagementPlan'
import RiskToSelfPage from './riskToSelf'
Expand Down Expand Up @@ -118,7 +119,8 @@ export {
RehabilitativeInterventions,
ReleaseDatePage,
RelocationRegionPage,
RfapDetailsPage,
PipeReferralPage,
PipeOpdScreening,
RiskManagementFeatures,
RiskManagementPlanPage,
RiskToSelfPage,
Expand Down
21 changes: 21 additions & 0 deletions integration_tests/pages/apply/pipeOpdScreening.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ApprovedPremisesApplication } from '@approved-premises/api'
import paths from '../../../server/paths/apply'

import ApplyPage from './applyPage'

export default class PipeOpdScreening extends ApplyPage {
constructor(application: ApprovedPremisesApplication) {
super(
'Has an application for PIPE placement been recommended in the OPD pathway plan?',
application,
'type-of-ap',
'pipe-opd-screening',
paths.applications.pages.show({ id: application.id, task: 'type-of-ap', page: 'pipe-referral' }),
)
}

completeForm() {
this.checkRadioButtonFromPageBody('pipeReferral')
this.completeTextInputFromPageBody('pipeReferralMoreDetail')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@ import paths from '../../../server/paths/apply'

import ApplyPage from './applyPage'

export default class RfapDetailsPage extends ApplyPage {
export default class PipeReferralPage extends ApplyPage {
constructor(application: ApprovedPremisesApplication) {
super(
'Recovery Focused Approved Premises (RFAP)',
'Has the person been screened into the Offender Personality Disorder Pathway (OPD)?',
application,
'type-of-ap',
'rfap-details',
'pipe-referral',
paths.applications.pages.show({ id: application.id, task: 'type-of-ap', page: 'ap-type' }),
)
}

completeForm() {
this.completeTextInputFromPageBody('motivation')
this.completeTextInputFromPageBody('continuedRecovery')
this.checkRadioButtonFromPageBody('receivingTreatment')
this.completeTextInputFromPageBody('receivingTreatmentDetail')
this.checkRadioButtonFromPageBody('opdPathway')
this.completeDateInputsFromPageBody('opdPathwayDate')
}
}
4 changes: 2 additions & 2 deletions integration_tests/pages/assess/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import CheckYourAnswersPage from './checkYourAnswersPage'
import SubmissionConfirmation from './submissionConfirmation'
import ShowPage from './showPage'
import ApplicationTimelinessPage from './applicationTimelinessPage'
import RfapSuitabilityPage from './rfapSuitability'
import PipeSuitabilityPage from './pipeSuitability'
import ContingencyPlanSuitabilityPage from './contingencyPlanSuitability'

export {
Expand All @@ -30,6 +30,6 @@ export {
SubmissionConfirmation,
ShowPage,
ApplicationTimelinessPage,
RfapSuitabilityPage,
PipeSuitabilityPage,
ContingencyPlanSuitabilityPage,
}
15 changes: 15 additions & 0 deletions integration_tests/pages/assess/pipeSuitability.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { ApprovedPremisesAssessment as Assessment } from '@approved-premises/api'

import AssessPage from './assessPage'

export default class PipeSuitabilityPage extends AssessPage {
constructor(assessment: Assessment) {
super('Suitability assessment', assessment, 'suitability-assessment', 'pipe-suitability')
}

completeForm() {
this.checkRadioButtonFromPageBody('pipeIdentifiedAsSuitable')
this.completeTextInputFromPageBody('yesDetail')
this.completeTextInputFromPageBody('unsuitabilityForPipeRationale')
}
}
15 changes: 0 additions & 15 deletions integration_tests/pages/assess/rfapSuitability.ts

This file was deleted.

6 changes: 3 additions & 3 deletions integration_tests/tests/assess/assess.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import AssessHelper from '../../helpers/assess'
import {
ContingencyPlanSuitabilityPage,
ListPage,
RfapSuitabilityPage,
PipeSuitabilityPage,
ShowPage,
SuitabilityAssessmentPage,
TaskListPage,
Expand Down Expand Up @@ -369,8 +369,8 @@ context('Assess', () => {
// And I review a section
const suitabilityAssessmentPage = new SuitabilityAssessmentPage(assessment)
suitabilityAssessmentPage.clickSubmit()
const rfapSuitabilityAssessmentPage = new RfapSuitabilityPage(assessment)
rfapSuitabilityAssessmentPage.clickSubmit()
const pipeSuitabilityAssessmentPage = new PipeSuitabilityPage(assessment)
pipeSuitabilityAssessmentPage.clickSubmit()
const contingencyPlanPage = new ContingencyPlanSuitabilityPage(assessment)
contingencyPlanPage.clickSubmit()

Expand Down
Loading

0 comments on commit 7057d29

Please sign in to comment.