Skip to content

Commit

Permalink
Merge pull request #661 from ministryofjustice/revert-656-change/1595…
Browse files Browse the repository at this point in the history
…-show-index-offence-id-in-referral

Revert "Show offence ID on check your answers and full referral pages"
  • Loading branch information
libuk authored Oct 3, 2023
2 parents 3efb59b + 50e35f1 commit c7423c8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ describe('OffendingSummary', () => {
const page = new OffendingSummary(body, application)

expect(page.response()).toEqual({
'Offence ID': application.offenceId,
'Summary of offending history': 'Offending summary',
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export type OffendingSummaryBody = {
summary: string
}

export const offenceIdKey = 'Offence ID'

@Page({ name: 'offending-summary', bodyProperties: ['summary'] })
export default class OffendingSummary implements TasklistPage {
title: string
Expand All @@ -25,10 +23,7 @@ export default class OffendingSummary implements TasklistPage {
}

response() {
return {
[offenceIdKey]: this.application.offenceId,
'Summary of offending history': this.body.summary,
}
return { 'Summary of offending history': this.body.summary }
}

previous() {
Expand Down
39 changes: 1 addition & 38 deletions server/utils/checkYourAnswersUtils/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ describe('checkYourAnswersUtils', () => {
})

describe('getTaskResponsesAsSummaryListItems', () => {
beforeEach(() => {
;(formatLines as jest.Mock).mockReset()
;(formatLines as jest.Mock).mockImplementation((value: string) => `Formatted "${value}"`)
})

it('returns the task responses as Summary List items and adds the actions object', () => {
const application = applicationFactory.build()
;(forPagesInTask as jest.MockedFunction<typeof forPagesInTask>).mockImplementation((_1, _2, callback) => {
Expand All @@ -40,6 +35,7 @@ describe('checkYourAnswersUtils', () => {

callback(page, 'some-page')
})
;(formatLines as jest.Mock).mockImplementation((value: string) => `Formatted "${value}"`)

expect(
getTaskResponsesAsSummaryListItems(
Expand Down Expand Up @@ -68,38 +64,5 @@ describe('checkYourAnswersUtils', () => {

expect(formatLines).toHaveBeenCalledWith('An answer')
})

describe('when the item is offence ID', () => {
it('returns the task response as a Summary List item without the actions object', () => {
const application = applicationFactory.build()
;(forPagesInTask as jest.MockedFunction<typeof forPagesInTask>).mockImplementation((_1, _2, callback) => {
const page = createMock<TasklistPage>()

page.response.mockReturnValue({
'Offence ID': '1234455',
})

callback(page, 'some-page')
})

expect(
getTaskResponsesAsSummaryListItems(
{ id: 'some-task', title: 'Some task', actionText: 'Complete some task', pages: {} },
application,
),
).toEqual([
{
key: {
text: 'Offence ID',
},
value: {
html: 'Formatted "1234455"',
},
},
])

expect(formatLines).toHaveBeenCalledWith('1234455')
})
})
})
})
21 changes: 9 additions & 12 deletions server/utils/checkYourAnswersUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import reviewSections from '../reviewUtils'
import { formatLines } from '../viewUtils'
import { embeddedSummaryListItem } from './embeddedSummaryListItem'
import { forPagesInTask } from '../applicationUtils'
import { offenceIdKey } from '../../form-pages/apply/accommodation-need/sentence-information/offendingSummary'

const checkYourAnswersSections = (application: TemporaryAccommodationApplication) =>
reviewSections(application, getTaskResponsesAsSummaryListItems)
Expand Down Expand Up @@ -41,22 +40,20 @@ const summaryListItemForResponse = (
pageName: string,
application: TemporaryAccommodationApplication,
) => {
const actions = {
items: [
{
href: paths.applications.pages.show({ task: task.id, page: pageName, id: application.id }),
text: 'Change',
visuallyHiddenText: key,
},
],
}

return {
key: {
text: key,
},
value,
...(key === offenceIdKey ? {} : { actions }),
actions: {
items: [
{
href: paths.applications.pages.show({ task: task.id, page: pageName, id: application.id }),
text: 'Change',
visuallyHiddenText: key,
},
],
},
}
}

Expand Down

0 comments on commit c7423c8

Please sign in to comment.