From a37d4fb7c92925c406a51798b7a194ee14ee7e4f Mon Sep 17 00:00:00 2001 From: Alex Saunders Date: Thu, 27 Feb 2025 15:37:48 +0000 Subject: [PATCH 1/2] MLPAB-2786 send voucher access code when fee approved and paid --- cmd/event-received/factory.go | 3 +- .../mock_ShareCodeSender_test.go | 48 +++++++++++ cmd/event-received/sirius_event_handler.go | 8 ++ .../sirius_event_handler_test.go | 82 +++++++++++++++++++ .../donor/donorpage/payment_confirmation.go | 2 +- 5 files changed, 141 insertions(+), 2 deletions(-) diff --git a/cmd/event-received/factory.go b/cmd/event-received/factory.go index 99a70e7874..0b4d8c5ce9 100644 --- a/cmd/event-received/factory.go +++ b/cmd/event-received/factory.go @@ -43,9 +43,10 @@ type SecretsClient interface { } type ShareCodeSender interface { + SendAttorneys(context.Context, appcontext.Data, *lpadata.Lpa) error SendCertificateProviderInvite(context.Context, appcontext.Data, sharecode.CertificateProviderInvite, notify.ToEmail) error SendCertificateProviderPrompt(context.Context, appcontext.Data, *donordata.Provided) error - SendAttorneys(context.Context, appcontext.Data, *lpadata.Lpa) error + SendVoucherAccessCode(ctx context.Context, provided *donordata.Provided, appData appcontext.Data) error } type UidStore interface { diff --git a/cmd/event-received/mock_ShareCodeSender_test.go b/cmd/event-received/mock_ShareCodeSender_test.go index 585259a1bb..fcd8fbc124 100644 --- a/cmd/event-received/mock_ShareCodeSender_test.go +++ b/cmd/event-received/mock_ShareCodeSender_test.go @@ -176,6 +176,54 @@ func (_c *mockShareCodeSender_SendCertificateProviderPrompt_Call) RunAndReturn(r return _c } +// SendVoucherAccessCode provides a mock function with given fields: ctx, provided, appData +func (_m *mockShareCodeSender) SendVoucherAccessCode(ctx context.Context, provided *donordata.Provided, appData appcontext.Data) error { + ret := _m.Called(ctx, provided, appData) + + if len(ret) == 0 { + panic("no return value specified for SendVoucherAccessCode") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *donordata.Provided, appcontext.Data) error); ok { + r0 = rf(ctx, provided, appData) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// mockShareCodeSender_SendVoucherAccessCode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendVoucherAccessCode' +type mockShareCodeSender_SendVoucherAccessCode_Call struct { + *mock.Call +} + +// SendVoucherAccessCode is a helper method to define mock.On call +// - ctx context.Context +// - provided *donordata.Provided +// - appData appcontext.Data +func (_e *mockShareCodeSender_Expecter) SendVoucherAccessCode(ctx interface{}, provided interface{}, appData interface{}) *mockShareCodeSender_SendVoucherAccessCode_Call { + return &mockShareCodeSender_SendVoucherAccessCode_Call{Call: _e.mock.On("SendVoucherAccessCode", ctx, provided, appData)} +} + +func (_c *mockShareCodeSender_SendVoucherAccessCode_Call) Run(run func(ctx context.Context, provided *donordata.Provided, appData appcontext.Data)) *mockShareCodeSender_SendVoucherAccessCode_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*donordata.Provided), args[2].(appcontext.Data)) + }) + return _c +} + +func (_c *mockShareCodeSender_SendVoucherAccessCode_Call) Return(_a0 error) *mockShareCodeSender_SendVoucherAccessCode_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockShareCodeSender_SendVoucherAccessCode_Call) RunAndReturn(run func(context.Context, *donordata.Provided, appcontext.Data) error) *mockShareCodeSender_SendVoucherAccessCode_Call { + _c.Call.Return(run) + return _c +} + // newMockShareCodeSender creates a new instance of mockShareCodeSender. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func newMockShareCodeSender(t interface { diff --git a/cmd/event-received/sirius_event_handler.go b/cmd/event-received/sirius_event_handler.go index d90b4bcba8..9084c2cf1d 100644 --- a/cmd/event-received/sirius_event_handler.go +++ b/cmd/event-received/sirius_event_handler.go @@ -178,6 +178,14 @@ func handleFeeApproved( return fmt.Errorf("failed to send share code to certificate provider: %w", err) } } + + if donor.Voucher.Allowed && donor.VoucherInvitedAt.IsZero() { + if err := shareCodeSender.SendVoucherAccessCode(ctx, donor, appData); err != nil { + return err + } + + donor.VoucherInvitedAt = now() + } } else { donor.Tasks.PayForLpa = task.PaymentStateApproved } diff --git a/cmd/event-received/sirius_event_handler_test.go b/cmd/event-received/sirius_event_handler_test.go index 924c2c6b9f..8f45397841 100644 --- a/cmd/event-received/sirius_event_handler_test.go +++ b/cmd/event-received/sirius_event_handler_test.go @@ -529,6 +529,88 @@ func TestHandleFeeApprovedWhenApprovedTypeDiffers(t *testing.T) { } } +func TestHandleFeeApprovedWhenVoucherSelected(t *testing.T) { + event := &events.CloudWatchEvent{ + DetailType: "reduced-fee-approved", + Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","approvedType":"NoFee"}`), + } + + donor := &donordata.Provided{ + PK: dynamo.LpaKey("123"), + SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), + FeeType: pay.NoFee, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}, + Voucher: donordata.Voucher{Allowed: true}, + } + + updatedDonor := *donor + updatedDonor.Tasks.PayForLpa = task.PaymentStateCompleted + updatedDonor.VoucherInvitedAt = testNow + updatedDonor.ReducedFeeApprovedAt = testNow + updatedDonor.UpdateHash() + updatedDonor.UpdatedAt = testNow + + client := newMockDynamodbClient(t) + client.EXPECT(). + OneByUID(ctx, "M-1111-2222-3333", mock.Anything). + Return(nil). + SetData(dynamo.Keys{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))}) + client.EXPECT(). + One(ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). + Return(nil). + SetData(donor) + client.EXPECT(). + Put(ctx, &updatedDonor). + Return(nil) + + shareCodeSender := newMockShareCodeSender(t) + shareCodeSender.EXPECT(). + SendVoucherAccessCode(ctx, &donordata.Provided{ + PK: dynamo.LpaKey("123"), + SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), + FeeType: pay.NoFee, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStateCompleted}, + Voucher: donordata.Voucher{Allowed: true}, + }, appcontext.Data{}). + Return(nil) + + err := handleFeeApproved(ctx, client, event, shareCodeSender, nil, nil, appcontext.Data{}, testNowFn) + assert.Nil(t, err) +} + +func TestHandleFeeApprovedWhenVoucherSelectedAndShareCodeSenderError(t *testing.T) { + event := &events.CloudWatchEvent{ + DetailType: "reduced-fee-approved", + Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","approvedType":"NoFee"}`), + } + + donor := &donordata.Provided{ + PK: dynamo.LpaKey("123"), + SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), + FeeType: pay.NoFee, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}, + Voucher: donordata.Voucher{Allowed: true}, + } + + client := newMockDynamodbClient(t) + client.EXPECT(). + OneByUID(mock.Anything, mock.Anything, mock.Anything). + Return(nil). + SetData(dynamo.Keys{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))}) + client.EXPECT(). + One(mock.Anything, mock.Anything, mock.Anything, mock.Anything). + Return(nil). + SetData(donor) + + shareCodeSender := newMockShareCodeSender(t) + shareCodeSender.EXPECT(). + SendVoucherAccessCode(mock.Anything, mock.Anything, mock.Anything). + Return(expectedError) + + err := handleFeeApproved(ctx, client, event, shareCodeSender, nil, nil, appcontext.Data{}, testNowFn) + assert.ErrorIs(t, err, expectedError) +} + func TestHandleFeeApprovedWhenDynamoClientPutError(t *testing.T) { event := &events.CloudWatchEvent{ DetailType: "reduced-fee-approved", diff --git a/internal/donor/donorpage/payment_confirmation.go b/internal/donor/donorpage/payment_confirmation.go index 5a92237a5f..964046d3a4 100644 --- a/internal/donor/donorpage/payment_confirmation.go +++ b/internal/donor/donorpage/payment_confirmation.go @@ -84,7 +84,7 @@ func PaymentConfirmation(logger Logger, payClient PayClient, donorStore DonorSto provided.Tasks.PayForLpa = task.PaymentStateCompleted nextPage = donor.PathTaskList - if provided.Voucher.Allowed { + if provided.Voucher.Allowed && provided.VoucherInvitedAt.IsZero() { if err := shareCodeSender.SendVoucherAccessCode(r.Context(), provided, appData); err != nil { return err } From 8c9a84f1721f0465e03d66444e6264ab612896f2 Mon Sep 17 00:00:00 2001 From: Alex Saunders Date: Thu, 27 Feb 2025 17:35:02 +0000 Subject: [PATCH 2/2] MLPAB-2786 add donor name fields to fixtures --- cypress/parallel-weights.json | 2 +- internal/page/fixtures/attorney.go | 2 +- .../page/fixtures/certificate_provider.go | 2 +- internal/page/fixtures/dashboard.go | 6 ++--- internal/page/fixtures/donor.go | 23 ++++++++++++++----- internal/page/fixtures/fixtures.go | 6 ++--- internal/page/fixtures/supporter.go | 4 ++-- internal/page/fixtures/voucher.go | 2 +- web/template/fixtures.gohtml | 2 ++ 9 files changed, 31 insertions(+), 18 deletions(-) diff --git a/cypress/parallel-weights.json b/cypress/parallel-weights.json index 93ff82dab8..e20e2fdd4b 100644 --- a/cypress/parallel-weights.json +++ b/cypress/parallel-weights.json @@ -1 +1 @@ -{"cypress/e2e/accessibility/data-loss-warning.cy.js":{"time":2519,"weight":4},"cypress/e2e/attorney/confirm-your-details.cy.js":{"time":5977,"weight":10},"cypress/e2e/attorney/language-preferences.cy.js":{"time":1255,"weight":2},"cypress/e2e/attorney/legal-rights-and-responsibilities.cy.js":{"time":679,"weight":1},"cypress/e2e/attorney/opt-out.cy.js":{"time":1950,"weight":3},"cypress/e2e/attorney/phone-number.cy.js":{"time":1988,"weight":3},"cypress/e2e/attorney/progress.cy.js":{"time":1450,"weight":2},"cypress/e2e/attorney/read-the-lpa.cy.js":{"time":1150,"weight":2},"cypress/e2e/attorney/sign.cy.js":{"time":5112,"weight":9},"cypress/e2e/attorney/start.cy.js":{"time":251,"weight":0},"cypress/e2e/attorney/task-list.cy.js":{"time":656,"weight":1},"cypress/e2e/attorney/trust-corporation.cy.js":{"time":13248,"weight":23},"cypress/e2e/attorney/what-happens-when-you-sign-the-lpa.cy.js":{"time":1343,"weight":2},"cypress/e2e/certificate-provider/certificate-provided.cy.js":{"time":1201,"weight":2},"cypress/e2e/certificate-provider/choose-not-to-be-a-certificate-provider.cy.js":{"time":2430,"weight":4},"cypress/e2e/certificate-provider/confirm-your-details.cy.js":{"time":4483,"weight":7},"cypress/e2e/certificate-provider/confirm-your-identity.cy.js":{"time":5258,"weight":9},"cypress/e2e/certificate-provider/dashboard.cy.js":{"time":1411,"weight":2},"cypress/e2e/certificate-provider/enter-date-of-birth.cy.js":{"time":6686,"weight":11},"cypress/e2e/certificate-provider/enter-reference-number.cy.js":{"time":5292,"weight":9},"cypress/e2e/certificate-provider/language-preferences.cy.js":{"time":1465,"weight":2},"cypress/e2e/certificate-provider/provide-certificate.cy.js":{"time":1924,"weight":3},"cypress/e2e/certificate-provider/read-the-lpa.cy.js":{"time":1201,"weight":2},"cypress/e2e/certificate-provider/start.cy.js":{"time":318,"weight":0},"cypress/e2e/certificate-provider/task-list.cy.js":{"time":603,"weight":1},"cypress/e2e/certificate-provider/what-is-your-home-address.cy.js":{"time":10022,"weight":17},"cypress/e2e/certificate-provider/who-is-eligible.cy.js":{"time":727,"weight":1},"cypress/e2e/dev-features.cy.js":{"time":831,"weight":1},"cypress/e2e/donor/add-correspondent.cy.js":{"time":7972,"weight":14},"cypress/e2e/donor/can-you-sign-your-lpa.cy.js":{"time":1490,"weight":2},"cypress/e2e/donor/certificate-provider.cy.js":{"time":16694,"weight":29},"cypress/e2e/donor/check-you-can-sign.cy.js":{"time":2011,"weight":3},"cypress/e2e/donor/check-your-details.cy.js":{"time":2030,"weight":3},"cypress/e2e/donor/check-your-lpa.cy.js":{"time":9441,"weight":16},"cypress/e2e/donor/choose-attorneys-address.cy.js":{"time":10422,"weight":18},"cypress/e2e/donor/choose-attorneys-summary.cy.js":{"time":9728,"weight":17},"cypress/e2e/donor/choose-attorneys-task.cy.js":{"time":17257,"weight":30},"cypress/e2e/donor/choose-attorneys.cy.js":{"time":11097,"weight":19},"cypress/e2e/donor/choose-people-to-notify-address.cy.js":{"time":3908,"weight":6},"cypress/e2e/donor/choose-replacement-attorneys-address.cy.js":{"time":8631,"weight":15},"cypress/e2e/donor/choose-replacement-attorneys-summary.cy.js":{"time":8295,"weight":14},"cypress/e2e/donor/choose-replacement-attorneys-task.cy.js":{"time":114089,"weight":201},"cypress/e2e/donor/choose-replacement-attorneys.cy.js":{"time":12213,"weight":21},"cypress/e2e/donor/choose-someone-to-vouch-for-you.cy.js":{"time":881,"weight":1},"cypress/e2e/donor/confirm-person-allowed-to-vouch.cy.js":{"time":3815,"weight":6},"cypress/e2e/donor/confirm-your-certificate-provider-is-not-related.cy.js":{"time":2676,"weight":4},"cypress/e2e/donor/confirm-your-identity.cy.js":{"time":11249,"weight":19},"cypress/e2e/donor/cost-of-repeat-application.cy.js":{"time":969,"weight":1},"cypress/e2e/donor/dashboard.cy.js":{"time":3557,"weight":6},"cypress/e2e/donor/delete-lpa.cy.js":{"time":1508,"weight":2},"cypress/e2e/donor/enter-access-code.cy.js":{"time":1399,"weight":2},"cypress/e2e/donor/enter-replacement-trust-corporation-address.cy.js":{"time":10514,"weight":18},"cypress/e2e/donor/enter-replacement-trust-corporation.cy.js":{"time":2539,"weight":4},"cypress/e2e/donor/enter-trust-corporation-address.cy.js":{"time":10355,"weight":18},"cypress/e2e/donor/enter-trust-corporation.cy.js":{"time":2358,"weight":4},"cypress/e2e/donor/enter-voucher.cy.js":{"time":2411,"weight":4},"cypress/e2e/donor/how-should-attorneys-make-decisions.cy.js":{"time":4144,"weight":7},"cypress/e2e/donor/how-should-replacement-attorneys-make-decisions.cy.js":{"time":2411,"weight":4},"cypress/e2e/donor/how-should-replacement-attorneys-step-in.cy.js":{"time":2656,"weight":4},"cypress/e2e/donor/language-preferences.cy.js":{"time":1189,"weight":2},"cypress/e2e/donor/life-sustaining-treatment.cy.js":{"time":2654,"weight":4},"cypress/e2e/donor/lpa-type.cy.js":{"time":5876,"weight":10},"cypress/e2e/donor/make-a-new-lpa.cy.js":{"time":5052,"weight":8},"cypress/e2e/donor/payment.cy.js":{"time":26899,"weight":47},"cypress/e2e/donor/people-to-notify.cy.js":{"time":10677,"weight":18},"cypress/e2e/donor/previous-application-number.cy.js":{"time":1372,"weight":2},"cypress/e2e/donor/progress.cy.js":{"time":9703,"weight":17},"cypress/e2e/donor/provide-your-details.cy.js":{"time":4982,"weight":8},"cypress/e2e/donor/remove-replacement-trust-corporation.cy.js":{"time":942,"weight":1},"cypress/e2e/donor/remove-trust-corporation.cy.js":{"time":951,"weight":1},"cypress/e2e/donor/restrictions.cy.js":{"time":766,"weight":1},"cypress/e2e/donor/sign-the-lpa.cy.js":{"time":9719,"weight":17},"cypress/e2e/donor/signing-on-behalf.cy.js":{"time":2805,"weight":4},"cypress/e2e/donor/start.cy.js":{"time":626,"weight":1},"cypress/e2e/donor/task-list.cy.js":{"time":644,"weight":1},"cypress/e2e/donor/view-lpa.cy.js":{"time":2222,"weight":3},"cypress/e2e/donor/want-replacement-attorneys.cy.js":{"time":2645,"weight":4},"cypress/e2e/donor/what-you-can-do-now.cy.js":{"time":16813,"weight":29},"cypress/e2e/donor/when-can-the-lpa-be-used.cy.js":{"time":1325,"weight":2},"cypress/e2e/donor/withdraw-lpa.cy.js":{"time":1529,"weight":2},"cypress/e2e/donor/you-cannot-sign-your-lpa-yet.cy.js":{"time":134,"weight":0},"cypress/e2e/donor/your-address.cy.js":{"time":8422,"weight":14},"cypress/e2e/donor/your-authorised-signatory.cy.js":{"time":2315,"weight":4},"cypress/e2e/donor/your-date-of-birth.cy.js":{"time":4532,"weight":8},"cypress/e2e/donor/your-independent-witness-address.cy.js":{"time":10339,"weight":18},"cypress/e2e/donor/your-independent-witness-mobile.cy.js":{"time":2067,"weight":3},"cypress/e2e/donor/your-independent-witness.cy.js":{"time":2893,"weight":5},"cypress/e2e/donor/your-name.cy.js":{"time":2518,"weight":4},"cypress/e2e/error-pages.cy.js":{"time":2135,"weight":3},"cypress/e2e/navigation.cy.js":{"time":1211,"weight":2},"cypress/e2e/supporter/add-correspondent.cy.js":{"time":10788,"weight":19},"cypress/e2e/supporter/dashboard.cy.js":{"time":9249,"weight":16},"cypress/e2e/supporter/donor-access.cy.js":{"time":4633,"weight":8},"cypress/e2e/supporter/edit-member.cy.js":{"time":8523,"weight":15},"cypress/e2e/supporter/enter-organisation-name.cy.js":{"time":1567,"weight":2},"cypress/e2e/supporter/invite-member.cy.js":{"time":4807,"weight":8},"cypress/e2e/supporter/manage-organisation.cy.js":{"time":4806,"weight":8},"cypress/e2e/supporter/manage-team-members.cy.js":{"time":1654,"weight":2},"cypress/e2e/supporter/start.cy.js":{"time":1360,"weight":2},"cypress/e2e/supporter/suspended.cy.js":{"time":428,"weight":0},"cypress/e2e/supporter/view-lpa.cy.js":{"time":6453,"weight":11},"cypress/e2e/voucher/confirm-your-identity.cy.js":{"time":7391,"weight":13},"cypress/e2e/voucher/confirm-your-name.cy.js":{"time":4141,"weight":7},"cypress/e2e/voucher/enter-reference-number.cy.js":{"time":3685,"weight":6},"cypress/e2e/voucher/verify-donor-details.cy.js":{"time":2001,"weight":3},"cypress/e2e/voucher/your-declaration.cy.js":{"time":1161,"weight":2}} \ No newline at end of file +{"cypress/e2e/accessibility/data-loss-warning.cy.js":{"time":3046,"weight":5},"cypress/e2e/attorney/confirm-your-details.cy.js":{"time":5956,"weight":10},"cypress/e2e/attorney/language-preferences.cy.js":{"time":1286,"weight":2},"cypress/e2e/attorney/legal-rights-and-responsibilities.cy.js":{"time":495,"weight":0},"cypress/e2e/attorney/opt-out.cy.js":{"time":1522,"weight":2},"cypress/e2e/attorney/phone-number.cy.js":{"time":2043,"weight":3},"cypress/e2e/attorney/progress.cy.js":{"time":2322,"weight":4},"cypress/e2e/attorney/read-the-lpa.cy.js":{"time":602,"weight":1},"cypress/e2e/attorney/sign.cy.js":{"time":4376,"weight":7},"cypress/e2e/attorney/start.cy.js":{"time":157,"weight":0},"cypress/e2e/attorney/task-list.cy.js":{"time":565,"weight":0},"cypress/e2e/attorney/trust-corporation.cy.js":{"time":13907,"weight":24},"cypress/e2e/attorney/what-happens-when-you-sign-the-lpa.cy.js":{"time":1156,"weight":2},"cypress/e2e/certificate-provider/certificate-provided.cy.js":{"time":1019,"weight":1},"cypress/e2e/certificate-provider/choose-not-to-be-a-certificate-provider.cy.js":{"time":2148,"weight":3},"cypress/e2e/certificate-provider/confirm-your-details.cy.js":{"time":4964,"weight":8},"cypress/e2e/certificate-provider/confirm-your-identity.cy.js":{"time":6267,"weight":10},"cypress/e2e/certificate-provider/dashboard.cy.js":{"time":1192,"weight":2},"cypress/e2e/certificate-provider/enter-date-of-birth.cy.js":{"time":6871,"weight":11},"cypress/e2e/certificate-provider/enter-reference-number.cy.js":{"time":4272,"weight":7},"cypress/e2e/certificate-provider/language-preferences.cy.js":{"time":1071,"weight":1},"cypress/e2e/certificate-provider/provide-certificate.cy.js":{"time":2883,"weight":4},"cypress/e2e/certificate-provider/read-the-lpa.cy.js":{"time":1448,"weight":2},"cypress/e2e/certificate-provider/start.cy.js":{"time":748,"weight":1},"cypress/e2e/certificate-provider/task-list.cy.js":{"time":438,"weight":0},"cypress/e2e/certificate-provider/what-is-your-home-address.cy.js":{"time":10295,"weight":17},"cypress/e2e/certificate-provider/who-is-eligible.cy.js":{"time":719,"weight":1},"cypress/e2e/dev-features.cy.js":{"time":394,"weight":0},"cypress/e2e/donor/add-correspondent.cy.js":{"time":9579,"weight":16},"cypress/e2e/donor/can-you-sign-your-lpa.cy.js":{"time":1687,"weight":2},"cypress/e2e/donor/certificate-provider.cy.js":{"time":16623,"weight":28},"cypress/e2e/donor/check-you-can-sign.cy.js":{"time":925,"weight":1},"cypress/e2e/donor/check-your-details.cy.js":{"time":2080,"weight":3},"cypress/e2e/donor/check-your-lpa.cy.js":{"time":9521,"weight":16},"cypress/e2e/donor/choose-attorneys-address.cy.js":{"time":10165,"weight":17},"cypress/e2e/donor/choose-attorneys-summary.cy.js":{"time":7413,"weight":12},"cypress/e2e/donor/choose-attorneys-task.cy.js":{"time":17363,"weight":30},"cypress/e2e/donor/choose-attorneys.cy.js":{"time":11554,"weight":19},"cypress/e2e/donor/choose-people-to-notify-address.cy.js":{"time":4226,"weight":7},"cypress/e2e/donor/choose-replacement-attorneys-address.cy.js":{"time":8812,"weight":15},"cypress/e2e/donor/choose-replacement-attorneys-summary.cy.js":{"time":8102,"weight":14},"cypress/e2e/donor/choose-replacement-attorneys-task.cy.js":{"time":116347,"weight":201},"cypress/e2e/donor/choose-replacement-attorneys.cy.js":{"time":12043,"weight":20},"cypress/e2e/donor/choose-someone-to-vouch-for-you.cy.js":{"time":675,"weight":1},"cypress/e2e/donor/confirm-person-allowed-to-vouch.cy.js":{"time":3931,"weight":6},"cypress/e2e/donor/confirm-your-certificate-provider-is-not-related.cy.js":{"time":2355,"weight":4},"cypress/e2e/donor/confirm-your-identity.cy.js":{"time":12903,"weight":22},"cypress/e2e/donor/cost-of-repeat-application.cy.js":{"time":891,"weight":1},"cypress/e2e/donor/dashboard.cy.js":{"time":4271,"weight":7},"cypress/e2e/donor/delete-lpa.cy.js":{"time":1040,"weight":1},"cypress/e2e/donor/enter-access-code.cy.js":{"time":978,"weight":1},"cypress/e2e/donor/enter-replacement-trust-corporation-address.cy.js":{"time":10605,"weight":18},"cypress/e2e/donor/enter-replacement-trust-corporation.cy.js":{"time":2290,"weight":3},"cypress/e2e/donor/enter-trust-corporation-address.cy.js":{"time":10227,"weight":17},"cypress/e2e/donor/enter-trust-corporation.cy.js":{"time":3054,"weight":5},"cypress/e2e/donor/enter-voucher.cy.js":{"time":4866,"weight":8},"cypress/e2e/donor/how-should-attorneys-make-decisions.cy.js":{"time":3043,"weight":5},"cypress/e2e/donor/how-should-replacement-attorneys-make-decisions.cy.js":{"time":2205,"weight":3},"cypress/e2e/donor/how-should-replacement-attorneys-step-in.cy.js":{"time":2479,"weight":4},"cypress/e2e/donor/language-preferences.cy.js":{"time":1091,"weight":1},"cypress/e2e/donor/life-sustaining-treatment.cy.js":{"time":1496,"weight":2},"cypress/e2e/donor/lpa-type.cy.js":{"time":6247,"weight":10},"cypress/e2e/donor/make-a-new-lpa.cy.js":{"time":4424,"weight":7},"cypress/e2e/donor/payment.cy.js":{"time":31333,"weight":54},"cypress/e2e/donor/people-to-notify.cy.js":{"time":10498,"weight":18},"cypress/e2e/donor/previous-application-number.cy.js":{"time":1467,"weight":2},"cypress/e2e/donor/progress.cy.js":{"time":19988,"weight":34},"cypress/e2e/donor/provide-your-details.cy.js":{"time":5177,"weight":8},"cypress/e2e/donor/remove-replacement-trust-corporation.cy.js":{"time":1075,"weight":1},"cypress/e2e/donor/remove-trust-corporation.cy.js":{"time":1108,"weight":1},"cypress/e2e/donor/restrictions.cy.js":{"time":793,"weight":1},"cypress/e2e/donor/sign-the-lpa.cy.js":{"time":8481,"weight":14},"cypress/e2e/donor/signing-on-behalf.cy.js":{"time":2859,"weight":4},"cypress/e2e/donor/start.cy.js":{"time":544,"weight":0},"cypress/e2e/donor/task-list.cy.js":{"time":532,"weight":0},"cypress/e2e/donor/view-lpa.cy.js":{"time":1768,"weight":3},"cypress/e2e/donor/want-replacement-attorneys.cy.js":{"time":2322,"weight":4},"cypress/e2e/donor/what-you-can-do-now.cy.js":{"time":16408,"weight":28},"cypress/e2e/donor/when-can-the-lpa-be-used.cy.js":{"time":971,"weight":1},"cypress/e2e/donor/withdraw-lpa.cy.js":{"time":1305,"weight":2},"cypress/e2e/donor/you-cannot-sign-your-lpa-yet.cy.js":{"time":2866,"weight":4},"cypress/e2e/donor/your-address.cy.js":{"time":7768,"weight":13},"cypress/e2e/donor/your-authorised-signatory.cy.js":{"time":2947,"weight":5},"cypress/e2e/donor/your-date-of-birth.cy.js":{"time":4566,"weight":7},"cypress/e2e/donor/your-independent-witness-address.cy.js":{"time":11003,"weight":19},"cypress/e2e/donor/your-independent-witness-mobile.cy.js":{"time":2067,"weight":3},"cypress/e2e/donor/your-independent-witness.cy.js":{"time":2368,"weight":4},"cypress/e2e/donor/your-name.cy.js":{"time":2633,"weight":4},"cypress/e2e/error-pages.cy.js":{"time":1678,"weight":2},"cypress/e2e/navigation.cy.js":{"time":575,"weight":0},"cypress/e2e/supporter/add-correspondent.cy.js":{"time":11372,"weight":19},"cypress/e2e/supporter/dashboard.cy.js":{"time":9676,"weight":16},"cypress/e2e/supporter/donor-access.cy.js":{"time":5047,"weight":8},"cypress/e2e/supporter/edit-member.cy.js":{"time":7446,"weight":12},"cypress/e2e/supporter/enter-organisation-name.cy.js":{"time":1558,"weight":2},"cypress/e2e/supporter/invite-member.cy.js":{"time":4300,"weight":7},"cypress/e2e/supporter/manage-organisation.cy.js":{"time":4739,"weight":8},"cypress/e2e/supporter/manage-team-members.cy.js":{"time":1752,"weight":3},"cypress/e2e/supporter/start.cy.js":{"time":1996,"weight":3},"cypress/e2e/supporter/suspended.cy.js":{"time":448,"weight":0},"cypress/e2e/supporter/view-lpa.cy.js":{"time":6045,"weight":10},"cypress/e2e/voucher/confirm-your-identity.cy.js":{"time":10244,"weight":17},"cypress/e2e/voucher/confirm-your-name.cy.js":{"time":3880,"weight":6},"cypress/e2e/voucher/enter-reference-number.cy.js":{"time":4796,"weight":8},"cypress/e2e/voucher/verify-donor-details.cy.js":{"time":1048,"weight":1},"cypress/e2e/voucher/your-declaration.cy.js":{"time":889,"weight":1},"cypress/smoke/smoke.cy.js":{"time":309,"weight":0}} \ No newline at end of file diff --git a/internal/page/fixtures/attorney.go b/internal/page/fixtures/attorney.go index 215d25714d..aa5225e6c1 100644 --- a/internal/page/fixtures/attorney.go +++ b/internal/page/fixtures/attorney.go @@ -178,7 +178,7 @@ func Attorney( donorDetails.SignedAt = testNow donorDetails.WitnessedByCertificateProviderAt = testNow - donorDetails.Donor = makeDonor(testEmail) + donorDetails.Donor = makeDonor(testEmail, "Sam", "Smith") if lpaType == "personal-welfare" && !isTrustCorporation { donorDetails.Type = lpadata.LpaTypePersonalWelfare diff --git a/internal/page/fixtures/certificate_provider.go b/internal/page/fixtures/certificate_provider.go index 0280c36bac..da74a6b1d7 100644 --- a/internal/page/fixtures/certificate_provider.go +++ b/internal/page/fixtures/certificate_provider.go @@ -261,7 +261,7 @@ func CertificateProvider( ) if donorChannel != "paper" { - donorDetails.Donor = makeDonor(donorEmail) + donorDetails.Donor = makeDonor(donorEmail, "Sam", "Smith") donorDetails.Type = lpadata.LpaTypePropertyAndAffairs if lpaType == "personal-welfare" { diff --git a/internal/page/fixtures/dashboard.go b/internal/page/fixtures/dashboard.go index 4783075da9..3bcf0254c3 100644 --- a/internal/page/fixtures/dashboard.go +++ b/internal/page/fixtures/dashboard.go @@ -55,7 +55,7 @@ func Dashboard( donorCtx := appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: meSessionID, LpaID: donor.LpaID}) donor.LpaUID = makeUID() - donor.Donor = makeDonor(testEmail) + donor.Donor = makeDonor(testEmail, "Sam", "Smith") donor.Type = lpadata.LpaTypePropertyAndAffairs donor.Attorneys = donordata.Attorneys{ @@ -72,7 +72,7 @@ func Dashboard( if err != nil { return err } - donor.Donor = makeDonor(testEmail) + donor.Donor = makeDonor(testEmail, "Sam", "Smith") donor.LpaUID = makeUID() if err := donorStore.Put(appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: donorSessionID, LpaID: donor.LpaID}), donor); err != nil { @@ -92,7 +92,7 @@ func Dashboard( if err != nil { return err } - donor.Donor = makeDonor(testEmail) + donor.Donor = makeDonor(testEmail, "Sam", "Smith") donor.Attorneys = donordata.Attorneys{ Attorneys: []donordata.Attorney{makeAttorney(attorneyNames[0])}, } diff --git a/internal/page/fixtures/donor.go b/internal/page/fixtures/donor.go index a4c8fd5046..cbcd5f2ac7 100644 --- a/internal/page/fixtures/donor.go +++ b/internal/page/fixtures/donor.go @@ -89,6 +89,8 @@ type FixtureData struct { CertificateProviderMobile string DonorSub string DonorEmail string + DonorFirstNames string + DonorLastName string IdStatus string Voucher string VouchAttempts string @@ -111,14 +113,14 @@ func Donor( data := setFixtureData(r) - if data.DonorSub == "" { - data.DonorSub = random.String(16) - } - if data.DonorEmail == "" { data.DonorEmail = testEmail } + if data.DonorSub == "" { + data.DonorSub = random.String(16) + } + if r.Method != http.MethodPost && !r.URL.Query().Has("redirect") { return tmpl(w, &fixturesData{ App: appData, @@ -210,9 +212,16 @@ func updateLPAProgress( voucherStore *voucher.Store, ) (*donordata.Provided, []func(context.Context, *lpastore.Client, *lpadata.Lpa) error, error) { var fns []func(context.Context, *lpastore.Client, *lpadata.Lpa) error - if data.Progress >= slices.Index(progressValues, "provideYourDetails") { - donorDetails.Donor = makeDonor(data.DonorEmail) + if data.DonorFirstNames == "" { + data.DonorFirstNames = "Sam" + } + + if data.DonorLastName == "" { + data.DonorLastName = "Smith" + } + + donorDetails.Donor = makeDonor(data.DonorEmail, data.DonorFirstNames, data.DonorLastName) donorDetails.Type = lpadata.LpaTypePropertyAndAffairs @@ -747,6 +756,8 @@ func setFixtureData(r *http.Request) FixtureData { CertificateProviderMobile: r.FormValue("certificateProviderMobile"), DonorSub: r.FormValue("donorSub"), DonorEmail: r.FormValue("donorEmail"), + DonorFirstNames: r.FormValue("donorFirstNames"), + DonorLastName: r.FormValue("donorLastName"), IdStatus: r.FormValue("idStatus"), Voucher: r.FormValue("voucher"), VouchAttempts: r.FormValue("vouchAttempts"), diff --git a/internal/page/fixtures/fixtures.go b/internal/page/fixtures/fixtures.go index 71ac7e361a..aab97ac365 100644 --- a/internal/page/fixtures/fixtures.go +++ b/internal/page/fixtures/fixtures.go @@ -127,11 +127,11 @@ func makeTrustCorporation(name string) donordata.TrustCorporation { } } -func makeDonor(email string) donordata.Donor { +func makeDonor(email, firstNames, lastname string) donordata.Donor { return donordata.Donor{ UID: actoruid.New(), - FirstNames: "Sam", - LastName: "Smith", + FirstNames: firstNames, + LastName: lastname, Address: place.Address{ Line1: "1 RICHMOND PLACE", Line2: "KINGS HEATH", diff --git a/internal/page/fixtures/supporter.go b/internal/page/fixtures/supporter.go index c1a193f8a8..2938fe7795 100644 --- a/internal/page/fixtures/supporter.go +++ b/internal/page/fixtures/supporter.go @@ -130,7 +130,7 @@ func Supporter( donorCtx := appcontext.ContextWithSession(r.Context(), &appcontext.Session{OrganisationID: org.ID, LpaID: donor.LpaID, SessionID: random.String(12)}) donor.LpaUID = makeUID() - donor.Donor = makeDonor(testEmail) + donor.Donor = makeDonor(testEmail, "Sam", "Smith") donor.Type = lpadata.LpaTypePropertyAndAffairs donor.CertificateProvider = makeCertificateProvider() donor.Attorneys = donordata.Attorneys{ @@ -185,7 +185,7 @@ func Supporter( donorCtx := appcontext.ContextWithSession(r.Context(), &appcontext.Session{OrganisationID: org.ID, LpaID: donor.LpaID}) donor.LpaUID = makeUID() - donor.Donor = makeDonor(testEmail) + donor.Donor = makeDonor(testEmail, "Sam", "Smith") donor.Type = lpadata.LpaTypePropertyAndAffairs donor.CertificateProvider = makeCertificateProvider() donor.Attorneys = donordata.Attorneys{ diff --git a/internal/page/fixtures/voucher.go b/internal/page/fixtures/voucher.go index b7329cf1bb..94b50e0a37 100644 --- a/internal/page/fixtures/voucher.go +++ b/internal/page/fixtures/voucher.go @@ -78,7 +78,7 @@ func Voucher( voucherCtx = appcontext.ContextWithSession(r.Context(), &appcontext.Session{SessionID: voucherSessionID, LpaID: donorDetails.LpaID}) ) - donorDetails.Donor = makeDonor(donorEmail) + donorDetails.Donor = makeDonor(donorEmail, "Sam", "Smith") donorDetails.Donor.Mobile = donorMobile donorDetails.LpaUID = makeUID() donorDetails.Type = lpadata.LpaTypePropertyAndAffairs diff --git a/web/template/fixtures.gohtml b/web/template/fixtures.gohtml index 0c9c743c34..c407215b76 100644 --- a/web/template/fixtures.gohtml +++ b/web/template/fixtures.gohtml @@ -36,6 +36,8 @@ {{ template "input" (input . "donorEmail" "Donor Email" .DonorEmail "classes" "govuk-input--width-20") }} + {{ template "input" (input . "donorFirstNames" "Donor First Names" "Sam" "classes" "govuk-input--width-20") }} + {{ template "input" (input . "donorLastName" "Donor Last Name" "Smith" "classes" "govuk-input--width-20") }} {{ template "input" (input . "donorSub" "Donor OneLogin sub" .Sub "classes" "govuk-input--width-20") }}
Copy this value or change to your own to log back in to an existing LPA from the start page