diff --git a/cmd/event-received/lpastore_event_handler.go b/cmd/event-received/lpastore_event_handler.go index 3b2eb5b1db..e01ee79979 100644 --- a/cmd/event-received/lpastore_event_handler.go +++ b/cmd/event-received/lpastore_event_handler.go @@ -32,7 +32,7 @@ func handleLpaUpdated(ctx context.Context, client dynamodbClient, event *events. return fmt.Errorf("failed to unmarshal detail: %w", err) } - if v.ChangeType != "PERFECT" { + if v.ChangeType != "STATUTORY_WAITING_PERIOD" { return nil } @@ -41,7 +41,7 @@ func handleLpaUpdated(ctx context.Context, client dynamodbClient, event *events. return err } - donor.PerfectAt = now() + donor.StatutoryWaitingPeriodAt = now() if err := putDonor(ctx, donor, now, client); err != nil { return fmt.Errorf("failed to update donor details: %w", err) diff --git a/cmd/event-received/lpastore_event_handler_test.go b/cmd/event-received/lpastore_event_handler_test.go index f415323f95..8046740278 100644 --- a/cmd/event-received/lpastore_event_handler_test.go +++ b/cmd/event-received/lpastore_event_handler_test.go @@ -23,14 +23,14 @@ func TestLpaStoreEventHandlerHandleUnknownEvent(t *testing.T) { func TestLpaStoreEventHandlerHandleLpaUpdated(t *testing.T) { event := &events.CloudWatchEvent{ DetailType: "lpa-updated", - Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","changeType":"PERFECT"}`), + Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","changeType":"STATUTORY_WAITING_PERIOD"}`), } updated := &donordata.Provided{ - PK: dynamo.LpaKey("123"), - SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), - PerfectAt: testNow, - UpdatedAt: testNow, + PK: dynamo.LpaKey("123"), + SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), + StatutoryWaitingPeriodAt: testNow, + UpdatedAt: testNow, } updated.UpdateHash() @@ -63,7 +63,7 @@ func TestLpaStoreEventHandlerHandleLpaUpdated(t *testing.T) { assert.Nil(t, err) } -func TestLpaStoreEventHandlerHandleLpaUpdatedWhenChangeTypeNotPerfect(t *testing.T) { +func TestLpaStoreEventHandlerHandleLpaUpdatedWhenChangeTypeNotStatutoryWaitingPeriod(t *testing.T) { event := &events.CloudWatchEvent{ DetailType: "lpa-updated", Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","changeType":"WHAT"}`), @@ -82,14 +82,14 @@ func TestLpaStoreEventHandlerHandleLpaUpdatedWhenChangeTypeNotPerfect(t *testing func TestLpaStoreEventHandlerHandleLpaUpdatedWhenDynamoGetErrors(t *testing.T) { event := &events.CloudWatchEvent{ DetailType: "lpa-updated", - Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","changeType":"PERFECT"}`), + Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","changeType":"STATUTORY_WAITING_PERIOD"}`), } updated := &donordata.Provided{ - PK: dynamo.LpaKey("123"), - SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), - PerfectAt: testNow, - UpdatedAt: testNow, + PK: dynamo.LpaKey("123"), + SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), + StatutoryWaitingPeriodAt: testNow, + UpdatedAt: testNow, } updated.UpdateHash() @@ -111,14 +111,14 @@ func TestLpaStoreEventHandlerHandleLpaUpdatedWhenDynamoGetErrors(t *testing.T) { func TestLpaStoreEventHandlerHandleLpaUpdatedWhenDynamoPutErrors(t *testing.T) { event := &events.CloudWatchEvent{ DetailType: "lpa-updated", - Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","changeType":"PERFECT"}`), + Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","changeType":"STATUTORY_WAITING_PERIOD"}`), } updated := &donordata.Provided{ - PK: dynamo.LpaKey("123"), - SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), - PerfectAt: testNow, - UpdatedAt: testNow, + PK: dynamo.LpaKey("123"), + SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), + StatutoryWaitingPeriodAt: testNow, + UpdatedAt: testNow, } updated.UpdateHash() diff --git a/cypress/e2e/donor/dashboard.cy.js b/cypress/e2e/donor/dashboard.cy.js index 26e402f3be..3008087424 100644 --- a/cypress/e2e/donor/dashboard.cy.js +++ b/cypress/e2e/donor/dashboard.cy.js @@ -43,7 +43,7 @@ describe('Dashboard', () => { }); }); - context('with perfect LPA', () => { + context('with statutory waiting period LPA', () => { it('shows the correct options', () => { cy.visit('/fixtures?redirect=&progress=submitted'); diff --git a/docker/mock-lpa-store/lpa-store.js b/docker/mock-lpa-store/lpa-store.js index 003c80746d..e24b891adb 100644 --- a/docker/mock-lpa-store/lpa-store.js +++ b/docker/mock-lpa-store/lpa-store.js @@ -67,12 +67,12 @@ switch (context.request.method) { lpa.certificateProvider.signedAt = signedAt; break; - case 'PERFECT': - lpa.status = 'perfect'; + case 'STATUTORY_WAITING_PERIOD': + lpa.status = 'statutory-waiting-period'; break; case 'REGISTER': - if (lpa.status === 'perfect') { + if (lpa.status === 'statutory-waiting-period') { lpa.status = 'registered'; lpa.registrationDate = new Date(Date.now()).toISOString(); } diff --git a/internal/donor/donordata/provided.go b/internal/donor/donordata/provided.go index 58ffe491ec..8dd2ea36a3 100644 --- a/internal/donor/donordata/provided.go +++ b/internal/donor/donordata/provided.go @@ -122,8 +122,9 @@ type Provided struct { SubmittedAt time.Time // WithdrawnAt is when the Lpa was withdrawn by the donor WithdrawnAt time.Time - // PerfectAt is when the Lpa transitioned to the PERFECT status in the lpa-store - PerfectAt time.Time + // StatutoryWaitingPeriodAt is when the Lpa transitioned to the STATUTORY_WAITING_PERIOD + // status in the lpa-store + StatutoryWaitingPeriodAt time.Time // RegisteringWithCourtOfProtection is set when the donor wishes to take the // Lpa to the Court of Protection for registration. RegisteringWithCourtOfProtection bool @@ -198,7 +199,7 @@ func (c toCheck) HashInclude(field string, _ any) (bool, error) { "SignedAt", "SubmittedAt", "WithdrawnAt", - "PerfectAt", + "StatutoryWaitingPeriodAt", "CertificateProviderCodes", "WitnessedByCertificateProviderAt", "IndependentWitnessCodes", diff --git a/internal/donor/donordata/provided_test.go b/internal/donor/donordata/provided_test.go index 518c2f181d..cebcdee770 100644 --- a/internal/donor/donordata/provided_test.go +++ b/internal/donor/donordata/provided_test.go @@ -41,14 +41,14 @@ func TestGenerateHash(t *testing.T) { } // DO change this value to match the updates - const modified uint64 = 0x171cc2a0256d4510 + const modified uint64 = 0x1270f2b79d9db4a5 // DO NOT change these initial hash values. If a field has been added/removed // you will need to handle the version gracefully by modifying // (*Provided).HashInclude and adding another testcase for the new // version. testcases := map[uint8]uint64{ - 0: 0x556e667fbc8c5f94, + 0: 0x71bd1fb1ede66b54, } for version, initial := range testcases { diff --git a/internal/lpastore/lpadata/lpa.go b/internal/lpastore/lpadata/lpa.go index dc29a05cf1..1bd7e3e77b 100644 --- a/internal/lpastore/lpadata/lpa.go +++ b/internal/lpastore/lpadata/lpa.go @@ -16,7 +16,7 @@ type Lpa struct { LpaUID string RegisteredAt time.Time WithdrawnAt time.Time - PerfectAt time.Time + StatutoryWaitingPeriodAt time.Time UpdatedAt time.Time Type LpaType Donor Donor diff --git a/internal/lpastore/resolving_service.go b/internal/lpastore/resolving_service.go index 6b8246ebb1..2aba02c8c2 100644 --- a/internal/lpastore/resolving_service.go +++ b/internal/lpastore/resolving_service.go @@ -82,7 +82,7 @@ func (s *ResolvingService) merge(lpa *lpadata.Lpa, donor *donordata.Provided) *l lpa.LpaOwnerKey = donor.SK lpa.LpaID = donor.LpaID lpa.LpaUID = donor.LpaUID - lpa.PerfectAt = donor.PerfectAt + lpa.StatutoryWaitingPeriodAt = donor.StatutoryWaitingPeriodAt if donor.SK.Equals(dynamo.DonorKey("PAPER")) { lpa.Drafted = true lpa.Submitted = true diff --git a/internal/lpastore/update.go b/internal/lpastore/update.go index ceae6ef208..3082862779 100644 --- a/internal/lpastore/update.go +++ b/internal/lpastore/update.go @@ -64,9 +64,9 @@ func (c *Client) SendRegister(ctx context.Context, lpaUID string) error { return c.sendUpdate(ctx, lpaUID, actoruid.Service, body) } -func (c *Client) SendPerfect(ctx context.Context, lpaUID string) error { +func (c *Client) SendStatutoryWaitingPeriod(ctx context.Context, lpaUID string) error { body := updateRequest{ - Type: "PERFECT", + Type: "STATUTORY_WAITING_PERIOD", } return c.sendUpdate(ctx, lpaUID, actoruid.Service, body) diff --git a/internal/lpastore/update_test.go b/internal/lpastore/update_test.go index 5b371edebe..5970062425 100644 --- a/internal/lpastore/update_test.go +++ b/internal/lpastore/update_test.go @@ -55,8 +55,8 @@ func TestClientSendRegister(t *testing.T) { assert.Nil(t, err) } -func TestClientSendPerfect(t *testing.T) { - json := `{"type":"PERFECT","changes":null}` +func TestClientSendStatutoryWaitingPeriod(t *testing.T) { + json := `{"type":"STATUTORY_WAITING_PERIOD","changes":null}` ctx := context.Background() @@ -84,7 +84,7 @@ func TestClientSendPerfect(t *testing.T) { client := New("http://base", secretsClient, "secret", doer) client.now = func() time.Time { return time.Date(2000, time.January, 2, 3, 4, 5, 6, time.UTC) } - err := client.SendPerfect(ctx, "lpa-uid") + err := client.SendStatutoryWaitingPeriod(ctx, "lpa-uid") assert.Nil(t, err) } diff --git a/internal/page/fixtures/donor.go b/internal/page/fixtures/donor.go index 85c5922296..292346f36e 100644 --- a/internal/page/fixtures/donor.go +++ b/internal/page/fixtures/donor.go @@ -61,7 +61,7 @@ var progressValues = []string{ "signedByCertificateProvider", "signedByAttorneys", "submitted", - "perfect", + "statutoryWaitingPeriod", "withdrawn", "certificateProviderOptedOut", "registered", @@ -575,11 +575,11 @@ func updateLPAProgress( donorDetails.SubmittedAt = time.Now() } - if data.Progress >= slices.Index(progressValues, "perfect") { + if data.Progress >= slices.Index(progressValues, "statutoryWaitingPeriod") { fns = append(fns, func(ctx context.Context, client *lpastore.Client, _ *lpadata.Lpa) error { - return client.SendPerfect(ctx, donorDetails.LpaUID) + return client.SendStatutoryWaitingPeriod(ctx, donorDetails.LpaUID) }) - donorDetails.PerfectAt = time.Now() + donorDetails.StatutoryWaitingPeriodAt = time.Now() } if data.Progress == slices.Index(progressValues, "withdrawn") { diff --git a/internal/task/progress.go b/internal/task/progress.go index 05e9d49ca5..36bf2383d6 100644 --- a/internal/task/progress.go +++ b/internal/task/progress.go @@ -192,12 +192,12 @@ func (pt ProgressTracker) Progress(lpa *lpadata.Lpa) Progress { progress.LpaSubmitted.State = StateCompleted - if lpa.PerfectAt.IsZero() { + if lpa.StatutoryWaitingPeriodAt.IsZero() { return progress } progress.NoticesOfIntentSent.Label = pt.Localizer.Format(labels["noticesOfIntentSent"], map[string]any{ - "SentOn": pt.Localizer.FormatDate(lpa.PerfectAt), + "SentOn": pt.Localizer.FormatDate(lpa.StatutoryWaitingPeriodAt), }) progress.NoticesOfIntentSent.State = StateCompleted progress.StatutoryWaitingPeriod.State = StateInProgress diff --git a/internal/task/progress_test.go b/internal/task/progress_test.go index 1348f59c15..8e09b3ad32 100644 --- a/internal/task/progress_test.go +++ b/internal/task/progress_test.go @@ -245,7 +245,7 @@ func TestProgressTrackerProgress(t *testing.T) { Return("AttorneysSigned translation") }, }, - "perfect": { + "statutory waiting period": { lpa: &lpadata.Lpa{ Paid: true, Donor: lpadata.Donor{FirstNames: "a", LastName: "b"}, @@ -254,7 +254,7 @@ func TestProgressTrackerProgress(t *testing.T) { SignedAt: lpaSignedAt, WitnessedByCertificateProviderAt: lpaSignedAt, Submitted: true, - PerfectAt: lpaSignedAt, + StatutoryWaitingPeriodAt: lpaSignedAt, }, expectedProgress: func() Progress { progress := initialProgress @@ -276,11 +276,11 @@ func TestProgressTrackerProgress(t *testing.T) { Count("attorneysHaveDeclared", 1). Return("AttorneysSigned translation") localizer.EXPECT(). - Format("weSentAnEmailYourLpaIsReadyToRegister", map[string]any{"SentOn": "perfect-on"}). + Format("weSentAnEmailYourLpaIsReadyToRegister", map[string]any{"SentOn": "statutory-waiting-period-on"}). Return("NoticesOfIntentSent translation") localizer.EXPECT(). FormatDate(lpaSignedAt). - Return("perfect-on") + Return("statutory-waiting-period-on") }, }, "registered": { @@ -292,7 +292,7 @@ func TestProgressTrackerProgress(t *testing.T) { Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid1, SignedAt: lpaSignedAt.Add(time.Minute)}}}, CertificateProvider: lpadata.CertificateProvider{SignedAt: lpaSignedAt}, Submitted: true, - PerfectAt: lpaSignedAt, + StatutoryWaitingPeriodAt: lpaSignedAt, RegisteredAt: lpaSignedAt, }, expectedProgress: func() Progress { @@ -316,11 +316,11 @@ func TestProgressTrackerProgress(t *testing.T) { Count("attorneysHaveDeclared", 1). Return("AttorneysSigned translation") localizer.EXPECT(). - Format("weSentAnEmailYourLpaIsReadyToRegister", map[string]any{"SentOn": "perfect-on"}). + Format("weSentAnEmailYourLpaIsReadyToRegister", map[string]any{"SentOn": "statutory-waiting-period-on"}). Return("NoticesOfIntentSent translation") localizer.EXPECT(). FormatDate(lpaSignedAt). - Return("perfect-on") + Return("statutory-waiting-period-on") }, }, } @@ -525,7 +525,7 @@ func TestLpaProgressAsSupporter(t *testing.T) { return progress }, }, - "perfect": { + "statutory waiting period": { lpa: &lpadata.Lpa{ IsOrganisationDonor: true, Donor: lpadata.Donor{ @@ -540,7 +540,7 @@ func TestLpaProgressAsSupporter(t *testing.T) { SignedAt: lpaSignedAt, WitnessedByCertificateProviderAt: lpaSignedAt, Submitted: true, - PerfectAt: lpaSignedAt, + StatutoryWaitingPeriodAt: lpaSignedAt, }, expectedProgress: func() Progress { progress := initialProgress @@ -558,11 +558,11 @@ func TestLpaProgressAsSupporter(t *testing.T) { }, setupLocalizer: func(localizer *mockLocalizer) { localizer.EXPECT(). - Format("weSentAnEmailTheLpaIsReadyToRegister", map[string]any{"SentOn": "perfect-on"}). + Format("weSentAnEmailTheLpaIsReadyToRegister", map[string]any{"SentOn": "statutory-waiting-period-on"}). Return("NoticesOfIntentSent translation") localizer.EXPECT(). FormatDate(lpaSignedAt). - Return("perfect-on") + Return("statutory-waiting-period-on") }, }, "registered": { @@ -580,7 +580,7 @@ func TestLpaProgressAsSupporter(t *testing.T) { SignedAt: lpaSignedAt, WitnessedByCertificateProviderAt: lpaSignedAt, Submitted: true, - PerfectAt: lpaSignedAt, + StatutoryWaitingPeriodAt: lpaSignedAt, RegisteredAt: lpaSignedAt, }, expectedProgress: func() Progress { @@ -600,11 +600,11 @@ func TestLpaProgressAsSupporter(t *testing.T) { }, setupLocalizer: func(localizer *mockLocalizer) { localizer.EXPECT(). - Format("weSentAnEmailTheLpaIsReadyToRegister", map[string]any{"SentOn": "perfect-on"}). + Format("weSentAnEmailTheLpaIsReadyToRegister", map[string]any{"SentOn": "statutory-waiting-period-on"}). Return("NoticesOfIntentSent translation") localizer.EXPECT(). FormatDate(lpaSignedAt). - Return("perfect-on") + Return("statutory-waiting-period-on") }, }, } diff --git a/web/template/dashboard.gohtml b/web/template/dashboard.gohtml index 7d2881ad9d..00d54fb889 100644 --- a/web/template/dashboard.gohtml +++ b/web/template/dashboard.gohtml @@ -16,7 +16,7 @@ {{ tr .App "cannotRegister" }} {{ else if not .Item.Lpa.RegisteredAt.IsZero }} {{ tr .App "registered" }} - {{ else if not .Item.Lpa.PerfectAt.IsZero }} + {{ else if not .Item.Lpa.StatutoryWaitingPeriodAt.IsZero }} {{ tr .App "waitingPeriod" }} {{ else if .Item.Lpa.Drafted }} {{ tr .App "inProgress" }} diff --git a/web/template/fixtures.gohtml b/web/template/fixtures.gohtml index 0f6abd3ec7..33e9663d2c 100644 --- a/web/template/fixtures.gohtml +++ b/web/template/fixtures.gohtml @@ -67,7 +67,7 @@ (item "signedByCertificateProvider" "Signed by certificate provider") (item "signedByAttorneys" "Signed by attorneys") (item "submitted" "Submitted") - (item "perfect" "Perfect") + (item "statutoryWaitingPeriod" "Statutory waiting period") (item "withdrawn" "Withdrawn") (item "certificateProviderOptedOut" "Certificate provider opted out (post signing)") (item "registered" "registered")