Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpearce-digital authored Dec 6, 2024
2 parents d99631a + 7f6d90f commit aa4b500
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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');
});
});
21 changes: 17 additions & 4 deletions internal/donor/donorpage/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
}
86 changes: 57 additions & 29 deletions internal/donor/donorpage/progress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 11 additions & 1 deletion lang/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1490,5 +1490,15 @@
"checkTheProgressOfYourLpa": "Welsh",
"checkTheProgressOfYourLpaContent": "<p class=\"govuk-body\">Welsh</p>",
"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"
}
8 changes: 7 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1390,5 +1390,11 @@
"checkTheProgressOfYourLpa": "Check the progress of your LPA",
"checkTheProgressOfYourLpaContent": "<p class=\"govuk-body\">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:</p><ul class=\"govuk-list govuk-list--bullet\"><li>you must complete – return to your task list to do this</li><li>your certificate provider or attorneys must complete</li><li>the Office of the Public Guardian (OPG) must complete</li></ul>",
"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."
}
23 changes: 22 additions & 1 deletion web/template/donor/progress.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,29 @@

{{ trHtml .App "checkTheProgressOfYourLpaContent" }}

<hr class="govuk-section-break govuk-section-break--m govuk-section-break--visible">
<hr class="govuk-section-break govuk-section-break--l govuk-section-break--visible">

{{ if .InfoNotifications }}
<div class="govuk-notification-banner" aria-labelledby="govuk-notification-banner-title" data-module="govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h1 class="govuk-notification-banner__title govuk-!-font-weight-regular" id="govuk-notification-banner-title">
<span class="govuk-!-font-weight-bold">{{ tr .App "important" }}:</span> {{ trFormatCount .App "notificationsFromOpg" (len .InfoNotifications) }}
</h1>
</div>

<div class="govuk-notification-banner__content">
{{ range $i, $_ := .InfoNotifications }}
{{ if gt $i 0 }}
<hr class="govuk-section-break govuk-section-break--m govuk-section-break--visible">
{{ end }}

<h2 class="govuk-notification-banner__heading">{{ tr $.App .Heading }}</h2>
<p class="govuk-body">{{ tr $.App .Body }}</p>
{{ end }}
</div>
</div>
{{ end }}

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

<div class="govuk-button-group">
Expand Down

0 comments on commit aa4b500

Please sign in to comment.