Skip to content

Commit

Permalink
Merge 867bdd1 into 3351f1a
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx authored Jul 16, 2024
2 parents 3351f1a + 867bdd1 commit c6272f1
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 15 deletions.
34 changes: 19 additions & 15 deletions internal/page/donor/task_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
70 changes: 70 additions & 0 deletions internal/page/donor/task_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit c6272f1

Please sign in to comment.