From 3b253f945f89f299c18065f0e039492af371eda9 Mon Sep 17 00:00:00 2001 From: Joshua Hawxwell Date: Thu, 5 Dec 2024 15:22:34 +0000 Subject: [PATCH] Show notification on progress when going to post office --- .../{lpa-progress.cy.js => progress.cy.js} | 30 ++++++- internal/donor/donorpage/progress.go | 21 ++++- internal/donor/donorpage/progress_test.go | 86 ++++++++++++------- lang/cy.json | 12 ++- lang/en.json | 8 +- web/template/donor/progress.gohtml | 23 ++++- 6 files changed, 143 insertions(+), 37 deletions(-) rename cypress/e2e/donor/{lpa-progress.cy.js => progress.cy.js} (61%) diff --git a/cypress/e2e/donor/lpa-progress.cy.js b/cypress/e2e/donor/progress.cy.js similarity index 61% rename from cypress/e2e/donor/lpa-progress.cy.js rename to cypress/e2e/donor/progress.cy.js index 7065ae8a44..46ffb9938d 100644 --- a/cypress/e2e/donor/lpa-progress.cy.js +++ b/cypress/e2e/donor/progress.cy.js @@ -1,8 +1,10 @@ -describe('LPA progress', () => { +describe('Progress', () => { it('when nothing completed', () => { cy.visit('/fixtures?redirect=/progress'); cy.checkA11yApp(); + cy.contains('Important:').should('not.exist'); + cy.contains('li', 'LPA paid for Not completed'); cy.contains('li', 'Your identity confirmed Not completed'); cy.contains('li', 'LPA signed by you Not completed'); @@ -37,4 +39,30 @@ describe('LPA progress', () => { cy.contains('li', 'OPG’s statutory 4-week waiting period begins Not completed'); cy.contains('li', 'LPA registered by OPG Not completed'); }) + + it('shows a notification when going to the post office', () => { + cy.visit('/fixtures?redirect=/task-list&progress=payForTheLpa'); + + cy.contains('a', 'Confirm your identity').click(); + cy.contains('button', 'Continue').click(); + cy.go(-2); + cy.contains('a', 'Confirm your identity').click(); + cy.contains('label', 'I will confirm my identity at a Post Office').click(); + cy.contains('button', 'Continue').click(); + + cy.visitLpa('/progress'); + cy.checkA11yApp(); + cy.contains('Important:') + cy.contains('1 notification from OPG'); + cy.contains('You have chosen to confirm your identity at a Post Office'); + + cy.contains('a', 'Go to task list').click(); + cy.contains('a', 'Confirm your identity').click(); + cy.contains('label', 'to complete my Post Office identity confirmation').click(); + cy.contains('button', 'Continue').click(); + cy.contains('button', 'Continue').click(); + + cy.contains('Important:').should('not.exist'); + cy.visitLpa('/progress'); + }); }); diff --git a/internal/donor/donorpage/progress.go b/internal/donor/donorpage/progress.go index 3e32c6a1a7..75b6fbb6a3 100644 --- a/internal/donor/donorpage/progress.go +++ b/internal/donor/donorpage/progress.go @@ -10,11 +10,17 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) +type progressNotification struct { + Heading string + Body string +} + type progressData struct { - App appcontext.Data - Donor *donordata.Provided - Progress task.Progress - Errors validation.List + App appcontext.Data + Errors validation.List + Donor *donordata.Provided + Progress task.Progress + InfoNotifications []progressNotification } func Progress(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, progressTracker ProgressTracker) Handler { @@ -30,6 +36,13 @@ func Progress(tmpl template.Template, lpaStoreResolvingService LpaStoreResolving Progress: progressTracker.Progress(lpa), } + if donor.IdentityUserData.Status.IsUnknown() && donor.Tasks.ConfirmYourIdentity.IsPending() { + data.InfoNotifications = append(data.InfoNotifications, progressNotification{ + Heading: "youHaveChosenToConfirmYourIdentityAtPostOffice", + Body: "whenYouHaveConfirmedAtPostOfficeReturnToTaskList", + }) + } + return tmpl(w, data) } } diff --git a/internal/donor/donorpage/progress_test.go b/internal/donor/donorpage/progress_test.go index d77fc563b2..37888d0935 100644 --- a/internal/donor/donorpage/progress_test.go +++ b/internal/donor/donorpage/progress_test.go @@ -13,35 +13,63 @@ import ( ) func TestGetProgress(t *testing.T) { - w := httptest.NewRecorder() - r, _ := http.NewRequest(http.MethodGet, "/", nil) - - lpa := &lpadata.Lpa{LpaUID: "lpa-uid"} - - lpaStoreResolvingService := newMockLpaStoreResolvingService(t) - lpaStoreResolvingService.EXPECT(). - Get(r.Context()). - Return(lpa, nil) - - progressTracker := newMockProgressTracker(t) - progressTracker.EXPECT(). - Progress(lpa). - Return(task.Progress{DonorSigned: task.ProgressTask{Done: true}}) - - template := newMockTemplate(t) - template.EXPECT(). - Execute(w, &progressData{ - App: testAppData, - Donor: &donordata.Provided{LpaUID: "lpa-uid"}, - Progress: task.Progress{DonorSigned: task.ProgressTask{Done: true}}, - }). - Return(nil) - - err := Progress(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid"}) - resp := w.Result() - - assert.Nil(t, err) - assert.Equal(t, http.StatusOK, resp.StatusCode) + testCases := map[string]struct { + provided *donordata.Provided + infoNotifications []progressNotification + }{ + "none": { + provided: &donordata.Provided{LpaUID: "lpa-uid"}, + }, + "going to the post office": { + provided: &donordata.Provided{ + LpaUID: "lpa-uid", + Tasks: donordata.Tasks{ + ConfirmYourIdentity: task.IdentityStatePending, + }, + }, + infoNotifications: []progressNotification{ + { + Heading: "youHaveChosenToConfirmYourIdentityAtPostOffice", + Body: "whenYouHaveConfirmedAtPostOfficeReturnToTaskList", + }, + }, + }, + } + + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + w := httptest.NewRecorder() + r, _ := http.NewRequest(http.MethodGet, "/", nil) + + lpa := &lpadata.Lpa{LpaUID: "lpa-uid"} + + lpaStoreResolvingService := newMockLpaStoreResolvingService(t) + lpaStoreResolvingService.EXPECT(). + Get(r.Context()). + Return(lpa, nil) + + progressTracker := newMockProgressTracker(t) + progressTracker.EXPECT(). + Progress(lpa). + Return(task.Progress{DonorSigned: task.ProgressTask{Done: true}}) + + template := newMockTemplate(t) + template.EXPECT(). + Execute(w, &progressData{ + App: testAppData, + Donor: tc.provided, + Progress: task.Progress{DonorSigned: task.ProgressTask{Done: true}}, + InfoNotifications: tc.infoNotifications, + }). + Return(nil) + + err := Progress(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, tc.provided) + resp := w.Result() + + assert.Nil(t, err) + assert.Equal(t, http.StatusOK, resp.StatusCode) + }) + } } func TestGetProgressWhenLpaStoreClientErrors(t *testing.T) { diff --git a/lang/cy.json b/lang/cy.json index 2b9a239ecd..e799622e5a 100644 --- a/lang/cy.json +++ b/lang/cy.json @@ -1530,5 +1530,15 @@ "checkTheProgressOfYourLpa": "Welsh", "checkTheProgressOfYourLpaContent": "

Welsh

", "checkTheProgressOfAnLpa": "Welsh", - "checkTheProgressOfDonorsLpa": "Welsh {{.DonorFullName}}" + "checkTheProgressOfDonorsLpa": "Welsh {{.DonorFullName}}", + "notificationsFromOpg": { + "zero": "{{.PluralCount}} Welsh", + "one": "{{.PluralCount}} Welsh", + "two": "{{.PluralCount}} Welsh", + "few": "{{.PluralCount}} Welsh", + "many": "{{.PluralCount}} Welsh", + "other": "{{.PluralCount}} Welsh" + }, + "youHaveChosenToConfirmYourIdentityAtPostOffice": "Welsh", + "whenYouHaveConfirmedAtPostOfficeReturnToTaskList": "Welsh" } diff --git a/lang/en.json b/lang/en.json index 41ffcf7cb9..593e7945a6 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1426,5 +1426,11 @@ "checkTheProgressOfYourLpa": "Check the progress of your LPA", "checkTheProgressOfYourLpaContent": "

Thank you for filling in your LPA. Before it can be registered and used, the steps on this page must be completed. We’ll contact you if you need to take action. Use this page to check items:

", "checkTheProgressOfAnLpa": "Check the progress of an LPA", - "checkTheProgressOfDonorsLpa": "Check the progress of {{possessive .DonorFullName}} LPA" + "checkTheProgressOfDonorsLpa": "Check the progress of {{possessive .DonorFullName}} LPA", + "notificationsFromOpg": { + "one": "{{.PluralCount}} notification from OPG", + "other": "{{.PluralCount}} notifications from OPG" + }, + "youHaveChosenToConfirmYourIdentityAtPostOffice": "You have chosen to confirm your identity at a Post Office", + "whenYouHaveConfirmedAtPostOfficeReturnToTaskList": "When you have confirmed your identity at a Post Office, return to your task list for the steps you must take to complete this process." } diff --git a/web/template/donor/progress.gohtml b/web/template/donor/progress.gohtml index 245fe7b5f2..fedbce57ef 100644 --- a/web/template/donor/progress.gohtml +++ b/web/template/donor/progress.gohtml @@ -21,8 +21,29 @@ {{ trHtml .App "checkTheProgressOfYourLpaContent" }} -
+
+ {{ if .InfoNotifications }} +
+
+

+ {{ tr .App "important" }}: {{ trFormatCount .App "notificationsFromOpg" (len .InfoNotifications) }} +

+
+ +
+ {{ range $i, $_ := .InfoNotifications }} + {{ if gt $i 0 }} +
+ {{ end }} + +

{{ tr $.App .Heading }}

+

{{ tr $.App .Body }}

+ {{ end }} +
+
+ {{ end }} + {{ template "donor-lpa-progress" . }}