Skip to content

Commit

Permalink
Show POM details below Referrer details
Browse files Browse the repository at this point in the history
  • Loading branch information
jsrobertson committed Dec 11, 2024
1 parent 261dec7 commit 4a099cb
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 2 deletions.
8 changes: 7 additions & 1 deletion integration_tests/pages/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,16 @@ export default abstract class Page {
referralSubmissionDate: Referral['submittedOn'],
referrerName: User['name'],
referrerEmail: CourseOffering['contactEmail'],
prisonOffenderManager: Referral['primaryPrisonOffenderManager'],
): void {
cy.get('[data-testid="submission-summary-list"]').then(summaryListElement => {
this.shouldContainSummaryListRows(
ShowReferralUtils.submissionSummaryListRows(referralSubmissionDate, referrerName, referrerEmail),
ShowReferralUtils.submissionSummaryListRows(
referralSubmissionDate,
referrerName,
referrerEmail,
prisonOffenderManager,
),
summaryListElement,
)
})
Expand Down
7 changes: 6 additions & 1 deletion integration_tests/pages/refer/new/duplicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ export default class NewReferralDuplicatePage extends Page {
shouldContainSubmissionSummaryList(referrerName: User['name'], referrerEmail: CourseOffering['contactEmail']): void {
cy.get('[data-testid="submission-summary-list"]').then(summaryListElement => {
this.shouldContainSummaryListRows(
ShowReferralUtils.submissionSummaryListRows(this.referral.submittedOn, referrerName, referrerEmail),
ShowReferralUtils.submissionSummaryListRows(
this.referral.submittedOn,
referrerName,
referrerEmail,
this.referral.primaryPrisonOffenderManager,
),
summaryListElement,
)
})
Expand Down
10 changes: 10 additions & 0 deletions integration_tests/support/sharedTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
referral.primaryPrisonOffenderManager,
)
additionalInformationPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
additionalInformationPage.shouldContainAdditionalInformationSummaryCard()
Expand Down Expand Up @@ -232,6 +233,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
referral.primaryPrisonOffenderManager,
)
offenceHistoryPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
offenceHistoryPage.shouldContainImportedFromText('NOMIS')
Expand Down Expand Up @@ -267,6 +269,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
referral.primaryPrisonOffenderManager,
)
programmeHistoryPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
programmeHistoryPage.shouldContainNoHistorySummaryCard()
Expand Down Expand Up @@ -334,6 +337,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
referral.primaryPrisonOffenderManager,
)
offenceHistoryPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
offenceHistoryPage.shouldContainImportedFromText('NOMIS')
Expand Down Expand Up @@ -365,6 +369,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
referral.primaryPrisonOffenderManager,
)
personalDetailsPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
personalDetailsPage.shouldContainImportedFromText('NOMIS')
Expand Down Expand Up @@ -406,6 +411,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
referral.primaryPrisonOffenderManager,
)
programmeHistoryPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
programmeHistoryPage.shouldContainHistorySummaryCards(courseParticipationsPresenter, referral.id, {
Expand Down Expand Up @@ -441,6 +447,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
referral.primaryPrisonOffenderManager,
)
releaseDatesPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
releaseDatesPage.shouldContainImportedFromText('NOMIS')
Expand Down Expand Up @@ -482,6 +489,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
referral.primaryPrisonOffenderManager,
)
releaseDatesPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
releaseDatesPage.shouldContainImportedFromText('NOMIS')
Expand Down Expand Up @@ -515,6 +523,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
referral.primaryPrisonOffenderManager,
)
sentenceInformationPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
sentenceInformationPage.shouldContainImportedFromText('NOMIS')
Expand Down Expand Up @@ -556,6 +565,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
referral.primaryPrisonOffenderManager,
)
sentenceInformationPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
sentenceInformationPage.shouldContainImportedFromText('NOMIS')
Expand Down
1 change: 1 addition & 0 deletions server/controllers/shared/referralsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export default class ReferralsController {
referral.submittedOn,
referrerUserFullName,
referrerEmailAddress,
referral.primaryPrisonOffenderManager,
),
}
}
Expand Down
51 changes: 51 additions & 0 deletions server/utils/referrals/showReferralUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
referralFactory,
referralStatusHistoryFactory,
referralStatusRefDataFactory,
staffDetailFactory,
} from '../../testutils/factories'
import CourseUtils from '../courseUtils'
import type { ReferralStatusHistoryPresenter } from '@accredited-programmes/ui'
Expand Down Expand Up @@ -348,6 +349,22 @@ describe('ShowReferralUtils', () => {
key: { text: 'Referrer email address' },
value: { html: `<a href="mailto:${referrerEmail}">${referrerEmail}</a>` },
},
{
key: {
text: 'Prison Offender Manager',
},
value: {
text: 'Not assigned',
},
},
{
key: {
text: 'Prison Offender Manager email address',
},
value: {
text: 'Not assigned',
},
},
])
})

Expand All @@ -365,6 +382,40 @@ describe('ShowReferralUtils', () => {
)
})
})

describe('when the referral has a prison offender manager assigned', () => {
const referral = referralFactory.submitted().build({
primaryPrisonOffenderManager: staffDetailFactory.build({
firstName: 'Bob',
lastName: 'Smith',
primaryEmail: '[email protected]',
}),
})

it('returns the prison offender manager details', () => {
expect(
ShowReferralUtils.submissionSummaryListRows(
referral.submittedOn,
'Test User',
'[email protected]',
referral.primaryPrisonOffenderManager,
),
).toEqual(
expect.arrayContaining([
{
key: { text: 'Prison Offender Manager' },
value: { text: 'Bob Smith' },
},
{
key: { text: 'Prison Offender Manager email address' },
value: {
html: '<a href="mailto:[email protected]">[email protected]</a>',
},
},
]),
)
})
})
})

describe('subNavigationItems', () => {
Expand Down
24 changes: 24 additions & 0 deletions server/utils/referrals/showReferralUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Request } from 'express'
import CaseListUtils from './caseListUtils'
import { assessPathBase, assessPaths, referPaths } from '../../paths'
import DateUtils from '../dateUtils'
import StringUtils from '../stringUtils'
import type { CourseOffering, Organisation, ReferralStatusRefData } from '@accredited-programmes/models'
import type {
CoursePresenter,
Expand Down Expand Up @@ -150,7 +151,10 @@ export default class ShowReferralUtils {
referralSubmissionDate: Referral['submittedOn'],
referrerName: User['name'],
referrerEmail: UserEmail['email'],
prisonOffenderManager?: Referral['primaryPrisonOffenderManager'],
): Array<GovukFrontendSummaryListRowWithKeyAndValue> {
const pomNotAssignedString = 'Not assigned'

return [
{
key: { text: 'Date referred' },
Expand All @@ -166,6 +170,26 @@ export default class ShowReferralUtils {
key: { text: 'Referrer email address' },
value: { html: `<a href="mailto:${referrerEmail}">${referrerEmail}</a>` },
},

{
key: { text: 'Prison Offender Manager' },
value: {
text:
prisonOffenderManager?.firstName || prisonOffenderManager?.lastName
? StringUtils.convertToTitleCase(`${prisonOffenderManager?.firstName} ${prisonOffenderManager?.lastName}`)
: pomNotAssignedString,
},
},
{
key: { text: 'Prison Offender Manager email address' },
value: {
...(prisonOffenderManager?.primaryEmail
? {
html: `<a href="mailto:${prisonOffenderManager.primaryEmail}">${prisonOffenderManager.primaryEmail}</a>`,
}
: { text: pomNotAssignedString }),
},
},
]
}

Expand Down

0 comments on commit 4a099cb

Please sign in to comment.