From 599d69eede3ce117d0ea542c1bb4a880b68447a5 Mon Sep 17 00:00:00 2001 From: Alex Saunders Date: Thu, 16 May 2024 13:44:01 +0100 Subject: [PATCH] MLPAB-1804, MLPAB-1641: Fix reusing details and trust corp contents (#1236) --- internal/page/donor/choose_address.go | 17 ++++---- internal/page/donor/your_address.go | 4 +- internal/page/donor/your_address_test.go | 50 +++++++++++++++++------- lang/cy.json | 4 +- lang/en.json | 10 +++-- web/template/donor/your_address.gohtml | 14 ++++++- 6 files changed, 69 insertions(+), 30 deletions(-) diff --git a/internal/page/donor/choose_address.go b/internal/page/donor/choose_address.go index 1c33c747f8..6942b48772 100644 --- a/internal/page/donor/choose_address.go +++ b/internal/page/donor/choose_address.go @@ -30,14 +30,15 @@ func newChooseAddressData(appData page.AppData, actorLabel, fullName string, UID } type chooseAddressData struct { - App page.AppData - Errors validation.List - ActorLabel string - FullName string - UID actoruid.UID - Addresses []place.Address - Form *form.AddressForm - TitleKeys titleKeys + App page.AppData + Errors validation.List + ActorLabel string + FullName string + UID actoruid.UID + Addresses []place.Address + Form *form.AddressForm + TitleKeys titleKeys + MakingAnotherLPA bool } type titleKeys struct { diff --git a/internal/page/donor/your_address.go b/internal/page/donor/your_address.go index d71e48ec05..17f0ef2596 100644 --- a/internal/page/donor/your_address.go +++ b/internal/page/donor/your_address.go @@ -25,6 +25,8 @@ func YourAddress(logger Logger, tmpl template.Template, addressClient AddressCli data.Form.Address = &donor.Donor.Address } + data.MakingAnotherLPA = r.URL.Query().Get("makingAnotherLPA") != "" + if r.Method == http.MethodPost { data.Form = form.ReadAddressForm(r) data.Errors = data.Form.Validate(true) @@ -46,7 +48,7 @@ func YourAddress(logger Logger, tmpl template.Template, addressClient AddressCli } } - if r.URL.Query().Get("makingAnotherLPA") != "" { + if data.MakingAnotherLPA { if !addressChangesMade { return page.Paths.MakeANewLPA.Redirect(w, r, appData, donor) } diff --git a/internal/page/donor/your_address_test.go b/internal/page/donor/your_address_test.go index 2a9b1a82e8..f16358d424 100644 --- a/internal/page/donor/your_address_test.go +++ b/internal/page/donor/your_address_test.go @@ -18,23 +18,45 @@ import ( ) func TestGetYourAddress(t *testing.T) { - w := httptest.NewRecorder() - r, _ := http.NewRequest(http.MethodGet, "/", nil) + testcases := map[string]struct { + query string + expectedData *chooseAddressData + }{ + "first time": { + expectedData: &chooseAddressData{ + App: testAppData, + Form: form.NewAddressForm(), + TitleKeys: testTitleKeys, + }, + }, + "making another LPA": { + query: "?makingAnotherLPA=1", + expectedData: &chooseAddressData{ + App: testAppData, + Form: form.NewAddressForm(), + TitleKeys: testTitleKeys, + MakingAnotherLPA: true, + }, + }, + } - template := newMockTemplate(t) - template.EXPECT(). - Execute(w, &chooseAddressData{ - App: testAppData, - Form: form.NewAddressForm(), - TitleKeys: testTitleKeys, - }). - Return(nil) + for name, tc := range testcases { + t.Run(name, func(t *testing.T) { + w := httptest.NewRecorder() + r, _ := http.NewRequest(http.MethodGet, "/"+tc.query, nil) - err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) - resp := w.Result() + template := newMockTemplate(t) + template.EXPECT(). + Execute(w, tc.expectedData). + Return(nil) - assert.Nil(t, err) - assert.Equal(t, http.StatusOK, resp.StatusCode) + err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + resp := w.Result() + + assert.Nil(t, err) + assert.Equal(t, http.StatusOK, resp.StatusCode) + }) + } } func TestGetYourAddressFromStore(t *testing.T) { diff --git a/lang/cy.json b/lang/cy.json index 7f0f9ef49f..cb5d15fe97 100644 --- a/lang/cy.json +++ b/lang/cy.json @@ -1200,5 +1200,7 @@ "whenYouSelectConfirmWeWillContactDonor": "Welsh {{ .DonorFirstNames }} Welsh", "thankYou": "Welsh", "weHaveContactedDonorToLetThemKnowYourDecision": "Welsh {{ .DonorFullName }} Welsh", - "reportAConcernContent": "

Welsh

Welsh:

Welsh Welsh Welsh

" + "reportAConcernContent": "

Welsh

Welsh:

Welsh Welsh Welsh

", + "yourAddress": "Welsh", + "yourAddressWarning": "Welsh" } diff --git a/lang/en.json b/lang/en.json index cf2d03aca6..9586b3e5d8 100644 --- a/lang/en.json +++ b/lang/en.json @@ -545,7 +545,7 @@ "legalRightsAndResponsibilities": "Legal rights and responsibilities", "attorneyRightsAndResponsibilitiesTitle": "Your legal rights and responsibilities", "attorneyRightsAndResponsibilitiesContent": "

Before signing, you must read your legal rights and responsibilities as an attorney.

How attorneys should act

When the donor signs their LPA, they are appointing their attorneys to make decisions for them.

As an attorney, you must follow the Mental Capacity Act Code of Practice:

How this LPA can be used

", - "trustCorporationRightsAndResponsibilitiesContent": "

Before signing, you must read the trust corporation’s legal rights and responsibilities as an attorney.

How attorneys should act

As an attorney, the trust corporation must follow the Mental Capacity Act Code of Practice:

How this LPA can be used

", + "trustCorporationRightsAndResponsibilitiesContent": "

Before signing, you must read the trust corporation’s legal rights and responsibilities as an attorney.

How attorneys should act

As an attorney, the trust corporation must follow the Mental Capacity Act Code of Practice:

How this LPA can be used

", "whatHappensWhenYouSignTheLpaTitle": "What happens when you sign the LPA", "whatHappensWhenYouSignTheLpaContentAttorneyPw": "

Signing the LPA is an important and powerful legal step.

When you sign, you’re officially saying that you want to be an attorney on {{ .DonorFullNamePossessive }} personal welfare LPA.

This means that once the LPA has been registered, you (and any other attorneys named in this LPA) can make decisions about:

", "whatHappensWhenYouSignTheLpaContentAttorneyPa": "

Signing the LPA is an important and powerful legal step.

When you sign, you’re officially saying that you want to be an attorney on {{ .DonorFullNamePossessive }} property and affairs LPA.

This means that once the LPA has been registered, you (and any other attorneys named in this LPA) have the power to:

", @@ -951,8 +951,8 @@ "youShouldOnlyChangeYourDetailsIfTheyNeedToBeUpdated": "

You should only change your details if they need to be updated. You cannot make an LPA for someone else using your own account. Find out more about how to make an LPA for someone else.

", "yourName": "Your name", "yourNameWarning": "You should only enter your details. You cannot make an LPA for someone else using your account.", - "yourDateOfBirth": "Your name", - "yourDateOfBirthWarning": "You should only enter your date of birth. You cannot make an LPA for someone else using your account.", + "yourDateOfBirth": "Your date of birth", + "yourDateOfBirthWarning": "You should only update your date of birth if it is incorrect. You cannot make an LPA for someone else using your account.", "detailUpdated": "{{ .Detail }} updated", "weHaveUpdatedYourDetail": "We have updated your {{ .Detail }}.", "weHaveUpdatedYourDetails": "We have updated your details", @@ -1132,5 +1132,7 @@ "whenYouSelectConfirmWeWillContactDonor": "When you select ‘Confirm’ we will contact {{ .DonorFirstNames }} to tell them what they should do next.", "thankYou": "Thank you", "weHaveContactedDonorToLetThemKnowYourDecision": "We have contacted {{ .DonorFullName }} to let them know of your decision to not be their certificate provider", - "reportAConcernContent": "

Report a concern

If you have concerns about this LPA you can contact our safeguarding team:

You can also report a concern using our online form.

" + "reportAConcernContent": "

Report a concern

If you have concerns about this LPA you can contact our safeguarding team:

You can also report a concern using our online form.

", + "yourAddress": "Your address", + "yourAddressWarning": "You should only enter your address. You cannot make an LPA for someone else using your account." } diff --git a/web/template/donor/your_address.gohtml b/web/template/donor/your_address.gohtml index 8c289e1860..74b8016469 100644 --- a/web/template/donor/your_address.gohtml +++ b/web/template/donor/your_address.gohtml @@ -1,6 +1,12 @@ {{ template "page" . }} -{{ define "pageTitle" }}{{ tr .App "whatIsYourAddress" }}{{ end }} +{{ define "pageTitle" }} + {{ if .MakingAnotherLPA }} + {{ tr .App "yourAddress" }} + {{ else }} + {{ tr .App "whatIsYourAddress" }} + {{ end }} +{{ end }} {{ define "main" }}
@@ -8,9 +14,13 @@
-

{{ tr .App "whatIsYourAddress" }}

+

{{ template "pageTitle" . }}

+ {{ if .MakingAnotherLPA }} + {{ template "warning" (content .App "yourAddressWarning") }} + {{ end }} + {{ if eq .Form.Action "manual" }} {{ template "input" (input . .Form.FieldNames.Line1 "addressLine1" .Form.Address.Line1 "autocomplete" "address-line1") }} {{ template "input" (input . .Form.FieldNames.Line2 "addressLine2" .Form.Address.Line2 "autocomplete" "address-line2") }}