Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trial squash 259 #657

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .snyk
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,10 @@ ignore:
expires: 2024-07-16T00:00:00.000Z
created: 2024-04-16T11:0522.224Z

patch: {}
SNYK-JS-BRACES-6838727:
- '*':
reason: No upgrade or patch available yet
expires: 2024-08-13T00:00:00.000Z
created: 2024-05-13T11:0522.224Z

patch: {}
2 changes: 2 additions & 0 deletions acceptance-test/test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ module.exports = {
HOW_WERE_THEY_TREATED: '#how-they-were-treated',
WHY_THEY_STAYED: '#why-they-stayed',
WHY_DID_THEY_LEAVE: '#how-why-did-they-leave-the-situation',
WHEN_LAST_CONTACT_LAST_WEEK: '#when-last-contact-last-week',
DETAILS_LAST_CONTACT: '#details-last-contact',
FIRST_CHANCE_TO_REPORT_NO: '#is-this-the-first-chance-to-report-no',
WHY_REPORT_NOW: '#why-report-now',
WHY_ARE_YOU_MAKING_REFERRAL: '#why-are-you-making-the-referral',
Expand Down
6 changes: 6 additions & 0 deletions acceptance-test/user-pathways/happy-path/happy-path.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
START_REPORT,
CONTINUE_BUTTON,
DOWNLOAD_REPORT,
DETAILS_LAST_CONTACT,
REFERENCE_INPUT,
ORGANISATION_INPUT,
EMAIL_INPUT,
Expand Down Expand Up @@ -43,6 +44,7 @@ const {
CURRENT_PV_LOCATION_UK_CITY,
CURRENT_PV_LOCATION_UK_REGION,
WHO_EXPLOITED_PV,
WHEN_LAST_CONTACT_LAST_WEEK,
ANY_OTHER_PVS_NO_OPTION,
PV_HAS_CRIME_REFERENCE_NUMBER_NO_OPTION,
REFER_CASE_TO_NRM_YES_OPTION,
Expand Down Expand Up @@ -211,6 +213,10 @@ describe.only('User path(s)', () => {
await clickSelector(page, CONTINUE_BUTTON);
await focusThenType(page, WHY_DID_THEY_LEAVE, 'Test input of why they left');
await clickSelector(page, CONTINUE_BUTTON);
await clickSelector(page, WHEN_LAST_CONTACT_LAST_WEEK);
await clickSelector(page, CONTINUE_BUTTON);
await focusThenType(page, DETAILS_LAST_CONTACT, 'Test input of details last contact');
await clickSelector(page, CONTINUE_BUTTON);
await clickSelector(page, FIRST_CHANCE_TO_REPORT_NO);
await clickSelector(page, CONTINUE_BUTTON);
await focusThenType(page, WHY_REPORT_NOW, 'Test input of why reporting now');
Expand Down
6 changes: 6 additions & 0 deletions apps/nrm/behaviours/format-answers.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ const formatAnswers = req => {
});
}

if (req.sessionModel.get('when-last-contact')) {
data = Object.assign({}, data, {
formattedWhenLastContact: capitaliseText(removeDashesFromText(req.sessionModel.get('when-last-contact')), true)
});
}

if (req.sessionModel.get('is-this-the-first-chance-to-report')) {
data = Object.assign({}, data, {
formattedIsThisTheFirstChanceToReport: removeDashesFromText(capitaliseText(
Expand Down
26 changes: 26 additions & 0 deletions apps/nrm/fields/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,32 @@ module.exports = {
}
]
},
'when-last-contact': {
mixin: 'radio-group',
validate: ['required'],
legend: {
className: 'visuallyhidden'
},
options: [
'last-week',
'last-month',
'last-3-months',
'last-6-months',
'year-ago',
'Not-sure'
]
},
'details-last-contact': {
mixin: 'textarea',
validate: ['notUrl', { type: 'maxlength', arguments: 15000 }],
className: 'govuk-textarea',
attributes: [
{
attribute: 'rows',
value: 14
}
]
},
'is-this-the-first-chance-to-report': {
mixin: 'radio-group',
validate: ['required'],
Expand Down
20 changes: 19 additions & 1 deletion apps/nrm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,25 @@ module.exports = {
saveFormSession
],
fields: ['how-why-did-they-leave-the-situation'],
next: '/is-this-the-first-chance-to-report'
next: '/when-last-contact'
},
'/when-last-contact': {
behaviours: [
saveFormSession
],
fields: ['when-last-contact'],
forks: [{
target: '/is-this-the-first-chance-to-report',
condition: req=> req.sessionModel.get('when-last-contact') === 'Not-sure'
}],
next: '/details-last-contact',
},
'/details-last-contact': {
behaviours: [
saveFormSession
],
fields: ['details-last-contact'],
next: '/is-this-the-first-chance-to-report',
},
'/is-this-the-first-chance-to-report': {
behaviours: [
Expand Down
2 changes: 2 additions & 0 deletions apps/nrm/models/submission.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ module.exports = data => {
response.ExploitationTreatment = data['how-they-were-treated'];
response.ExploitationWhyTheyStayed = data['why-they-stayed'];
response.ExploitationReasonTheyLeft = data['how-why-did-they-leave-the-situation'];
response.PVExploitersLastContact = data['when-last-contact'];
response.DetailsLastContact = data['details-last-contact'];

const firstChangeToReport = {
yes: 'Yes',
Expand Down
28 changes: 28 additions & 0 deletions apps/nrm/translations/src/en/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,34 @@
"label": "How and why they left",
"hint": "Ask if it was their decision to leave and if anyone helped them. "
},
"when-last-contact":{
"legend": "when victim and exploiters last in contact",
"hint": "This includes in person conversations, phone calls, instant messages, emails, writing, or communicating through another person",
"options": {
"last-week": {
"label": "Within the last week"
},
"last-month": {
"label": "Within the last month"
},
"last-3-months": {
"label": "Within the last 3 months"
},
"last-6-months": {
"label": "Within the last 6 months"
},
"year-ago": {
"label": "Over a year ago"
},
"Not-sure": {
"label": "Not sure"
}
}
},
"details-last-contact": {
"label": "Details of last contact",
"hint": "You can email any files as evidence to us after you have submitted the report"
},
"is-this-the-first-chance-to-report": {
"legend": "Is this the first chance they have had to report this?",
"options": {
Expand Down
16 changes: 16 additions & 0 deletions apps/nrm/translations/src/en/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@
"how-why-did-they-leave-the-situation": {
"header": "How and why did they leave the situation?"
},
"when-last-contact": {
"header": "When were the potential victim and exploiters last in contact?"
},
"details-last-contact": {
"header" : "Last contact between the potential victim and their exploiters",
"paragraph-1" : "To assess the risk that the potential victim may be exploited or trafficked again, we need to know about any communication between them and their exploiters.",
"paragraph-2" : "You can provide information about how they communicated, what was said and who was involved.",
"paragraph-3": "Include details about any threats the exploiters have made. If applicable, describe any steps the potential victim has taken to prevent contact with their exploiters.",
"second-header": "Details of the last contact (optional)"
},
"is-this-the-first-chance-to-report": {
"header": "Is this the first chance they have had to report this?"
},
Expand Down Expand Up @@ -262,6 +272,12 @@
"how-why-did-they-leave-the-situation": {
"label": "How and why they left the situation"
},
"when-last-contact": {
"label": "Victim and exploiters last in contact?"
},
"details-last-contact": {
"label": "Details of last contact"
},
"is-this-the-first-chance-to-report": {
"label": "Is this the first chance they have had to report this?"
},
Expand Down
3 changes: 3 additions & 0 deletions apps/nrm/translations/src/en/validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
"required": "Enter how and why they left",
"maxlength": "Enter no more than 15,000 characters"
},
"when-last-contact": {
"required": "Tell us when they were last in contact"
},
"is-this-the-first-chance-to-report" : {
"required": "You must select an option"
},
Expand Down
16 changes: 16 additions & 0 deletions apps/nrm/views/details-last-contact.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{<partials-page}}
{{$page-content}}
<p class="govuk-body">{{#t}}pages.details-last-contact.paragraph-1{{/t}}</p>
<p class="govuk-body">{{#t}}pages.details-last-contact.paragraph-2{{/t}}</p>
<p class="govuk-body">{{#t}}pages.details-last-contact.paragraph-3{{/t}}</p>

<h2>Details of the last contact (optional)</h2>

{{#fields}}
{{#renderField}}{{/renderField}}
{{/fields}}


{{#input-submit}}continue{{/input-submit}} {{> partials-save-and-exit-link}}
{{/page-content}}
{{/partials-page}}
24 changes: 24 additions & 0 deletions apps/nrm/views/partials/summary-table-your-report.html
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,30 @@ <h2 class="details-header">{{#t}}pages.confirm.sections.your-report.header{{/t}}
</tr>
{{/values.is-this-the-first-chance-to-report}}

{{#values.when-last-contact}}
<tr>
<td>{{#t}}pages.confirm.fields.when-last-contact.label{{/t}}</td>
<td class="no-white-space">
<span>{{formattedWhenLastContact}}</span>
</td>
<td>
<a href="/nrm/when-last-contact/edit" class="button" aria-label="Change {{#t}}pages.confirm.fields.when-last-contact.label{{/t}}">Change</a>
</td>
</tr>
{{/values.when-last-contact}}

{{#values.details-last-contact}}
<tr>
<td>{{#t}}pages.confirm.fields.details-last-contact.label{{/t}}</td>
<td class="no-white-space">
<span>{{values.details-last-contact}}</span>
</td>
<td>
<a href="/nrm/details-last-contact/edit" class="button" aria-label="Change {{#t}}pages.confirm.fields.values.details-last-contact.legend{{/t}}">Change</a>
</td>
</tr>
{{/values.details-last-contact}}

{{#values.why-report-now}}
<tr>
<td>{{#t}}pages.confirm.fields.why-report-now.label{{/t}}</td>
Expand Down
8 changes: 8 additions & 0 deletions apps/nrm/views/when-last-contact.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{<partials-page}}
{{$page-content}}
{{#fields}}
{{#renderField}}{{/renderField}}
{{/fields}}
{{#input-submit}}continue{{/input-submit}} {{> partials-save-and-exit-link}}
{{/page-content}}
{{/partials-page}}
2 changes: 1 addition & 1 deletion assets/scss/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,4 @@ textarea {
.govuk-list--bullet {
margin-left: 15px;
padding-left: 20px;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"ms-uk-local-authorities": "^2.2.3",
"ms-uk-police-forces": "^2.0.0",
"ms-uk-regions": "^2.1.1",
"notifications-node-client": "8.0.0",
"notifications-node-client": "^8.0.0",
"pg": "^8.7.1",
"request": "^2.88.0",
"sqs-producer": "^1.6.3",
Expand Down
22 changes: 21 additions & 1 deletion test/_ui-integration/nrm/application.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,29 @@ describe('the journey of a nrm application', () => {
const response = await passStep(URI, {
'how-why-did-they-leave-the-situation': 'Test'
});
expect(response.text).to.contain('Found. Redirecting to /nrm/is-this-the-first-chance-to-report');
expect(response.text).to.contain('Found. Redirecting to /nrm/when-last-contact');
});

it('goes to the when-last-contact page when user enters how and why the last contact was',
async () => {
const URI = '/when-last-contact';
await initSession(URI);
const response = await passStep(URI, {
'when-last-contact': 'last-week'
});
expect(response.text).to.contain('Found. Redirecting to /nrm/details-last-contact');
});

it('goes to the is-this-the-first-chance-to-report page when user enters optional details of last contact',
async () => {
const URI = '/details-last-contact';
await initSession(URI);
const response = await passStep(URI, {
'details-last-contact': 'optional text'
});
expect(response.text).to.contain('Found. Redirecting to /nrm/is-this-the-first-chance-to-report');
});

it('goes to the is-this-the-first-chance-to-report page when user enters Is this the first chance they have ' +
'had to report this?', async () => {
const URI = '/is-this-the-first-chance-to-report';
Expand Down
22 changes: 21 additions & 1 deletion test/_ui-integration/nrm/automatic-referral-application.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,29 @@ describe('the journey of a nrm automatic referral application', () => {
const response = await passStep(URI, {
'how-why-did-they-leave-the-situation': 'Test'
});
expect(response.text).to.contain('Found. Redirecting to /nrm/is-this-the-first-chance-to-report');
expect(response.text).to.contain('Found. Redirecting to /nrm/when-last-contact');
});

it('goes to the when-last-contact page when user enters how and why the last contact was',
async () => {
const URI = '/when-last-contact';
await initSession(URI);
const response = await passStep(URI, {
'when-last-contact': 'last-week'
});
expect(response.text).to.contain('Found. Redirecting to /nrm/details-last-contact');
});

it('goes to the is-this-the-first-chance-to-report page when user enters optional details of last contact',
async () => {
const URI = '/details-last-contact';
await initSession(URI);
const response = await passStep(URI, {
'details-last-contact': 'optional text'
});
expect(response.text).to.contain('Found. Redirecting to /nrm/is-this-the-first-chance-to-report');
});

it('goes to the is-this-the-first-chance-to-report page when user enters Is this the first chance they have ' +
'had to report this?', async () => {
const URI = '/is-this-the-first-chance-to-report';
Expand Down
15 changes: 15 additions & 0 deletions test/_ui-integration/nrm/validations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,21 @@ describe('validation checks of the nrm journey', () => {
});
});

describe('First Responder exploiters last in contact Validation', () => {
it('does not pass the when-last-contact page if nothing entered', async () => {
const URI = '/when-last-contact';
await initSession(URI);
await passStep(URI, {});
const res = await getUrl(URI);
const docu = await parseHtml(res);
const validationSummary = docu.find('.validation-summary');

expect(validationSummary.length === 1).to.be.true;
expect(validationSummary.html())
.to.match(/Tell us when they were last in contact/);
});
});

describe('User enters is this the first chance to report Validation', () => {
it('does not pass is this the first chance to report page if nothing entered', async () => {
const URI = '/is-this-the-first-chance-to-report';
Expand Down
2 changes: 2 additions & 0 deletions test/helpers/supertest_session/session-data/nrm/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ module.exports = [
'/were-they-taken-somewhere-by-their-exploiter',
'/how-they-were-treated',
'/how-why-did-they-leave-the-situation',
'/when-last-contact',
'/details-last-contact',
'/is-this-the-first-chance-to-report',
'/why-report-now',
'/why-are-you-making-the-referral',
Expand Down