diff --git a/internal/donor/donorpage/register_with_court_of_protection.go b/internal/donor/donorpage/register_with_court_of_protection.go index e90059536c..612ba9a0ca 100644 --- a/internal/donor/donorpage/register_with_court_of_protection.go +++ b/internal/donor/donorpage/register_with_court_of_protection.go @@ -8,7 +8,6 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/donor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" - "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -40,7 +39,7 @@ func RegisterWithCourtOfProtection(tmpl template.Template, donorStore DonorStore return err } - return page.PathDashboard.Redirect(w, r, appData) + return donor.PathReadYourLpa.Redirect(w, r, appData, provided) } } diff --git a/internal/donor/donorpage/register_with_court_of_protection_test.go b/internal/donor/donorpage/register_with_court_of_protection_test.go index b49cd98e8d..d5ab1110cb 100644 --- a/internal/donor/donorpage/register_with_court_of_protection_test.go +++ b/internal/donor/donorpage/register_with_court_of_protection_test.go @@ -72,7 +72,7 @@ func TestPostRegisterWithCourtOfProtection(t *testing.T) { Return(nil) return donorStore }, - expectedRedirect: page.PathDashboard.Format(), + expectedRedirect: donor.PathReadYourLpa.Format("lpa-id"), }, } diff --git a/internal/donor/donorpage/task_list.go b/internal/donor/donorpage/task_list.go index 8bfb4df536..efda0df016 100644 --- a/internal/donor/donorpage/task_list.go +++ b/internal/donor/donorpage/task_list.go @@ -181,23 +181,39 @@ func taskListSignSection(provided *donordata.Provided) taskListSection { switch provided.IdentityUserData.Status { case identity.StatusConfirmed: - if !provided.SignedAt.IsZero() { + signPath = donor.PathOneLoginIdentityDetails + + if !provided.WitnessedByCertificateProviderAt.IsZero() { signPath = donor.PathYouHaveSubmittedYourLpa + } else if !provided.SignedAt.IsZero() { + signPath = donor.PathWitnessingYourSignature } else if provided.DonorIdentityConfirmed() { signPath = donor.PathReadYourLpa - } else { - signPath = donor.PathOneLoginIdentityDetails } case identity.StatusFailed: signPath = donor.PathRegisterWithCourtOfProtection + if provided.RegisteringWithCourtOfProtection { + signPath = donor.PathReadYourLpa + + if !provided.WitnessedByCertificateProviderAt.IsZero() { + signPath = donor.PathYouHaveSubmittedYourLpa + } else if !provided.SignedAt.IsZero() { + signPath = donor.PathWitnessingYourSignature + } + } + case identity.StatusExpired: signPath = donor.PathWhatYouCanDoNowExpired case identity.StatusInsufficientEvidence: - if !provided.SignedAt.IsZero() { + signPath = donor.PathUnableToConfirmIdentity + + if !provided.WitnessedByCertificateProviderAt.IsZero() { signPath = donor.PathYouHaveSubmittedYourLpa + } else if !provided.SignedAt.IsZero() { + signPath = donor.PathWitnessingYourSignature } else if provided.RegisteringWithCourtOfProtection { signPath = donor.PathWhatHappensNextRegisteringWithCourtOfProtection } else if provided.Voucher.FirstNames != "" { @@ -206,8 +222,6 @@ func taskListSignSection(provided *donordata.Provided) taskListSection { signPath = donor.PathEnterVoucher } else if provided.WantVoucher.IsNo() { signPath = donor.PathWhatYouCanDoNow - } else { - signPath = donor.PathUnableToConfirmIdentity } default: diff --git a/internal/donor/donorpage/task_list_test.go b/internal/donor/donorpage/task_list_test.go index a7ce836037..b4256ff991 100644 --- a/internal/donor/donorpage/task_list_test.go +++ b/internal/donor/donorpage/task_list_test.go @@ -144,6 +144,60 @@ func TestGetTaskList(t *testing.T) { return sections }, }, + "failed identity and is applying to court of protection and has not signed": { + appData: testAppData, + donor: &donordata.Provided{ + LpaID: "lpa-id", + Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, + IdentityUserData: identity.UserData{Status: identity.StatusFailed, LastName: "a"}, + WantVoucher: form.No, + RegisteringWithCourtOfProtection: true, + }, + expected: func(sections []taskListSection) []taskListSection { + sections[2].Items = []taskListItem{ + {Name: "confirmYourIdentityAndSign", Path: donor.PathReadYourLpa.Format("lpa-id")}, + } + + return sections + }, + }, + "failed identity and is applying to court of protection and has signed and not witnessed": { + appData: testAppData, + donor: &donordata.Provided{ + LpaID: "lpa-id", + Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, + IdentityUserData: identity.UserData{Status: identity.StatusFailed, LastName: "a"}, + WantVoucher: form.No, + RegisteringWithCourtOfProtection: true, + SignedAt: testNow, + }, + expected: func(sections []taskListSection) []taskListSection { + sections[2].Items = []taskListItem{ + {Name: "confirmYourIdentityAndSign", Path: donor.PathWitnessingYourSignature.Format("lpa-id")}, + } + + return sections + }, + }, + "failed identity and is applying to court of protection and has signed and witnessed": { + appData: testAppData, + donor: &donordata.Provided{ + LpaID: "lpa-id", + Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, + IdentityUserData: identity.UserData{Status: identity.StatusFailed, LastName: "a"}, + WantVoucher: form.No, + RegisteringWithCourtOfProtection: true, + SignedAt: testNow, + WitnessedByCertificateProviderAt: testNow, + }, + expected: func(sections []taskListSection) []taskListSection { + sections[2].Items = []taskListItem{ + {Name: "confirmYourIdentityAndSign", Path: donor.PathYouHaveSubmittedYourLpa.Format("lpa-id")}, + } + + return sections + }, + }, "expired identity": { appData: testAppData, donor: &donordata.Provided{ @@ -190,7 +244,7 @@ func TestGetTaskList(t *testing.T) { return sections }, }, - "does not want a voucher": { + "insufficient evidence and does not want a voucher": { appData: testAppData, donor: &donordata.Provided{ LpaID: "lpa-id", @@ -206,7 +260,7 @@ func TestGetTaskList(t *testing.T) { return sections }, }, - "wants a voucher": { + "insufficient evidence and wants a voucher": { appData: testAppData, donor: &donordata.Provided{ LpaID: "lpa-id", @@ -222,7 +276,7 @@ func TestGetTaskList(t *testing.T) { return sections }, }, - "is applying to court of protection": { + "insufficient evidence and is applying to court of protection": { appData: testAppData, donor: &donordata.Provided{ LpaID: "lpa-id", @@ -239,7 +293,7 @@ func TestGetTaskList(t *testing.T) { return sections }, }, - "is applying to court of protection and has signed": { + "insufficient evidence and is applying to court of protection and has signed": { appData: testAppData, donor: &donordata.Provided{ LpaID: "lpa-id", @@ -249,6 +303,25 @@ func TestGetTaskList(t *testing.T) { RegisteringWithCourtOfProtection: true, SignedAt: testNow, }, + expected: func(sections []taskListSection) []taskListSection { + sections[2].Items = []taskListItem{ + {Name: "confirmYourIdentityAndSign", Path: donor.PathWitnessingYourSignature.Format("lpa-id")}, + } + + return sections + }, + }, + "insufficient evidence and is applying to court of protection and has witnessed": { + appData: testAppData, + donor: &donordata.Provided{ + LpaID: "lpa-id", + Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, + IdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence, LastName: "a"}, + WantVoucher: form.No, + RegisteringWithCourtOfProtection: true, + SignedAt: testNow, + WitnessedByCertificateProviderAt: testNow, + }, expected: func(sections []taskListSection) []taskListSection { sections[2].Items = []taskListItem{ {Name: "confirmYourIdentityAndSign", Path: donor.PathYouHaveSubmittedYourLpa.Format("lpa-id")}, @@ -337,6 +410,58 @@ func TestGetTaskList(t *testing.T) { return sections }, }, + "identity confirmed, not signed": { + appData: testAppData, + donor: &donordata.Provided{ + LpaID: "lpa-id", + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, + CertificateProvider: donordata.CertificateProvider{LastName: "a", Address: place.Address{Line1: "x"}}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ + {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, + {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, + }}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ + {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, + }}, + IdentityUserData: identity.UserData{Status: identity.StatusConfirmed, FirstNames: "a", LastName: "b"}, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateCompleted, + WhenCanTheLpaBeUsed: task.StateCompleted, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateCompleted, + CheckYourLpa: task.StateCompleted, + AddCorrespondent: task.StateCompleted, + PayForLpa: task.PaymentStateCompleted, + ConfirmYourIdentityAndSign: task.IdentityStateCompleted, + }, + }, + expected: func(sections []taskListSection) []taskListSection { + sections[0].Items = []taskListItem{ + {Name: "provideYourDetails", Path: donor.PathYourDetails.Format("lpa-id"), State: task.StateCompleted}, + {Name: "chooseYourAttorneys", Path: donor.PathChooseAttorneysSummary.Format("lpa-id"), State: task.StateCompleted, Count: 2}, + {Name: "chooseYourReplacementAttorneys", Path: donor.PathChooseReplacementAttorneysSummary.Format("lpa-id"), State: task.StateCompleted, Count: 1}, + {Name: "chooseWhenTheLpaCanBeUsed", Path: donor.PathWhenCanTheLpaBeUsed.Format("lpa-id"), State: task.StateCompleted}, + {Name: "addRestrictionsToTheLpa", Path: donor.PathRestrictions.Format("lpa-id"), State: task.StateCompleted}, + {Name: "chooseYourCertificateProvider", Path: donor.PathWhatACertificateProviderDoes.Format("lpa-id"), State: task.StateCompleted}, + {Name: "peopleToNotifyAboutYourLpa", Path: donor.PathDoYouWantToNotifyPeople.Format("lpa-id")}, + {Name: "addCorrespondent", Path: donor.PathAddCorrespondent.Format("lpa-id"), State: task.StateCompleted}, + {Name: "chooseYourSignatoryAndIndependentWitness", Path: donor.PathGettingHelpSigning.Format("lpa-id"), Hidden: true}, + {Name: "checkAndSendToYourCertificateProvider", Path: donor.PathCheckYourLpa.Format("lpa-id"), State: task.StateCompleted}, + } + + sections[1].Items = []taskListItem{ + {Name: "payForTheLpa", Path: donor.PathAboutPayment.Format("lpa-id"), PaymentState: task.PaymentStateCompleted}, + } + + sections[2].Items = []taskListItem{ + {Name: "confirmYourIdentityAndSign", Path: donor.PathReadYourLpa.Format("lpa-id"), IdentityState: task.IdentityStateCompleted}, + } + + return sections + }, + }, "signed": { appData: testAppData, donor: &donordata.Provided{ @@ -383,6 +508,60 @@ func TestGetTaskList(t *testing.T) { {Name: "payForTheLpa", Path: donor.PathAboutPayment.Format("lpa-id"), PaymentState: task.PaymentStateCompleted}, } + sections[2].Items = []taskListItem{ + {Name: "confirmYourIdentityAndSign", Path: donor.PathWitnessingYourSignature.Format("lpa-id"), IdentityState: task.IdentityStateCompleted}, + } + + return sections + }, + }, + "witnessed": { + appData: testAppData, + donor: &donordata.Provided{ + LpaID: "lpa-id", + SignedAt: time.Now(), + WitnessedByCertificateProviderAt: testNow, + Donor: donordata.Donor{FirstNames: "this"}, + CertificateProvider: donordata.CertificateProvider{LastName: "a", Address: place.Address{Line1: "x"}}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ + {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, + {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, + }}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ + {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, + }}, + IdentityUserData: identity.UserData{Status: identity.StatusConfirmed, LastName: "a"}, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateCompleted, + WhenCanTheLpaBeUsed: task.StateCompleted, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateCompleted, + CheckYourLpa: task.StateCompleted, + AddCorrespondent: task.StateCompleted, + PayForLpa: task.PaymentStateCompleted, + ConfirmYourIdentityAndSign: task.IdentityStateCompleted, + }, + }, + expected: func(sections []taskListSection) []taskListSection { + sections[0].Items = []taskListItem{ + {Name: "provideYourDetails", Path: donor.PathYourDetails.Format("lpa-id"), State: task.StateCompleted}, + {Name: "chooseYourAttorneys", Path: donor.PathChooseAttorneysSummary.Format("lpa-id"), State: task.StateCompleted, Count: 2}, + {Name: "chooseYourReplacementAttorneys", Path: donor.PathChooseReplacementAttorneysSummary.Format("lpa-id"), State: task.StateCompleted, Count: 1}, + {Name: "chooseWhenTheLpaCanBeUsed", Path: donor.PathWhenCanTheLpaBeUsed.Format("lpa-id"), State: task.StateCompleted}, + {Name: "addRestrictionsToTheLpa", Path: donor.PathRestrictions.Format("lpa-id"), State: task.StateCompleted}, + {Name: "chooseYourCertificateProvider", Path: donor.PathWhatACertificateProviderDoes.Format("lpa-id"), State: task.StateCompleted}, + {Name: "peopleToNotifyAboutYourLpa", Path: donor.PathDoYouWantToNotifyPeople.Format("lpa-id")}, + {Name: "addCorrespondent", Path: donor.PathAddCorrespondent.Format("lpa-id"), State: task.StateCompleted}, + {Name: "chooseYourSignatoryAndIndependentWitness", Path: donor.PathGettingHelpSigning.Format("lpa-id"), Hidden: true}, + {Name: "checkAndSendToYourCertificateProvider", Path: donor.PathCheckYourLpa.Format("lpa-id"), State: task.StateCompleted}, + } + + sections[1].Items = []taskListItem{ + {Name: "payForTheLpa", Path: donor.PathAboutPayment.Format("lpa-id"), PaymentState: task.PaymentStateCompleted}, + } + sections[2].Items = []taskListItem{ {Name: "confirmYourIdentityAndSign", Path: donor.PathYouHaveSubmittedYourLpa.Format("lpa-id"), IdentityState: task.IdentityStateCompleted}, }