Skip to content

Commit

Permalink
Merge pull request #1521 from ministryofjustice/MLPAB-2287-fix-regist…
Browse files Browse the repository at this point in the history
…er-with-cop-routing

MLPAB-2287: Fix ID and sign task list and registering with COP routing
  • Loading branch information
acsauk authored Oct 1, 2024
2 parents a43cd6b + 3f848b3 commit 36ff90a
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestPostRegisterWithCourtOfProtection(t *testing.T) {
Return(nil)
return donorStore
},
expectedRedirect: page.PathDashboard.Format(),
expectedRedirect: donor.PathReadYourLpa.Format("lpa-id"),
},
}

Expand Down
26 changes: 20 additions & 6 deletions internal/donor/donorpage/task_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand All @@ -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:
Expand Down
187 changes: 183 additions & 4 deletions internal/donor/donorpage/task_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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")},
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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},
}
Expand Down

0 comments on commit 36ff90a

Please sign in to comment.