From 34ebc8edc2b2efb3f17c20cf8aa5fe1e766143bf Mon Sep 17 00:00:00 2001 From: Sarah-Jane Luff Date: Wed, 24 May 2023 12:09:54 +0100 Subject: [PATCH 01/14] BRP-5: Re-route duplicate application requests to separate email address. * behaviours/email.js changed to include setSubmissionReference and addSubmissionReference functions to check if report has previously been submitted. * models/email.js updated to include isResubmission property. * email/index.js updated to include switch statement to change between the two mail boxes. * behaviours/email.spec.js and models/email.spec.js updated for unit tests to support the new logic. --- apps/common/behaviours/email.js | 49 +++++++++++--- apps/common/models/email.js | 1 + services/email/index.js | 5 +- .../apps/common/behaviours/email.spec.js | 65 ++++++++++++++++++- test/_unit/apps/common/models/email.spec.js | 7 +- 5 files changed, 113 insertions(+), 14 deletions(-) diff --git a/apps/common/behaviours/email.js b/apps/common/behaviours/email.js index 0f042aba..29ef8e58 100644 --- a/apps/common/behaviours/email.js +++ b/apps/common/behaviours/email.js @@ -6,12 +6,43 @@ const StatsD = require('hot-shots'); const client = new StatsD(); const Model = require('../models/email'); +const {customAlphabet} = require('nanoid'); +const alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; +const nanoid = customAlphabet(alphabet, 9); + function errorChecked(key, data) { if (data[key + '-checkbox']) { return key; } } +function setSubmissionReference(data) { + // This function is responsible for storing a submission referene if one is required + + // Did the user say this is a resubmission? + if (data['previous-submission'] === 'yes') { + // Yes they did - Mark this as a resubmission for easier assessment when sending the email to caseworkers + data['is-resubmission'] = true; + // Did the user provide a reference for their previous submission? + // If they did, we should keep it the same + // If they did not, we should not populate the reference in + // the emails that are sent out so ensure this remains undefined + data['submission-reference'] = (data['submission-reference'] ? data['submission-reference'] : undefined); + } else { + data['is-resubmission'] = false; + // It's a new submission so generate a reference + data['submission-reference'] = nanoid(); + } +} + +function addSubmissionReference(data) { + // If we do not already have a submission reference, create one and store it in our data object + // We may want to re-use this later + setSubmissionReference(data); + // Ensure there's a space in front of it, since this is being appended to the end of the email subject + return !!data['submission-reference'] ? ` Ref: ${data['submission-reference']}` : ''; +} + function checkedErrors(data) { const checked = _.filter(_.keys(data), valueKey => { return errorChecked(valueKey, data); @@ -20,10 +51,10 @@ function checkedErrors(data) { } const serviceMap = { - '/not-arrived': () => { + '/not-arrived': data => { return { template: 'delivery', - subject: 'Form submitted: Your BRP hasn\'t arrived.' + subject: `Form submitted: Your BRP hasn\'t arrived.${addSubmissionReference(data)}` }; }, '/correct-mistakes': data => { @@ -34,26 +65,26 @@ const serviceMap = { const suffix = data.triage ? '-triage' : ''; return { template: 'error' + suffix, - subject: 'Form submitted: Report a problem with your new BRP (' + subjectErrors + ')' + subject: `Form submitted: Report a problem with your new BRP (${subjectErrors}).${addSubmissionReference(data)}` }; }, '/lost-stolen': data => { const suffix = (data['inside-uk'] === 'yes') ? '-uk' : '-abroad'; return { template: 'lost-or-stolen' + suffix, - subject: 'Form submitted: Report a lost or stolen BRP.' + subject: `Form submitted: Report a lost or stolen BRP.${addSubmissionReference(data)}` }; }, - '/collection': () => { + '/collection': data => { return { template: 'collection', - subject: 'Form submitted: Report a collection problem.' + subject: `Form submitted: Report a collection problem.${addSubmissionReference(data)}` }; }, - '/someone-else': () => { + '/someone-else': data => { return { template: 'someone-else', - subject: 'Form submitted: Report someone else collecting your BRP.' + subject: `Form submitted: Report someone else collecting your BRP.${addSubmissionReference(data)}` }; } }; @@ -62,6 +93,8 @@ module.exports = superclass => class Emailer extends superclass { saveValues(req, res, callback) { super.saveValues(req, res, () => { const data = _.pick(req.sessionModel.toJSON(), _.identity); + + // Generate a reference for this submission const service = serviceMap[req.baseUrl] && serviceMap[req.baseUrl](data); if (!service) { diff --git a/apps/common/models/email.js b/apps/common/models/email.js index 913051ea..d7911ff5 100644 --- a/apps/common/models/email.js +++ b/apps/common/models/email.js @@ -11,6 +11,7 @@ module.exports = class Email extends Model { template: this.get('template'), to: this.get('email'), subject: this.get('subject'), + isResubmission: this.get('is-resubmission'), dataToSend: _.omit(this.toJSON(), ['steps', 'csrf-secret', 'template']) }, callback); } diff --git a/services/email/index.js b/services/email/index.js index 85b5419b..1f2e13f2 100644 --- a/services/email/index.js +++ b/services/email/index.js @@ -117,7 +117,10 @@ function Emailer() { } Emailer.prototype.getEmailRecipient = email => { - let recipientEmailAddress = config.email.caseworker[email.template]; + // If it's a resubmission, we shouold be sending them through to the new duplicate inbox + // Else we continue to send to the original caseworker inbox + let recipientEmailAddress = email.isResubmission ? + config.email.caseworker.duplicate : config.email.caseworker[email.template]; // As per BRP-111 we should also send a copy to our integrations inbox // This should only be done in UAT/Staging // Since this email address is only configured in diff --git a/test/_unit/apps/common/behaviours/email.spec.js b/test/_unit/apps/common/behaviours/email.spec.js index 4bec8517..517c3126 100644 --- a/test/_unit/apps/common/behaviours/email.spec.js +++ b/test/_unit/apps/common/behaviours/email.spec.js @@ -23,7 +23,10 @@ describe('apps/common/controllers/confirm', () => { set: setStub, save: saveStub.yieldsAsync() }), - 'hot-shots': sinon.stub().returns({ increment: sinon.stub() }) + 'hot-shots': sinon.stub().returns({ increment: sinon.stub() }), + nanoid: { + customAlphabet: sinon.stub().returns(function () { return 'fpgyxSgw7'; }) + } }); req = reqres.req({ @@ -42,7 +45,9 @@ describe('apps/common/controllers/confirm', () => { req.baseUrl = '/collection'; controller.saveValues(req, res, err => { expect(err).not.to.be.ok; - constructorStub.should.have.been.calledWith({ foo: 'bar' }); + constructorStub.should.have.been.calledWith( + { foo: 'bar', 'is-resubmission': false, 'submission-reference': 'fpgyxSgw7' } + ); saveStub.should.have.been.called; }); }); @@ -106,7 +111,7 @@ describe('apps/common/controllers/confirm', () => { controller.saveValues(req, res, err => { expect(err).not.to.be.ok; setStub.should.have.been.calledWith('subject', - 'Form submitted: Report a problem with your new BRP (test-error)'); + 'Form submitted: Report a problem with your new BRP (test-error). Ref: fpgyxSgw7'); }); }); @@ -117,5 +122,59 @@ describe('apps/common/controllers/confirm', () => { err.message.should.equal('no service found'); }); }); + + it('correctly marks an email as a resubmission with the correct reference ' + + 'in the email subject when a reference is supplied', () => { + req.baseUrl = '/collection'; + req.sessionModel.set('previous-submission', 'yes'); + req.sessionModel.set('submission-reference', '123456'); + + controller.saveValues(req, res, err => { + setStub.should.have.been.calledWith('subject', + 'Form submitted: Report a collection problem. Ref: 123456'); + constructorStub.should.have.been.calledWith({ + foo: 'bar', + 'previous-submission': 'yes', + 'submission-reference': '123456', + 'is-resubmission': true + }); + expect(err).not.to.be.ok; + }); + }); + + it('correctly marks an email as a resubmission but does not include a reference number in' + + 'the email subject when a previous reference is not supplied', () => { + req.baseUrl = '/collection'; + req.sessionModel.set('previous-submission', 'yes'); + + controller.saveValues(req, res, err => { + setStub.should.have.been.calledWith('subject', + 'Form submitted: Report a collection problem.'); + constructorStub.should.have.been.calledWith({ + foo: 'bar', + 'previous-submission': 'yes', + 'is-resubmission': true, + 'submission-reference': undefined + }); + expect(err).not.to.be.ok; + }); + }); + + it('correctly marks an email as a not a resubmission with a new random reference in the email subject', () => { + req.baseUrl = '/collection'; + req.sessionModel.set('previous-submission', 'no'); + + controller.saveValues(req, res, err => { + setStub.should.have.been.calledWith('subject', + 'Form submitted: Report a collection problem. Ref: fpgyxSgw7'); + constructorStub.should.have.been.calledWith({ + foo: 'bar', + 'previous-submission': 'no', + 'is-resubmission': false, + 'submission-reference': 'fpgyxSgw7' + }); + expect(err).not.to.be.ok; + }); + }); }); }); diff --git a/test/_unit/apps/common/models/email.spec.js b/test/_unit/apps/common/models/email.spec.js index 7e23c4d1..98452adb 100644 --- a/test/_unit/apps/common/models/email.spec.js +++ b/test/_unit/apps/common/models/email.spec.js @@ -16,7 +16,8 @@ describe('apps/common/models/email', () => { email: 'email@email.com', subject: 'email subject', name: 'dave', - other: 'data' + other: 'data', + 'is-resubmission': false }); }); @@ -30,11 +31,13 @@ describe('apps/common/models/email', () => { template: 'test_template', to: 'email@email.com', subject: 'email subject', + isResubmission: false, dataToSend: { email: 'email@email.com', name: 'dave', other: 'data', - subject: 'email subject' + subject: 'email subject', + 'is-resubmission': false } }); }); From 4ac026d7d7aa5e215581d42dc6f25f472a080254 Mon Sep 17 00:00:00 2001 From: Sarah-Jane Luff Date: Wed, 24 May 2023 13:39:54 +0100 Subject: [PATCH 02/14] BRP-5: Nanoid version 4.0.2 added to package.json --- package.json | 3 ++- yarn.lock | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 84ffe50e..e13deef7 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "nodemailer": "^6.4.16", "typeahead-aria": "^1.0.1", "underscore": "^1.12.1", - "winston": "^3.3.0" + "winston": "^3.3.0", + "nanoid": "^4.0.2" }, "devDependencies": { "@cucumber/cucumber": "^7.3.0", diff --git a/yarn.lock b/yarn.lock index 81c554d3..9a476a1d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3949,6 +3949,11 @@ nanoid@3.3.1: resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== +nanoid@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-4.0.2.tgz#140b3c5003959adbebf521c170f282c5e7f9fb9e" + integrity sha512-7ZtY5KTCNheRGfEFxnedV5zFiORN1+Y1N6zvPTnHQd8ENUvfaDBeuJDZb2bN/oXwXxu3qkTXDzy57W5vAmDTBw== + natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" From f5a366c102aa76c099e40a993a18c2b80d73ea8d Mon Sep 17 00:00:00 2001 From: Sarah-Jane Luff Date: Wed, 24 May 2023 14:03:06 +0100 Subject: [PATCH 03/14] test nanoid --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index e13deef7..873b5658 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "typeahead-aria": "^1.0.1", "underscore": "^1.12.1", "winston": "^3.3.0", - "nanoid": "^4.0.2" + "nanoid": "3.3.4" }, "devDependencies": { "@cucumber/cucumber": "^7.3.0", diff --git a/yarn.lock b/yarn.lock index 9a476a1d..cf4a74dc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3949,10 +3949,10 @@ nanoid@3.3.1: resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== -nanoid@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-4.0.2.tgz#140b3c5003959adbebf521c170f282c5e7f9fb9e" - integrity sha512-7ZtY5KTCNheRGfEFxnedV5zFiORN1+Y1N6zvPTnHQd8ENUvfaDBeuJDZb2bN/oXwXxu3qkTXDzy57W5vAmDTBw== +nanoid@3.3.4: + version "3.3.4" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab" + integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw== natural-compare@^1.4.0: version "1.4.0" From 63bdbc8023f5514f7d3f3d8b3e2e2ec9b753822e Mon Sep 17 00:00:00 2001 From: Sarah-Jane Luff Date: Thu, 1 Jun 2023 10:51:49 +0100 Subject: [PATCH 04/14] sonar scanner updated --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 20047090..c85f9daa 100644 --- a/.drone.yml +++ b/.drone.yml @@ -41,7 +41,7 @@ unit_tests: &unit_tests sonar_scanner: &sonar_scanner pull: if-not-exists - image: quay.io/ukhomeofficedigital/sonar-scanner-node:549b75f593f28da1c4a0a6f79877ec69d3b21037 + image: quay.io/ukhomeofficedigital/sonar-scanner-nodejs:latest commands: - sonar-scanner -Dproject.settings=./sonar-project.properties From 410f93638cd8f87212ec819ad28dfd26e11339fa Mon Sep 17 00:00:00 2001 From: Sarah-Jane Luff Date: Thu, 1 Jun 2023 11:29:44 +0100 Subject: [PATCH 05/14] BRP-5: Reroute duplicate requests * TBC --- apps/collection/index.js | 8 ++ .../collection/views/previous-submission.html | 20 +++++ apps/common/fields/index.js | 1 + apps/common/fields/previous-submission.js | 25 ++++++ apps/common/translations/src/en/fields.json | 15 ++++ apps/common/translations/src/en/pages.json | 5 ++ .../translations/src/en/validation.json | 6 ++ apps/correct-mistakes/index.js | 8 ++ .../views/previous-submission.html | 20 +++++ apps/lost-stolen/index.js | 8 ++ .../views/previous-submission.html | 20 +++++ apps/not-arrived/index.js | 10 ++- .../views/previous-submission.html | 20 +++++ apps/someone-else/index.js | 8 ++ .../views/previous-submission.html | 20 +++++ config.js | 3 +- services/email/index.js | 4 +- test/_features/brp/collection_form.feature | 26 +++++- test/_features/brp/correct_mistakes.feature | 21 +++++ test/_features/brp/lost_stolen.feature | 79 +++++++++++-------- test/_features/brp/not_arrived.feature | 25 +++++- test/_features/brp/someone_else.feature | 20 ++++- 22 files changed, 333 insertions(+), 39 deletions(-) create mode 100644 apps/collection/views/previous-submission.html create mode 100644 apps/common/fields/previous-submission.js create mode 100644 apps/common/translations/src/en/pages.json create mode 100644 apps/correct-mistakes/views/previous-submission.html create mode 100644 apps/lost-stolen/views/previous-submission.html create mode 100644 apps/not-arrived/views/previous-submission.html create mode 100644 apps/someone-else/views/previous-submission.html diff --git a/apps/collection/index.js b/apps/collection/index.js index 320f2869..293873c2 100644 --- a/apps/collection/index.js +++ b/apps/collection/index.js @@ -10,11 +10,19 @@ module.exports = { baseUrl: '/collection', params: '/:action?', steps: { + '/previous-submission': { + fields: [ + 'previous-submission', + 'submission-reference' + ], + next: '/where' + }, '/where': { fields: [ 'collection-where-radio', 'collection-date' ], + backLink: 'previous-submission', next: '/reasons' }, '/reasons': { diff --git a/apps/collection/views/previous-submission.html b/apps/collection/views/previous-submission.html new file mode 100644 index 00000000..732288ee --- /dev/null +++ b/apps/collection/views/previous-submission.html @@ -0,0 +1,20 @@ +{{ +
+ {{#input-text}}submission-reference{{/input-text}} +
+ + + {{#input-submit}}continue{{/input-submit}} + {{/form}} + {{/partials-form}} + {{/content}} +{{/partials-page}} diff --git a/apps/common/fields/index.js b/apps/common/fields/index.js index ed8eb63d..86d8b8dc 100644 --- a/apps/common/fields/index.js +++ b/apps/common/fields/index.js @@ -3,5 +3,6 @@ module.exports = Object.assign({}, require('./contact-details'), require('./personal-details'), + require('./previous-submission'), require('./organisation-details') ); diff --git a/apps/common/fields/previous-submission.js b/apps/common/fields/previous-submission.js new file mode 100644 index 00000000..8ffbcd42 --- /dev/null +++ b/apps/common/fields/previous-submission.js @@ -0,0 +1,25 @@ +'use-strict'; + +module.exports = { + 'previous-submission': { + mixin: 'radio-group', + validate: ['required'], + className: ['inline', 'form-group'], + legend: { + className: 'visuallyhidden' + }, + options: [{ + value: 'yes', + toggle: 'previous-submission-reference-group' + }, { + value: 'no' + }] + }, + 'submission-reference': { + validate: [ {type: 'regex', arguments: /^[A-Za-z0-9]{9}$|(^$)+/g }], + dependent: { + field: 'previous-submission', + value: 'yes' + } + } +}; diff --git a/apps/common/translations/src/en/fields.json b/apps/common/translations/src/en/fields.json index 9f0506bb..36c34572 100644 --- a/apps/common/translations/src/en/fields.json +++ b/apps/common/translations/src/en/fields.json @@ -52,5 +52,20 @@ "label": "Support organisation" } } + }, + "previous-submission": { + "label": "Have you previously submitted this request?", + "options": { + "yes": { + "label": "Yes" + }, + "no": { + "label": "No" + } + } + }, + "submission-reference": { + "label": "What is the reference for this request?", + "hint": "For example ZxeJ8vfBI" } } diff --git a/apps/common/translations/src/en/pages.json b/apps/common/translations/src/en/pages.json new file mode 100644 index 00000000..b52e579b --- /dev/null +++ b/apps/common/translations/src/en/pages.json @@ -0,0 +1,5 @@ +{ + "previous-submission": { + "header": "Have you previously submitted this request?" + } +} diff --git a/apps/common/translations/src/en/validation.json b/apps/common/translations/src/en/validation.json index 691d27ba..f445cb38 100644 --- a/apps/common/translations/src/en/validation.json +++ b/apps/common/translations/src/en/validation.json @@ -43,5 +43,11 @@ "fullname": { "required": "Enter your full name", "notUrl": "Full name must not be a URL" + }, + "previous-submission": { + "required": "Have you previously submitted this request?" + }, + "submission-reference": { + "regex": "Please enter a 9 digit reference code" } } diff --git a/apps/correct-mistakes/index.js b/apps/correct-mistakes/index.js index e0e06696..ed0245bd 100644 --- a/apps/correct-mistakes/index.js +++ b/apps/correct-mistakes/index.js @@ -6,11 +6,19 @@ module.exports = { params: '/:action?', behaviours: [require('../common/behaviours/location')], steps: { + '/previous-submission': { + fields: [ + 'previous-submission', + 'submission-reference' + ], + next: '/location' + }, '/location': { template: 'location-applied', fields: [ 'location-applied' ], + backLink: 'previous-submission', next: '/about-error' }, '/about-error': { diff --git a/apps/correct-mistakes/views/previous-submission.html b/apps/correct-mistakes/views/previous-submission.html new file mode 100644 index 00000000..aa448b93 --- /dev/null +++ b/apps/correct-mistakes/views/previous-submission.html @@ -0,0 +1,20 @@ +{{ +
+ {{#input-text}}submission-reference{{/input-text}} +
+ + + {{#input-submit}}continue{{/input-submit}} + {{/form}} + {{/partials-form}} + {{/content}} +{{/partials-page}} diff --git a/apps/lost-stolen/index.js b/apps/lost-stolen/index.js index a2ceeb50..31f00c10 100644 --- a/apps/lost-stolen/index.js +++ b/apps/lost-stolen/index.js @@ -6,8 +6,16 @@ module.exports = { params: '/:action?', behaviours: [require('../common/behaviours/location')], steps: { + '/previous-submission': { + fields: [ + 'previous-submission', + 'submission-reference' + ], + next: '/where' + }, '/where': { fields: ['inside-uk', 'country'], + backLink: 'previous-submission', next: '/date-lost' }, '/date-lost': { diff --git a/apps/lost-stolen/views/previous-submission.html b/apps/lost-stolen/views/previous-submission.html new file mode 100644 index 00000000..86dbea64 --- /dev/null +++ b/apps/lost-stolen/views/previous-submission.html @@ -0,0 +1,20 @@ +{{ +
+ {{#input-text}}submission-reference{{/input-text}} +
+ + + {{#input-submit}}continue{{/input-submit}} + {{/form}} + {{/partials-form}} + {{/content}} +{{/partials-page}} diff --git a/apps/not-arrived/index.js b/apps/not-arrived/index.js index f9ae7884..88bfba0b 100644 --- a/apps/not-arrived/index.js +++ b/apps/not-arrived/index.js @@ -5,7 +5,15 @@ module.exports = { baseUrl: '/not-arrived', params: '/:action?', steps: { + '/previous-submission': { + fields: [ + 'previous-submission', + 'submission-reference' + ], + next: '/post-office-collect' + }, '/post-office-collect': { + backLink: 'previous-submission', next: '/consignment-number', behaviours: [require('./behaviours/change-path')], template: 'collection.html', @@ -90,7 +98,7 @@ module.exports = { next: '/confirm' }, '/confirm': { - behaviours: [ require('../common/behaviours/email')], + behaviours: ['complete', require('../common/behaviours/email')], fields: [ 'org-help', 'rep-name', diff --git a/apps/not-arrived/views/previous-submission.html b/apps/not-arrived/views/previous-submission.html new file mode 100644 index 00000000..330ab2cd --- /dev/null +++ b/apps/not-arrived/views/previous-submission.html @@ -0,0 +1,20 @@ +{{ +
+ {{#input-text}}submission-reference{{/input-text}} +
+ + + {{#input-submit}}continue{{/input-submit}} + {{/form}} + {{/partials-form}} + {{/content}} +{{/partials-page}} diff --git a/apps/someone-else/index.js b/apps/someone-else/index.js index 57603ea6..d4b0774c 100644 --- a/apps/someone-else/index.js +++ b/apps/someone-else/index.js @@ -5,6 +5,13 @@ module.exports = { baseUrl: '/someone-else', params: '/:action?', steps: { + '/previous-submission': { + fields: [ + 'previous-submission', + 'submission-reference' + ], + next: '/arrange' + }, '/arrange': { behaviours: [require('./behaviours/someone-else-brp')], fields: [ @@ -14,6 +21,7 @@ module.exports = { 'someone-else-id-type', 'someone-else-id-number' ], + backLink: 'previous-submission', next: '/reason' }, '/reason': { diff --git a/apps/someone-else/views/previous-submission.html b/apps/someone-else/views/previous-submission.html new file mode 100644 index 00000000..e97be0d3 --- /dev/null +++ b/apps/someone-else/views/previous-submission.html @@ -0,0 +1,20 @@ +{{ +
+ {{#input-text}}submission-reference{{/input-text}} +
+ + + {{#input-submit}}continue{{/input-submit}} + {{/form}} + {{/partials-form}} + {{/content}} +{{/partials-page}} diff --git a/config.js b/config.js index e09e4302..36ea5eba 100644 --- a/config.js +++ b/config.js @@ -23,7 +23,8 @@ module.exports = { 'lost-or-stolen-abroad': process.env.CASEWORKER_LOSTSTOLEN_EMAIL || 'caseworker_email_address@test.com', delivery: process.env.CASEWORKER_DELIVERY_EMAIL || 'caseworker_email_address@test.com', collection: process.env.CASEWORKER_COLLECTION_EMAIL || 'caseworker_email_address@test.com', - 'someone-else': process.env.CASEWORKER_SOMEONEELSE_EMAIL || 'someoneelse_email_address@test.com' + 'someone-else': process.env.CASEWORKER_SOMEONEELSE_EMAIL || 'someoneelse_email_address@test.com', + duplicate: process.env.CASEWORKER_DUPLICATE_EMAIL || 'caseworker_email_address@test.com' }, 'integration-email-recipient': process.env.INTEGRATION_EMAIL_RECIPIENT || '', port: process.env.EMAIL_PORT || 587, diff --git a/services/email/index.js b/services/email/index.js index 1f2e13f2..cb01d537 100644 --- a/services/email/index.js +++ b/services/email/index.js @@ -172,7 +172,7 @@ Emailer.prototype.send = function send(email, callback) { function sendCustomerEmail() { if (email.to) { - logger.info('Emailing customer: ' + email.subject); + logger.info(`Emailing customer: ${email.subject}`); this.transporter.sendMail({ from: config.email.from, replyTo: config.email.replyTo, @@ -187,7 +187,7 @@ Emailer.prototype.send = function send(email, callback) { } } - logger.info('Emailing caseworker: ' + email.subject); + logger.info(`Emailing caseworker: ${email.subject}`); this.transporter.sendMail({ from: config.email.from, to: this.getEmailRecipient(email), diff --git a/test/_features/brp/collection_form.feature b/test/_features/brp/collection_form.feature index b777e446..64a31b5d 100644 --- a/test/_features/brp/collection_form.feature +++ b/test/_features/brp/collection_form.feature @@ -4,6 +4,9 @@ Feature: A user should access the collection problem service and be able to log @unprovenIdentity Scenario: collection application to be contacted via email Given I start the 'collection' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'where' page showing 'From where were you asked to collect your BRP?' Then I check 'collection-where-radio-Sponsor' Then I fill the date 'collection-date' with '30-5-2021' @@ -26,6 +29,9 @@ Feature: A user should access the collection problem service and be able to log @unprovenIdentity Scenario: collection application to be contacted via post Given I start the 'collection' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'where' page showing 'From where were you asked to collect your BRP?' Then I check 'collection-where-radio-Post\ Office' Then I fill the date 'collection-date' with '30-5-2021' @@ -54,6 +60,9 @@ Feature: A user should access the collection problem service and be able to log @lostPassport Scenario: collection application to be contacted via post Given I start the 'collection' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'where' page showing 'From where were you asked to collect your BRP?' Then I check 'collection-where-radio-Post\ Office' Then I fill the date 'collection-date' with '30-5-2021' @@ -82,6 +91,9 @@ Feature: A user should access the collection problem service and be able to log @lostPassport Scenario: collection application to be contacted via email Given I start the 'collection' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'where' page showing 'From where were you asked to collect your BRP?' Then I check 'collection-where-radio-Sponsor' Then I fill the date 'collection-date' with '30-5-2021' @@ -104,6 +116,9 @@ Feature: A user should access the collection problem service and be able to log @noBrp Scenario: collection application to be contacted via post Given I start the 'collection' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'where' page showing 'From where were you asked to collect your BRP?' Then I check 'collection-where-radio-Post\ Office' Then I fill the date 'collection-date' with '30-5-2021' @@ -131,6 +146,9 @@ Feature: A user should access the collection problem service and be able to log @noBrp Scenario: collection application to be contacted via email Given I start the 'collection' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'where' page showing 'From where were you asked to collect your BRP?' Then I check 'collection-where-radio-Sponsor' Then I fill the date 'collection-date' with '30-5-2021' @@ -153,6 +171,9 @@ Feature: A user should access the collection problem service and be able to log @noBrp Scenario: collection application to be contacted via email Given I start the 'collection' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'where' page showing 'From where were you asked to collect your BRP?' Then I check 'collection-where-radio-Sponsor' Then I fill the date 'collection-date' with '30-5-2021' @@ -174,6 +195,9 @@ Feature: A user should access the collection problem service and be able to log @validation Scenario: Collection application Personal Details not a URL validation Given I start the 'collection' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'where' page showing 'From where were you asked to collect your BRP?' Then I check 'collection-where-radio-Sponsor' Then I fill the date 'collection-date' with '30-5-2021' @@ -188,4 +212,4 @@ Feature: A user should access the collection problem service and be able to log Then I fill 'passport' with 'www.google.com' Then I select 'Continue' Then I should see 'Full name must not be a URL' on the page - And I should see 'Passport Number must not be a URL' on the page \ No newline at end of file + And I should see 'Passport Number must not be a URL' on the page diff --git a/test/_features/brp/correct_mistakes.feature b/test/_features/brp/correct_mistakes.feature index e8af6702..f244c1f0 100644 --- a/test/_features/brp/correct_mistakes.feature +++ b/test/_features/brp/correct_mistakes.feature @@ -4,6 +4,9 @@ Feature: A user should access the correct mistakes service and be able to log an @in_uk Scenario: correct mistakes on brp form within the uk Given I start the 'correct-mistakes' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'location' page showing 'Where did you apply for your visa?' Then I check 'location-applied-yes' Then I select 'Continue' @@ -28,6 +31,9 @@ Feature: A user should access the correct mistakes service and be able to log an @out_uk Scenario: correct mistakes on brp form outside the uk Given I start the 'correct-mistakes' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'location' page showing 'Where did you apply for your visa?' Then I check 'location-applied-no' Then I select 'Continue' @@ -57,6 +63,9 @@ Feature: A user should access the correct mistakes service and be able to log an @validation Scenario: validation of about-error page Given I start the 'correct-mistakes' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'location' page showing 'Where did you apply for your visa?' Then I check 'location-applied-yes' Then I select 'Continue' @@ -90,6 +99,9 @@ Feature: A user should access the correct mistakes service and be able to log an @validation Scenario: BRP number validation Given I start the 'correct-mistakes' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'location' page showing 'Where did you apply for your visa?' Then I check 'location-applied-no' Then I select 'Continue' @@ -116,6 +128,9 @@ Feature: A user should access the correct mistakes service and be able to log an @validation Scenario: Correct Mistakes Personal Details not a URL validation Given I start the 'correct-mistakes' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'location' page showing 'Where did you apply for your visa?' Then I check 'location-applied-no' Then I select 'Continue' @@ -142,6 +157,9 @@ Feature: A user should access the correct mistakes service and be able to log an @validation Scenario: Correct Mistakes Representative Personal Details not a URL validation Given I start the 'correct-mistakes' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'location' page showing 'Where did you apply for your visa?' Then I check 'location-applied-yes' Then I select 'Continue' @@ -171,6 +189,9 @@ Feature: A user should access the correct mistakes service and be able to log an @validation Scenario: Correct Mistakes Family Name and Given Name(s) not a URL validation Given I start the 'correct-mistakes' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'location' page showing 'Where did you apply for your visa?' Then I check 'location-applied-yes' Then I select 'Continue' diff --git a/test/_features/brp/lost_stolen.feature b/test/_features/brp/lost_stolen.feature index 27efd09e..1ff47cb7 100644 --- a/test/_features/brp/lost_stolen.feature +++ b/test/_features/brp/lost_stolen.feature @@ -3,6 +3,9 @@ Feature: A user should be able to log a lost or stolen BRP Scenario: Lost brp in the UK Given I start the 'lost-stolen' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'where' page showing 'Where are you now?' Then I check 'inside-uk-yes' Then I select 'Continue' @@ -22,6 +25,9 @@ Feature: A user should be able to log a lost or stolen BRP Scenario: Lost brp outside the UK Given I start the 'lost-stolen' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'where' page showing 'Where are you now?' Then I check 'inside-uk-no' Then I fill 'country' with 'Bahamas' @@ -43,6 +49,9 @@ Feature: A user should be able to log a lost or stolen BRP @validation Scenario: Lost or Stolen application Personal Details not a URL validation Given I start the 'lost-stolen' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'where' page showing 'Where are you now?' Then I check 'inside-uk-no' Then I fill 'country' with 'Bahamas' @@ -57,36 +66,44 @@ Feature: A user should be able to log a lost or stolen BRP @validation Scenario: Lost or Stolen application Representative Personal Details not a URL validation - Given I start the 'lost-stolen' application journey - Then I should be on the 'where' page showing 'Where are you now?' - Then I check 'inside-uk-yes' - Then I select 'Continue' - Then I should be on the 'date-lost' page showing 'When did you realise you no longer had your BRP?' - Then I fill the date 'date-lost' with '30-05-2021' - Then I select 'Continue' - Then I should be on the 'personal-details' page showing 'What are your personal details?' - Then I fill 'fullname' with 'Ronald Testman' - Then I fill the date 'date-of-birth' with '30-05-1990' - Then I fill 'nationality' with 'Namibia' - Then I fill 'brp-card' with 'ZRX000123' - Then I select 'Continue' - Then I should be on the 'contact-details' page showing 'How should we contact you to tell you what to do next?' - Then I fill 'email' with 'test@dtest.testemail' - Then I select 'Continue' - Then I should be on the 'confirm' page showing 'Check the details you have provided' - Then I check 'org-help-yes' - Then I should see 'We will attempt to contact the BRP holder directly. We will only use these details to contact you if needed.' on the page - Then I fill 'rep-name' with 'www.google.com' - Then I submit the application - Then I should see 'Full name must not be a URL' on the page - + Given I start the 'lost-stolen' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' + Then I should be on the 'where' page showing 'Where are you now?' + Then I check 'inside-uk-yes' + Then I select 'Continue' + Then I should be on the 'date-lost' page showing 'When did you realise you no longer had your BRP?' + Then I fill the date 'date-lost' with '30-05-2021' + Then I select 'Continue' + Then I should be on the 'personal-details' page showing 'What are your personal details?' + Then I fill 'fullname' with 'Ronald Testman' + Then I fill the date 'date-of-birth' with '30-05-1990' + Then I fill 'nationality' with 'Namibia' + Then I fill 'brp-card' with 'ZRX000123' + Then I select 'Continue' + Then I should be on the 'contact-details' page showing 'How should we contact you to tell you what to do next?' + Then I fill 'email' with 'test@dtest.testemail' + Then I select 'Continue' + Then I should be on the 'confirm' page showing 'Check the details you have provided' + Then I check 'org-help-yes' + Then I should see 'We will attempt to contact the BRP holder directly. We will only use these details to contact you if needed.' on the page + Then I fill 'rep-name' with 'www.google.com' + Then I submit the application + Then I should see 'Full name must not be a URL' on the page + + @validation_error Scenario: Lost or stolen application - Preventing user from entering a date before 31st July 2015 - Given I start the 'lost-stolen' application journey - Then I should be on the 'where' page showing 'Where are you now?' - Then I check 'inside-uk-yes' - Then I select 'Continue' - Then I should be on the 'date-lost' page showing 'When did you realise you no longer had your BRP?' - Then I fill the date 'date-lost' with '30-07-2015' - Then I select 'Continue' - Then I should see the 'Enter a date from 31/07/2015' error + Given I start the 'lost-stolen' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' + Then I should be on the 'where' page showing 'Where are you now?' + Then I check 'inside-uk-yes' + Then I select 'Continue' + Then I should be on the 'date-lost' page showing 'When did you realise you no longer had your BRP?' + Then I fill the date 'date-lost' with '30-07-2015' + Then I select 'Continue' + Then I should see the 'Enter a date from 31/07/2015' error + diff --git a/test/_features/brp/not_arrived.feature b/test/_features/brp/not_arrived.feature index c26cfe01..c0da9df9 100644 --- a/test/_features/brp/not_arrived.feature +++ b/test/_features/brp/not_arrived.feature @@ -3,13 +3,19 @@ Feature: I should be able to log that my BRP has not arrived Scenario: Due to collect the document from the postcode Given I start the 'not-arrived' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'post-office-collect' page showing 'Were you due to collect your document from the Post Office?' Then I check 'collection-yes' Then I select 'Continue' - Then I should be redirected to the 'collection' journey on the 'where' page showing 'From where were you asked to collect your BRP?' + Then I should be redirected to the 'collection' journey on the 'previous-submission' page showing 'Have you previously submitted this request?' Scenario: Letter not received from the home office Given I start the 'not-arrived' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'post-office-collect' page showing 'Were you due to collect your document from the Post Office?' Then I check 'collection-no' Then I select 'Continue' @@ -23,6 +29,9 @@ Feature: I should be able to log that my BRP has not arrived Scenario: BRP resent to same address Given I start the 'not-arrived' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'post-office-collect' page showing 'Were you due to collect your document from the Post Office?' Then I check 'collection-no' Then I select 'Continue' @@ -51,6 +60,9 @@ Feature: I should be able to log that my BRP has not arrived Scenario: BRP resent to different address Given I start the 'not-arrived' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'post-office-collect' page showing 'Were you due to collect your document from the Post Office?' Then I check 'collection-no' Then I select 'Continue' @@ -88,6 +100,9 @@ Feature: I should be able to log that my BRP has not arrived @validation Scenario: Not Arrived application Personal Details not a URL validation Given I start the 'not-arrived' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'post-office-collect' page showing 'Were you due to collect your document from the Post Office?' Then I check 'collection-no' Then I select 'Continue' @@ -113,6 +128,9 @@ Feature: I should be able to log that my BRP has not arrived @validation Scenario: Not Arrived application Representative Personal Details not a URL validation Given I start the 'not-arrived' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'post-office-collect' page showing 'Were you due to collect your document from the Post Office?' Then I check 'collection-no' Then I select 'Continue' @@ -140,8 +158,11 @@ Feature: I should be able to log that my BRP has not arrived Then I should be on the 'confirm' page showing 'Check the details you have provided' @validation - Scenario: Not arrived application changing mind on letter recieved + Scenario: Not arrived application changing mind on letter received Given I start the 'not-arrived' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'post-office-collect' page showing 'Were you due to collect your document from the Post Office?' Then I check 'collection-no' Then I select 'Continue' diff --git a/test/_features/brp/someone_else.feature b/test/_features/brp/someone_else.feature index 9ee7161e..32a48f15 100644 --- a/test/_features/brp/someone_else.feature +++ b/test/_features/brp/someone_else.feature @@ -3,6 +3,9 @@ Feature: I want someone else to collect my BRP Scenario: I want someone else to collect my BRP because I have a medical condition Given I start the 'someone-else' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'arrange' page showing 'Who would you like to nominate?' Then I fill 'someone-else-fullname' with 'Donald Testman' Then I fill the date 'someone-else-date' with '24-5-1990' @@ -30,6 +33,9 @@ Feature: I want someone else to collect my BRP Scenario: I need someone else to collect my BRP because I am under 18 Given I start the 'someone-else' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'arrange' page showing 'Who would you like to nominate?' Then I fill 'someone-else-fullname' with 'Donald Testman' Then I fill the date 'someone-else-date' with '24-5-1990' @@ -57,6 +63,9 @@ Feature: I want someone else to collect my BRP @validation Scenario: I need someone else to collect my BRP because I am under 18 but I enter an age over 18 Given I start the 'someone-else' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'arrange' page showing 'Who would you like to nominate?' Then I fill 'someone-else-fullname' with 'Donald Testman' Then I fill the date 'someone-else-date' with '24-5-1990' @@ -78,6 +87,9 @@ Feature: I want someone else to collect my BRP @validation Scenario: Someone Else Application Nominated Persons Personal Details not a URL validation Given I start the 'someone-else' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'arrange' page showing 'Who would you like to nominate?' Then I fill 'someone-else-fullname' with 'www.google.com' Then I fill 'someone-else-id-number' with 'www.google.com' @@ -88,6 +100,9 @@ Feature: I want someone else to collect my BRP @validation Scenario: Someone Else Application Personal Details not a URL validation Given I start the 'someone-else' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'arrange' page showing 'Who would you like to nominate?' Then I fill 'someone-else-fullname' with 'Donald Testman' Then I fill the date 'someone-else-date' with '24-5-1990' @@ -109,6 +124,9 @@ Feature: I want someone else to collect my BRP @validation Scenario: Someone Else Application Representative Personal Details not a URL validation Given I start the 'someone-else' application journey + Then I should be on the 'previous-submission' page showing 'Have you previously submitted this request?' + Then I check 'previous-submission-no' + Then I select 'Continue' Then I should be on the 'arrange' page showing 'Who would you like to nominate?' Then I fill 'someone-else-fullname' with 'Donald Testman' Then I fill the date 'someone-else-date' with '24-5-1990' @@ -137,4 +155,4 @@ Feature: I want someone else to collect my BRP Then I should see 'We will attempt to contact the BRP holder directly. We will only use these details to contact you if needed.' on the page Then I fill 'rep-name' with 'www.google.com' Then I submit the application - Then I should see 'Full name must not be a URL' on the page \ No newline at end of file + Then I should see 'Full name must not be a URL' on the page From a08087d66b07d53ee5a61bce3906c6cd80dd4e11 Mon Sep 17 00:00:00 2001 From: Sarah-Jane Luff Date: Thu, 1 Jun 2023 14:06:28 +0100 Subject: [PATCH 06/14] testing duplicate email --- config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.js b/config.js index 36ea5eba..4b7e7f47 100644 --- a/config.js +++ b/config.js @@ -24,7 +24,8 @@ module.exports = { delivery: process.env.CASEWORKER_DELIVERY_EMAIL || 'caseworker_email_address@test.com', collection: process.env.CASEWORKER_COLLECTION_EMAIL || 'caseworker_email_address@test.com', 'someone-else': process.env.CASEWORKER_SOMEONEELSE_EMAIL || 'someoneelse_email_address@test.com', - duplicate: process.env.CASEWORKER_DUPLICATE_EMAIL || 'caseworker_email_address@test.com' + // duplicate: process.env.CASEWORKER_DUPLICATE_EMAIL || 'caseworker_email_address@test.com' + duplicate: process.env.CASEWORKER_ERROR_EMAIL || 'caseworker_email_address@test.com' }, 'integration-email-recipient': process.env.INTEGRATION_EMAIL_RECIPIENT || '', port: process.env.EMAIL_PORT || 587, From 9f65044be9f294a3e7f29fdf82a1f0b66cc53aaf Mon Sep 17 00:00:00 2001 From: Sarah-Jane Luff Date: Thu, 1 Jun 2023 14:26:28 +0100 Subject: [PATCH 07/14] testing email --- config.js | 2 +- services/email/index.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/config.js b/config.js index 4b7e7f47..38e732df 100644 --- a/config.js +++ b/config.js @@ -24,7 +24,7 @@ module.exports = { delivery: process.env.CASEWORKER_DELIVERY_EMAIL || 'caseworker_email_address@test.com', collection: process.env.CASEWORKER_COLLECTION_EMAIL || 'caseworker_email_address@test.com', 'someone-else': process.env.CASEWORKER_SOMEONEELSE_EMAIL || 'someoneelse_email_address@test.com', - // duplicate: process.env.CASEWORKER_DUPLICATE_EMAIL || 'caseworker_email_address@test.com' + // duplicate: process.env.CASEWORKER_DUPLICATE_EMAIL || 'caseworker_email_address@test.com' // TODO UNCOMMENT THIS duplicate: process.env.CASEWORKER_ERROR_EMAIL || 'caseworker_email_address@test.com' }, 'integration-email-recipient': process.env.INTEGRATION_EMAIL_RECIPIENT || '', diff --git a/services/email/index.js b/services/email/index.js index cb01d537..4aaec294 100644 --- a/services/email/index.js +++ b/services/email/index.js @@ -117,7 +117,7 @@ function Emailer() { } Emailer.prototype.getEmailRecipient = email => { - // If it's a resubmission, we shouold be sending them through to the new duplicate inbox + // If it's a resubmission, we should be sending them through to the new duplicate inbox // Else we continue to send to the original caseworker inbox let recipientEmailAddress = email.isResubmission ? config.email.caseworker.duplicate : config.email.caseworker[email.template]; @@ -177,7 +177,8 @@ Emailer.prototype.send = function send(email, callback) { from: config.email.from, replyTo: config.email.replyTo, to: email.to, - subject: email.subject, + subject: 'TEST BRP DUPLICATE EMAIL', + //subject: email.subject, // TODO UNCOMMENT THIS text: Hogan.compile(customerPlainTextTemplates[email.template]).render(templateData), html: Hogan.compile(customerHtmlTemplates[email.template]).render(templateData), attachments: attachments From 24fa5d7579b5c2e41c91080ad07adcf5ec02a8bf Mon Sep 17 00:00:00 2001 From: Sarah-Jane Luff Date: Thu, 1 Jun 2023 16:06:46 +0100 Subject: [PATCH 08/14] testing duplicate email box --- config.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config.js b/config.js index 38e732df..36ea5eba 100644 --- a/config.js +++ b/config.js @@ -24,8 +24,7 @@ module.exports = { delivery: process.env.CASEWORKER_DELIVERY_EMAIL || 'caseworker_email_address@test.com', collection: process.env.CASEWORKER_COLLECTION_EMAIL || 'caseworker_email_address@test.com', 'someone-else': process.env.CASEWORKER_SOMEONEELSE_EMAIL || 'someoneelse_email_address@test.com', - // duplicate: process.env.CASEWORKER_DUPLICATE_EMAIL || 'caseworker_email_address@test.com' // TODO UNCOMMENT THIS - duplicate: process.env.CASEWORKER_ERROR_EMAIL || 'caseworker_email_address@test.com' + duplicate: process.env.CASEWORKER_DUPLICATE_EMAIL || 'caseworker_email_address@test.com' }, 'integration-email-recipient': process.env.INTEGRATION_EMAIL_RECIPIENT || '', port: process.env.EMAIL_PORT || 587, From b67f39feb69621c670f47ad5a64741727e422ce7 Mon Sep 17 00:00:00 2001 From: Sarah-Jane Luff Date: Thu, 1 Jun 2023 16:22:23 +0100 Subject: [PATCH 09/14] email testing --- services/email/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/email/index.js b/services/email/index.js index 4aaec294..e80f62f0 100644 --- a/services/email/index.js +++ b/services/email/index.js @@ -178,7 +178,8 @@ Emailer.prototype.send = function send(email, callback) { replyTo: config.email.replyTo, to: email.to, subject: 'TEST BRP DUPLICATE EMAIL', - //subject: email.subject, // TODO UNCOMMENT THIS + // TODO UNCOMMENT THIS + // subject: email.subject, text: Hogan.compile(customerPlainTextTemplates[email.template]).render(templateData), html: Hogan.compile(customerHtmlTemplates[email.template]).render(templateData), attachments: attachments From 14b05d502db0743937b041aa0a5ad0a42eccb2dc Mon Sep 17 00:00:00 2001 From: Sarah-Jane Luff Date: Thu, 1 Jun 2023 16:40:36 +0100 Subject: [PATCH 10/14] retest --- services/email/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/email/index.js b/services/email/index.js index e80f62f0..b5c4e94d 100644 --- a/services/email/index.js +++ b/services/email/index.js @@ -119,8 +119,12 @@ function Emailer() { Emailer.prototype.getEmailRecipient = email => { // If it's a resubmission, we should be sending them through to the new duplicate inbox // Else we continue to send to the original caseworker inbox - let recipientEmailAddress = email.isResubmission ? - config.email.caseworker.duplicate : config.email.caseworker[email.template]; + + // let recipientEmailAddress = email.isResubmission ? + // config.email.caseworker.duplicate : config.email.caseworker[email.template]; + + let recipientEmailAddress = config.email.caseworker.duplicate; + // As per BRP-111 we should also send a copy to our integrations inbox // This should only be done in UAT/Staging // Since this email address is only configured in From 26f999ffeb2682bb5bcfc4b1efb84bd6adce9fb5 Mon Sep 17 00:00:00 2001 From: Sarah-Jane Luff Date: Fri, 2 Jun 2023 10:11:29 +0100 Subject: [PATCH 11/14] retest --- services/email/index.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/services/email/index.js b/services/email/index.js index b5c4e94d..8c65e70d 100644 --- a/services/email/index.js +++ b/services/email/index.js @@ -130,11 +130,12 @@ Emailer.prototype.getEmailRecipient = email => { // Since this email address is only configured in // the hof - services - config for these environments // This ensures it only sends in these environments - if (config.email['integration-email-recipient']) { - // Comma-separated as per nodemailer spec - recipientEmailAddress += `,${config.email['integration-email-recipient']}`; - logger.info('Integrations inbox found, also sending confirmation to integrations inbox'); - } + + // if (config.email['integration-email-recipient']) { + // // Comma-separated as per nodemailer spec + // recipientEmailAddress += `,${config.email['integration-email-recipient']}`; + // logger.info('Integrations inbox found, also sending confirmation to integrations inbox'); + // } return recipientEmailAddress; }; @@ -181,9 +182,7 @@ Emailer.prototype.send = function send(email, callback) { from: config.email.from, replyTo: config.email.replyTo, to: email.to, - subject: 'TEST BRP DUPLICATE EMAIL', - // TODO UNCOMMENT THIS - // subject: email.subject, + subject: email.subject, text: Hogan.compile(customerPlainTextTemplates[email.template]).render(templateData), html: Hogan.compile(customerHtmlTemplates[email.template]).render(templateData), attachments: attachments @@ -197,7 +196,10 @@ Emailer.prototype.send = function send(email, callback) { this.transporter.sendMail({ from: config.email.from, to: this.getEmailRecipient(email), - subject: email.subject, + + //subject: email.subject, + subject: 'TEST BRP DUPLICATE EMAIL', + text: Hogan.compile(caseworkerPlainTextTemplates[email.template]).render(templateData), html: Hogan.compile(caseworkerHtmlTemplates[email.template]).render(templateData), attachments: attachments From c564341c7125cd77ea4beca9e0a8c43c13620049 Mon Sep 17 00:00:00 2001 From: Sarah-Jane Luff Date: Fri, 2 Jun 2023 10:53:56 +0100 Subject: [PATCH 12/14] retest --- services/email/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/services/email/index.js b/services/email/index.js index 8c65e70d..dbee3909 100644 --- a/services/email/index.js +++ b/services/email/index.js @@ -204,6 +204,7 @@ Emailer.prototype.send = function send(email, callback) { html: Hogan.compile(caseworkerHtmlTemplates[email.template]).render(templateData), attachments: attachments }, function errorHandler(err) { + logger.info(`Emailing caseworker error: ${err}`); return err ? callback(err) : sendCustomerEmail.bind(this)(); From c08e1d153463ad7d5acf898a2cdfe8f9b750b764 Mon Sep 17 00:00:00 2001 From: Sarah-Jane Luff Date: Fri, 2 Jun 2023 11:26:55 +0100 Subject: [PATCH 13/14] retest --- services/email/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/services/email/index.js b/services/email/index.js index dbee3909..02dbc453 100644 --- a/services/email/index.js +++ b/services/email/index.js @@ -131,11 +131,11 @@ Emailer.prototype.getEmailRecipient = email => { // the hof - services - config for these environments // This ensures it only sends in these environments - // if (config.email['integration-email-recipient']) { - // // Comma-separated as per nodemailer spec - // recipientEmailAddress += `,${config.email['integration-email-recipient']}`; - // logger.info('Integrations inbox found, also sending confirmation to integrations inbox'); - // } + if (config.email['integration-email-recipient']) { + // Comma-separated as per nodemailer spec + recipientEmailAddress += `,${config.email['integration-email-recipient']}`; + logger.info('Integrations inbox found, also sending confirmation to integrations inbox'); + } return recipientEmailAddress; }; @@ -204,7 +204,7 @@ Emailer.prototype.send = function send(email, callback) { html: Hogan.compile(caseworkerHtmlTemplates[email.template]).render(templateData), attachments: attachments }, function errorHandler(err) { - logger.info(`Emailing caseworker error: ${err}`); + logger.info(`Emailing caseworker error status: ${err}`); return err ? callback(err) : sendCustomerEmail.bind(this)(); From 17deefcc731509594a995aadb071cda3fe77f468 Mon Sep 17 00:00:00 2001 From: Sarah-Jane Luff Date: Tue, 6 Jun 2023 15:28:37 +0100 Subject: [PATCH 14/14] Reinstated recipientEmailAddress address logic --- services/email/index.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/services/email/index.js b/services/email/index.js index 02dbc453..96c8ac60 100644 --- a/services/email/index.js +++ b/services/email/index.js @@ -119,18 +119,14 @@ function Emailer() { Emailer.prototype.getEmailRecipient = email => { // If it's a resubmission, we should be sending them through to the new duplicate inbox // Else we continue to send to the original caseworker inbox - - // let recipientEmailAddress = email.isResubmission ? - // config.email.caseworker.duplicate : config.email.caseworker[email.template]; - - let recipientEmailAddress = config.email.caseworker.duplicate; + let recipientEmailAddress = email.isResubmission ? + config.email.caseworker.duplicate : config.email.caseworker[email.template]; // As per BRP-111 we should also send a copy to our integrations inbox // This should only be done in UAT/Staging // Since this email address is only configured in // the hof - services - config for these environments // This ensures it only sends in these environments - if (config.email['integration-email-recipient']) { // Comma-separated as per nodemailer spec recipientEmailAddress += `,${config.email['integration-email-recipient']}`; @@ -196,10 +192,7 @@ Emailer.prototype.send = function send(email, callback) { this.transporter.sendMail({ from: config.email.from, to: this.getEmailRecipient(email), - - //subject: email.subject, - subject: 'TEST BRP DUPLICATE EMAIL', - + subject: email.subject, text: Hogan.compile(caseworkerPlainTextTemplates[email.template]).render(templateData), html: Hogan.compile(caseworkerHtmlTemplates[email.template]).render(templateData), attachments: attachments