From 867bdd166ea21a5ed7ff0eb264b78b0441834716 Mon Sep 17 00:00:00 2001 From: Joshua Hawxwell Date: Tue, 16 Jul 2024 08:49:08 +0100 Subject: [PATCH] Go to enter voucher from task list when want one Also go to "you have submitted" when signed for confirmed identity path --- internal/page/donor/task_list.go | 34 +++++++------ internal/page/donor/task_list_test.go | 70 +++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 15 deletions(-) diff --git a/internal/page/donor/task_list.go b/internal/page/donor/task_list.go index c0c3c6fa5f..0bcb753a02 100644 --- a/internal/page/donor/task_list.go +++ b/internal/page/donor/task_list.go @@ -165,31 +165,35 @@ func taskListPaymentSection(donor *actor.DonorProvidedDetails) taskListSection { func taskListSignSection(donor *actor.DonorProvidedDetails) taskListSection { var signPath page.LpaPath + switch donor.DonorIdentityUserData.Status { case identity.StatusConfirmed: - signPath = page.Paths.ReadYourLpa - if !donor.DonorIdentityConfirmed() { + if !donor.SignedAt.IsZero() { + signPath = page.Paths.YouHaveSubmittedYourLpa + } else if donor.DonorIdentityConfirmed() { + signPath = page.Paths.ReadYourLpa + } else { signPath = page.Paths.OneLoginIdentityDetails } + case identity.StatusFailed: signPath = page.Paths.RegisterWithCourtOfProtection + case identity.StatusInsufficientEvidence: - signPath = page.Paths.UnableToConfirmIdentity - if donor.WantVoucher.IsNo() { + if !donor.SignedAt.IsZero() { + signPath = page.Paths.YouHaveSubmittedYourLpa + } else if donor.RegisteringWithCourtOfProtection { + signPath = page.Paths.WhatHappensNextRegisteringWithCourtOfProtection + } else if donor.Voucher.FirstNames != "" { + signPath = page.Paths.ReadYourLpa + } else if donor.WantVoucher.IsYes() { + signPath = page.Paths.EnterVoucher + } else if donor.WantVoucher.IsNo() { signPath = page.Paths.WhatYouCanDoNow - - if donor.RegisteringWithCourtOfProtection { - signPath = page.Paths.WhatHappensNextRegisteringWithCourtOfProtection - } - - if !donor.SignedAt.IsZero() { - signPath = page.Paths.YouHaveSubmittedYourLpa - } + } else { + signPath = page.Paths.UnableToConfirmIdentity } - if donor.Voucher.FirstNames != "" { - signPath = page.Paths.ReadYourLpa - } default: signPath = page.Paths.HowToConfirmYourIdentityAndSign } diff --git a/internal/page/donor/task_list_test.go b/internal/page/donor/task_list_test.go index eb60d1dd88..58e8932509 100644 --- a/internal/page/donor/task_list_test.go +++ b/internal/page/donor/task_list_test.go @@ -4,6 +4,7 @@ import ( "net/http" "net/http/httptest" "testing" + "time" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" @@ -187,6 +188,22 @@ func TestGetTaskList(t *testing.T) { return sections }, }, + "wants a voucher": { + appData: testAppData, + donor: &actor.DonorProvidedDetails{ + LpaID: "lpa-id", + Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, + DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence, LastName: "a"}, + WantVoucher: form.Yes, + }, + expected: func(sections []taskListSection) []taskListSection { + sections[2].Items = []taskListItem{ + {Name: "confirmYourIdentityAndSign", Path: page.Paths.EnterVoucher.Format("lpa-id")}, + } + + return sections + }, + }, "is applying to court of protection": { appData: testAppData, donor: &actor.DonorProvidedDetails{ @@ -302,6 +319,59 @@ func TestGetTaskList(t *testing.T) { return sections }, }, + "signed": { + appData: testAppData, + donor: &actor.DonorProvidedDetails{ + LpaID: "lpa-id", + SignedAt: time.Now(), + Donor: actor.Donor{FirstNames: "this"}, + CertificateProvider: actor.CertificateProvider{LastName: "a", Address: place.Address{Line1: "x"}}, + Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, + {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, + }}, + ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, + }}, + DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed, LastName: "a"}, + Tasks: actor.DonorTasks{ + YourDetails: actor.TaskCompleted, + ChooseAttorneys: actor.TaskCompleted, + ChooseReplacementAttorneys: actor.TaskCompleted, + WhenCanTheLpaBeUsed: actor.TaskCompleted, + Restrictions: actor.TaskCompleted, + CertificateProvider: actor.TaskCompleted, + CheckYourLpa: actor.TaskCompleted, + AddCorrespondent: actor.TaskCompleted, + PayForLpa: actor.PaymentTaskCompleted, + ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted, + }, + }, + expected: func(sections []taskListSection) []taskListSection { + sections[0].Items = []taskListItem{ + {Name: "provideYourDetails", Path: page.Paths.YourDetails.Format("lpa-id"), State: actor.TaskCompleted}, + {Name: "chooseYourAttorneys", Path: page.Paths.ChooseAttorneysGuidance.Format("lpa-id"), State: actor.TaskCompleted, Count: 2}, + {Name: "chooseYourReplacementAttorneys", Path: page.Paths.DoYouWantReplacementAttorneys.Format("lpa-id"), State: actor.TaskCompleted, Count: 1}, + {Name: "chooseWhenTheLpaCanBeUsed", Path: page.Paths.WhenCanTheLpaBeUsed.Format("lpa-id"), State: actor.TaskCompleted}, + {Name: "addRestrictionsToTheLpa", Path: page.Paths.Restrictions.Format("lpa-id"), State: actor.TaskCompleted}, + {Name: "chooseYourCertificateProvider", Path: page.Paths.WhatACertificateProviderDoes.Format("lpa-id"), State: actor.TaskCompleted}, + {Name: "peopleToNotifyAboutYourLpa", Path: page.Paths.DoYouWantToNotifyPeople.Format("lpa-id")}, + {Name: "addCorrespondent", Path: page.Paths.AddCorrespondent.Format("lpa-id"), State: actor.TaskCompleted}, + {Name: "chooseYourSignatoryAndIndependentWitness", Path: page.Paths.GettingHelpSigning.Format("lpa-id"), Hidden: true}, + {Name: "checkAndSendToYourCertificateProvider", Path: page.Paths.CheckYourLpa.Format("lpa-id"), State: actor.TaskCompleted}, + } + + sections[1].Items = []taskListItem{ + {Name: "payForTheLpa", Path: page.Paths.AboutPayment.Format("lpa-id"), PaymentState: actor.PaymentTaskCompleted}, + } + + sections[2].Items = []taskListItem{ + {Name: "confirmYourIdentityAndSign", Path: page.Paths.YouHaveSubmittedYourLpa.Format("lpa-id"), IdentityState: actor.IdentityTaskCompleted}, + } + + return sections + }, + }, "supporter": { appData: page.AppData{ SessionID: "session-id",