From d7116feed007d8aed971afcc158d8b3161e29199 Mon Sep 17 00:00:00 2001 From: Emir Demirbag <17883910+edemirbag@users.noreply.github.com> Date: Wed, 15 May 2024 13:34:06 +0100 Subject: [PATCH] [ASL-4413] HBA upload functionality in PPL transfer journeys (#1577) * Latest functional and content changes towards ASL-4413, including those cherry picked from commit b77a5381e9aaf9badf92f9cb85a62eb96b8c0706 * - Content updates for various journey points of establishment transfer, as set out in the copy deck, as part of ASL-4413 - Content updates for various journey points of change in project licence holder, as set out in the copy deck, as part of ASL-4413 * transfer anf amendment success page content changed. * action = update for license holder change. * More content updates to journey point 5 for both journeys (ASL-4421) * redirecting to upload-hba.jsx page. * content added proposed PPL license holder, for confirm-hba.jsx page. * content updated for confirm-hba page. * confirm-hba.jsx warning text content chanage. * switch btw transfer/amendment journey content update. * confirm-hba.jsx content changed for transfer and amendment journey done. * confirm-hba.jsx content warning to use their own json data for amendment/ transfer journey. * task view page content update on activity comp, reworded. * task view pages content updated for ProfileDetails. * props added to ProfileLink. * refactored task-details & extend logic, lint fixes. * existing test typo fixed for this branch. * test aded for upload-hba transfer journey. * transfer and amendment upload-jsx to use seperate content intro keys. * radio button for confirm-hba.jsx content overriden. * test passing, lint passing. DONE * Update view.js - remove console.log() * Provisionally adding back Applicant label --------- Co-authored-by: Ishaq <156688098+farrukhishaq@users.noreply.github.com> --- pages/common/content/index.js | 2 +- pages/success/content/index.js | 38 ++++++++-- pages/success/index.js | 12 ++++ pages/task/content/status.js | 35 +++++---- pages/task/read/content/base.js | 5 +- pages/task/read/content/confirm-hba.js | 20 +++++- pages/task/read/content/confirm.js | 2 +- pages/task/read/content/project.js | 3 +- pages/task/read/content/upload-hba.js | 5 +- pages/task/read/routers/confirm-hba.js | 24 +++++++ pages/task/read/routers/confirm.js | 4 +- pages/task/read/routers/read.js | 2 +- pages/task/read/views/adjusted-wording.js | 4 +- .../read/views/components/activity-log.jsx | 2 +- .../read/views/components/task-details.jsx | 4 +- pages/task/read/views/confirm-hba.jsx | 71 +++++++++++++++---- pages/task/read/views/confirm.jsx | 7 +- pages/task/read/views/upload-hba.jsx | 4 +- pages/task/schema/view.js | 19 ++++- .../pages/task/read/views/upload-hba.spec.jsx | 21 +++++- 20 files changed, 224 insertions(+), 60 deletions(-) diff --git a/pages/common/content/index.js b/pages/common/content/index.js index 023419ab0..010195a19 100644 --- a/pages/common/content/index.js +++ b/pages/common/content/index.js @@ -226,7 +226,7 @@ module.exports = { }, success: { whatNext: { - title: 'What happens next?' + title: 'What happens next' } }, notifications: { diff --git a/pages/success/content/index.js b/pages/success/content/index.js index f8d4986ab..30ca8c7f4 100644 --- a/pages/success/content/index.js +++ b/pages/success/content/index.js @@ -105,21 +105,21 @@ module.exports = { title: 'Approved' }, whatNext: { - body: `This request has been approved.`, + body: ``, internal: 'The relevant people have been emailed.', external: '' }, taskLink: { - before: 'You can ', - linkText: 'view the history of this request.' + before: '', + linkText: 'View history of application' } }, 'rejected': { panel: { - title: 'Rejected' + title: 'Refused' }, whatNext: { - body: `This request has been rejected.`, + body: `This request has been refused.`, internal: 'The relevant people have been emailed.' }, taskLink: { @@ -205,5 +205,33 @@ The relevant people have been emailed.` before: 'You can ', linkText: 'view the history of this request.' } + }, + 'licence-amended': { + panel: { + title: 'Licence amended' + }, + whatNext: { + body: `This request has been approved.`, + internal: 'The relevant people have been emailed.', + external: '' + }, + taskLink: { + before: 'You can ', + linkText: 'view the history of this request.' + } + }, + 'pil-transfer': { + panel: { + title: 'Transfer approved' + }, + whatNext: { + body: `This request has been approved.`, + internal: 'The relevant people have been emailed.', + external: '' + }, + taskLink: { + before: 'You can ', + linkText: 'view the history of this request.' + } } }; diff --git a/pages/success/index.js b/pages/success/index.js index cc9d11d6e..34fcff788 100644 --- a/pages/success/index.js +++ b/pages/success/index.js @@ -41,6 +41,10 @@ const getTaskLabel = task => { case 'project': if (action === 'grant-ra') { return 'Retrospective assessment'; + } else if (action === 'transfer') { + return 'Project licence transfer'; + } else if (action === 'update') { + return 'Project licence amendment'; } return `${upperFirst(model)} ${taskType}`; @@ -96,6 +100,14 @@ const getSuccessType = task => { if (['discarded-by-applicant', 'discarded-by-asru'].includes(task.status)) { return 'discarded'; } + // HBA amendment licence holder content change on success + if (task?.type === 'amendment' && task?.data?.model === 'project') { + return 'licence-amended'; + } + // HBA PPL transfer establishment content change on success + if (task?.type === 'transfer' && task?.data?.model === 'project') { + return 'pil-transfer'; + } return task.status; }; diff --git a/pages/task/content/status.js b/pages/task/content/status.js index 6d051fe9c..d4d68a14a 100644 --- a/pages/task/content/status.js +++ b/pages/task/content/status.js @@ -51,14 +51,19 @@ module.exports = { }, 'returned-to-applicant': { state: 'Returned', - action: 'Return to applicant', + action: { + default: 'Return with comments', + transfer: 'Return transfer request with comments', + amendment: 'Return amendment with comments' + }, hint: { - application: 'The application will be returned to the applicant with your comments.', - amendment: 'The amendment will be returned to the applicant with your comments.', - revocation: 'The revocation request will be returned to the applicant with your comments.', - transfer: 'The transfer request will be returned to the applicant with your comments.', - review: 'The review request will be returned to the applicant with your comments.', - ra: 'The assessment will be returned to the applicant with your comments.' + application: 'Return application with comments.', + revocation: 'Return revocation request with comments.', + review: 'Return review request with comments.', + ra: 'Return assessment with comments.' + }, + confirmTitle: { + transfer: 'Return transfer request' }, log: 'Returned by', currentlyWith: '**Currently with:** Applicant' @@ -236,20 +241,20 @@ module.exports = { rejected: { state: 'Rejected', action: { - application: 'Reject application', - amendment: 'Reject amendment', - revocation: 'Reject revocation', - transfer: 'Reject transfer request', - ra: 'Reject retrospective assessment' + application: 'Refuse application', + amendment: 'Refuse amendment', + revocation: 'Refuse revocation', + transfer: 'Refuse transfer request', + ra: 'Refuse retrospective assessment' }, hint: { application: 'The applicant will need to create a new application to apply for this type of licence in the future.', - amendment: 'The applicant will need to create a new amendment to submit these changes again.', + amendment: 'The applicant will need to create a new amendment in the future, if required.', revocation: 'The applicant will need to create a new revocation request for this licence to be revoked.', - transfer: 'The applicant will need to create a new transfer request.', + transfer: 'The applicant will need to create a new transfer request in the future, if required.', ra: 'The applicant will need to create a new assessment.' }, - log: 'Rejected by' + log: 'Refused by' }, 'intention-to-refuse': { state: 'Returned', diff --git a/pages/task/read/content/base.js b/pages/task/read/content/base.js index be82110cb..3e62fd0c9 100644 --- a/pages/task/read/content/base.js +++ b/pages/task/read/content/base.js @@ -13,8 +13,8 @@ module.exports = { label: '' }, comment: { - label: '{{#commentRequired}}Reason for {{commentLabel}}{{/commentRequired}}{{^commentRequired}}Remarks (optional){{/commentRequired}}', - hint: 'Your {{#commentRequired}}reason{{/commentRequired}}{{^commentRequired}}remarks{{/commentRequired}} will be recorded and visible to relevant establishment and Home Office personnel.' + label: '{{#commentRequired}}Reason for {{commentLabel}}{{/commentRequired}}{{^commentRequired}}Comments (optional){{/commentRequired}}', + hint: 'Your {{#commentRequired}}reason{{/commentRequired}}{{^commentRequired}}comments{{/commentRequired}} will be recorded and visible to relevant establishment and Home Office staff.' }, assignedTo: { label: 'Assign to:' @@ -109,6 +109,7 @@ module.exports = { global: 'Name', applicant: 'Applicant', licenceHolder: 'Licence holder', + amendment: 'Current licence holder', pelh: 'Establishment licence holder', nprc: 'Named person responsible for compliance' } diff --git a/pages/task/read/content/confirm-hba.js b/pages/task/read/content/confirm-hba.js index eaa4491c1..df9bdd613 100644 --- a/pages/task/read/content/confirm-hba.js +++ b/pages/task/read/content/confirm-hba.js @@ -10,9 +10,21 @@ module.exports = merge({}, baseContent, { establishment: { label: 'Establishment:' }, + currentEstablishment: { + label: 'Current establishment:' + }, + proposedEstablishment: { + label: 'Proposed establishment:' + }, applicant: { label: 'Applicant:' }, + pplHolder: { + label: 'PPL holder:' + }, + proposedApplicant: { + label: 'Proposed PPL licence holder:' + }, hbaFilename: { label: 'Selected HBA file:', download: 'Download file' @@ -20,13 +32,15 @@ module.exports = merge({}, baseContent, { confirmHba: { label: 'What do you want to do?', options: { - yes: 'Confirm and continue to grant or amend licence', + yes: 'Confirm and continue to amend licence', no: 'Discard selected file and choose another' } } }, - warning: - 'Once confirmed, this HBA file in ASPeL (not SharePoint) will be the single point of reference for this {{type}}, for future assessment and audit purposes.', + warning: { + transfer: 'Once confirmed, this HBA file in ASPeL (not SharePoint) will be the single point of reference for this transfer request, for future assessment and audit purposes.', + amendment: 'Once confirmed, this HBA file in ASPeL (not SharePoint) will be the single point of reference for this amendment, for future assessment and audit purposes.' + }, errors: { confirmHba: { required: 'Select an option', diff --git a/pages/task/read/content/confirm.js b/pages/task/read/content/confirm.js index fb2b11763..7c4b79f5a 100644 --- a/pages/task/read/content/confirm.js +++ b/pages/task/read/content/confirm.js @@ -25,7 +25,7 @@ module.exports = merge({}, baseContent, { 'awerb-no-review-reason' ]) }, - hba: 'Selected harm benefit analysis file: ', + hba: 'Selected HBA file: ', declaration: { title: 'Declaration', endorsed: { diff --git a/pages/task/read/content/project.js b/pages/task/read/content/project.js index 497338072..09cf1d882 100644 --- a/pages/task/read/content/project.js +++ b/pages/task/read/content/project.js @@ -41,7 +41,8 @@ module.exports = { resolved: { hint: { application: 'Upload the harm benefit analysis and a new licence will be granted.', - amendment: 'Upload the harm benefit analysis file and the existing licence will be updated.' + amendment: 'Upload the harm benefit analysis file and the existing licence will be updated.', + transfer: 'Upload the harm benefit analysis and the licence will be transferred to the proposed establishment.' } } }, diff --git a/pages/task/read/content/upload-hba.js b/pages/task/read/content/upload-hba.js index 705a56017..400c9f333 100644 --- a/pages/task/read/content/upload-hba.js +++ b/pages/task/read/content/upload-hba.js @@ -5,9 +5,12 @@ const tasks = require('../../content/tasks'); module.exports = merge({}, baseContent, { tasks, title: 'Upload harm benefit analysis file', - intro: `To {{action}} this licence you must upload the PPL assessment form containing the harm benefit analysis (HBA) for this {{type}}. + intro: `To {{action}} the licence you must upload the PPL assessment form containing the harm benefit analysis (HBA) for this {{type}}. The HBA will be visible to ASRU only.`, + transferIntro: `To approve this transfer you must upload the PPL assessment form containing the harm benefit analysis (HBA) for this request. + + The HBA will be visible to ASRU.`, fields: { upload: { label: 'Upload {{#model.hbaToken}}new {{/model.hbaToken}}file', diff --git a/pages/task/read/routers/confirm-hba.js b/pages/task/read/routers/confirm-hba.js index 61d65fcad..f16374626 100644 --- a/pages/task/read/routers/confirm-hba.js +++ b/pages/task/read/routers/confirm-hba.js @@ -5,6 +5,21 @@ const { get } = require('lodash'); module.exports = (config) => { const app = Router({ mergeParams: true }); + function confirmHbaSchema(taskType) { + let actionMessage = ''; + switch (taskType) { + case 'grant': + actionMessage = 'Confirm and continue to grant licence'; + break; + case 'transfer': + actionMessage = 'Confirm and continue to approve transfer'; + break; + case 'amendment': + actionMessage = 'Confirm and continue to amend licence'; + break; + } + return actionMessage; + } app.get('/', async (req, res, next) => { const { hbaToken, hbaFilename } = req.task.data.meta; @@ -26,9 +41,18 @@ module.exports = (config) => { console.error('No HBA detected, redirecting back to task page'); return res.redirect(req.buildRoute('task.read')); } + + // content overiden for radio buttons. + schema.confirmHba.options.forEach(option => { + if (option.value === 'yes') { + option.label = confirmHbaSchema(req.task.type); + } + }); + next(); }); + // this middleware is used to create radio buttons... app.use( form({ schema, diff --git a/pages/task/read/routers/confirm.js b/pages/task/read/routers/confirm.js index d21a90072..0b1236542 100644 --- a/pages/task/read/routers/confirm.js +++ b/pages/task/read/routers/confirm.js @@ -29,7 +29,7 @@ module.exports = (config) => { const values = get(req, `session.form[${req.task.id}].values`, {}); const status = values.status; - if (model === 'project' && action === 'grant' && status === 'resolved') { + if (model === 'project' && ['grant', 'transfer', 'update'].includes(action) && status === 'resolved') { const { hbaToken, hbaFilename } = req.task.data.meta; if (!hbaToken) { @@ -80,7 +80,7 @@ module.exports = (config) => { set(res.locals.static, 'inspector', req.user.profile); set( res.locals.static, - 'content.status.intention-to-refuse.action', + 'content.status.intention-to-refuse.action.default', 'Give reason for refusal' ); } diff --git a/pages/task/read/routers/read.js b/pages/task/read/routers/read.js index e16a2d0c3..92850b106 100644 --- a/pages/task/read/routers/read.js +++ b/pages/task/read/routers/read.js @@ -495,7 +495,7 @@ module.exports = () => { const { status } = req.form.values; - if (model === 'project' && action === 'grant' && status === 'resolved') { + if (model === 'project' && ['grant', 'transfer', 'update'].includes(action) && status === 'resolved') { return res.redirect(req.buildRoute('task.read.uploadHba')); } diff --git a/pages/task/read/views/adjusted-wording.js b/pages/task/read/views/adjusted-wording.js index 8c77502ba..d9fb615f3 100644 --- a/pages/task/read/views/adjusted-wording.js +++ b/pages/task/read/views/adjusted-wording.js @@ -3,11 +3,11 @@ const getActionAdjustedWording = (action, type) => { }; const getTypeAdjustedWording = (action, type) => { - return isAmendment(action, type) ? 'amendment' : 'application'; + return isAmendment(action, type) ? 'amendment' : 'transfer'; }; const isAmendment = (action, type) => { - return action === 'grant' && type === 'amendment'; + return ['update', 'grant'].includes(action) && type === 'amendment'; }; module.exports = { diff --git a/pages/task/read/views/components/activity-log.jsx b/pages/task/read/views/components/activity-log.jsx index 578e718bd..bfa9d4c17 100644 --- a/pages/task/read/views/components/activity-log.jsx +++ b/pages/task/read/views/components/activity-log.jsx @@ -315,7 +315,7 @@ function Comment({ changedBy, comment }) { comment && (
{`${changedBy.firstName} ${changedBy.lastName} remarked:`}
+{`${changedBy.firstName} ${changedBy.lastName} commented:`}
)}
-
-
- {establishment.name}
-
+
+
+ {establishment.name}
+
+
+
+ {proposedEstablishmentName.name}
+
+
+
+ {establishment.name}
+
+
+
+ {task.data.profile.name}
+
+
+
+ {licenceHolder.name}
+
+
+
+ {task.data.profile.name}
+
-
-
- {licenceHolder.name}
-
-
diff --git a/pages/task/schema/view.js b/pages/task/schema/view.js index d29aea990..9de32c61b 100644 --- a/pages/task/schema/view.js +++ b/pages/task/schema/view.js @@ -11,8 +11,23 @@ module.exports = task => { .filter(step => step.id !== 'recovered') // don't display recovered as an option (has separate UI) .map(option => { const label = option.id === 'resubmitted' && model === 'role' - ? get(content, `status.${option.id}.action.role-${task.type}`, get(content, `status.${option.id}.action`)) - : get(content, `status.${option.id}.action.${task.type}`, get(content, `status.${option.id}.action`)); + ? get( + content, + `status.${option.id}.action.role-${task.type}`, + get( + content, + `status.${option.id}.action.default`, + get(content, `status.${option.id}.action`) + )) + : get( + content, + `status.${option.id}.action.${task.type}`, + get( + content, + `status.${option.id}.action.default`, + get(content, `status.${option.id}.action`) + ) + ); const hint = option.id === 'resubmitted' && model === 'pil' && action === 'update-conditions' ? get(content, `status.${option.id}.hint.updateConditions`, get(content, `status.${option.id}.hint.default`)) diff --git a/test/unit/pages/task/read/views/upload-hba.spec.jsx b/test/unit/pages/task/read/views/upload-hba.spec.jsx index c5aa6d5cf..06cd75efa 100644 --- a/test/unit/pages/task/read/views/upload-hba.spec.jsx +++ b/test/unit/pages/task/read/views/upload-hba.spec.jsx @@ -5,7 +5,7 @@ import {Snippet} from '@ukhomeoffice/asl-components/src/snippet'; describe('HBA Upload intro', () => { const content = { - intro: `To {{action}} this licence you must upload the PPL assessment form containing the harm benefit analysis (HBA) for this {{type}}. + intro: `To {{action}} the licence you must upload the PPL assessment form containing the harm benefit analysis (HBA) for this {{type}}. The HBA will be visible to ASRU only.` }; @@ -20,7 +20,7 @@ describe('HBA Upload intro', () => { const paragraphs = wrapper.find('p'); expect(paragraphs.length).toEqual(2); expect(paragraphs[0].children[0].data).toEqual( - 'To amend this licence you must upload the PPL assessment form containing the harm benefit analysis (HBA) for this amendment.'); + 'To amend the licence you must upload the PPL assessment form containing the harm benefit analysis (HBA) for this amendment.'); expect(paragraphs[1].children[0].data).toEqual( 'The HBA will be visible to ASRU only.'); }); @@ -35,7 +35,22 @@ describe('HBA Upload intro', () => { const paragraphs = wrapper.find('p'); expect(paragraphs.length).toEqual(2); expect(paragraphs[0].children[0].data).toEqual( - 'To grant this licence you must upload the PPL assessment form containing the harm benefit analysis (HBA) for this application.'); + 'To grant the licence you must upload the PPL assessment form containing the harm benefit analysis (HBA) for this application.'); + expect(paragraphs[1].children[0].data).toEqual( + 'The HBA will be visible to ASRU only.'); + }); + + test('Mustache framework append Transfer into content', () => { + const wrapper = render( +