Skip to content

Commit

Permalink
Merge pull request #1170 from ministryofjustice/feature/updates-for-c…
Browse files Browse the repository at this point in the history
…as3-ui-swagger-changeover

Updates for generating the UI code from generated swagger docs
  • Loading branch information
aliuk2012 authored Dec 17, 2024
2 parents 9eeab65 + a7e70a8 commit 96b4203
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 51 deletions.
17 changes: 7 additions & 10 deletions cypress_shared/helpers/apply.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import {
ActiveOffence,
Adjudication,
ArrayOfOASysOffenceDetailsQuestions,
ArrayOfOASysRiskManagementPlanQuestions,
ArrayOfOASysRiskOfSeriousHarmSummaryQuestions,
ArrayOfOASysRiskToSelfQuestions,
ArrayOfOASysSupportingInformationQuestions,
Document,
OASysQuestion,
OASysSection,
OASysSupportingInformationQuestion,
Person,
PersonAcctAlert,
TemporaryAccommodationApplication,
Expand Down Expand Up @@ -112,15 +109,15 @@ export default class ApplyHelper {

otherOasysSections: Array<OASysSection> = []

roshSummaries: ArrayOfOASysRiskOfSeriousHarmSummaryQuestions = []
roshSummaries: Array<OASysQuestion> = []

offenceDetailSummaries: ArrayOfOASysOffenceDetailsQuestions = []
offenceDetailSummaries: Array<OASysQuestion> = []

supportingInformationSummaries: ArrayOfOASysSupportingInformationQuestions = []
supportingInformationSummaries: Array<OASysSupportingInformationQuestion> = []

riskManagementPlanSummaries: ArrayOfOASysRiskManagementPlanQuestions = []
riskManagementPlanSummaries: Array<OASysQuestion> = []

riskToSelfSummaries: ArrayOfOASysRiskToSelfQuestions = []
riskToSelfSummaries: Array<OASysQuestion> = []

adjudications: Array<Adjudication> = []

Expand Down
28 changes: 11 additions & 17 deletions cypress_shared/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
import {
ArrayOfOASysOffenceDetailsQuestions,
ArrayOfOASysRiskManagementPlanQuestions,
ArrayOfOASysRiskOfSeriousHarmSummaryQuestions,
ArrayOfOASysRiskToSelfQuestions,
ArrayOfOASysSupportingInformationQuestions,
} from '@approved-premises/api'
import { OASysQuestion, OASysSupportingInformationQuestion } from '@approved-premises/api'
import { TableRow } from '@approved-premises/ui'
import oasysDataJson from '../fixtures/oasysData.json'

const roshSummariesFromJson = (): ArrayOfOASysRiskOfSeriousHarmSummaryQuestions => {
return oasysDataJson['rosh-summary'].roshSummaries as ArrayOfOASysRiskOfSeriousHarmSummaryQuestions
const roshSummariesFromJson = (): Array<OASysQuestion> => {
return oasysDataJson['rosh-summary'].roshSummaries as Array<OASysQuestion>
}

const offenceDetailSummariesFromJson = (): ArrayOfOASysOffenceDetailsQuestions => {
return oasysDataJson['offence-details'].offenceDetailsSummaries as ArrayOfOASysOffenceDetailsQuestions
const offenceDetailSummariesFromJson = (): Array<OASysQuestion> => {
return oasysDataJson['offence-details'].offenceDetailsSummaries as Array<OASysQuestion>
}

const supportInformationFromJson = (): ArrayOfOASysSupportingInformationQuestions => {
const supportInformationFromJson = (): Array<OASysSupportingInformationQuestion> => {
return oasysDataJson['supporting-information']
.supportingInformationSummaries as ArrayOfOASysSupportingInformationQuestions
.supportingInformationSummaries as Array<OASysSupportingInformationQuestion>
}

const riskManagementPlanFromJson = (): ArrayOfOASysRiskManagementPlanQuestions => {
return oasysDataJson['risk-management-plan'].riskManagementSummaries as ArrayOfOASysRiskManagementPlanQuestions
const riskManagementPlanFromJson = (): Array<OASysQuestion> => {
return oasysDataJson['risk-management-plan'].riskManagementSummaries as Array<OASysQuestion>
}

const riskToSelfSummariesFromJson = (): ArrayOfOASysRiskToSelfQuestions => {
return oasysDataJson['risk-to-self'].riskToSelfSummaries as ArrayOfOASysRiskToSelfQuestions
const riskToSelfSummariesFromJson = (): Array<OASysQuestion> => {
return oasysDataJson['risk-to-self'].riskToSelfSummaries as Array<OASysQuestion>
}

const tableRowsToArrays = (tableRows: Array<TableRow>): Array<Array<string>> => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import type { TemporaryAccommodationApplication } from '@approved-premises/api'
import { ArrayOfOASysRiskManagementPlanQuestions } from '../../../../../server/@types/shared'
import type { OASysQuestion, TemporaryAccommodationApplication } from '@approved-premises/api'
import paths from '../../../../../server/paths/apply'
import ApplyPage from '../../applyPage'

export default class RiskManagementPlanPage extends ApplyPage {
constructor(
application: TemporaryAccommodationApplication,
private readonly riskRiskManagementPlanSummaries: ArrayOfOASysRiskManagementPlanQuestions,
private readonly riskRiskManagementPlanSummaries: Array<OASysQuestion>,
private readonly oasysMissing: boolean,
) {
super(
Expand Down
7 changes: 2 additions & 5 deletions integration_tests/mockApis/assessments.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { SuperAgentRequest } from 'superagent'
import { AnyValue, Assessment, AssessmentSummary } from '../../server/@types/shared'
import { Assessment, AssessmentSummary, Unit } from '../../server/@types/shared'

import api from '../../server/paths/api'
import { getMatchingRequests, stubFor } from '../../wiremock'
Expand Down Expand Up @@ -167,10 +167,7 @@ export default {
jsonBody: {},
},
}),
stubUpdateAssessmentError: (args: {
assessment: Assessment
errorBody: Record<string, AnyValue>
}): SuperAgentRequest =>
stubUpdateAssessmentError: (args: { assessment: Assessment; errorBody: Record<string, Unit> }): SuperAgentRequest =>
stubFor({
request: {
method: 'PUT',
Expand Down
14 changes: 3 additions & 11 deletions server/@types/ui/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import {
Adjudication,
TemporaryAccommodationApplicationSummary as ApplicationSummary,
ArrayOfOASysOffenceDetailsQuestions,
ArrayOfOASysRiskManagementPlanQuestions,
ArrayOfOASysRiskOfSeriousHarmSummaryQuestions,
ArrayOfOASysRiskToSelfQuestions,
ArrayOfOASysSupportingInformationQuestions,
TemporaryAccommodationAssessment as Assessment,
AssessmentSortField,
AssessmentStatus,
BookingSearchSortField,
Document,
LocalAuthorityArea,
OASysQuestion,
OASysSection,
OASysSections,
OASysSupportingInformationQuestion,
PersonAcctAlert,
PersonRisks,
PrisonCaseNote,
Expand Down Expand Up @@ -261,12 +258,7 @@ export interface GroupedApplications {
submitted: Array<ApplicationSummary>
}

export type OasysImportArrays =
| ArrayOfOASysOffenceDetailsQuestions
| ArrayOfOASysRiskOfSeriousHarmSummaryQuestions
| ArrayOfOASysSupportingInformationQuestions
| ArrayOfOASysRiskToSelfQuestions
| ArrayOfOASysRiskManagementPlanQuestions
export type OasysImportArrays = Array<OASysQuestion> | Array<OASysSupportingInformationQuestion>

export type JourneyType = 'applications' | 'assessments'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
TemporaryAccommodationApplication as Application,
ArrayOfOASysRiskManagementPlanQuestions,
} from '@approved-premises/api'
import { TemporaryAccommodationApplication as Application, OASysQuestion } from '@approved-premises/api'
import type { DataServices, OasysPage, PersonRisksUI } from '@approved-premises/ui'
import { Page } from '../../../utils/decorators'

Expand All @@ -11,7 +8,7 @@ import { getOasysSections, oasysImportReponse, validateOasysEntries } from '../.
export type RiskManagementPlanBody = {
version: string
riskManagementAnswers: Record<string, string>
riskManagementSummaries: ArrayOfOASysRiskManagementPlanQuestions
riskManagementSummaries: Array<OASysQuestion>
oasysImported: string
oasysCompleted: string
}
Expand Down

0 comments on commit 96b4203

Please sign in to comment.