diff --git a/app/journeyCheck.js b/app/journeyCheck.js index 3633de0c8b..1d4345d436 100644 --- a/app/journeyCheck.js +++ b/app/journeyCheck.js @@ -34,23 +34,23 @@ const gopOnlyPages = [ '/executors-additional-invite-sent', '/executor-address', '/executor-address/*', + '/check-will-executors', '/executors-alias', '/executors-all-alive', '/other-executors-applying', '/executors-change-made', '/executor-contact-details', '/executor-contact-details/*', - '/executor-current-name', - '/executor-current-name/*', - '/executor-current-name-reason', - '/executor-current-name-reason/*', - '/executors-dealing-with-estate', + '/executor-id-name', + '/executor-id-name/*', + '/executor-name-reason', + '/executor-name-reason/*', '/executors-invite', '/executors-invites-sent', '/executors-names', '/executor-notified', '/executor-notified/*', - '/executors-number', + '/executors-named', '/executors-other-names', '/executor-roles', '/executor-roles/*', diff --git a/app/journeys/probate.js b/app/journeys/probate.js index c610726576..4dd6477802 100644 --- a/app/journeys/probate.js +++ b/app/journeys/probate.js @@ -178,12 +178,15 @@ const stepList = { ApplicantAlias: 'ApplicantAliasReason', ApplicantAliasReason: 'ApplicantPhone', ApplicantPhone: 'ApplicantAddress', - ApplicantAddress: 'ExecutorsNumber', - ExecutorsNumber: { - oneExecutor: 'Equality', - otherwise: 'ExecutorsNames' + ApplicantAddress: 'ExecutorCheckWill', + ExecutorCheckWill: 'ExecutorsNamed', + ExecutorsNamed: { + multiExec: 'ExecutorsNames', + multiExecOptionNo: 'ExecutorsAllAlive', + otherwise: 'Equality' }, - ExecutorsNames: 'ExecutorsAllAlive', + RemoveExecutor: 'ExecutorsNamed', + ExecutorsNames: 'ExecutorsNamed', ExecutorsAllAlive: { isAlive: 'ExecutorsApplying', whoDied: 'ExecutorsWhoDied' @@ -195,12 +198,11 @@ const stepList = { otherwise: 'ExecutorsApplying' }, ExecutorsApplying: { - otherExecutorsApplying: 'ExecutorsDealingWithEstate', + otherExecutorsApplying: 'ExecutorsAlias', otherwise: 'ExecutorRoles' }, - ExecutorsDealingWithEstate: 'ExecutorsAlias', ExecutorsAlias: { - withAlias: 'ExecutorsWithOtherNames', + withAlias: 'ExecutorCurrentName', otherwise: 'ExecutorContactDetails' }, ExecutorsWithOtherNames: 'ExecutorCurrentName', @@ -209,7 +211,7 @@ const stepList = { otherwise: 'ExecutorContactDetails', }, ExecutorCurrentNameReason: { - continue: 'ExecutorCurrentName', + continue: 'ExecutorsAlias', otherwise: 'ExecutorContactDetails' }, ExecutorContactDetails: 'ExecutorAddress', diff --git a/app/resources/cy/translation/executors/address.json b/app/resources/cy/translation/executors/address.json index 095fa5cc8a..cb52c903be 100644 --- a/app/resources/cy/translation/executors/address.json +++ b/app/resources/cy/translation/executors/address.json @@ -1,6 +1,6 @@ { "title": "Cyfeiriad yr ysgutor", - "question": "Beth yw cyfeiriad parhaol {executorName}?", + "question": "Beth yw cyfeiriad {executorName}?", "explanation1": "Bydd hwn yn cael ei argraffu ar y grant profiant.", "postcode": "Cod post", "postTown": "Tref neu ddinas", @@ -10,7 +10,7 @@ "addressLabel2": "Ail linell y cyfeiriad (dewisol)", "addressLabel3": "Trydydd llinell y cyfeiriad (dewisol)", "selectAddress": "Dewiswch gyfeiriad", - "enterManually": "Teipiwch y cyfeiriad (gan gynnwys cyfeiriadau rhyngwladol)", + "enterManually": "Neu teipiwch eu cyfeiriad", "errors": { "addressLine1": { diff --git a/app/resources/cy/translation/executors/alias.json b/app/resources/cy/translation/executors/alias.json index e4086dfa9d..fdb5090c1a 100644 --- a/app/resources/cy/translation/executors/alias.json +++ b/app/resources/cy/translation/executors/alias.json @@ -1,12 +1,19 @@ { "title": "A oes gan unrhyw un o’r ysgutorion hyn enw gwahanol nawr i beth sydd yn yr ewyllys neu unrhyw godisiliau", - "question": "A oes gan unrhyw un o’r ysgutorion hyn enw gwahanol nawr i beth sydd yn yr ewyllys neu unrhyw godisiliau?", - "optionYes": "Oes", - "optionNo": "Nac oes", + "question": "Ydy’r enw ‘{executorWillName}’ yn wahanol i sut mae’n ymddangos ar eu pasbort neu ffurf arall o brawf adnabod?", + "paragraph1": "Dylech wneud yn siŵr mai hwn yw’r un math o ddull adnabod y bydd {executorWillName} yn ei ddefnyddio pan fyddant yn delio ag ystad {deceasedName}.", + "paragraph2": "Gallai eu henw fod yn wahanol oherwydd:", + "listItem1": "gwnaethant newid eu henw ar ôl gwneud yr ewyllys", + "listItem2": "ni chafodd rhan o’u henw ei gynnwys yn yr ewyllys", + "listItem3": "roedd camgymeriad sillafu yn yr ewyllys", + "listItem4": "maent hefyd yn cael eu hadnabod fel enw gwahanol", + "paragraph3": "Os oes gwahaniaeth, byddwch yn gallu dweud wrthym pam yn ddiweddarach.", + "optionYes": "Yes", + "optionNo": "No", "errors": { "alias": { - "required": "Dewiswch ‘oes’ os oes gan unrhyw un o’r ysgutorion enw gwahanol i beth sydd yn yr ewyllys neu unrhyw godisiliau" + "required": "Dewiswch do ydy os ydy enw {executorName} yn wahanol i’r ffordd y mae’n ymddangos ar eu pasbort neu ffurf arall o brawf adnabod" } } } diff --git a/app/resources/cy/translation/executors/allalive.json b/app/resources/cy/translation/executors/allalive.json index ce3ca803a0..53495f70e5 100644 --- a/app/resources/cy/translation/executors/allalive.json +++ b/app/resources/cy/translation/executors/allalive.json @@ -1,12 +1,14 @@ { "title": "A yw’r holl ysgutorion dal yn fyw", - "question": "A yw’r holl ysgutorion yn fyw?", + "oneOtherQuestion": "A yw {executorName} wedi marw ers i'r ewyllys gael ei llofnodi?", + "multipleExecutorQuestion": "A oes unrhyw un o’r ysgutorion wedi marw ers llofnodi’r ewyllys?", "optionYes": "Ydyn", "optionNo": "Nac ydyn", "errors": { "allalive": { - "required": "Atebwch ‘ydyn’ os yw’r holl ysgutorion dal yn fyw" + "singleExecutorRequired": "Atebwch ‘ydyn’ os yw’r holl ysgutorion dal yn fyw", + "multipleExecutorRequired": "Dewiswch oes os oes unrhyw un o’r ysgutorion wedi marw ers llofnodi’r ewyllys" } } } diff --git a/app/resources/cy/translation/executors/applying.json b/app/resources/cy/translation/executors/applying.json index 370157e1dd..75aca544ab 100644 --- a/app/resources/cy/translation/executors/applying.json +++ b/app/resources/cy/translation/executors/applying.json @@ -1,15 +1,21 @@ { - "title": "A fydd unrhyw un o’r ysgutorion eraill yn delio â’r ystad", - "question": "A fydd unrhyw un o’r ysgutorion eraill yn delio â’r ystad?", - "paragraph1": "Bydd yr ysgutorion hyn yn cael hawl gyfreithiol i:", - "applicant-rights1": "gasglu asedau’r ystad (eiddo ac arian)", + "title": "Ysgutorion sy’n delio â’r ystad", + "question": "Ysgutorion sy’n delio â’r ystad", + "paragraph1": "Gellir enwi hyd at 4 ysgutor gan gynnwys eich hun, ar y cais a’r grant am brofiant.", + "paragraph2": "Bydd pob ysgutor a enwir yn cael yr hawl gyfreithiol i ddelio ag ystad {deceasedName}. Mae hyn yn cynnwys:", + "applicant-rights1": "casglu asedau’r ystad (eiddo ac arian)", "applicant-rights2": "talu unrhyw drethi a dyledion", "applicant-rights3": "dosrannu beth sydd ar ôl i’r bobl sydd â hawl iddo (y ‘buddiolwyr’)", - "optionYes": "Bydd", - "optionNo": "Na fydd", + "contactOtherExecs": "Byddwn yn cysylltu â’r ysgutorion eraill ac yn gofyn iddynt wirio’r wybodaeth a ddarparwyd gennych yn y cais hwn ac yn cadarnhau ei fod yn gywir.", + "applicantsNotDealing": "Gofynnir i chi am ysgutorion na fyddant yn delio â’r ystad yn ddiweddarach.", + "multiExecQuestion": "Pa ysgutorion fydd hefyd yn delio â’r ystad?", + "oneOtherExecQuestion": "A fydd {executorName} hefyd yn delio â’r ystad?", + "optionYes": "Yes", + "optionNo": "No", "errors": { "otherExecutorsApplying": { + "invalid": "You can not select more than 4 executors", "required": "Atebwch ‘bydd’ os yw unrhyw un o’r ysgutorion eraill yn delio â’r ystad" } } diff --git a/app/resources/cy/translation/executors/checkwill.json b/app/resources/cy/translation/executors/checkwill.json new file mode 100644 index 0000000000..3825a52f7d --- /dev/null +++ b/app/resources/cy/translation/executors/checkwill.json @@ -0,0 +1,10 @@ +{ + "title": "Gwiriwch yr ewyllys wreiddiol", + "titleWithCodicil": "Gwiriwch yr ewyllys wreiddiol a’r codisiliau nawr", + "paragraph1": "Mae angen i ni wybod am bawb a enwir gan {deceasedName} fel ysgutor yn yr ewyllys.", + "paragraph1WithCodicil": "Mae angen i ni wybod am bawb a enwir gan {deceasedName} fel ysgutor yn yr ewyllys ac unrhyw godisiliau.", + "paragraph2": "Mae hyn yn cynnwys unrhyw un sydd:", + "bullet1": "wedi marw ers llofnodi’r ewyllys – hyd yn oed os yw’r ewyllys yn enwi ysgutor dirprwyol", + "bullet2": "ddim eisiau gwneud cais am brofiant ar hyn o bryd", + "bullet3": "yn ildio eu hawl i wneud cais yn barhaol" +} diff --git a/app/resources/cy/translation/executors/contactdetails.json b/app/resources/cy/translation/executors/contactdetails.json index c5bda76021..d39e9f6f00 100644 --- a/app/resources/cy/translation/executors/contactdetails.json +++ b/app/resources/cy/translation/executors/contactdetails.json @@ -1,11 +1,11 @@ { "title": "Manylion cyswllt ysgutor", - "question": "Beth yw cyfeiriad e-bost a rhif ffôn symudol {executorName}?", - "questionHint": "Byddwn yn cysylltu â’r ysgutor hwn ac fe ofynnir iddynt gadarnhau manylion yr ystad.", + "question": "Beth yw manylion cyswllt {executorName}?", + "paragraph1": "Byddwn yn anfon e-bost a neges testun at {executorName} i wirio eu hunaniaeth ac i gadarnhau manylion yr ystad.", + "paragraph2": "Mae’n rhaid i chi ddarparu eu cyfeiriad e-bost cyfredol a’u rhif ffôn symudol. Ar gyfer rhifau rhyngwladol, nodwch god y wlad.", "email": "Cyfeiriad e-bost", - "email2": "Rhaid i hwn fod yn gyfeiriad e-bost personol yr ysgutor", "mobile": "Rhif ffôn symudol", - "mobileHint": "Rhaid i hwn fod yn rhif ffôn symudol personol yr ysgutor. Er enghraifft, 07900123456 neu +33123456789", + "mobileHint": "Er enghraifft, 07700900900 neu +39133457090", "errors": { "email": { diff --git a/app/resources/cy/translation/executors/currentname.json b/app/resources/cy/translation/executors/currentname.json index 3f53e595c9..b1aade2b4a 100644 --- a/app/resources/cy/translation/executors/currentname.json +++ b/app/resources/cy/translation/executors/currentname.json @@ -1,12 +1,11 @@ { "title": "Enw cyfredol", - "question": "Beth yw enw cyfredol {executorFullName}?", - "currentNameHint": "Gan gynnwys enwau canol", - "currentName": "Enw cyfredol", + "question": "Sut mae enw {executorFullName} wedi’i ysgrifennu ar eu pasbort neu ffurf arall o brawf adnabod?", + "currentName": "Enw llawn", "errors": { "currentName": { - "required": "Nodwch enw cyfredol yr ysgutor", + "required": "Nodwch enw {executorName} yn union fel y mae wedi’i ysgrifennu ar eu pasbort neu ffurf arall o brawf adnabod", "invalid": "Rhowch enw ysgutor dilys - dim ond llythrennau a i z, bylchau, cysylltnodau a chollnodau y gellir eu cynnwys" } } diff --git a/app/resources/cy/translation/executors/currentnamereason.json b/app/resources/cy/translation/executors/currentnamereason.json index 4e92ef556f..de3194c1cf 100644 --- a/app/resources/cy/translation/executors/currentnamereason.json +++ b/app/resources/cy/translation/executors/currentnamereason.json @@ -1,15 +1,19 @@ { "title": "Rheswm dros yr Enw Arall", - "question": "Pam bod gan {executorName} enw arall?", - "optionMarriage": "Wedi priodi", - "optionDivorce": "Wedi ysgaru", - "optionDeedPoll": "Gweithred newid enw", + "question": "Why is {executorName}’s name different to how it is written in the will?", + "questionWithCodicil": "Pam fod enw {executorName} yn wahanol i sut mae wedi’i ysgrifennu ar yr ewyllys neu unrhyw godisiliau?", + "paragraph1": "Rhaid i chi egluro’r rheswm am y gwahaniaeth, er enghraifft, mae {executorName} wedi newid eu henw ers ysgrifennu’r ewyllys, neu ni chafodd eu henw canol ei gynnwys.", + "optionMarriage": "Mae nhw wedi priodi neu wedi ffurfio partneriaeth sifil", + "optionDivorce": "Mae nhw wedi ysgaru neu wedi dod â’u partneriaeth sifil i ben", + "optionDeedPoll": "Bu iddynt newid eu henw trwy weithred newid enw", + "optionDifferentSpelling": "Cafodd eu henw ei sillafu’n wahanol", + "optionPartOfNameNotIncluded": "Ni chafodd rhan o’u henw ei gynnwys", "optionOther": "Arall", - "optionOtherHint": "Rheswm dros y newid enw", + "optionOtherHint": "Rheswm dros y gwahaniaeth", "errors": { "currentNameReason": { - "required": "Dewiswch reswm dros y newid enw" + "required": "Dewiswch reswm dros pam fod enw {executorName} yn wahanol" }, "otherReason": { "required": "Nodwch y rheswm dros y newid enw" diff --git a/app/resources/cy/translation/executors/dealingwithestate.json b/app/resources/cy/translation/executors/dealingwithestate.json deleted file mode 100644 index 00c3a7f4c5..0000000000 --- a/app/resources/cy/translation/executors/dealingwithestate.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "title": "Pa ysgutorion fydd yn delio â’r ystad", - "question": "Pa ysgutorion fydd yn delio â’r ystad?", - "paragraph1": "Gellir enwi hyd at 4 ysgutor ar y grant profiant.", - "applicant-rights1": "gasglu asedau’r ystad (eiddo ac arian)", - "applicant-rights2": "talu unrhyw drethi a dyledion", - "applicant-rights3": "dosrannu beth sydd ar ôl i’r bobl sydd â hawl iddo (y ‘buddiolwyr’)", - "applicants-not-dealing": "Fe ofynnir ichi am yr ysgutorion na fydd yn delio â’r ystad hwyrach ymlaen yn y cais. ", - - "errors": { - "executorsApplying": { - "required": "Dewiswch o leiaf un ysgutor", - "invalid": "Ni allwch ddewis mwy na 4 ysgutor" - } - } -} diff --git a/app/resources/cy/translation/executors/named.json b/app/resources/cy/translation/executors/named.json new file mode 100644 index 0000000000..7adb6a0508 --- /dev/null +++ b/app/resources/cy/translation/executors/named.json @@ -0,0 +1,24 @@ +{ + "title": "Ysgutorion a enwir yn yr ewyllys", + "titleWithCodicil": "Ysgutorion a enwir yn yr ewyllys ac unrhyw godisiliau", + "question": "A oes unrhyw ysgutorion eraill a enwir?", + "hintText": "Sicrhewch eich bod yn cynnwys pob ysgutor a enwir yn yr ewyllys, gan gynnwys unrhyw un sydd:", + "hintTextWithCodicil": "Sicrhewch eich bod yn cynnwys pob ysgutor a enwir yn yr ewyllys ac unrhyw godisiliau, gan gynnwys unrhyw un sydd:", + "executorsDied": "wedi marw", + "executorsNotApplying": "ddim yn gwneud cais am brofiant", + "executorsGivenUpRight": "wedi ildio eu hawl i wneud cais", + "applicantExecutor" : "Ysgutor (chi)", + "furtherExecutor": "Ysgutor", + "executorTellUsMore": "Byddwch yn gallu dweud mwy wrthym am bob ysgutor yn ddiweddarach.", + "optionYes": "Oes", + "optionNo": "Nac oes", + "removeAction": "Dileu", + + "errors": { + "executorsNamed": { + "required": "Dewiswch ‘oes’ os oes mwy o ysgutorion wedi’u henwi yn yr ewyllys", + "requiredCodicils": "Dewiswch ‘oes’ os oes mwy o ysgutorion wedi’u henwi yn yr ewyllys neu ei chodisiliau", + "invalid": "Rhaid i nifer yr ysgutorion fod yn rhif cyfan rhwng 1 a 20" + } + } +} diff --git a/app/resources/cy/translation/executors/names.json b/app/resources/cy/translation/executors/names.json index 45399d9e40..527fa814c5 100644 --- a/app/resources/cy/translation/executors/names.json +++ b/app/resources/cy/translation/executors/names.json @@ -1,11 +1,10 @@ { "title": "Enwau’r ysgutorion", - "question": "Beth yw enwau’r ysgutorion?", - "paragraph": "Ysgrifennwch enwau’r holl ysgutorion yn union fel y maent yn ymddangos ar yr ewyllys ac unrhyw godisiliau.", + "question": "Sut mae enw’r ysgutor wedi’i ysgrifennu ar yr ewyllys neu’r codisil?", + "paragraph": "Rhowch enw’r ysgutor yn union fel y mae wedi’i ysgrifennu ar yr ewyllys neu’r codisil.", + "paragraph2": "Os oes mwy o ysgutorion, byddwch yn gallu eu hychwanegu yn y cam nesaf.", "executor": "Ysgutor", - "fullName": "Enw Llawn", - "fullNameHint": "Gan gynnwys enwau canol", - "numberOfExecutorsPage": "Newid y nifer o ysgutorion", + "fullName": "Enw llawn", "errors": { "executorName": { diff --git a/app/resources/cy/translation/executors/notified.json b/app/resources/cy/translation/executors/notified.json index a038c9f315..c951a28b06 100644 --- a/app/resources/cy/translation/executors/notified.json +++ b/app/resources/cy/translation/executors/notified.json @@ -1,13 +1,12 @@ { "title": "Ysgutor wedi’i hysbysu", - "question": "Ydych chi wedi hysbysu {executorName} yn ysgrifenedig eich bod yn gwneud cais?", + "question": "Ydych chi wedi hysbysu {executorName} yn ysgrifenedig eich bod yn gwneud y cais hwn?", "optionYes": "Do", "optionNo": "Naddo", - "informInWriting": "Mae’n rhaid ichi hysbysu’r ysgutor yn ysgrifenedig eich bod yn gwneud cais am brofiant", "errors": { "executorNotified": { - "required": "Atebwch ‘do’ os ydych wedi hysbysu’r ysgutor yn ysgrifenedig " + "required": "Dewiswch do os ydych wedi hysbysu {executorName} yn ysgrifenedig" } } } diff --git a/app/resources/cy/translation/executors/number.json b/app/resources/cy/translation/executors/number.json deleted file mode 100644 index 7b44fc5470..0000000000 --- a/app/resources/cy/translation/executors/number.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "title": "Faint o ysgutorion sydd wedi’u henwi ar yr ewyllys ac unrhyw codisiliau", - "question": "Faint o ysgutorion sydd wedi’u henwi ar yr ewyllys ac unrhyw codisiliau?", - "hintText": "Gwiriwch yr ewyllys a’r codisiliau nawr gan fod rhaid ichi gynnwys pob ysgutor a enwir, yn cynnwys y rhai sydd wedi marw.", - "executorsNumber": "Nifer yr ysgutorion", - - "errors": { - "executorsNumber": { - "required": "Nodwch nifer yr ysgutorion", - "invalid": "Rhaid i nifer yr ysgutorion fod yn rhif cyfan rhwng 1 a 20" - } - } -} diff --git a/app/resources/cy/translation/executors/roles.json b/app/resources/cy/translation/executors/roles.json index 1c89b64b3e..d86ef942a0 100644 --- a/app/resources/cy/translation/executors/roles.json +++ b/app/resources/cy/translation/executors/roles.json @@ -1,15 +1,14 @@ { "title": "Rheswm dros beidio â gwneud cais am brofiant", - "question": "Pam nad yw {executorFullName} yn gwneud cais am brofiant?", - "optionPowerReserved": "Nid yw’r ysgutor hwn eisiau gwneud cais nawr, ond efallai y bydd yn dymuno gwneud hynny yn y dyfodol (gelwir hyn hefyd yn cadw’r hawl)", - "optionRenunciated": "Nid yw’r ysgutor hwn eisiau gwneud cais nawr, ac mae’n rhoi fyny yr hawl i wneud hynny yn y dyfodol (gelwir hyn hefyd yn ymwrthod, a bydd angen i’r ysgutor lenwi ffurflen)", - "optionRenunciatedHint": "Llenwch naill ai ffurflen PA15 neu PA16 (agor mewn ffenestr newydd) os ydych eisiau ildio eich cyfrifoldeb cyfreithiol a’ch swyddogaeth yn barhaol (a elwir hefyd yn ‘ymwrthod’) i wneud cais am brofiant i reoli ystad rhywun a fu farw fel un ai:", - "optionRenunciatedHintBullet1": "ysgutor a enwir yn ei ewyllys, neu", - "optionRenunciatedHintBullet2": "priod neu bartner sifil sy’n gweithredu fel gweinyddwr.", + "question": "Pam nad yw {executorName} yn gwneud cais am brofiant?", + "optionPowerReserved": "Mae {executorName} yn cadw’r hawl i wneud cais yn ddiweddarach (a elwir yn ‘cadw’r hawl’)", + "optionPowerReservedHint": "Bydd angen i chi roi gwybod iddynt yn ysgrifenedig eich bod yn gwneud y cais hwn.", + "optionRenunciated": "Mae {executorName} yn ildio eu hawl i wneud cais yn barhaol (a elwir hefyd yn ‘ymwrthod’)", + "optionRenunciatedHint": "Bydd angen i chi anfon eu ymwrthod wedi’i llenwi atom ffurflen PA15 (yn agor mewn tab newydd) ynghyd â’ch dogfennau eraill.", "errors": { "notApplyingReason": { - "required": "Dewiswch y rheswm pam nad yw’r ysgutor yn gwneud cais " + "required": "Dewiswch reswm dros pam nad yw {executorName} yn gwneud cais" } } } diff --git a/app/resources/cy/translation/executors/whendied.json b/app/resources/cy/translation/executors/whendied.json index 4e481b086c..35ccd83fea 100644 --- a/app/resources/cy/translation/executors/whendied.json +++ b/app/resources/cy/translation/executors/whendied.json @@ -1,13 +1,13 @@ { "title": "Pryd farwodd yr ysgutor?", - "question": "A wnaeth {executorFullName} farw cyn yr unigolyn sydd wedi marw?", + "question": "A wnaeth {executorFullName} farw cyn {deceasedName}?", "optionYes": "Do", "optionNo": "Naddo", "executorFullName": "", "errors": { "diedbefore": { - "required": "Atebwch ‘do’ os farwodd yr ysgutor cyn yr unigolyn sydd wedi marw" + "required": "Dewiswch do os wnaeth {executorName} farw cyn {deceasedName}" } } } diff --git a/app/resources/cy/translation/removeExecutor.json b/app/resources/cy/translation/removeExecutor.json new file mode 100644 index 0000000000..566380c558 --- /dev/null +++ b/app/resources/cy/translation/removeExecutor.json @@ -0,0 +1,23 @@ +{ + "title": "Ysgutorion a enwir yn yr ewyllys", + "titleWithCodicil": "Ysgutorion a enwir yn yr ewyllys ac unrhyw godisiliau", + "question": "A oes unrhyw ysgutorion eraill a enwir?", + "hintText": "Sicrhewch eich bod yn cynnwys pob ysgutor a enwir yn yr ewyllys, gan gynnwys unrhyw un sydd:", + "hintTextWithCodicil": "Sicrhewch eich bod yn cynnwys pob ysgutor a enwir yn yr ewyllys ac unrhyw godisiliau, gan gynnwys unrhyw un sydd:", + "executorsDied": "wedi marw", + "executorsNotApplying": "ddim yn gwneud cais am brofiant", + "executorsGivenUpRight": "wedi ildio eu hawl i wneud cais", + "executorsNamed": "Nifer yr ysgutorion", + "applicantExecutor" : "Ysgutor (chi)", + "furtherExecutor": "Ysgutor", + "executorTellUsMore": "Byddwch yn gallu dweud mwy wrthym am bob ysgutor yn ddiweddarach.", + "optionYes": "Oes", + "optionNo": "Nac oes", + "removeAction": "Dileu", + + "errors": { + "executorsNamed": { + "required": "Nodwch nifer yr ysgutorion" + } + } +} diff --git a/app/resources/en/translation/executors/address.json b/app/resources/en/translation/executors/address.json index be10c3ce76..394faf0c79 100644 --- a/app/resources/en/translation/executors/address.json +++ b/app/resources/en/translation/executors/address.json @@ -1,6 +1,6 @@ { "title": "Executor address", - "question": "What is {executorName}’s permanent address?", + "question": "What is {executorName}’s address?", "explanation1": "This will be printed on the grant of probate.", "postcode": "Postcode", "postTown": "Town or city", @@ -10,7 +10,7 @@ "addressLabel2": "Address Line 2 (optional)", "addressLabel3": "Address Line 3 (optional)", "selectAddress": "Select address", - "enterManually": "Enter manually (including international addresses)", + "enterManually": "Enter their address instead", "errors": { "addressLine1": { diff --git a/app/resources/en/translation/executors/alias.json b/app/resources/en/translation/executors/alias.json index 90bd157d38..b1895ebdba 100644 --- a/app/resources/en/translation/executors/alias.json +++ b/app/resources/en/translation/executors/alias.json @@ -1,12 +1,19 @@ { - "title": "Do any of these executors now have a different name to that on the will or any codicil", - "question": "Do any of these executors now have a different name to that on the will or any codicil?", + "title": "Executor alias", + "question": "Is the name ‘{executorWillName}’ different to how it appears on their passport or other form of ID?", + "paragraph1": "You should make sure that this is the same form of identification {executorWillName} will use when they are dealing with {deceasedName}’s estate.", + "paragraph2": "Their name could be different because:", + "listItem1": "they changed their name after the will was made", + "listItem2": "part of their name was not included in the will", + "listItem3": "there was a spelling mistake in the will", + "listItem4": "they are also known by a different name", + "paragraph3": "If there is a difference, you’ll be able to tell us why later.", "optionYes": "Yes", "optionNo": "No", "errors": { "alias": { - "required": "Select ‘yes’ if any of the executors have a different name to that on the will or any codicil" + "required": "Select yes if {executorName}’s name is different to how it appears on their passport or other form of ID" } } } diff --git a/app/resources/en/translation/executors/allalive.json b/app/resources/en/translation/executors/allalive.json index f82053f533..f44facbd84 100644 --- a/app/resources/en/translation/executors/allalive.json +++ b/app/resources/en/translation/executors/allalive.json @@ -1,12 +1,14 @@ { - "title": "Are all the executors still alive", - "question": "Are all the executors alive?", + "title": "Have any of the executors died since the will was signed?", + "oneOtherQuestion": "Has {executorName} died since the will was signed?", + "multipleExecutorQuestion": "Have any of the executors died since the will was signed?", "optionYes": "Yes", "optionNo": "No", "errors": { "allalive": { - "required": "Answer ‘yes’ if all executors are still alive" + "singleExecutorRequired": "Select yes if {executorName} has died since the will was signed", + "multipleExecutorRequired": "Select yes if any of the executors have died since the will was signed" } } } diff --git a/app/resources/en/translation/executors/applying.json b/app/resources/en/translation/executors/applying.json index dcf190b6e7..60668efef8 100644 --- a/app/resources/en/translation/executors/applying.json +++ b/app/resources/en/translation/executors/applying.json @@ -1,16 +1,24 @@ { - "title": "Will any of the other executors be dealing with the estate", - "question": "Will any of the other executors be dealing with the estate?", - "paragraph1": "These executors will be given the legal right to:", + "title": "Executors dealing with the estate", + "question": "Executors dealing with the estate", + "paragraph1": "Up to 4 executors, including yourself, can be named on the application and the grant of probate.", + "paragraph2": "All named executors will be given the legal right to deal with {deceasedName}’s estate. This includes:", "applicant-rights1": "collect the estate’s assets (property, money and possessions)", "applicant-rights2": "pay any taxes and debts", "applicant-rights3": "distribute what’s left to the people entitled to it (the ‘beneficiaries’)", + "contactOtherExecs": "We will contact the other executors and ask them to check the information you have provided in this application and confirmation that it is correct.", + "applicantsNotDealing": "You will be asked about executors who will not be dealing with the estate later.", + "multiExecQuestion": "Which executors will also be dealing with the estate?", + "oneOtherExecQuestion": "Will {executorName} also be dealing with the estate?", "optionYes": "Yes", "optionNo": "No", "errors": { "otherExecutorsApplying": { - "required": "Answer ‘yes’ if any of the other executors are dealing with the estate" + "required": "Select yes if {executorName} will be dealing with the estate" + }, + "executorsApplying": { + "invalid": "You can not select more than 4 executors" } } } diff --git a/app/resources/en/translation/executors/checkwill.json b/app/resources/en/translation/executors/checkwill.json new file mode 100644 index 0000000000..b0e2b3287a --- /dev/null +++ b/app/resources/en/translation/executors/checkwill.json @@ -0,0 +1,10 @@ +{ + "title": "Check the original will", + "titleWithCodicil": "Check the original will and codicils now", + "paragraph1": "We need to know about everyone {deceasedName} named as an executor in the will.", + "paragraph1WithCodicil": "We need to know about everyone {deceasedName} named as an executor in the will and any codicils.", + "paragraph2": "This includes anyone who:", + "bullet1": "has died since the will was signed - even if the will names a substitute executor", + "bullet2": "does not want to apply for probate right now", + "bullet3": "is permanently giving up their right to apply" +} diff --git a/app/resources/en/translation/executors/contactdetails.json b/app/resources/en/translation/executors/contactdetails.json index 2ebd860ef1..32c921954d 100644 --- a/app/resources/en/translation/executors/contactdetails.json +++ b/app/resources/en/translation/executors/contactdetails.json @@ -1,11 +1,11 @@ { "title": "Executor contact details", - "question": "What are {executorName}’s email address and mobile number?", - "questionHint": "This executor will be contacted and asked to confirm details of the estate.", + "question": "What are {executorName}’s contact details?", + "paragraph1": "We will send {executorName} an email and text message to verify their identity and to confirm details of the estate.", + "paragraph2": "You must provide their current email address and mobile phone number. For international numbers include the country code.", "email": "Email address", - "email2": "This must be the executor’s own email address", - "mobile": "Mobile phone number", - "mobileHint": "This must be the executor’s own mobile phone number. For example, 07900123456 or +33123456789", + "mobile": "Mobile number", + "mobileHint": "For example, 07700900900 or +39133457090", "errors": { "email": { diff --git a/app/resources/en/translation/executors/currentname.json b/app/resources/en/translation/executors/currentname.json index 86631c8c60..d8348ef3ce 100644 --- a/app/resources/en/translation/executors/currentname.json +++ b/app/resources/en/translation/executors/currentname.json @@ -1,12 +1,11 @@ { "title": "Current name", - "question": "What is {executorFullName}’s current name?", - "currentNameHint": "Including middle names", - "currentName": "Current name", + "question": "How is {executorFullName}’s name written on their passport or other form of ID?", + "currentName": "Full name", "errors": { "currentName": { - "required": "Enter the executor’s current name", + "required": "Enter {executorName}’s name exactly as it is written in their passport or other form of ID", "invalid": "Enter a valid executor’s name - can only contain letters a to z, spaces, hyphens and apostrophes" } } diff --git a/app/resources/en/translation/executors/currentnamereason.json b/app/resources/en/translation/executors/currentnamereason.json index 15d67fcc10..14af1516e4 100644 --- a/app/resources/en/translation/executors/currentnamereason.json +++ b/app/resources/en/translation/executors/currentnamereason.json @@ -1,15 +1,19 @@ { "title": "Executor Alias Reason", - "question": "What is the reason for {executorName}’s name change?", - "optionMarriage": "Marriage", - "optionDivorce": "Divorce", - "optionDeedPoll": "Change by deed poll", + "question": "Why is {executorName}’s name different to how it is written in the will?", + "questionWithCodicil": "Why is {executorName}’s name different to how it is written in the will or any codicils?", + "paragraph1": "You must explain the reason for the difference, for example, {executorName} changed their name since the will was written, or their middle name was not included.", + "optionMarriage": "They got married or formed a civil partnership", + "optionDivorce": "They got divorced or ended their civil partnership", + "optionDeedPoll": "They changed their name by deed poll", + "optionDifferentSpelling": "Their name was spelled differently", + "optionPartOfNameNotIncluded": "Part of their name was not included", "optionOther": "Other", - "optionOtherHint": "Reason for name change", + "optionOtherHint": "Reason for difference", "errors": { "currentNameReason": { - "required": "Select a reason for the change of name" + "required": "Select a reason why {executorName}’s name is different" }, "otherReason": { "required": "Enter the reason for the change of name" diff --git a/app/resources/en/translation/executors/dealingwithestate.json b/app/resources/en/translation/executors/dealingwithestate.json deleted file mode 100644 index 3bfee6531b..0000000000 --- a/app/resources/en/translation/executors/dealingwithestate.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "title": "Which executors will be dealing with the estate", - "question": "Which executors will be dealing with the estate?", - "paragraph1": "Up to 4 executors can be named on the grant of probate.", - "applicant-rights1": "collect the estate’s assets (property, money and possessions)", - "applicant-rights2": "pay any taxes and debts", - "applicant-rights3": "distribute what’s left to the people entitled to it (the ‘beneficiaries’)", - "applicants-not-dealing": "You’ll be asked about executors who won’t be dealing with the estate later in the application.", - - "errors": { - "executorsApplying": { - "required": "Select at least one executor", - "invalid": "You can not select more than 4 executors" - } - } -} diff --git a/app/resources/en/translation/executors/named.json b/app/resources/en/translation/executors/named.json new file mode 100644 index 0000000000..695779daa2 --- /dev/null +++ b/app/resources/en/translation/executors/named.json @@ -0,0 +1,24 @@ +{ + "title": "Executors named in the will", + "titleWithCodicil": "Executors named in the will and any codicils", + "question": "Are there any other executors named?", + "hintText": "You must make sure to include every executor named in the will, including anyone who:", + "hintTextWithCodicil": "You must make sure to include every executor named in the will and any codicils, including anyone who:", + "executorsDied": "has died", + "executorsNotApplying": "is not applying for probate", + "executorsGivenUpRight": "has given up their right to apply", + "applicantExecutor" : "Executor (you)", + "furtherExecutor": "Executor", + "executorTellUsMore": "You'll be able to tell us more about each executor later.", + "optionYes": "Yes", + "optionNo": "No", + "removeAction": "Remove", + + "errors": { + "executorsNamed": { + "required": "Select yes if there are more executors named in the will", + "requiredCodicils": "Select yes if there are more executors named in the will and any codicils", + "invalid": "Number of executors must be a whole number between 1 and 20" + } + } +} diff --git a/app/resources/en/translation/executors/names.json b/app/resources/en/translation/executors/names.json index 0c54412399..bd869d23f9 100644 --- a/app/resources/en/translation/executors/names.json +++ b/app/resources/en/translation/executors/names.json @@ -1,11 +1,12 @@ { "title": "Executors’ names", - "question": "What are the executors’ names?", - "paragraph": "Write the names of all the executors exactly as they appear on the will and any codicils.", + "question": "How is the executor’s name written in the will?", + "questionWithCodicil": "How is the executor’s name written in the will or codicil?", + "paragraph": "Enter the name of the executor exactly as it is written in the will.", + "paragraphWithCodicil": "Enter the name of the executor exactly as it is written in the will or codicil.", + "paragraph2": "If there are more executors, you will be able to add them in the next step.", "executor": "Executor", "fullName": "Full name", - "fullNameHint": "Including middle names", - "numberOfExecutorsPage": "Change number of executors", "errors": { "executorName": { diff --git a/app/resources/en/translation/executors/notified.json b/app/resources/en/translation/executors/notified.json index c57cc88bc8..79d3e47ce0 100644 --- a/app/resources/en/translation/executors/notified.json +++ b/app/resources/en/translation/executors/notified.json @@ -1,13 +1,12 @@ { "title": "Executor notified", - "question": "Have you notified {executorName} in writing that you are applying?", + "question": "Have you notified {executorName} in writing that you are making this application?", "optionYes": "Yes", "optionNo": "No", - "informInWriting": "You must inform the executor in writing that you are applying for probate", "errors": { "executorNotified": { - "required": "Answer ‘yes’ if you have have notified the executor in writing" + "required": "Select yes if you have notified {executorName} in writing" } } } diff --git a/app/resources/en/translation/executors/number.json b/app/resources/en/translation/executors/number.json deleted file mode 100644 index 5490c22896..0000000000 --- a/app/resources/en/translation/executors/number.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "title": "How many executors are named on the will and any codicils", - "question": "How many executors are named on the will and any codicils?", - "hintText": "Check the will and codicils now as you must include all named executors, including those that have died.", - "executorsNumber": "Number of executors", - - "errors": { - "executorsNumber": { - "required": "Enter the number of executors", - "invalid": "Number of executors must be a whole number between 1 and 20" - } - } -} diff --git a/app/resources/en/translation/executors/roles.json b/app/resources/en/translation/executors/roles.json index 06e111a3ff..40e2ae5c5b 100644 --- a/app/resources/en/translation/executors/roles.json +++ b/app/resources/en/translation/executors/roles.json @@ -1,15 +1,14 @@ { "title": "Executor non application reason", - "question": "Why isn’t {executorFullName} applying for probate?", - "optionPowerReserved": "This executor doesn’t want to apply now, but may do in the future (this is also known as power reserved)", - "optionRenunciated": "This executor doesn’t want to apply now, and gives up the right to do so in the future (this is also known as renunciation, and the executor will need to fill in a form)", - "optionRenunciatedHint": "Fill in either form PA15 or PA16 (opens in a new window) if you want to give up your legal responsibility and role permanently (also known as ‘renunciation’) to apply for probate to manage the estate of someone who died as either:", - "optionRenunciatedHintBullet1": "an executor named in their will or", - "optionRenunciatedHintBullet2": "their spouse or civil partner acting as an administrator.", + "question": "Why is {executorName} not applying for probate?", + "optionPowerReserved": "{executorName} is reserving the right to apply later (also known as holding ‘power reserved’)", + "optionPowerReservedHint": "You will need to inform them in writing that you are making this application.", + "optionRenunciated": "{executorName} is giving up their right to apply permanently (also known as ‘renunciation’)", + "optionRenunciatedHint": "You will need to send us their completed PA15 renunciation form (opens in a new tab) along with your other documents.", "errors": { "notApplyingReason": { - "required": "Select the reason why the executor isn’t applying" + "required": "Select a reason why {executorName} is not applying" } } } diff --git a/app/resources/en/translation/executors/whendied.json b/app/resources/en/translation/executors/whendied.json index 3dea9a8123..f450a6d3ad 100644 --- a/app/resources/en/translation/executors/whendied.json +++ b/app/resources/en/translation/executors/whendied.json @@ -1,13 +1,13 @@ { "title": "When did the executor die?", - "question": "Did {executorFullName} die before the person who died?", + "question": "Did {executorFullName} die before {deceasedName}?", "optionYes": "Yes", "optionNo": "No", "executorFullName": "", "errors": { "diedbefore": { - "required": "Answer ‘yes’ if the executor died before the person who died" + "required": "Select yes if {executorName} died before {deceasedName}" } } } diff --git a/app/resources/en/translation/removeExecutor.json b/app/resources/en/translation/removeExecutor.json new file mode 100644 index 0000000000..e18dbdd551 --- /dev/null +++ b/app/resources/en/translation/removeExecutor.json @@ -0,0 +1,23 @@ +{ + "title": "Executors named in the will", + "titleWithCodicil": "Executors named in the will and any codicils", + "question": "Are there any other executors named?", + "hintText": "You must make sure to include every executor named in the will, including anyone who:", + "hintTextWithCodicil": "You must make sure to include every executor named in the will and any codicils, including anyone who:", + "executorsDied": "has died", + "executorsNotApplying": "is not applying for probate", + "executorsGivenUpRight": "has given up their right to apply", + "executorsNamed": "Number of executors", + "applicantExecutor" : "Executor (you)", + "furtherExecutor": "Executor", + "executorTellUsMore": "You'll be able to tell us more about each executor later.", + "optionYes": "Yes", + "optionNo": "No", + "removeAction": "Remove", + + "errors": { + "executorsNamed": { + "required": "Select yes if there are more executors named in the will and any codicils" + } + } +} diff --git a/app/steps/action/removeExecutor/index.js b/app/steps/action/removeExecutor/index.js new file mode 100644 index 0000000000..a2c54b1851 --- /dev/null +++ b/app/steps/action/removeExecutor/index.js @@ -0,0 +1,38 @@ +'use strict'; + +const ExecutorsNamed = require('app/steps/ui/executors/named'); +const {set, isEmpty} = require('lodash'); +const ActionStepRunner = require('app/core/runners/ActionStepRunner'); + +class RemoveExecutor extends ExecutorsNamed { + + static getUrl(index = '*') { + return `/executor-names/remove/${index}`; + } + + constructor(steps, section, templatePath, i18next, schema, language) { + super(steps, section, templatePath, i18next, schema, language); + this.section = 'executors'; + } + + getContextData(req) { + const ctx = super.getContextData(req); + ctx.index = req.params[0]; + ctx.list.splice(ctx.index, 1); + return ctx; + } + + runner() { + return new ActionStepRunner(); + } + + handlePost(ctx, errors, formdata) { + set(formdata, 'executors.list', ctx.list); + if (!isEmpty(errors)) { + set(formdata, 'executors.errors', errors); + } + return [ctx, errors]; + } +} + +module.exports = RemoveExecutor; diff --git a/app/steps/action/removeExecutor/schema.json b/app/steps/action/removeExecutor/schema.json new file mode 100644 index 0000000000..fdcb5c0e45 --- /dev/null +++ b/app/steps/action/removeExecutor/schema.json @@ -0,0 +1,7 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "$id": "remove-executor", + "type": "object", + "properties": { + } +} diff --git a/app/steps/ui/executors/address/template.html b/app/steps/ui/executors/address/template.html index fca016d58e..8c96aeaa4e 100644 --- a/app/steps/ui/executors/address/template.html +++ b/app/steps/ui/executors/address/template.html @@ -22,7 +22,7 @@ isPageHeading: true } }) %} -
{{ content.explanation1 | safe }}
+{{ content.explanation1 | safe }}
{{ addressFinder( fields, content, diff --git a/app/steps/ui/executors/alias/index.js b/app/steps/ui/executors/alias/index.js index 4a139355d1..f0936a203b 100644 --- a/app/steps/ui/executors/alias/index.js +++ b/app/steps/ui/executors/alias/index.js @@ -1,18 +1,37 @@ 'use strict'; const ValidationStep = require('app/core/steps/ValidationStep'); +const {findIndex} = require('lodash'); +const FormatName = require('../../../../utils/FormatName'); +const ExecutorsWrapper = require('app/wrappers/Executors'); +const pageUrl = '/executors-alias'; class ExecutorsAlias extends ValidationStep { + static getUrl(index = '*') { + return `${pageUrl}/${index}`; + } + + getContextData(req) { + const ctx = super.getContextData(req); + if (req.params && !isNaN(req.params[0])) { + ctx.index = parseInt(req.params[0]); + } else { + ctx.index = this.recalcIndex(ctx, 0); + ctx.redirect = `${pageUrl}/${ctx.index}`; + } + ctx.otherExecName = ctx.list?.[ctx.index] ? ctx.list[ctx.index].fullName : ''; + ctx.deceasedName = FormatName.format(req.session.form.deceased); + return ctx; + } - static getUrl() { - return '/executors-alias'; + recalcIndex(ctx, index) { + return findIndex(ctx.list, o => o.isApplying === true && o.isDead !== true, index + 1); } pruneFormData(ctx) { - if (ctx.list && ctx.alias === 'optionNo') { + if (ctx.list && Array.isArray(ctx.list)) { const list = ctx.list.map(executor => { - if (executor.hasOtherName) { - executor.hasOtherName = false; + if (executor.hasOtherName === false) { delete executor.currentName; delete executor.currentNameReason; delete executor.otherReason; @@ -23,12 +42,44 @@ class ExecutorsAlias extends ValidationStep { } return ctx; } - + handleGet(ctx) { + if (ctx.list?.[ctx.index]) { + if (ctx.list[ctx.index].hasOtherName === true) { + ctx.alias = 'optionYes'; + } else if (ctx.list[ctx.index].hasOtherName === false) { + ctx.alias = 'optionNo'; + } else { + ctx.alias = ''; + } + } + return [ctx]; + } handlePost(ctx, errors) { - ctx = this.pruneFormData(ctx); + const executor = ctx.list[ctx.index]; + if (executor.isApplying) { + if (ctx.alias === 'optionYes') { + executor.hasOtherName = true; + } else if (ctx.alias === 'optionNo') { + executor.hasOtherName = false; + ctx = this.pruneFormData(ctx); + } + } return [ctx, errors]; } + nextStepUrl(req, ctx) { + if (ctx.alias === 'optionNo') { + const nextIndex = this.recalcIndex(ctx, ctx.index); + if (nextIndex !== -1) { + return ExecutorsAlias.getUrl(nextIndex); + } + return '/executor-contact-details/1'; + } else if (ctx.alias === 'optionYes') { + return `/executor-id-name/${ctx.index}`; + } + return this.next(req, ctx).constructor.getUrl(ctx.index); + } + nextStepOptions() { return { options: [ @@ -36,6 +87,33 @@ class ExecutorsAlias extends ValidationStep { ] }; } + + isComplete(ctx) { + const executorsWrapper = new ExecutorsWrapper(ctx); + const executors = executorsWrapper.executorsApplying(true); + + const allExecutorsValid = executors.every(executor => { + return (executor.hasOtherName === true && executor.currentName && executor.currentNameReason) || executor.hasOtherName === false; + }); + + return [allExecutorsValid, 'inProgress']; + } + + generateFields(language, ctx, errors) { + const fields = super.generateFields(language, ctx, errors); + if (fields.otherExecName && errors) { + errors[0].msg = errors[0].msg.replace('{executorName}', fields.otherExecName.value); + } + return fields; + } + + action(ctx, formdata) { + super.action(ctx, formdata); + delete ctx.index; + delete ctx.alias; + delete ctx.continue; + return [ctx, formdata]; + } } module.exports = ExecutorsAlias; diff --git a/app/steps/ui/executors/alias/template.html b/app/steps/ui/executors/alias/template.html index 839cb06510..95654c2b93 100644 --- a/app/steps/ui/executors/alias/template.html +++ b/app/steps/ui/executors/alias/template.html @@ -2,20 +2,33 @@ {% from "govuk/components/radios/macro.njk" import govukRadios %} {% from "govuk/components/button/macro.njk" import govukButton %} +{% from "govuk/components/fieldset/macro.njk" import govukFieldset %} {% block form_content %} - {{ govukRadios({ + {% call govukFieldset({ + legend: { + text: content.question | replace("{executorWillName}", fields.otherExecName.value) | safe, + isPageHeading: true, + classes: "govuk-fieldset__legend--l" + } + }) %} +{{ content.paragraph1 | replace("{executorWillName}", fields.otherExecName.value) + | replace("{deceasedName}", fields.deceasedName.value) | safe }}
+ +{{ content.paragraph2 | safe }}
+{{ content.paragraph3 | safe }}
+{{ govukRadios({ classes: "govuk-radios--inline", idPrefix: "alias", name: "alias", - fieldset: { - legend: { - text: content.question | safe, - isPageHeading: true, - classes: "govuk-fieldset__legend--l" - } - }, - errorMessage: { text: fields.alias.errorMessage | safe } if fields.alias.errorMessage, + errorMessage: { text: fields.alias.errorMessage + | replace("{executorName}", fields.otherExecName.value) | safe } if fields.alias.errorMessage, items: [ { value: "optionYes", @@ -29,6 +42,7 @@ } ] }) }} + {% endcall %}{{ content.paragraph1 | safe }}
+{{ content.paragraph1 | safe }}
+{{ content.paragraph2| replace("{deceasedName}", fields.deceasedName.value) | safe }}
{{ unorderedList([ content["applicant-rights1"], content["applicant-rights2"], content["applicant-rights3"]]) }} +{{ content.contactOtherExecs | safe }}
+{{ content.applicantsNotDealing | safe }}
+ {% if fields.list.value | length == 2 %} +{{ content.paragraph1WithCodicil if fields.codicilPresent.value == "true" else content.paragraph1 | replace("{deceasedName}", fields.deceasedName.value) | safe}}
+{{ content.paragraph2 | safe }}
+ +{{ content.questionHint | safe }}
+{{ content.paragraph1 | replace("{executorName}", fields.otherExecName.value) | safe }}
+{{ content.paragraph2 | safe }}
- {% set label = content.email + "{{ content.mobileHint | safe }}
- {{ govukInput({ label: { text: content.mobile | safe }, id: "mobile", name: "mobile", + hint: { + text: content.mobileHint | safe + }, value: fields.mobile.value | safe, errorMessage: { text: fields.mobile.errorMessage | safe } if fields.mobile.errorMessage, attributes: { diff --git a/app/steps/ui/executors/currentname/index.js b/app/steps/ui/executors/currentname/index.js index 70c7c6848b..8a806f18fa 100644 --- a/app/steps/ui/executors/currentname/index.js +++ b/app/steps/ui/executors/currentname/index.js @@ -3,7 +3,7 @@ const ValidationStep = require('app/core/steps/ValidationStep'); const {findIndex, get} = require('lodash'); const ExecutorsWrapper = require('app/wrappers/Executors'); -const pageUrl = '/executor-current-name'; +const pageUrl = '/executor-id-name'; class ExecutorCurrentName extends ValidationStep { @@ -19,11 +19,12 @@ class ExecutorCurrentName extends ValidationStep { ctx.index = this.recalcIndex(ctx, 0); ctx.redirect = `${pageUrl}/${ctx.index}`; } + ctx.executorName = ctx.list?.[ctx.index] ? ctx.list[ctx.index].fullName : ''; return ctx; } handleGet(ctx) { - if (ctx.list && ctx.list[ctx.index]) { + if (ctx.list?.[ctx.index]) { ctx.currentName = ctx.list[ctx.index].currentName; } return [ctx]; @@ -66,6 +67,14 @@ class ExecutorCurrentName extends ValidationStep { const executorsWrapper = new ExecutorsWrapper(ctx); return [executorsWrapper.executorsWithAnotherName().every(exec => exec.currentName), 'inProgress']; } + + generateFields(language, ctx, errors) { + const fields = super.generateFields(language, ctx, errors); + if (fields.executorName && errors) { + errors[0].msg = errors[0].msg.replace('{executorName}', fields.executorName.value); + } + return fields; + } } module.exports = ExecutorCurrentName; diff --git a/app/steps/ui/executors/currentname/template.html b/app/steps/ui/executors/currentname/template.html index 62e32581a8..1381ecee73 100644 --- a/app/steps/ui/executors/currentname/template.html +++ b/app/steps/ui/executors/currentname/template.html @@ -18,11 +18,9 @@ }, id: "currentName", name: "currentName", - hint: { - text: content.currentNameHint | safe - }, value: fields.currentName.value | safe, - errorMessage: { text: fields.currentName.errorMessage | safe } if fields.currentName.errorMessage, + errorMessage: { text: fields.currentName.errorMessage + | replace("{executorName}", fields.executorName.value) | safe } if fields.currentName.errorMessage, attributes: { maxlength: 200 }, diff --git a/app/steps/ui/executors/currentnamereason/index.js b/app/steps/ui/executors/currentnamereason/index.js index b21a4827db..118150010d 100644 --- a/app/steps/ui/executors/currentnamereason/index.js +++ b/app/steps/ui/executors/currentnamereason/index.js @@ -4,8 +4,10 @@ const ValidationStep = require('app/core/steps/ValidationStep'); const {findIndex, get, startsWith} = require('lodash'); const ExecutorsWrapper = require('app/wrappers/Executors'); const AliasData = require('app/utils/AliasData.js'); +const FieldError = require('../../../../components/error'); +const WillWrapper = require('../../../../wrappers/Will'); -const path = '/executor-current-name-reason/'; +const path = '/executor-name-reason/'; class ExecutorCurrentNameReason extends ValidationStep { @@ -15,6 +17,7 @@ class ExecutorCurrentNameReason extends ValidationStep { getContextData(req) { const ctx = super.getContextData(req); + this.setCodicilFlagInCtx(ctx, req.session.form); if (req.params && !isNaN(req.params[0])) { ctx.index = parseInt(req.params[0]); req.session.indexPosition = ctx.index; @@ -24,18 +27,32 @@ class ExecutorCurrentNameReason extends ValidationStep { } else if (startsWith(req.path, path)) { ctx.index = this.recalcIndex(ctx, 0); } - if (ctx.list && ctx.list[ctx.index]) { + if (ctx.list?.[ctx.index]) { ctx.otherExecName = ctx.list[ctx.index].currentName; + } + return ctx; + } + pruneFormData(ctx) { + if (ctx.list && ctx.alias === 'optionNo') { + const list = ctx.list.map(executor => { + if (executor.hasOtherName) { + executor.hasOtherName = false; + delete executor.currentNameReason; + } + return executor; + }); + return Object.assign(ctx, {list}); } return ctx; } handleGet(ctx) { - if (ctx.list && ctx.list[ctx.index]) { + if (ctx.list?.[ctx.index]) { ctx.currentNameReason = ctx.list[ctx.index].currentNameReason; ctx.otherReason = ctx.list[ctx.index].otherReason; } + ctx = this.pruneFormData(ctx); return [ctx]; } @@ -60,7 +77,7 @@ class ExecutorCurrentNameReason extends ValidationStep { } recalcIndex(ctx, index) { - return findIndex(ctx.list, o => o.hasOtherName, index + 1); + return findIndex(ctx.list, o => o.isApplying, index + 1); } nextStepUrl(req, ctx) { @@ -79,11 +96,51 @@ class ExecutorCurrentNameReason extends ValidationStep { }; } + setCodicilFlagInCtx(ctx, formdata) { + ctx.codicilPresent = (new WillWrapper(formdata.will)).hasCodicils(); + } + isComplete(ctx) { const executorsWrapper = new ExecutorsWrapper(ctx); return [executorsWrapper.executorsWithAnotherName().every(exec => exec.currentNameReason), 'inProgress']; } + validate(ctx, formdata, language) { + const validationResult = super.validate(ctx, formdata, language); + if (!validationResult[0]) { + ctx.errors = this.createErrorMessages(validationResult[1], ctx, language); + } + return validationResult; + } + + createErrorMessages(validationErrors, ctx, language) { + const errorMessages = []; + validationErrors.forEach((validationError) => { + const executorName = ctx.list[ctx.index].fullName; + const errorMessage = this.composeMessage(language, ctx, executorName); + errorMessages.push(errorMessage); + validationError.msg = errorMessage.msg; + if (ctx.currentNameReason === 'optionOther' && !ctx.otherReason) { + validationError.field = 'otherReason'; + } else { + validationError.field = 'currentNameReason'; + } + }); + return errorMessages; + } + + composeMessage(language, ctx, executorName) { + if (ctx.currentNameReason === 'optionOther' && !ctx.otherReason) { + const messageType = 'required'; + return FieldError('otherReason', messageType, this.resourcePath, this.generateContent({}, {}, language), language); + } else if (typeof ctx.currentNameReason === 'undefined' || !ctx.currentNameReason) { + const messageType = 'required'; + const errorMessage = FieldError('currentNameReason', messageType, this.resourcePath, this.generateContent({}, {}, language), language); + errorMessage.msg = errorMessage.msg.replace('{executorName}', executorName); + return errorMessage; + } + } + action(ctx, formdata) { super.action(ctx, formdata); diff --git a/app/steps/ui/executors/currentnamereason/template.html b/app/steps/ui/executors/currentnamereason/template.html index dabc941653..b75156160b 100644 --- a/app/steps/ui/executors/currentnamereason/template.html +++ b/app/steps/ui/executors/currentnamereason/template.html @@ -3,6 +3,7 @@ {% from "govuk/components/radios/macro.njk" import govukRadios %} {% from "govuk/components/input/macro.njk" import govukInput %} {% from "govuk/components/button/macro.njk" import govukButton %} +{% from "govuk/components/fieldset/macro.njk" import govukFieldset %} {% block form_content %} {% set otherHtml %} @@ -21,17 +22,20 @@ }) }} {% endset -%} + {% call govukFieldset({ + legend: { + text: ((content.questionWithCodicil if fields.codicilPresent.value == "true" else content.question) | replace("{executorName}", fields.otherExecName.value)) | safe, + isPageHeading: true, + classes: "govuk-fieldset__legend--l" + } + }) %} + +{{ content.paragraph1 | replace("{executorName}", fields.otherExecName.value) | safe }}
+ {{ govukRadios({ classes: "govuk-radios", idPrefix: "currentNameReason", name: "currentNameReason", - fieldset: { - legend: { - text: content.question | replace("{executorName}", fields.otherExecName.value) | safe, - isPageHeading: true, - classes: "govuk-fieldset__legend--l" - } - }, errorMessage: { text: fields.currentNameReason.errorMessage | safe } if fields.currentNameReason.errorMessage, items: [ { @@ -49,6 +53,16 @@ text: content["optionDeedPoll"] | safe, checked: true if fields.currentNameReason.value == "optionDeedPoll" }, + { + value: "optionDifferentSpelling", + text: content["optionDifferentSpelling"] | safe, + checked: true if fields.currentNameReason.value == "optionDifferentSpelling" + }, + { + value: "optionPartOfNameNotIncluded", + text: content["optionPartOfNameNotIncluded"] | safe, + checked: true if fields.currentNameReason.value == "optionPartOfNameNotIncluded" + }, { value: "optionOther", text: content["optionOther"] | safe, @@ -59,6 +73,7 @@ } ] }) }} + {% endcall %}{{ content.paragraph1 | safe }}
- {{ unorderedList([ - content["applicant-rights1"], - content["applicant-rights2"], - content["applicant-rights3"]]) - }} -{{ content["applicants-not-dealing"] | safe }}
- - {{ govukCheckboxes({ - idPrefix: "executorsApplying", - name: "executorsApplying[]", - errorMessage: { text: fields.executorsApplying.errorMessage | safe } if fields.executorsApplying.errorMessage, - items: fields.options.value - }) }} - {% endcall %} - -{{ content.hintTextWithCodicil if fields.codicilPresent.value == "true" else content.hintText | safe }}
+ +{{ content.paragraph | safe }}
-{{ fields.applicantCurrentName.value | safe }}
+{{ content.paragraphWillCodicil if fields.codicilPresent.value == "true" else content.paragraph | safe }}
+{{ content.paragraph2 | safe }}
- {% for i in range(0, fields.executorsNumber.value -1) %} -{{ content.hintText | safe }}
- - {{ govukInput({ - label: { - html: content.executorsNumber - }, - id: "executorsNumber", - name: "executorsNumber", - type: "number", - value: fields.executorsNumber.value | safe, - errorMessage: { text: fields.executorsNumber.errorMessage | safe } if fields.executorsNumber.errorMessage, - attributes: { - maxlength: 5 - }, - classes: "govuk-input--width-3" - }) }} - {% endcall %} - -{{ content.optionRenunciatedHint | replace("{applicationFormPA15}", globals.links.applicationFormPA15) | safe }}
-{{ content.optionPowerReservedHint | safe }}
{% endset %} {{ govukRadios({ @@ -17,21 +17,25 @@ name: "notApplyingReason", fieldset: { legend: { - text: content.question | replace("{executorFullName}", fields.list.value[fields.index.value].fullName) | safe, + text: content.question | replace("{executorName}", fields.executorName.value) | safe, isPageHeading: true, classes: "govuk-fieldset__legend--l" } }, - errorMessage: { text: fields.notApplyingReason.errorMessage | safe } if fields.notApplyingReason.errorMessage, + errorMessage: { text: fields.notApplyingReason.errorMessage + | replace("{executorName}", fields.executorName.value) | safe } if fields.notApplyingReason.errorMessage, items: [ { value: "optionPowerReserved", - text: content["optionPowerReserved"] | safe, - checked: true if fields.notApplyingReason.value == "optionPowerReserved" + text: content["optionPowerReserved"] | replace("{executorName}", fields.executorName.value) | safe, + checked: true if fields.notApplyingReason.value == "optionPowerReserved", + conditional: { + html: optionPowerReservedHint + } }, { value: "optionRenunciated", - text: content["optionRenunciated"] | safe, + text: content["optionRenunciated"] | replace("{executorName}", fields.executorName.value) | safe, checked: true if fields.notApplyingReason.value == "optionRenunciated", conditional: { html: optionRenunciatedHint diff --git a/app/steps/ui/executors/whendied/index.js b/app/steps/ui/executors/whendied/index.js index d46ac7101f..98092e6f18 100644 --- a/app/steps/ui/executors/whendied/index.js +++ b/app/steps/ui/executors/whendied/index.js @@ -2,6 +2,7 @@ const CollectionStep = require('app/core/steps/CollectionStep'); const {findIndex, every, tail, has, get} = require('lodash'); +const FormatName = require('../../../../utils/FormatName'); const path = '/executor-when-died/'; class ExecutorsWhenDied extends CollectionStep { @@ -22,6 +23,14 @@ class ExecutorsWhenDied extends CollectionStep { return [ctx]; } + getContextData(req) { + const ctx = super.getContextData(req); + const formData = req.session.form; + ctx.deceasedName = FormatName.format(formData.deceased); + ctx.executorFullName = ctx.list?.[ctx.index] ? ctx.list[ctx.index].fullName : ''; + return ctx; + } + recalcIndex(ctx, index) { return findIndex(ctx.list, o => o.isDead === true, index + 1); } @@ -59,6 +68,15 @@ class ExecutorsWhenDied extends CollectionStep { return [every(deadExecs, exec => has(exec, 'diedBefore')), 'inProgress']; } + generateFields(language, ctx, errors) { + const fields = super.generateFields(language, ctx, errors); + if (fields.deceasedName && fields.executorFullName && errors) { + errors[0].msg = errors[0].msg.replace('{deceasedName}', fields.deceasedName.value) + .replace('{executorName}', fields.executorFullName.value); + } + return fields; + } + action(ctx, formdata) { super.action(ctx, formdata); delete ctx.diedbefore; diff --git a/app/steps/ui/executors/whendied/template.html b/app/steps/ui/executors/whendied/template.html index 14f8fb09bc..6d51530908 100644 --- a/app/steps/ui/executors/whendied/template.html +++ b/app/steps/ui/executors/whendied/template.html @@ -10,12 +10,14 @@ name: "diedbefore", fieldset: { legend: { - text: content.question | replace("{executorFullName}", fields.list.value[fields.index.value].fullName) | safe, + text: content.question | replace("{executorFullName}", fields.executorFullName.value) + | replace("{deceasedName}", fields.deceasedName.value) | safe, isPageHeading: true, classes: "govuk-fieldset__legend--l" } }, - errorMessage: { text: fields.diedbefore.errorMessage | safe } if fields.diedbefore.errorMessage, + errorMessage: { text: fields.diedbefore.errorMessage | replace("{executorName}", fields.executorFullName.value) +| replace("{deceasedName}", fields.deceasedName.value) | safe } if fields.diedbefore.errorMessage, items: [ { value: "optionYes", diff --git a/app/steps/ui/summary/includes/executors-others-details.njk b/app/steps/ui/summary/includes/executors-others-details.njk index 33217c5433..f24dfb05c7 100644 --- a/app/steps/ui/summary/includes/executors-others-details.njk +++ b/app/steps/ui/summary/includes/executors-others-details.njk @@ -6,7 +6,7 @@ visible: true } ], - url = content.ExecutorsNames.url, + url = content.ExecutorsNamed.url, common = common, alreadyDeclared = fields.summary.alreadyDeclared.value )}} diff --git a/app/steps/ui/summary/includes/executors-others-not-applying.njk b/app/steps/ui/summary/includes/executors-others-not-applying.njk index 27c142474a..f69b3db0ba 100644 --- a/app/steps/ui/summary/includes/executors-others-not-applying.njk +++ b/app/steps/ui/summary/includes/executors-others-not-applying.njk @@ -3,8 +3,8 @@ {{checkanswer( items = [ { - question: content.ExecutorRoles.question | replace("{executorFullName}", executor.fullName ), - answer: content.ExecutorRoles[executor.notApplyingReason], + question: content.ExecutorRoles.question | replace("{executorName}", executor.fullName ), + answer: content.ExecutorRoles[executor.notApplyingReason].replace("{executorName}", executor.fullName), visible: true } ], diff --git a/app/steps/ui/summary/includes/executors-others.njk b/app/steps/ui/summary/includes/executors-others.njk index 6dafee0603..742df9e34f 100644 --- a/app/steps/ui/summary/includes/executors-others.njk +++ b/app/steps/ui/summary/includes/executors-others.njk @@ -10,20 +10,22 @@ common = common, alreadyDeclared = fields.summary.alreadyDeclared.value )}} - +{% if fields.executors.executorsNumber.value > 2 %} {{checkanswer( items = [ { - question: content.ExecutorsDealingWithEstate.question, + question: content.ExecutorsApplying.question, answer: fields.summary.executorsDealingWithEstate.value, - visible: fields.executors.otherExecutorsApplying.value == "optionYes" + visible: fields.summary.executorsDealingWithEstate.value } ], - url = content.ExecutorsDealingWithEstate.url, + url = content.ExecutorsApplying.url, common = common, alreadyDeclared = fields.summary.alreadyDeclared.value, answerIsCollection = true )}} +{% endif %} + {% if fields.executors.alias.value == "optionYes" %} {{checkanswer( diff --git a/app/steps/ui/summary/includes/executors.njk b/app/steps/ui/summary/includes/executors.njk index c6e5a7de25..87f27d675a 100644 --- a/app/steps/ui/summary/includes/executors.njk +++ b/app/steps/ui/summary/includes/executors.njk @@ -1,12 +1,12 @@ {{checkanswer( items = [ { - question: content.ExecutorsNumber.question, - answer: fields.executors.executorsNumber.value, + question: content.ExecutorsNamed.question, + answer: fields.executors.executorsNamed.value, visible: true } ], - url = content.ExecutorsNumber.url, + url = content.ExecutorsNamed.url, common = common, alreadyDeclared = fields.summary.alreadyDeclared.value )}} @@ -14,7 +14,7 @@ {{checkanswer( items = [ { - question: content.ExecutorsAllAlive.question, + question: content.ExecutorsAllAlive.multipleExecutorQuestion, answer: content.ExecutorsAllAlive[fields.executors.allalive.value], visible: fields.executors.executorsNumber.value > 1 } @@ -29,7 +29,7 @@ { question: content.ExecutorsWhoDied.question, answer: fields.summary.executorsWhoDied.value, - visible: fields.executors.allalive.value == "optionNo" + visible: fields.executors.allalive.value == "optionYes" } ], url = content.ExecutorsWhoDied.url, diff --git a/charts/probate-frontend/Chart.yaml b/charts/probate-frontend/Chart.yaml index 619ca7c81a..a7f64f4008 100644 --- a/charts/probate-frontend/Chart.yaml +++ b/charts/probate-frontend/Chart.yaml @@ -3,7 +3,7 @@ appVersion: "1.0" description: A Helm chart for the HMCTS probate product name: probate-frontend home: https://github.com/hmcts/probate-frontend -version: 2.3.34 +version: 2.3.35 dependencies: - name: nodejs version: 3.1.1 diff --git a/charts/probate-frontend/values.yaml b/charts/probate-frontend/values.yaml index 96c6b11daa..9cbad9ceaf 100644 --- a/charts/probate-frontend/values.yaml +++ b/charts/probate-frontend/values.yaml @@ -21,7 +21,7 @@ nodejs: IDAM_S2S_URL: http://rpe-service-auth-provider-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal PAYMENT_API_URL: http://payment-api-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal VALIDATION_SERVICE_URL: http://probate-business-service-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal/validate - ORCHESTRATOR_SERVICE_URL: http://probate-orchestrator-service-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal + ORCHESTRATOR_SERVICE_URL: http://probate-orchestrator-service-pr-1143-java FEES_REGISTRY_URL: http://fees-register-api-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal/fees-register REFORM_ENVIRONMENT : '{{ .Values.global.environment }}' REDIS_HOST: probate-frontend-redis-cache-{{ .Values.global.environment }}.redis.cache.windows.net diff --git a/test/accessibility/a11yTest.js b/test/accessibility/a11yTest.js index af46a58784..596e4156ec 100644 --- a/test/accessibility/a11yTest.js +++ b/test/accessibility/a11yTest.js @@ -15,7 +15,7 @@ const caseTypes = require('app/utils/CaseTypes'); const stepsToExclude = [ 'Dashboard', 'Summary', 'TaskList', 'Equality', 'PinPage', 'PinSent', 'PinResend', 'AddressLookup', 'ExecutorAddress', 'ExecutorContactDetails', 'ExecutorName', - 'ExecutorNotified', 'ExecutorNameAsOnWill', 'ExecutorApplying', 'DeleteExecutor', 'PaymentStatus', 'AddAlias', 'RemoveAlias', 'ExecutorRoles', 'ExecutorsWhenDied', 'AvayaWebchat' + 'ExecutorNotified', 'ExecutorNameAsOnWill', 'ExecutorApplying', 'DeleteExecutor', 'PaymentStatus', 'AddAlias', 'RemoveAlias', 'ExecutorRoles', 'ExecutorsWhenDied', 'AvayaWebchat', 'RemoveExecutor' ]; const steps = initSteps([`${__dirname}/../../app/steps/action/`, `${__dirname}/../../app/steps/ui`], 'en'); const nock = require('nock'); diff --git a/test/component/applicant/testAddress.js b/test/component/applicant/testAddress.js index 5da27d56e0..f6753149d5 100644 --- a/test/component/applicant/testAddress.js +++ b/test/component/applicant/testAddress.js @@ -1,14 +1,14 @@ 'use strict'; const TestWrapper = require('test/util/TestWrapper'); -const ExecutorsNumber = require('app/steps/ui/executors/number'); +const ExecutorCheckWill = require('app/steps/ui/executors/checkwill'); const formatAddress = address => address.replace(/,/g, ', '); const testCommonContent = require('test/component/common/testCommonContent.js'); describe('applicant-address', () => { let testWrapper; let testAddressData; - const expectedNextUrlForExecsNumber = ExecutorsNumber.getUrl(); + const expectedNextUrlForExecsNumber = ExecutorCheckWill.getUrl(); beforeEach(() => { testWrapper = new TestWrapper('ApplicantAddress'); diff --git a/test/component/deceased/testDivorcePlace.js b/test/component/deceased/testDivorcePlace.js index 096d36309a..b6e218512b 100644 --- a/test/component/deceased/testDivorcePlace.js +++ b/test/component/deceased/testDivorcePlace.js @@ -63,7 +63,7 @@ describe('divorce-place', () => { .send(sessionData) .end(() => { const data = { - '{legalProcess}': 'divorce' + legalProcess: 'divorce' }; testWrapper.testErrors(done, data, 'required'); diff --git a/test/component/executors/testExecutorAlias.js b/test/component/executors/testExecutorAlias.js index 524ef768af..06fdc520e0 100644 --- a/test/component/executors/testExecutorAlias.js +++ b/test/component/executors/testExecutorAlias.js @@ -1,18 +1,37 @@ 'use strict'; const TestWrapper = require('test/util/TestWrapper'); -const ExecutorsWithOtherNames = require('app/steps/ui/executors/othername'); +const ExecutorsAlias = require('app/steps/ui/executors/alias'); +const ExecutorsCurrentName = require('app/steps/ui/executors/currentname'); const ExecutorContactDetails = require('app/steps/ui/executors/contactdetails'); -const testCommonContent = require('test/component/common/testCommonContent.js'); const caseTypes = require('app/utils/CaseTypes'); +const commonContent = require('../../../app/resources/en/translation/common.json'); describe('executors-alias', () => { - let testWrapper; - const expectedNextUrlForExecOtherNames = ExecutorsWithOtherNames.getUrl(); - const expectedNextUrlForExecContactDetails = ExecutorContactDetails.getUrl(); + let testWrapper, sessionData; + const expectedNextUrlForExecOtherNames = ExecutorsCurrentName.getUrl(1); + const expectedNextUrlForExecContactDetails = ExecutorContactDetails.getUrl(1); beforeEach(() => { testWrapper = new TestWrapper('ExecutorsAlias'); + sessionData = { + type: caseTypes.GOP, + ccdCase: { + state: 'Pending', + id: 1234567890123456 + }, + executors: { + list: [ + {firstName: 'John', lastName: 'TheApplicant', isApplying: true, isApplicant: true}, + {fullName: 'Executor Name1', isApplying: true}, + {fullName: 'Executor Name2', isApplying: true} + ] + }, + deceased: { + firstName: 'John', + lastName: 'Doe' + } + }; }); afterEach(() => { @@ -20,30 +39,55 @@ describe('executors-alias', () => { }); describe('Verify Content, Errors and Redirection', () => { - testCommonContent.runTest('ExecutorsAlias', null, null, [], false, {type: caseTypes.GOP}); - it('test content loaded on the page', (done) => { - const sessionData = { - type: caseTypes.GOP, - ccdCase: { - state: 'Pending', - id: 1234567890123456 - } - }; + it('test help block content is loaded on page', (done) => { + testWrapper.pageUrl = ExecutorsAlias.getUrl(1); + testWrapper.agent.post('/prepare-session/form') + .send(sessionData) + .end(() => { + const playbackData = { + helpTitle: commonContent.helpTitle, + helpHeading1: commonContent.helpHeading1, + helpHeading2: commonContent.helpHeading2, + helpHeading3: commonContent.helpHeading3, + helpTelephoneNumber: commonContent.helpTelephoneNumber, + helpTelephoneOpeningHoursTitle: commonContent.helpTelephoneOpeningHoursTitle, + helpTelephoneOpeningHours1: commonContent.helpTelephoneOpeningHours1, + helpTelephoneOpeningHours2: commonContent.helpTelephoneOpeningHours2, + helpEmailLabel: commonContent.helpEmailLabel.replace(/{contactEmailAddress}/g, commonContent.helpEmail) + }; + testWrapper.testDataPlayback(done, playbackData); + }); + }); + it('test content loaded on the page', (done) => { + sessionData.otherExecName = 'Executor Name1'; + testWrapper.pageUrl = ExecutorsAlias.getUrl(1); testWrapper.agent.post('/prepare-session/form') .send(sessionData) .end(() => { - testWrapper.testContent(done); + const contentData = { + executorWillName: 'Executor Name1', + deceasedName: 'John Doe' + }; + testWrapper.testContent(done, contentData); }); }); it('test errors message displayed for missing data', (done) => { - testWrapper.testErrors(done, {}, 'required'); + testWrapper.pageUrl = testWrapper.pageToTest.constructor.getUrl(1); + const errorsToTest = ['alias']; + testWrapper.testErrors(done, {}, 'required', errorsToTest); }); it(`test it redirects to Executor Other Names when Yes: ${expectedNextUrlForExecOtherNames}`, (done) => { + testWrapper.pageUrl = testWrapper.pageToTest.constructor.getUrl(1); const data = { + list: [ + {firstName: 'John', lastName: 'TheApplicant', isApplying: true, isApplicant: true}, + {fullName: 'Executor Name1', isApplying: true}, + {fullName: 'Executor Name2', isApplying: true} + ], alias: 'optionYes' }; @@ -51,8 +95,14 @@ describe('executors-alias', () => { }); it(`test it redirects to Executor Contact Details when No: ${expectedNextUrlForExecContactDetails}`, (done) => { + testWrapper.pageUrl = testWrapper.pageToTest.constructor.getUrl(1); const data = { - alias: 'optionNo' + list: [ + {firstName: 'John', lastName: 'TheApplicant', isApplying: true, isApplicant: true}, + {fullName: 'Executor Name1', isApplying: true}, + {fullName: 'Executor Name2', isApplying: true} + ], + alias: 'optionNo', }; testWrapper.testRedirect(done, data, expectedNextUrlForExecContactDetails); diff --git a/test/component/executors/testExecutorCurrentName.js b/test/component/executors/testExecutorCurrentName.js index cce7866e67..1193181b96 100644 --- a/test/component/executors/testExecutorCurrentName.js +++ b/test/component/executors/testExecutorCurrentName.js @@ -72,7 +72,9 @@ describe('executor-current-name', () => { }); it('test errors message displayed for missing data', (done) => { - testWrapper.testErrors(done, {}, 'required'); + testWrapper.pageUrl = testWrapper.pageToTest.constructor.getUrl(1); + const errorsToTest = ['currentName']; + testWrapper.testErrors(done, {}, 'required', errorsToTest); }); it('test errors message displayed for invalid currentname', (done) => { diff --git a/test/component/executors/testExecutorCurrentNameReason.js b/test/component/executors/testExecutorCurrentNameReason.js index a440910766..9383fa5029 100644 --- a/test/component/executors/testExecutorCurrentNameReason.js +++ b/test/component/executors/testExecutorCurrentNameReason.js @@ -34,30 +34,52 @@ describe('/executor-current-name-reason/', () => { describe('Verify Content, Errors and Redirection', () => { it('test content loaded on the page', (done) => { + const idsToExclude = ['questionWithCodicil']; testWrapper.agent.post('/prepare-session/form') .send(sessionData) .end(() => { const contentData = { executorFullName: 'Executor Name2', - executorName: 'Name2 Executor' + executorName: 'Name2 Executor', + list: [ + {firstName: 'John', lastName: 'TheApplicant', isApplying: true, isApplicant: true}, + {fullName: 'Executor Name1', isApplying: false}, + {fullName: 'Executor Name2', isApplying: true, currentName: 'Name2 Executor', hasOtherName: true}, + ] }; testWrapper.pageUrl = testWrapper.pageToTest.constructor.getUrl(2); - testWrapper.testContent(done, contentData); + testWrapper.testContent(done, contentData, idsToExclude); }); }); - it('test alias reason validation when no data is entered', (done) => { + it('test alias reason validation when no data is entered for current name reason', (done) => { + testWrapper.pageUrl = testWrapper.pageToTest.constructor.getUrl(2); const errorsToTest = ['currentNameReason']; - testWrapper.testErrors(done, {}, 'required', errorsToTest); + testWrapper.agent.post('/prepare-session/form') + .send(sessionData) + .end(() => { + const data = { + currentNameReason: '', + executorName: 'Executor Name2' + }; + + testWrapper.testErrors(done, data, 'required', errorsToTest); + }); }); it('test alias reason validation when other is selected but no reason is entered', (done) => { + testWrapper.pageUrl = testWrapper.pageToTest.constructor.getUrl(2); const errorsToTest = ['otherReason']; const data = { currentNameReason: 'optionOther', - otherReason: '' + otherReason: '', + list: [ + {firstName: 'John', lastName: 'TheApplicant', isApplying: true, isApplicant: true}, + {fullName: 'Executor Name1', isApplying: false}, + {fullName: 'Executor Name2', isApplying: true, currentName: 'Name2 Executor', hasOtherName: true}, + ] }; testWrapper.testErrors(done, data, 'required', errorsToTest); diff --git a/test/component/executors/testExecutorsAllAlive.js b/test/component/executors/testExecutorsAllAlive.js index f58ebf9c97..29a22297fe 100644 --- a/test/component/executors/testExecutorsAllAlive.js +++ b/test/component/executors/testExecutorsAllAlive.js @@ -39,12 +39,36 @@ describe('executors-all-alive', () => { }); it('test errors message displayed for missing data', (done) => { - testWrapper.testErrors(done, {}, 'required'); + const sessionData = { + type: caseTypes.GOP, + ccdCase: { + state: 'Pending', + id: 1234567890123456 + }, + executors: { + executorsNumber: 3, + list: [ + {firstName: 'John', lastName: 'TheApplicant', isApplying: true, isApplicant: true}, + {fullName: 'Many Clouds', isApplying: true}, + {fullName: 'Harvey Smith', isApplying: false} + ] + }, + applicant: {} + }; + const errorsToTest = ['allalive']; + + testWrapper.agent.post('/prepare-session/form') + .send(sessionData) + .end(() => { + const data = { + }; + testWrapper.testErrors(done, data, 'multipleExecutorRequired', errorsToTest); + }); }); it(`test it redirects to executors applying: ${expectedNextUrlForExecsApplying}`, (done) => { const data = { - allalive: 'optionYes' + allalive: 'optionNo' }; testWrapper.testRedirect(done, data, expectedNextUrlForExecsApplying); @@ -52,7 +76,7 @@ describe('executors-all-alive', () => { it(`test it redirects to which executors died: ${expectedNextUrlForExecsWhoDied}`, (done) => { const data = { - allalive: 'optionNo' + allalive: 'optionYes' }; testWrapper.testRedirect(done, data, expectedNextUrlForExecsWhoDied); diff --git a/test/component/executors/testExecutorsApplying.js b/test/component/executors/testExecutorsApplying.js index ea15767d92..db1c14d06d 100644 --- a/test/component/executors/testExecutorsApplying.js +++ b/test/component/executors/testExecutorsApplying.js @@ -1,14 +1,14 @@ 'use strict'; const TestWrapper = require('test/util/TestWrapper'); -const ExecutorsDealingWithEstate = require('app/steps/ui/executors/dealingwithestate'); +const ExecutorsAlias = require('app/steps/ui/executors/alias'); const ExecutorRoles = require('app/steps/ui/executors/roles'); const testCommonContent = require('test/component/common/testCommonContent.js'); const caseTypes = require('app/utils/CaseTypes'); describe('executors-applying', () => { let testWrapper; - const expectedNextUrlForExecDealingWith = ExecutorsDealingWithEstate.getUrl(); + const expectedNextUrlForExecAliasWith = ExecutorsAlias.getUrl('*'); const expectedNextUrlForExecRoles = ExecutorRoles.getUrl('*'); beforeEach(() => { @@ -22,40 +22,180 @@ describe('executors-applying', () => { describe('Verify Content, Errors and Redirection', () => { testCommonContent.runTest('ExecutorsApplying', null, null, [], false, {type: caseTypes.GOP}); - it('test content loaded on the page', (done) => { + it('test content loaded on the page for single executor', (done) => { const sessionData = { type: caseTypes.GOP, ccdCase: { state: 'Pending', id: 1234567890123456 + }, + executors: { + executorsNumber: 3, + list: [ + {firstName: 'John', lastName: 'TheApplicant', isApplying: true, isApplicant: true}, + {fullName: 'Many Clouds', isApplying: true} + ] + }, + applicant: { + alias: 'Bobby Alias' + }, + deceased: { + firstName: 'John', + lastName: 'Doe' } }; + const contentToExclude = ['multiExecQuestion']; testWrapper.agent.post('/prepare-session/form') .send(sessionData) .end(() => { - testWrapper.testContent(done); + const contentData = {deceasedName: 'John Doe', executorName: 'Many Clouds'}; + + testWrapper.testContent(done, contentData, contentToExclude); }); }); + it('test content loaded on the page for multiple executors', (done) => { + const sessionData = { + type: caseTypes.GOP, + ccdCase: { + state: 'Pending', + id: 1234567890123456 + }, + executors: { + executorsNumber: 3, + list: [ + {firstName: 'John', lastName: 'TheApplicant', isApplying: true, isApplicant: true}, + {fullName: 'Many Clouds', isApplying: true}, + {fullName: 'Executor Two', isApplying: true} + ] + }, + applicant: { + alias: 'Bobby Alias' + }, + deceased: { + firstName: 'John', + lastName: 'Doe' + } + }; + const contentToExclude = ['oneOtherExecQuestion', 'optionYes', 'optionNo']; + + testWrapper.agent.post('/prepare-session/form') + .send(sessionData) + .end(() => { + const contentData = {deceasedName: 'John Doe', executorName: 'Many Clouds'}; + + testWrapper.testContent(done, contentData, contentToExclude); + }); + }); it('test errors message displayed for missing data', (done) => { - testWrapper.testErrors(done, {}, 'required'); + const sessionData = { + type: caseTypes.GOP, + ccdCase: { + state: 'Pending', + id: 1234567890123456 + }, + executors: { + executorsNumber: 3, + list: [ + {firstName: 'John', lastName: 'TheApplicant', isApplying: true, isApplicant: true}, + {fullName: 'Many Clouds', isApplying: true} + ] + }, + applicant: {} + }; + const errorsToTest = ['otherExecutorsApplying']; + + testWrapper.agent.post('/prepare-session/form') + .send(sessionData) + .end(() => { + const data = { + otherExecutorsApplying: '', + executorName: 'Many Clouds' + }; + + testWrapper.testErrors(done, data, 'required', errorsToTest); + }); }); - it(`test it redirects to ExecutorsDealingWithEstate if there are other executors dealing with the estate: ${expectedNextUrlForExecDealingWith}`, (done) => { + it('test errors message displayed for more than 3 additional applicants', (done) => { + const sessionData = { + type: caseTypes.GOP, + ccdCase: { + state: 'Pending', + id: 1234567890123456 + }, + executors: { + executorsNumber: 3, + list: [ + {firstName: 'John', lastName: 'TheApplicant', isApplying: true, isApplicant: true}, + {fullName: 'Many Clouds', isApplying: true}, + {fullName: 'Harvey Smith', isApplying: false} + ] + }, + applicant: {} + }; + const errorsToTest = ['executorsApplying']; + + testWrapper.agent.post('/prepare-session/form') + .send(sessionData) + .end(() => { + const data = { + executorsApplying: ['many clouds', 'many clouds', 'many clouds', 'many clouds'] + }; + + testWrapper.testErrors(done, data, 'invalid', errorsToTest); + }); + }); + + it(`test it redirects to ExecutorsAlias if there are single other executor dealing with the estate: ${expectedNextUrlForExecAliasWith}`, (done) => { const data = { + list: [ + {firstName: 'John', lastName: 'TheApplicant', isApplying: true, isApplicant: true}, + {fullName: 'Executor Name 1', isApplying: true} + ], otherExecutorsApplying: 'optionYes' }; - testWrapper.testRedirect(done, data, expectedNextUrlForExecDealingWith); + testWrapper.testRedirect(done, data, expectedNextUrlForExecAliasWith); }); - it(`test it redirects to executors roles if there are no other executors dealing with the estate: ${expectedNextUrlForExecRoles}`, (done) => { + it(`test it redirects to ExecutorsAlias if there are multi executors dealing with the estate: ${expectedNextUrlForExecAliasWith}`, (done) => { + const data = { + list: [ + {firstName: 'John', lastName: 'TheApplicant', isApplying: true, isApplicant: true}, + {fullName: 'Executor Name 1', isApplying: true}, + {fullName: 'Executor Name 2', isApplying: true} + ], + executorsApplying: ['Executor Name 1', 'Executor Name 2'] + }; + + testWrapper.testRedirect(done, data, expectedNextUrlForExecAliasWith); + }); + it(`test it redirects to executors roles if there are no executor dealing with the estate: ${expectedNextUrlForExecRoles}`, (done) => { const data = { + list: [ + {firstName: 'John', lastName: 'TheApplicant', isApplying: true, isApplicant: true}, + {fullName: 'Executor Name 1', isApplying: true} + ], otherExecutorsApplying: 'optionNo' }; testWrapper.testRedirect(done, data, expectedNextUrlForExecRoles); }); + + it(`test it redirects to executors roles if there are no multi executors dealing with the estate: ${expectedNextUrlForExecRoles}`, (done) => { + const data = { + list: [ + {firstName: 'John', lastName: 'TheApplicant', isApplying: true, isApplicant: true}, + {fullName: 'Executor Name 1', isApplying: true}, + {fullName: 'Executor Name 2', isApplying: true}, + {fullName: 'Executor Name 3', isApplying: true}, + ], + executorsApplying: [' '] + }; + + testWrapper.testRedirect(done, data, expectedNextUrlForExecRoles); + }); }); }); diff --git a/test/component/executors/testExecutorsDealing.js b/test/component/executors/testExecutorsDealing.js deleted file mode 100644 index d9e10d3fb9..0000000000 --- a/test/component/executors/testExecutorsDealing.js +++ /dev/null @@ -1,78 +0,0 @@ -'use strict'; - -const TestWrapper = require('test/util/TestWrapper'); -const testCommonContent = require('test/component/common/testCommonContent.js'); -const caseTypes = require('app/utils/CaseTypes'); - -describe('executors-dealing-with-estate', () => { - let testWrapper, sessionData; - - beforeEach(() => { - testWrapper = new TestWrapper('ExecutorsDealingWithEstate'); - sessionData = { - type: caseTypes.GOP, - ccdCase: { - state: 'Pending', - id: 1234567890123456 - }, - executors: { - executorsNumber: 3, - list: [ - {firstName: 'John', lastName: 'TheApplicant', isApplying: true, isApplicant: true}, - {fullName: 'Many Clouds', isApplying: true}, - {fullName: 'Harvey Smith', isApplying: false} - ] - }, - applicant: {} - }; - }); - - afterEach(() => { - testWrapper.destroy(); - }); - - describe('Verify Content, Errors and Redirection', () => { - testCommonContent.runTest('ExecutorsDealingWithEstate', null, null, [], false, {type: caseTypes.GOP}); - - it('test correct content loaded on the page when lead applicant does not have an alias', (done) => { - testWrapper.agent.post('/prepare-session/form') - .send(sessionData) - .end(() => { - testWrapper.testContent(done); - }); - }); - - it('test correct content loaded on the page when lead applicant does have an alias', (done) => { - sessionData.applicant.alias = 'Bobby Alias'; - testWrapper.agent.post('/prepare-session/form') - .send(sessionData) - .end(() => { - testWrapper.testContent(done); - }); - }); - - it('test errors message displayed for missing data', (done) => { - const errorsToTest = ['executorsApplying']; - - testWrapper.agent.post('/prepare-session/form') - .send(sessionData) - .end(() => { - testWrapper.testErrors(done, {}, 'required', errorsToTest); - }); - }); - - it('test errors message displayed for more than 3 additional applicants', (done) => { - const errorsToTest = ['executorsApplying']; - - testWrapper.agent.post('/prepare-session/form') - .send(sessionData) - .end(() => { - const data = { - executorsApplying: ['many clouds', 'many clouds', 'many clouds', 'many clouds'] - }; - - testWrapper.testErrors(done, data, 'invalid', errorsToTest); - }); - }); - }); -}); diff --git a/test/component/executors/testExecutorsNamed.js b/test/component/executors/testExecutorsNamed.js new file mode 100644 index 0000000000..7bc5de8440 --- /dev/null +++ b/test/component/executors/testExecutorsNamed.js @@ -0,0 +1,95 @@ +'use strict'; + +const TestWrapper = require('test/util/TestWrapper'); +const ExecutorsNames = require('app/steps/ui/executors/names'); +const Equality = require('app/steps/ui/equality'); +const testCommonContent = require('test/component/common/testCommonContent.js'); +const caseTypes = require('app/utils/CaseTypes'); + +describe('executors-named', () => { + let testWrapper, sessionData; + const expectedNextUrlForExecNames = ExecutorsNames.getUrl(); + const expectedNextUrlForEquality = Equality.getUrl(); + + beforeEach(() => { + testWrapper = new TestWrapper('ExecutorsNamed'); + sessionData = { + type: caseTypes.GOP, + ccdCase: { + state: 'Pending', + id: 1234567890123456 + }, + applicant: { + 'firstName': 'Bobby', + 'lastName': 'Applicant', + 'nameAsOnTheWill': 'optionYes', + 'isApplying': true, + 'isApplicant': true, + 'fullName': 'Bobby Applicant' + }, + executors: { + executorsNumber: 2, + list: [ + { + 'fullName': 'Fred Exec One', + 'isApplying': false + }, + { + 'fullName': 'Jeff Exec Two', + 'isApplying': false + } + ] + } + }; + }); + + afterEach(() => { + testWrapper.destroy(); + }); + + describe('Verify Content, Errors and Redirection', () => { + testCommonContent.runTest('ExecutorsNamed', null, null, [], false, {type: caseTypes.GOP}); + + it('test redirection to names page when selecting yes with multiple executors', (done) => { + const data = {executorsNamed: 'optionYes'}; + testWrapper.testRedirect(done, data, expectedNextUrlForExecNames); + }); + + it('test redirection to equality page when selecting no', (done) => { + const data = {list: [{ + 'fullName': 'Jeff Exec Two', + 'isApplying': false + }], + executorsNamed: 'optionNo'}; + testWrapper.testRedirect(done, data, expectedNextUrlForEquality); + }); + + it('test errors message displayed for no number entered', (done) => { + testWrapper.testErrors(done, {}, 'required'); + }); + + //Working on these below + it('test correct content loaded on the page when lead applicant does not have an alias', (done) => { + const contentToExclude = ['titleWithCodicil', 'hintTextWithCodicil']; + testWrapper.agent.post('/prepare-session/form') + .send(sessionData) + .end(() => { + testWrapper.testContent(done, {}, contentToExclude); + }); + }); + + it('test correct content loaded on the page when lead applicant does have an alias', (done) => { + const contentToExclude = ['titleWithCodicil', 'hintTextWithCodicil']; + sessionData.executors.list[0].fullName = 'Fred Exec One'; + testWrapper.agent.post('/prepare-session/form') + .send(sessionData) + .end(() => { + testWrapper.testContent(done, {}, contentToExclude); + }); + }); + + it('test errors message displayed for required data', (done) => { + testWrapper.testErrors(done, {}, 'required'); + }); + }); +}); diff --git a/test/component/executors/testExecutorsNames.js b/test/component/executors/testExecutorsNames.js index 176c87da62..022b84f7da 100644 --- a/test/component/executors/testExecutorsNames.js +++ b/test/component/executors/testExecutorsNames.js @@ -36,19 +36,21 @@ describe('executors-names', () => { testCommonContent.runTest('ExecutorsNames', null, null, [], false, {type: caseTypes.GOP}); it('test correct content loaded on the page when lead applicant does not have an alias', (done) => { + const idsToExclude = ['questionWithCodicil', 'paragraphWithCodicil']; testWrapper.agent.post('/prepare-session/form') .send(sessionData) .end(() => { - testWrapper.testContent(done); + testWrapper.testContent(done, {}, idsToExclude); }); }); it('test correct content loaded on the page when lead applicant does have an alias', (done) => { sessionData.executors.list[0].alias = 'Bobby Alias'; + const idsToExclude = ['questionWithCodicil', 'paragraphWithCodicil']; testWrapper.agent.post('/prepare-session/form') .send(sessionData) .end(() => { - testWrapper.testContent(done); + testWrapper.testContent(done, {}, idsToExclude); }); }); @@ -70,7 +72,7 @@ describe('executors-names', () => { .send(sessionData) .end(() => { const data = { - executorName: [''] + executorName: '' }; const errorsToTest = ['executorName']; diff --git a/test/component/executors/testExecutorsNumber.js b/test/component/executors/testExecutorsNumber.js deleted file mode 100644 index 55d9188272..0000000000 --- a/test/component/executors/testExecutorsNumber.js +++ /dev/null @@ -1,75 +0,0 @@ -'use strict'; - -const TestWrapper = require('test/util/TestWrapper'); -const Equality = require('app/steps/ui/equality'); -const ExecutorsNames = require('app/steps/ui/executors/names'); -const testCommonContent = require('test/component/common/testCommonContent.js'); -const caseTypes = require('app/utils/CaseTypes'); - -describe('executors-number', () => { - let testWrapper; - const expectedNextUrlForExecNames = ExecutorsNames.getUrl(); - const expectedNextUrlForEquality = Equality.getUrl(); - - beforeEach(() => { - testWrapper = new TestWrapper('ExecutorsNumber'); - }); - - afterEach(() => { - testWrapper.destroy(); - }); - - describe('Verify Content, Errors and Redirection', () => { - testCommonContent.runTest('ExecutorsNumber', null, null, [], false, {type: caseTypes.GOP}); - - it('test content loaded on the page', (done) => { - const sessionData = { - type: caseTypes.GOP, - ccdCase: { - state: 'Pending', - id: 1234567890123456 - } - }; - - testWrapper.agent.post('/prepare-session/form') - .send(sessionData) - .end(() => { - testWrapper.testContent(done); - }); - }); - - it('test errors message displayed for invalid data', (done) => { - const data = {executorsNumber: 'abd'}; - - testWrapper.testErrors(done, data, 'invalid'); - }); - - it('test errors message displayed for invalid data - negative numbers', (done) => { - const data = {executorsNumber: '-1'}; - - testWrapper.testErrors(done, data, 'invalid'); - }); - - it('test errors message displayed for no number entered', (done) => { - testWrapper.testErrors(done, {}, 'required'); - }); - - it('test it displays the errors when there are more than 20 executors', (done) => { - const data = {executorsNumber: 21}; - - testWrapper.testErrors(done, data, 'invalid'); - }); - - it(`test it redirects to next page: ${expectedNextUrlForExecNames}`, (done) => { - const data = {executorsNumber: 2}; - - testWrapper.testRedirect(done, data, expectedNextUrlForExecNames); - }); - - it(`test it redirects to next page when there is only one executor: ${expectedNextUrlForEquality}`, (done) => { - const data = {executorsNumber: 1}; - - testWrapper.testRedirect(done, data, expectedNextUrlForEquality); - }); - }); -}); diff --git a/test/component/executors/testExecutorsWhenDied.js b/test/component/executors/testExecutorsWhenDied.js index 4685b24a86..d84f2122b7 100644 --- a/test/component/executors/testExecutorsWhenDied.js +++ b/test/component/executors/testExecutorsWhenDied.js @@ -3,7 +3,6 @@ const initSteps = require('app/core/initSteps'); const assert = require('chai').assert; const TestWrapper = require('test/util/TestWrapper'); -const contentData = {executorFullName: 'many clouds'}; const commonContent = require('app/resources/en/translation/common'); const caseTypes = require('app/utils/CaseTypes'); @@ -53,6 +52,10 @@ describe('executors-when-died', () => { {fullName: 'many clouds', isDead: true}, {fullName: 'harvey smith', isDead: false} ] + }, + deceased: { + firstName: 'John', + lastName: 'Doe' } }; }); @@ -87,19 +90,16 @@ describe('executors-when-died', () => { testWrapper.agent.post('/prepare-session/form') .send(sessionData) .end(() => { + const contentData = {deceasedName: 'John Doe', executorFullName: 'Many Clouds'}; + testWrapper.testContent(done, contentData); }); }); it('test errors message displayed for missing data', (done) => { testWrapper.pageUrl = testWrapper.pageToTest.constructor.getUrl(1); - testWrapper.agent.post('/prepare-session/form') - .send(sessionData) - .end(() => { - const data = { - }; - testWrapper.testErrors(done, data, 'required'); - }); + const errorsToTest = ['diedbefore']; + testWrapper.testErrors(done, {}, 'required', errorsToTest); }); }); diff --git a/test/component/executors/testNotified.js b/test/component/executors/testNotified.js index 711e59346d..9fa20828de 100644 --- a/test/component/executors/testNotified.js +++ b/test/component/executors/testNotified.js @@ -52,13 +52,12 @@ describe('executor-notified', () => { }); it('test right content loaded on the page', (done) => { - + testWrapper.pageUrl = testWrapper.pageToTest.constructor.getUrl(1); testWrapper.agent.post('/prepare-session/form') .send(sessionData) .end(() => { const contentData = {executorName: 'Manah Mana'}; - testWrapper.pageUrl = testWrapper.pageToTest.constructor.getUrl(1); testWrapper.testContent(done, contentData); }); }); diff --git a/test/component/executors/testRoles.js b/test/component/executors/testRoles.js index a6c96f0275..2948d85bf9 100644 --- a/test/component/executors/testRoles.js +++ b/test/component/executors/testRoles.js @@ -71,7 +71,7 @@ describe('executor-roles', () => { .send(sessionData) .end(() => { const contentData = { - executorFullName: 'Mana Manah', + executorName: 'Mana Manah', applicationFormPA15: config.links.applicationFormPA15 }; @@ -81,17 +81,9 @@ describe('executor-roles', () => { }); it('test schema validation when executor is not applying', (done) => { - testWrapper.agent.post('/prepare-session/form') - .send(sessionData) - .end(() => { - const errorsToTest = ['notApplyingReason']; - const data = { - notApplyingReason: null - }; - - testWrapper.pageUrl = testWrapper.pageToTest.constructor.getUrl(1); - testWrapper.testErrors(done, data, 'required', errorsToTest); - }); + testWrapper.pageUrl = testWrapper.pageToTest.constructor.getUrl(1); + const errorsToTest = ['notApplyingReason']; + testWrapper.testErrors(done, {}, 'required', errorsToTest); }); }); diff --git a/test/component/summary/testExecutorsSection.js b/test/component/summary/testExecutorsSection.js index 31fb3c702d..851d6c52d2 100644 --- a/test/component/summary/testExecutorsSection.js +++ b/test/component/summary/testExecutorsSection.js @@ -132,7 +132,6 @@ describe('summary-executor-section', () => { testWrapper.testDataPlayback(done, playbackData); }); }); - it('test data is played back correctly on the summary page executors section', (done) => { const executorsData = require('test/data/summary-executors'); @@ -148,7 +147,7 @@ describe('summary-executor-section', () => { questionLastName: applicantNameContent.lastName, questionPhoneNumber: applicantPhoneContent.phoneNumber, questionApplicantAddress: applicantAddressContent.question, - questionExecutorsAllAlive: executorsAllAliveContent.question, + questionExecutorsAllAlive: executorsAllAliveContent.multipleExecutorQuestion, allAlive: executorsAllAliveContent[executorsData.executors.allAlive], @@ -160,7 +159,7 @@ describe('summary-executor-section', () => { exec3fullName: executorsData.executors.list[2].fullName, exec3IsApplying: executorsData.executors.list[2].isApplying ? executorsApplyingContent.optionYes : executorsApplyingContent.optionNo, - exec3NotApplyingReason: executorsRoles[executorsData.executors.list[2].notApplyingReason], + exec3NotApplyingReason: executorsRoles[executorsData.executors.list[2].notApplyingReason].replace('{executorName}', executorsData.executors.list[2].fullName), exec4fullName: executorsData.executors.list[3].fullName, exec4IsApplying: executorsData.executors.list[3].isApplying ? executorsApplyingContent.optionYes : executorsApplyingContent.optionNo, @@ -171,7 +170,6 @@ describe('summary-executor-section', () => { playbackData.address = executorsData.applicant.address.formattedAddress; playbackData.nameAsOnTheWill = applicantNameAsOnWillContent[playbackData.nameAsOnTheWill]; playbackData.aliasReason = applicantAliasReasonContent[playbackData.aliasReason]; - testWrapper.testDataPlayback(done, playbackData); }); }); diff --git a/test/data/complete-form-will-condition-toggle-on.json b/test/data/complete-form-will-condition-toggle-on.json index 13b9e0524c..60162d23cf 100644 --- a/test/data/complete-form-will-condition-toggle-on.json +++ b/test/data/complete-form-will-condition-toggle-on.json @@ -92,6 +92,7 @@ { "fullName": "Number 2", "isApplying": true, + "hasOtherName": false, "email": "test@email.com", "mobile": "07234156431", "address": { @@ -108,8 +109,9 @@ } ], "executorsNumber": 2, + "executorsNamed": "optionNo", "invitesSent": "true", - "allalive": "optionYes", + "allalive": "optionNo", "otherExecutorsApplying": "optionYes", "alias": "optionNo", "mentalCapacity": "optionYes" diff --git a/test/data/complete-form.json b/test/data/complete-form.json index c2a521bc48..16ae41de3d 100644 --- a/test/data/complete-form.json +++ b/test/data/complete-form.json @@ -93,6 +93,9 @@ "isApplying": true, "email": "test@email.com", "mobile": "07234156431", + "hasOtherName": true, + "currentName": "Number 2", + "currentNameReason": "optionMarriage", "address": { "addressLine1": "21 Treelined Avenue", "addressLine2": "", @@ -107,8 +110,9 @@ } ], "executorsNumber": 2, + "executorsNamed": "optionNo", "invitesSent": "true", - "allalive": "optionYes", + "allalive": "optionNo", "otherExecutorsApplying": "optionYes", "alias": "optionNo", "mentalCapacity": "optionYes" diff --git a/test/data/summary-executors.json b/test/data/summary-executors.json index a5a7cd1fe7..4143eacbf3 100644 --- a/test/data/summary-executors.json +++ b/test/data/summary-executors.json @@ -9,8 +9,10 @@ }, "executors": { - "executorsNumber": 3, + "executorsNamed": "optionNo", + "executorsNumber": 3, "otherExecutorsApplying": "optionYes", + "executorsApplying": ["dean plummer", "sam simms"], "allAlive": "optionNo", "list": [ { diff --git a/test/unit/executors/testExecutorCurrentName.js b/test/unit/executors/testExecutorCurrentName.js index 1190d1bc85..c761f7be4b 100644 --- a/test/unit/executors/testExecutorCurrentName.js +++ b/test/unit/executors/testExecutorCurrentName.js @@ -93,7 +93,7 @@ describe('ExecutorCurrentName', () => { }; const ExecutorCurrentName = steps.ExecutorCurrentName; const nextStepUrl = ExecutorCurrentName.nextStepUrl(req, ctx); - expect(nextStepUrl).to.equal('/executor-current-name-reason/1'); + expect(nextStepUrl).to.equal('/executor-name-reason/1'); done(); }); }); diff --git a/test/unit/executors/testExecutorCurrentNameReason.js b/test/unit/executors/testExecutorCurrentNameReason.js index 4ed3775640..cd777eef75 100644 --- a/test/unit/executors/testExecutorCurrentNameReason.js +++ b/test/unit/executors/testExecutorCurrentNameReason.js @@ -6,7 +6,7 @@ const initSteps = require('app/core/initSteps'); const {assert, expect} = require('chai'); const ExecutorsWrapper = require('app/wrappers/Executors'); const journey = require('app/journeys/probate'); -const executorCurrentNameReasonPath = '/executor-current-name-reason/'; +const executorCurrentNameReasonPath = '/executor-name-reason/'; describe('ExecutorCurrentNameReason', () => { const steps = initSteps([`${__dirname}/../../../app/steps/action/`, `${__dirname}/../../../app/steps/ui`]); @@ -87,13 +87,13 @@ describe('ExecutorCurrentNameReason', () => { it('sets the index when startsWith(req.path, path)', (done) => { const req = { - path: '/executor-current-name-reason/', + path: '/executor-name-reason/', session: { form: { executors: { list: [ - {currentName: 'executor current name', hasOtherName: true}, - {currentName: 'bob smith', hasOtherName: true} + {currentName: 'executor current name', isApplying: true, hasOtherName: true}, + {currentName: 'bob smith', isApplying: true, hasOtherName: true} ] } } @@ -255,7 +255,7 @@ describe('ExecutorCurrentNameReason', () => { }, { isApplying: true }], - index: -1, + index: 1, executorsWrapper: new ExecutorsWrapper(), currentNameReason: 'optionMarriage' }); @@ -275,7 +275,7 @@ describe('ExecutorCurrentNameReason', () => { }; const index = ExecutorCurrentNameReason.recalcIndex(testCtx, 0); - expect(index).to.equal(2); + expect(index).to.equal(1); done(); }); @@ -318,7 +318,7 @@ describe('ExecutorCurrentNameReason', () => { }; const ExecutorCurrentNameReason = steps.ExecutorCurrentNameReason; const nextStepUrl = ExecutorCurrentNameReason.nextStepUrl(req, ctx); - expect(nextStepUrl).to.equal('/executor-current-name/1'); + expect(nextStepUrl).to.equal('/executors-alias/1'); done(); }); }); @@ -374,4 +374,37 @@ describe('ExecutorCurrentNameReason', () => { done(); }); }); + describe('ExecutorCurrentNameReason isComplete', () => { + let ctx; + + beforeEach(() => { + ctx = { + list: [ + {fullName: 'Executor 1', hasOtherName: true, currentNameReason: 'Reason 1'}, + {fullName: 'Executor 2', hasOtherName: true, currentNameReason: 'Reason 2'}, + {fullName: 'Executor 3', hasOtherName: false} + ] + }; + }); + + it('should return inProgress if all executors with another name have a current name reason', () => { + const result = ExecutorCurrentNameReason.isComplete(ctx); + expect(result).to.deep.equal([true, 'inProgress']); + }); + + it('should return inProgress if no executors have another name', () => { + ctx.list = [ + {fullName: 'Executor 1', hasOtherName: false}, + {fullName: 'Executor 2', hasOtherName: false} + ]; + const result = ExecutorCurrentNameReason.isComplete(ctx); + expect(result).to.deep.equal([true, 'inProgress']); + }); + + it('should return inProgress if executors list is empty', () => { + ctx.list = []; + const result = ExecutorCurrentNameReason.isComplete(ctx); + expect(result).to.deep.equal([true, 'inProgress']); + }); + }); }); diff --git a/test/unit/executors/testExecutorNames.js b/test/unit/executors/testExecutorNames.js index a989402f6e..d0ebf0423c 100644 --- a/test/unit/executors/testExecutorNames.js +++ b/test/unit/executors/testExecutorNames.js @@ -50,4 +50,27 @@ describe('ExecutorsNames', () => { done(); }); }); + describe('handlePost', () => { + it('should initialize ctx.list if it does not exist', () => { + const ctx = {}; + const errors = []; + ExecutorsNames.handlePost(ctx, errors); + expect(ctx.list).to.deep.equal([]); + }); + + it('should add executorName to ctx.list if executorName exists and is not empty', () => { + const ctx = {executorName: 'John Doe'}; + const errors = []; + ExecutorsNames.handlePost(ctx, errors); + expect(ctx.list).to.deep.equal([{fullName: 'John Doe'}]); + }); + }); + describe('action', () => { + it('should delete applicantCurrentName and executorName from ctx', () => { + const ctx = {applicantCurrentName: 'John Doe', executorName: 'Jane Doe'}; + const formdata = {}; + const result = ExecutorsNames.action(ctx, formdata); + expect(result).to.deep.equal([{}, formdata]); + }); + }); }); diff --git a/test/unit/executors/testExecutorNotified.js b/test/unit/executors/testExecutorNotified.js index 79aaee4ffb..1663f5363e 100644 --- a/test/unit/executors/testExecutorNotified.js +++ b/test/unit/executors/testExecutorNotified.js @@ -77,4 +77,33 @@ describe('ExecutorNotified', () => { assert.isUndefined(ctx.nextExecutor); }); }); + describe('ExecutorNotified generateFields', () => { + let ctx; + let errors; + let language; + + beforeEach(() => { + ctx = { + list: [ + {fullName: 'Executor 1', isDead: false}, + {fullName: 'Executor 2', isDead: false} + ], + executorName: 'Executor 1', + index: 0 + }; + errors = [{msg: 'Error message for {executorName}'}]; + language = 'en'; + }); + + it('should replace {executorName} placeholder in error message if executorName is present', () => { + ExecutorNotified.generateFields(language, ctx, errors); + expect(errors[0].msg).to.equal('Error message for Executor 1'); + }); + + it('should not modify error message if executorName is not present in fields', () => { + ctx.executorName = ''; + ExecutorNotified.generateFields(language, ctx, errors); + expect(errors[0].msg).to.equal('Error message for '); + }); + }); }); diff --git a/test/unit/executors/testExecutorWhenDied.js b/test/unit/executors/testExecutorWhenDied.js index 8fa3f90f25..6f77373ca4 100644 --- a/test/unit/executors/testExecutorWhenDied.js +++ b/test/unit/executors/testExecutorWhenDied.js @@ -78,4 +78,66 @@ describe('ExecutorWhenDied', () => { assert.isUndefined(ctx.allDead); }); }); + describe('ExecutorsWhenDied generateFields', () => { + let ctx; + let errors; + let language; + + beforeEach(() => { + ctx = { + list: [ + {fullName: 'Executor 1', isDead: true}, + {fullName: 'Executor 2', isDead: false} + ], + deceasedName: 'Deceased Name', + executorFullName: 'Executor 1' + }; + errors = [{msg: 'Error message for {deceasedName} and {executorName}'}]; + language = 'en'; + }); + + it('should replace {deceasedName} and {executorName} placeholders in error message', () => { + ExecutorWhenDied.generateFields(language, ctx, errors); + expect(errors[0].msg).to.equal('Error message for Deceased Name and Executor 1'); + }); + + it('should not modify error message if executorFullName is not present in fields', () => { + ctx.executorFullName = ''; + ExecutorWhenDied.generateFields(language, ctx, errors); + expect(errors[0].msg).to.equal('Error message for Deceased Name and '); + }); + }); + describe('ExecutorsWhenDied isComplete', () => { + let ctx; + + beforeEach(() => { + ctx = { + list: [ + {fullName: 'Executor 1', isDead: true, diedBefore: 'optionYes'}, + {fullName: 'Executor 2', isDead: true, diedBefore: 'optionNo'}, + {fullName: 'Executor 3', isDead: false} + ] + }; + }); + + it('should return inProgress if all dead executors have diedBefore property', () => { + const result = ExecutorWhenDied.isComplete(ctx); + expect(result).to.deep.equal([true, 'inProgress']); + }); + + it('should return inProgress if no executors are dead', () => { + ctx.list = [ + {fullName: 'Executor 1', isDead: false}, + {fullName: 'Executor 2', isDead: false} + ]; + const result = ExecutorWhenDied.isComplete(ctx); + expect(result).to.deep.equal([true, 'inProgress']); + }); + + it('should return inProgress if executors list is empty', () => { + ctx.list = []; + const result = ExecutorWhenDied.isComplete(ctx); + expect(result).to.deep.equal([true, 'inProgress']); + }); + }); }); diff --git a/test/unit/executors/testExecutorsAlias.js b/test/unit/executors/testExecutorsAlias.js index b55e2391f6..d1594587a9 100644 --- a/test/unit/executors/testExecutorsAlias.js +++ b/test/unit/executors/testExecutorsAlias.js @@ -9,7 +9,7 @@ describe('Executors-Alias', () => { describe('getUrl()', () => { it('should return the correct url', (done) => { const url = ExecutorsAlias.constructor.getUrl(); - expect(url).to.equal('/executors-alias'); + expect(url).to.equal('/executors-alias/*'); done(); }); }); @@ -21,8 +21,8 @@ describe('Executors-Alias', () => { ctx = { alias: 'optionNo', list: [ - {fullName: 'Ronnie D', hasOtherName: true, currentName: 'Steve', currentNameReason: 'optionMarriage'}, - {fullName: 'Aggie D', hasOtherName: true, currentName: 'Danny', currentNameReason: 'optionOther', otherReason: 'Yolo'} + {fullName: 'Ronnie D', hasOtherName: false, currentName: 'Steve', currentNameReason: 'optionMarriage'}, + {fullName: 'Aggie D', hasOtherName: false, currentName: 'Danny', currentNameReason: 'optionOther', otherReason: 'Yolo'} ] }; ctx = ExecutorsAlias.pruneFormData(ctx); @@ -55,4 +55,155 @@ describe('Executors-Alias', () => { done(); }); }); + + describe('ExecutorsAlias handleGet', () => { + let ctx; + + beforeEach(() => { + ctx = { + list: [ + {fullName: 'Executor 1', hasOtherName: false}, + {fullName: 'Executor 2', hasOtherName: true}, + {fullName: 'Executor 3'} + ], + index: 0 + }; + }); + + it('should set alias to optionYes if executor has other name', () => { + ctx.index = 1; + [ctx] = ExecutorsAlias.handleGet(ctx); + expect(ctx.alias).to.equal('optionYes'); + }); + + it('should set alias to optionNo if executor does not have other name', () => { + ctx.index = 0; + [ctx] = ExecutorsAlias.handleGet(ctx); + expect(ctx.alias).to.equal('optionNo'); + }); + + it('should set alias to empty string if executor hasOtherName is not defined', () => { + ctx.index = 2; + [ctx] = ExecutorsAlias.handleGet(ctx); + expect(ctx.alias).to.equal(''); + }); + }); + describe('ExecutorsAlias nextStepUrl', () => { + let ctx; + let req; + beforeEach(() => { + ctx = { + alias: '', + index: 0, + list: [ + {fullName: 'Executor 1', isApplying: true}, + {fullName: 'Executor 2', isApplying: true} + ] + }; + req = {}; + }); + + it('should return the URL for the next executor if alias is optionNo and there is another executor', () => { + ctx.alias = 'optionNo'; + const url = ExecutorsAlias.nextStepUrl(req, ctx); + expect(url).to.equal('/executors-alias/1'); + }); + + it('should return the URL for executor contact details if alias is optionNo and there are no more executors', () => { + ctx.alias = 'optionNo'; + ctx.index = 1; + const url = ExecutorsAlias.nextStepUrl(req, ctx); + expect(url).to.equal('/executor-contact-details/1'); + }); + + it('should return the URL for executor ID name if alias is optionYes', () => { + ctx.alias = 'optionYes'; + const url = ExecutorsAlias.nextStepUrl(req, ctx); + expect(url).to.equal('/executor-id-name/0'); + }); + }); + describe('ExecutorsAlias generateFields', () => { + let ctx; + let errors; + let language; + + beforeEach(() => { + ctx = { + list: [ + {fullName: 'Executor 1', hasOtherName: false}, + {fullName: 'Executor 2', hasOtherName: true} + ], + otherExecName: 'Executor 2' + }; + errors = [{msg: 'Error message for {executorName}'}]; + language = 'en'; + }); + + it('should replace {executorName} placeholder in error message with executor name', () => { + ExecutorsAlias.generateFields(language, ctx, errors); + expect(errors[0].msg).to.equal('Error message for Executor 2'); + }); + + it('should not modify error message if otherExecName is not present in fields', () => { + ctx.otherExecName = ''; + ExecutorsAlias.generateFields(language, ctx, errors); + expect(errors[0].msg).to.equal('Error message for '); + }); + }); + describe('isComplete', () => { + it('returns true and inProgress when all executors are valid', () => { + const ctx = { + list: [ + {fullName: 'Executor one', isApplying: true, hasOtherName: true, currentName: 'John Doe', currentNameReason: 'Legal'}, + {fullName: 'Executor one', isApplying: true, hasOtherName: false} + ] + }; + const result = ExecutorsAlias.isComplete(ctx); + expect(result).to.deep.equal([true, 'inProgress']); + }); + + it('returns false and inProgress when an executor with other name is missing currentName', () => { + const ctx = { + list: [ + {fullName: 'Executor one', isApplying: true, hasOtherName: true, currentNameReason: 'Legal'}, + {fullName: 'Executor one', isApplying: true, hasOtherName: false} + ] + }; + const result = ExecutorsAlias.isComplete(ctx); + expect(result).to.deep.equal([false, 'inProgress']); + }); + + it('returns false and inProgress when an executor with other name is missing currentNameReason', () => { + const ctx = { + list: [ + {fullName: 'Executor one', isApplying: true, hasOtherName: true, currentName: 'John Doe'}, + {fullName: 'Executor one', isApplying: true, hasOtherName: false} + ] + }; + const result = ExecutorsAlias.isComplete(ctx); + expect(result).to.deep.equal([false, 'inProgress']); + }); + + it('returns false and inProgress when an executor with other name is missing both currentName and currentNameReason', () => { + const ctx = { + list: [ + {fullName: 'Executor one', isApplying: true, hasOtherName: true}, + {fullName: 'Executor one', isApplying: true, hasOtherName: false} + ] + }; + const result = ExecutorsAlias.isComplete(ctx); + expect(result).to.deep.equal([false, 'inProgress']); + }); + + it('returns true and inProgress when all executors have hasOtherName as false', () => { + const ctx = { + list: [ + {fullName: 'Executor one', isApplying: true, hasOtherName: false}, + {fullName: 'Executor one', isApplying: true, hasOtherName: false} + ] + }; + const result = ExecutorsAlias.isComplete(ctx); + expect(result).to.deep.equal([true, 'inProgress']); + }); + }); }); diff --git a/test/unit/executors/testExecutorsAllAlive.js b/test/unit/executors/testExecutorsAllAlive.js index 3e297dca04..e2435e4d07 100644 --- a/test/unit/executors/testExecutorsAllAlive.js +++ b/test/unit/executors/testExecutorsAllAlive.js @@ -8,7 +8,7 @@ const ExecutorsAllAlive = steps.ExecutorsAllAlive; describe('ExecutorsAllAlive', () => { describe('nextStepUrl()', () => { - it('should return url for the next step if all the excutors are alive', (done) => { + it('should return url for the next step if all the executors are not alive', (done) => { const req = { session: { journey: journey @@ -18,11 +18,11 @@ describe('ExecutorsAllAlive', () => { allalive: 'optionYes' }; const nextStepUrl = ExecutorsAllAlive.nextStepUrl(req, ctx); - expect(nextStepUrl).to.equal('/other-executors-applying'); + expect(nextStepUrl).to.equal('/executors-who-died'); done(); }); - it('should return url for the next step if all the executors are not alive', (done) => { + it('should return url for the next step if all the executors are alive', (done) => { const req = { session: { journey: journey @@ -32,7 +32,7 @@ describe('ExecutorsAllAlive', () => { allalive: 'optionNo' }; const nextStepUrl = ExecutorsAllAlive.nextStepUrl(req, ctx); - expect(nextStepUrl).to.equal('/executors-who-died'); + expect(nextStepUrl).to.equal('/other-executors-applying'); done(); }); }); diff --git a/test/unit/executors/testExecutorsApplying.js b/test/unit/executors/testExecutorsApplying.js index e3a52cd6f0..5db56773d8 100644 --- a/test/unit/executors/testExecutorsApplying.js +++ b/test/unit/executors/testExecutorsApplying.js @@ -1,9 +1,12 @@ 'use strict'; const initSteps = require('app/core/initSteps'); +const {expect} = require('chai'); const assert = require('chai').assert; describe('Executors-Applying', () => { let ctx; + let errors; + let data; const ExecsApplying = initSteps([`${__dirname}/../../../app/steps/action/`, `${__dirname}/../../../app/steps/ui`]).ExecutorsApplying; describe('handlePost', () => { @@ -28,18 +31,235 @@ describe('Executors-Applying', () => { }; }); - it('test executor isApplying flag is deleted when No option is selected', () => { - ctx.otherExecutorsApplying = 'optionNo'; + it('test executor isApplying flag is deleted when no executor is applying', () => { + ctx.executorsApplying = []; ExecsApplying.handlePost(ctx); assert.isUndefined(ctx.list[1].isApplying); assert.isUndefined(ctx.list[2].isApplying); }); - it('test executor isApplying flag is true when Yes option selected', () => { - ctx.otherExecutorsApplying = 'optionYes'; + it('test executor isApplying flag is true when multiple executors are applying', () => { + ctx.executorsApplying = ['Ed Brown', 'Dave Miller']; ExecsApplying.handlePost(ctx); assert.isTrue(ctx.list[1].isApplying); assert.isTrue(ctx.list[2].isApplying); }); + it('test executor isApplying flag is true when single executor is applying', () => { + ctx.list= [ + { + lastName: 'the', + firstName: 'applicant', + isApplying: true, + isApplicant: true + }, { + isApplying: true, + fullName: 'Ed Brown', + address: '20 Green Street, London, L12 9LN' + } + ]; + ctx.otherExecutorsApplying = 'optionYes'; + ExecsApplying.handlePost(ctx); + assert.isTrue(ctx.list[1].isApplying); + }); + it('test executor isApplying flag is false when single executor is not applying', () => { + ctx.list= [ + { + lastName: 'the', + firstName: 'applicant', + isApplying: true, + isApplicant: true + }, { + isApplying: true, + fullName: 'Ed Brown', + address: '20 Green Street, London, L12 9LN' + } + ]; + ctx.otherExecutorsApplying = 'optionNo'; + [ctx, errors] = ExecsApplying.handlePost(ctx); + assert.isUndefined(ctx.list[1].isApplying); + assert.isEmpty(errors); + }); + it('should add an error if applyingCount is greater than 4', () => { + ctx.list.push({fullName: 'Executor 3', isApplying: true}); + ctx.list.push({fullName: 'Executor 4', isApplying: true}); + ctx.executorsApplying = ['Ed Brown', 'Dave Miller', 'Executor 3', 'Executor 4']; + const invalid = 'You can not select more than 4 executors'; + + [ctx, errors] = ExecsApplying.handlePost(ctx, errors, {}, {language: 'en'}); + + expect(errors).to.deep.equal([ + { + field: 'executorsApplying', + href: '#executorsApplying', + msg: invalid + } + ]); + }); + + it('should not add an error if applyingCount is 4 or less', () => { + ctx.list.push({fullName: 'Executor 3', isApplying: true}); + ctx.list.push({fullName: 'Executor 4', isApplying: true}); + ctx.executorsApplying = ['Ed Brown', 'Dave Miller']; + + [ctx, errors] = ExecsApplying.handlePost(ctx); + + expect(errors).to.deep.equal([]); + }); + }); + + describe('getContextData()', () => { + let req; + beforeEach(() => { + req = { + session: { + form: { + applicant: { + firstName: 'Robert', + lastName: 'Bruce', + nameAsOnTheWill: 'optionYes', + phone: '075345435345', + address: '102 Petty France' + }, + executors: { + list: [ + { + 'lastName': 'Bruce', + 'firstName': 'Robert', + 'isApplying': 'optionYes', + 'isApplicant': true + }, { + isApplying: true, + fullName: 'Ed Brown', + address: '20 Green Street, London, L12 9LN' + }, { + isApplying: true, + fullName: 'Dave Miller', + address: '102 Petty Street, London, L12 9LN' + } + ] + } + } + } + }; + }); + + it('should set the formatted lead applicant name as the option when there is no Applicant Alias', (done) => { + ctx = ExecsApplying.getContextData(req); + expect(ctx.options).to.deep.equal([ + {text: 'Robert Bruce', value: 'Robert Bruce', checked: true, disabled: true}, + {text: 'Ed Brown', value: 'Ed Brown', checked: true}, + {text: 'Dave Miller', value: 'Dave Miller', checked: true} + ]); + done(); + }); + + it('should set the lead applicant alias as the option when the Applicant Alias is set', (done) => { + req.session.form.applicant.alias = 'Bobby Alias'; + ctx = ExecsApplying.getContextData(req); + expect(ctx.options).to.deep.equal([ + {text: 'Bobby Alias', value: 'Bobby Alias', checked: true, disabled: true}, + {text: 'Ed Brown', value: 'Ed Brown', checked: true}, + {text: 'Dave Miller', value: 'Dave Miller', checked: true} + ]); + done(); + }); + + it('should set checked to false when isApplying is false for other executor', (done) => { + req.session.form.executors.list[1].isApplying = false; + ctx = ExecsApplying.getContextData(req); + expect(ctx.options).to.deep.equal([ + {text: 'Robert Bruce', value: 'Robert Bruce', checked: true, disabled: true}, + {text: 'Ed Brown', value: 'Ed Brown', checked: false}, + {text: 'Dave Miller', value: 'Dave Miller', checked: true} + ]); + done(); + }); + }); + + describe('pruneExecutorData', () => { + it('test that isApplying flag is deleted when executor is not applying', () => { + data = { + fullName: 'Ed Brown', + isApplying: false + }; + ExecsApplying.pruneExecutorData(data); + assert.isUndefined(data.isApplying); + expect(data).to.deep.equal({fullName: 'Ed Brown'}); + }); + + it('test that notApplying data is pruned when executor is applying', () => { + data = { + fullName: 'Ed Brown', + isApplying: true, + isDead: 'not sure', + diedBefore: 'not sure', + notApplyingReason: 'not sure', + notApplyingKey: 'not sure' + }; + ExecsApplying.pruneExecutorData(data); + expect(data).to.deep.equal({ + fullName: 'Ed Brown', + isApplying: true + }); + }); + + const ctx = { + 'list': [ + { + 'lastName': 'Applicant', + 'firstName': 'Main', + 'isApplying': true, + 'isApplicant': true + }, + { + 'email': 'probate0@mailinator.com', + 'mobile': '07900123456', + 'address': 'Princes house address', + 'postcode': 'NW1 8SS', + 'fullName': 'Prince Rogers Nelson', + 'hasOtherName': true, + 'currentName': 'Prince', + 'isApplying': false, + 'notApplyingKey': 'optionRenunciated', + 'notApplyingReason': 'optionRenunciated', + 'currentNameReason': 'Divorce', + } + ] + }; + + it('removes email from data if isApplying is false', () => { + const data = ExecsApplying.pruneExecutorData(ctx.list[1]); + assert.isUndefined(data.email); + }); + + it('removes mobile from data if isApplying is false', () => { + const data = ExecsApplying.pruneExecutorData(ctx.list[1]); + assert.isUndefined(data.mobile); + }); + + it('removes address from data if isApplying is false', () => { + const data = ExecsApplying.pruneExecutorData(ctx.list[1]); + assert.isUndefined(data.address); + }); + + it('removes postcode from data if isApplying is false', () => { + const data = ExecsApplying.pruneExecutorData(ctx.list[1]); + assert.isUndefined(data.postcode); + }); + + it('removes currentName from data if isApplying is false', () => { + const data = ExecsApplying.pruneExecutorData(ctx.list[1]); + assert.isUndefined(data.currentName); + }); + + it('removes hasOtherName from data if isApplying is false', () => { + const data = ExecsApplying.pruneExecutorData(ctx.list[1]); + assert.isUndefined(data.hasOtherName); + }); + + it('removes currentNameReason from data if isApplying is false', () => { + const data = ExecsApplying.pruneExecutorData(ctx.list[1]); + assert.isUndefined(data.currentNameReason); + }); }); }); diff --git a/test/unit/executors/testExecutorsDealing.js b/test/unit/executors/testExecutorsDealing.js deleted file mode 100644 index 33cf7216a7..0000000000 --- a/test/unit/executors/testExecutorsDealing.js +++ /dev/null @@ -1,228 +0,0 @@ -'use strict'; - -const initSteps = require('app/core/initSteps'); -const {expect, assert} = require('chai'); - -describe('Executors-Applying', () => { - let ctx; - let ctxTest; - let data; - let errors; - const ExecsDealing = initSteps([`${__dirname}/../../../app/steps/action/`, `${__dirname}/../../../app/steps/ui`]).ExecutorsDealingWithEstate; - - describe('getContextData()', () => { - let req; - beforeEach(() => { - req = { - session: { - form: { - applicant: { - firstName: 'Robert', - lastName: 'Bruce', - nameAsOnTheWill: 'optionYes', - phone: '075345435345', - address: '102 Petty France' - }, - executors: { - list: [ - { - 'lastName': 'Bruce', - 'firstName': 'Robert', - 'isApplying': 'optionYes', - 'isApplicant': true - }, { - isApplying: true, - fullName: 'Ed Brown', - address: '20 Green Street, London, L12 9LN' - }, { - isApplying: true, - fullName: 'Dave Miller', - address: '102 Petty Street, London, L12 9LN' - } - ] - } - } - } - }; - }); - - it('should set the formatted lead applicant name as the option when there is no Applicant Alias', (done) => { - ctx = ExecsDealing.getContextData(req); - expect(ctx.options).to.deep.equal([ - {text: 'Robert Bruce', value: 'Robert Bruce', checked: true, disabled: true}, - {text: 'Ed Brown', value: 'Ed Brown', checked: true}, - {text: 'Dave Miller', value: 'Dave Miller', checked: true} - ]); - done(); - }); - - it('should set the lead applicant alias as the option when the Applicant Alias is set', (done) => { - req.session.form.applicant.alias = 'Bobby Alias'; - ctx = ExecsDealing.getContextData(req); - expect(ctx.options).to.deep.equal([ - {text: 'Bobby Alias', value: 'Bobby Alias', checked: true, disabled: true}, - {text: 'Ed Brown', value: 'Ed Brown', checked: true}, - {text: 'Dave Miller', value: 'Dave Miller', checked: true} - ]); - done(); - }); - - it('should set checked to false when isApplying is false for other executor', (done) => { - req.session.form.executors.list[1].isApplying = false; - ctx = ExecsDealing.getContextData(req); - expect(ctx.options).to.deep.equal([ - {text: 'Robert Bruce', value: 'Robert Bruce', checked: true, disabled: true}, - {text: 'Ed Brown', value: 'Ed Brown', checked: false}, - {text: 'Dave Miller', value: 'Dave Miller', checked: true} - ]); - done(); - }); - }); - - describe('pruneExecutorData', () => { - it('test that isApplying flag is deleted when executor is not applying', () => { - data = { - fullName: 'Ed Brown', - isApplying: false - }; - ExecsDealing.pruneExecutorData(data); - assert.isUndefined(data.isApplying); - expect(data).to.deep.equal({fullName: 'Ed Brown'}); - }); - - it('test that notApplying data is pruned when executor is applying', () => { - data = { - fullName: 'Ed Brown', - isApplying: true, - isDead: 'not sure', - diedBefore: 'not sure', - notApplyingReason: 'not sure', - notApplyingKey: 'not sure' - }; - ExecsDealing.pruneExecutorData(data); - expect(data).to.deep.equal({ - fullName: 'Ed Brown', - isApplying: true - }); - }); - - const ctx = { - 'list': [ - { - 'lastName': 'Applicant', - 'firstName': 'Main', - 'isApplying': true, - 'isApplicant': true - }, - { - 'email': 'probate0@mailinator.com', - 'mobile': '07900123456', - 'address': 'Princes house address', - 'postcode': 'NW1 8SS', - 'fullName': 'Prince Rogers Nelson', - 'hasOtherName': true, - 'currentName': 'Prince', - 'isApplying': false, - 'notApplyingKey': 'optionRenunciated', - 'notApplyingReason': 'optionRenunciated', - 'currentNameReason': 'Divorce', - } - ] - }; - - it('removes email from data if isApplying is false', () => { - const data = ExecsDealing.pruneExecutorData(ctx.list[1]); - assert.isUndefined(data.email); - }); - - it('removes mobile from data if isApplying is false', () => { - const data = ExecsDealing.pruneExecutorData(ctx.list[1]); - assert.isUndefined(data.mobile); - }); - - it('removes address from data if isApplying is false', () => { - const data = ExecsDealing.pruneExecutorData(ctx.list[1]); - assert.isUndefined(data.address); - }); - - it('removes postcode from data if isApplying is false', () => { - const data = ExecsDealing.pruneExecutorData(ctx.list[1]); - assert.isUndefined(data.postcode); - }); - - it('removes currentName from data if isApplying is false', () => { - const data = ExecsDealing.pruneExecutorData(ctx.list[1]); - assert.isUndefined(data.currentName); - }); - - it('removes hasOtherName from data if isApplying is false', () => { - const data = ExecsDealing.pruneExecutorData(ctx.list[1]); - assert.isUndefined(data.hasOtherName); - }); - - it('removes currentNameReason from data if isApplying is false', () => { - const data = ExecsDealing.pruneExecutorData(ctx.list[1]); - assert.isUndefined(data.currentNameReason); - }); - }); - - describe('handlePost', () => { - beforeEach(() => { - ctxTest = { - list: [ - { - 'lastName': 'the', - 'firstName': 'applicant', - 'isApplying': 'optionYes', - 'isApplicant': true - }, - { - fullName: 'Ed Brown', - address: '20 Green Street, London, L12 9LN' - }, - { - fullName: 'Dave Miller', - address: '102 Petty Street, London, L12 9LN' - }, - { - email: 'probate0@mailinator.com', - mobile: '07900123456', - address: 'cher address', - fullName: 'Cher', - isApplying: false, - notApplyingKey: 'optionRenunciated', - notApplyingReason: 'optionRenunciated' - } - ], - executorsApplying: ['Dave Miller'], - executorsNumber: 4 - }; - }); - - it('test executors (with checkbox unchecked) isApplying flag is deleted', () => { - [ctx, errors] = ExecsDealing.handlePost(ctxTest); - assert.isUndefined(ctx.list[1].isApplying); - assert.isUndefined(errors); - }); - - it('test executors (with checkbox checked) isApplying flag is set to true', () => { - [ctx, errors] = ExecsDealing.handlePost(ctxTest); - assert.isTrue(ctx.list[2].isApplying); - assert.isUndefined(errors); - }); - - it('should prune executor 3 data', () => { - [ctx, errors] = ExecsDealing.handlePost(ctxTest); - assert.isUndefined(ctx.list[3].isApplying); - assert.isUndefined(ctx.list[3].address); - assert.isUndefined(errors); - }); - - it('should not prune executor 2 data', () => { - [ctx, errors] = ExecsDealing.handlePost(ctxTest); - expect(ctx.list[2].isApplying).to.equal(true); - expect(ctx.list[2].address).to.equal('102 Petty Street, London, L12 9LN'); - assert.isUndefined(errors); - }); - }); -}); diff --git a/test/unit/executors/testExecutorsNamed.js b/test/unit/executors/testExecutorsNamed.js new file mode 100644 index 0000000000..12d79f97de --- /dev/null +++ b/test/unit/executors/testExecutorsNamed.js @@ -0,0 +1,213 @@ +'use strict'; +const initSteps = require('app/core/initSteps'); +const {expect, assert} = require('chai'); +const content = require('../../../app/resources/en/translation/executors/named.json'); +const steps = initSteps([`${__dirname}/../../../app/steps/action/`, `${__dirname}/../../../app/steps/ui`]); +const ExecutorsNamed = steps.ExecutorsNamed; + +describe('ExecutorsNamed', () => { + + describe('getUrl()', () => { + it('should return the correct url', (done) => { + const url = ExecutorsNamed.constructor.getUrl(); + expect(url).to.equal('/executors-named'); + done(); + }); + }); + + describe('nextStepOptions()', () => { + it('should return the correct options', (done) => { + const ctx = {}; + const nextStepOptions = ExecutorsNamed.nextStepOptions(ctx); + expect(nextStepOptions).to.deep.equal({ + options: [ + {key: 'multiExec', value: true, choice: 'multiExec'}, + {key: 'multiExecOptionNo', value: true, choice: 'multiExecOptionNo'}, + {key: 'singleExec', value: true, choice: 'otherwise'} + ] + }); + done(); + }); + }); + + describe('createExecutorList()', () => { + it('should create a list with the main applicant as the first executor', () => { + const ctx = {}; + const formdata = { + applicant: { + 'firstName': 'Dave', + 'lastName': 'Bassett', + 'nameAsOnTheWill': 'optionYes', + 'alias': 'David James', + 'aliasReason': 'Divorce', + 'otherReason': '' + }, + executors: [] + }; + ExecutorsNamed.createExecutorList(ctx, formdata); + assert.lengthOf(ctx.list, 1); + expect(ctx.list[0]).to.deep.equal({ + firstName: 'Dave', + lastName: 'Bassett', + nameAsOnTheWill: 'optionYes', + alias: 'David James', + aliasReason: 'Divorce', + otherReason: '', + isApplying: true, + isApplicant: true, + fullName: 'Dave Bassett' + }); + }); + + it('should handle an empty executors list', () => { + const ctx = {}; + const formdata = { + applicant: { + 'firstName': 'Dave', + 'lastName': 'Bassett', + 'nameAsOnTheWill': 'optionYes', + 'alias': 'David James', + 'aliasReason': 'Divorce', + 'otherReason': '' + }, + executors: [] + }; + ExecutorsNamed.createExecutorList(ctx, formdata); + assert.lengthOf(ctx.list, 1); + }); + + it('should handle multiple executors', () => { + const ctx = {}; + const formdata = { + applicant: { + 'firstName': 'Dave', + 'lastName': 'Bassett', + 'nameAsOnTheWill': 'optionYes', + 'alias': 'David James', + 'aliasReason': 'Divorce', + 'otherReason': '' + }, + executors: { + list: [ + { + 'firstName': 'Dave', + 'lastName': 'Bassett', + 'isApplying': 'optionYes', + 'isApplicant': true + }, { + fullName: 'Ed Brown' + }, { + fullName: 'Dave Miller' + } + ] + } + }; + ExecutorsNamed.createExecutorList(ctx, formdata); + assert.lengthOf(ctx.list, 3); + expect(ctx.list[1]).to.deep.equal({ + fullName: 'Ed Brown' + }); + expect(ctx.list[2]).to.deep.equal({ + fullName: 'Dave Miller' + }); + }); + }); + describe('isComplete', () => { + it('should return inProgresswhen executorsNamed is Yes', () => { + const ctx = {executorsNamed: 'optionYes'}; + const result = ExecutorsNamed.isComplete(ctx); + expect(result).to.deep.equal([true, 'inProgress']); + }); + + it('should return inProgress when executorsNamed is No', () => { + const ctx = {executorsNamed: 'optionNo'}; + const result = ExecutorsNamed.isComplete(ctx); + expect(result).to.deep.equal([true, 'inProgress']); + }); + + it('should not return inProgress when executorsNamed is undefined', () => { + const ctx = {}; + const result = ExecutorsNamed.isComplete(ctx); + expect(result).to.deep.equal([false, 'inProgress']); + }); + }); + describe('ExecutorsNamed handlePost', () => { + let ctx; + let errors; + let formdata; + let session; + + beforeEach(() => { + ctx = { + executorsNamed: '', + list: [], + codicilPresent: false + }; + errors = []; + formdata = {}; + session = {language: 'en'}; + }); + + it('should add requiredCodicils error if executorsNamed is empty and codicilPresent is true', () => { + ctx.codicilPresent = true; + [ctx, errors] = ExecutorsNamed.handlePost(ctx, errors, formdata, session); + expect(errors).to.deep.equal([ + { + field: 'executorsNamed', + href: '#executorsNamed', + msg: content.errors.executorsNamed.requiredCodicils + } + ]); + }); + + it('should add required error if executorsNamed is empty and codicilPresent is false', () => { + [ctx, errors] = ExecutorsNamed.handlePost(ctx, errors, formdata, session); + expect(errors).to.deep.equal([ + { + field: 'executorsNamed', + href: '#executorsNamed', + msg: content.errors.executorsNamed.required + } + ]); + }); + + it('should add invalid error if list length is less than 1', () => { + ctx.executorsNamed = 'optionYes'; + [ctx, errors] = ExecutorsNamed.handlePost(ctx, errors, formdata, session); + expect(errors).to.deep.equal([ + { + field: 'executorsNamed', + href: '#executorsNamed', + msg: content.errors.executorsNamed.invalid + } + ]); + }); + + it('should add invalid error if list length is greater than 20', () => { + ctx.executorsNamed = 'optionYes'; + ctx.list = new Array(21).fill({}); + [ctx, errors] = ExecutorsNamed.handlePost(ctx, errors, formdata, session); + expect(errors).to.deep.equal([ + { + field: 'executorsNamed', + href: '#executorsNamed', + msg: content.errors.executorsNamed.invalid + } + ]); + }); + + it('should set executorName if executorsNamed is optionYes', () => { + ctx.executorsNamed = 'optionYes'; + ctx.list = [{fullName: 'Executor 1'}, {fullName: 'Executor 2'}]; + [ctx, errors] = ExecutorsNamed.handlePost(ctx, errors, formdata, session); + expect(ctx.executorName).to.deep.equal(['Executor 1', 'Executor 2']); + }); + + it('should set executorsNumber to the length of the list', () => { + ctx.executorsNamed = 'optionYes'; + ctx.list = [{fullName: 'Executor 1'}, {fullName: 'Executor 2'}]; + [ctx, errors] = ExecutorsNamed.handlePost(ctx, errors, formdata, session); + expect(ctx.executorsNumber).to.equal(2); + }); + }); +}); diff --git a/test/unit/executors/testExecutorsNumber.js b/test/unit/executors/testExecutorsNumber.js deleted file mode 100644 index b8d4e33a27..0000000000 --- a/test/unit/executors/testExecutorsNumber.js +++ /dev/null @@ -1,123 +0,0 @@ -'use strict'; -const initSteps = require('app/core/initSteps'); -const {expect, assert} = require('chai'); -const steps = initSteps([`${__dirname}/../../../app/steps/action/`, `${__dirname}/../../../app/steps/ui`]); -const ExecutorsNumber = steps.ExecutorsNumber; - -describe('ExecutorsNumber', () => { - let ctx; - let formdata; - - describe('getUrl()', () => { - it('should return the correct url', (done) => { - const url = ExecutorsNumber.constructor.getUrl(); - expect(url).to.equal('/executors-number'); - done(); - }); - }); - - describe('nextStepOptions()', () => { - it('should return the correct options', (done) => { - const ctx = {}; - const nextStepOptions = ExecutorsNumber.nextStepOptions(ctx); - expect(nextStepOptions).to.deep.equal({ - options: [{ - key: 'executorsNumber', - value: 1, - choice: 'oneExecutor' - }] - }); - done(); - }); - }); - - describe('createExecutorList', () => { - beforeEach(() => { - ctx = {}; - formdata = { - applicant: { - 'firstName': 'Dave', - 'lastName': 'Bassett', - 'nameAsOnTheWill': 'optionYes', - 'alias': 'David James', - 'aliasReason': 'Divorce', - 'otherReason': '' - }, - executors: { - list: [ - { - 'firstName': 'Dave', - 'lastName': 'Bassett', - 'isApplying': 'optionYes', - 'isApplicant': true - }, { - fullName: 'Ed Brown' - }, { - fullName: 'Dave Miller' - } - ] - } - }; - }); - - it('test only the main applicant is in the executors list when executors number is reduced', () => { - ctx.executorsNumber = 2; - ctx = ExecutorsNumber.createExecutorList(ctx, formdata); - assert.lengthOf(ctx.list, 1); - expect(ctx.list).to.deep.equal([{ - 'firstName': 'Dave', - 'lastName': 'Bassett', - 'nameAsOnTheWill': 'optionYes', - 'alias': 'David James', - 'aliasReason': 'Divorce', - 'otherReason': '', - 'isApplying': true, - 'isApplicant': true - }]); - }); - - it('test only the executors list remains the same when executors number is not reduced', () => { - ctx.executorsNumber = 3; - ctx = ExecutorsNumber.createExecutorList(ctx, formdata); - assert.lengthOf(ctx.list, 3); - expect(ctx.list).to.deep.equal([ - { - 'firstName': 'Dave', - 'lastName': 'Bassett', - 'nameAsOnTheWill': 'optionYes', - 'alias': 'David James', - 'aliasReason': 'Divorce', - 'otherReason': '', - 'isApplying': true, - 'isApplicant': true - }, { - fullName: 'Ed Brown' - }, { - fullName: 'Dave Miller' - } - ]); - }); - - it('test only the executors list remains the same when executors number is increased', () => { - ctx.executorsNumber = 5; - ctx = ExecutorsNumber.createExecutorList(ctx, formdata); - assert.lengthOf(ctx.list, 3); - expect(ctx.list).to.deep.equal([ - { - 'firstName': 'Dave', - 'lastName': 'Bassett', - 'nameAsOnTheWill': 'optionYes', - 'alias': 'David James', - 'aliasReason': 'Divorce', - 'otherReason': '', - 'isApplying': true, - 'isApplicant': true - }, { - fullName: 'Ed Brown' - }, { - fullName: 'Dave Miller' - } - ]); - }); - }); -}); diff --git a/test/util/TestWrapper.js b/test/util/TestWrapper.js index ceb022bc69..64ea927ae5 100644 --- a/test/util/TestWrapper.js +++ b/test/util/TestWrapper.js @@ -246,6 +246,7 @@ class TestWrapper { if (errorMessageValueMatch) { errorMessageValueMatch.forEach(placeholder => { const placeholderRegex = new RegExp(placeholder, 'g'); + placeholder = placeholder.replace(/[{}]/g, ''); contentToSubstitute[contentKey][type] = contentToSubstitute[contentKey][type].replace(placeholderRegex, data[placeholder]); }); }