Skip to content

Commit

Permalink
MLPAB-1283 Only show LPAs with UIDs on the dashboard (#718)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx authored Sep 20, 2023
1 parent 8729d7d commit b410a07
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
8 changes: 7 additions & 1 deletion cypress/e2e/donor/dashboard.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ describe('Dashboard', () => {
cy.get('#f-can-sign').check();
cy.contains('button', 'Continue').click();

cy.visitLpa('/lpa-type');
cy.get('#f-lookup-postcode').type('B14 7ED');
cy.contains('button', 'Find address').click();

cy.get('#f-select-address').select('1 RICHMOND PLACE, BIRMINGHAM, B14 7ED');
cy.contains('button', 'Continue').click();
cy.contains('button', 'Continue').click();

cy.get('#f-lpa-type-2').check();
cy.contains('button', 'Continue').click();

cy.visit('/dashboard');
cy.visit('/dashboard');

cy.contains('Property and affairs: Sam Smith');
Expand Down
8 changes: 6 additions & 2 deletions internal/app/dashboard_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ func (s *dashboardStore) GetAll(ctx context.Context) (donor, attorney, certifica
return nil, nil, nil, err
}

certificateProviderMap := make(map[string]page.LpaAndActorTasks)
attorneyMap := make(map[string]page.LpaAndActorTasks)
certificateProviderMap := map[string]page.LpaAndActorTasks{}
attorneyMap := map[string]page.LpaAndActorTasks{}

for _, item := range lpasOrProvidedDetails {
var ks keys
Expand All @@ -100,6 +100,10 @@ func (s *dashboardStore) GetAll(ctx context.Context) (donor, attorney, certifica
return nil, nil, nil, err
}

if lpa.UID == "" {
continue
}

switch keyMap[lpa.ID] {
case actor.TypeDonor:
donor = append(donor, page.LpaAndActorTasks{Lpa: lpa})
Expand Down
12 changes: 8 additions & 4 deletions internal/app/dashboard_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ import (
)

func TestDashboardStoreGetAll(t *testing.T) {
lpa0 := &page.Lpa{ID: "0", UpdatedAt: time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC), SK: donorKey("an-id"), PK: lpaKey("0")}
lpa123 := &page.Lpa{ID: "123", UpdatedAt: time.Date(2001, time.January, 1, 0, 0, 0, 0, time.UTC), SK: donorKey("an-id"), PK: lpaKey("123")}
lpa456 := &page.Lpa{ID: "456", SK: donorKey("another-id"), PK: lpaKey("456")}
lpa0 := &page.Lpa{ID: "0", UID: "M", UpdatedAt: time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC), SK: donorKey("an-id"), PK: lpaKey("0")}
lpa123 := &page.Lpa{ID: "123", UID: "M", UpdatedAt: time.Date(2001, time.January, 1, 0, 0, 0, 0, time.UTC), SK: donorKey("an-id"), PK: lpaKey("123")}
lpa456 := &page.Lpa{ID: "456", UID: "M", SK: donorKey("another-id"), PK: lpaKey("456")}
lpa456CpProvidedDetails := &actor.CertificateProviderProvidedDetails{
LpaID: "456", Tasks: actor.CertificateProviderTasks{ConfirmYourDetails: actor.TaskCompleted}, SK: certificateProviderKey("an-id"),
}
lpa789 := &page.Lpa{ID: "789", SK: donorKey("different-id"), PK: lpaKey("789")}
lpa789 := &page.Lpa{ID: "789", UID: "M", SK: donorKey("different-id"), PK: lpaKey("789")}
lpa789AttorneyProvidedDetails := &actor.AttorneyProvidedDetails{
LpaID: "789", Tasks: actor.AttorneyTasks{ConfirmYourDetails: actor.TaskInProgress}, SK: attorneyKey("an-id"),
}
lpaNoUID := &page.Lpa{ID: "999", UpdatedAt: time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC), SK: donorKey("an-id"), PK: lpaKey("0")}

testCases := map[string][]map[string]types.AttributeValue{
"details returned after lpas": {
Expand All @@ -35,6 +36,7 @@ func TestDashboardStoreGetAll(t *testing.T) {
makeAttributeValueMap(lpa0),
},
"details returned before lpas": {
makeAttributeValueMap(lpaNoUID),
makeAttributeValueMap(lpa456CpProvidedDetails),
makeAttributeValueMap(lpa789AttorneyProvidedDetails),
makeAttributeValueMap(lpa123),
Expand All @@ -55,6 +57,7 @@ func TestDashboardStoreGetAll(t *testing.T) {
{PK: "LPA#456", SK: "#SUB#an-id", DonorKey: "#DONOR#another-id", ActorType: actor.TypeCertificateProvider},
{PK: "LPA#789", SK: "#SUB#an-id", DonorKey: "#DONOR#different-id", ActorType: actor.TypeAttorney},
{PK: "LPA#0", SK: "#SUB#an-id", DonorKey: "#DONOR#an-id", ActorType: actor.TypeDonor},
{PK: "LPA#999", SK: "#SUB#an-id", DonorKey: "#DONOR#an-id", ActorType: actor.TypeDonor},
}, nil)
dynamoClient.ExpectGetAllByKeys(ctx, []dynamo.Key{
{PK: "LPA#123", SK: "#DONOR#an-id"},
Expand All @@ -63,6 +66,7 @@ func TestDashboardStoreGetAll(t *testing.T) {
{PK: "LPA#789", SK: "#DONOR#different-id"},
{PK: "LPA#789", SK: "#ATTORNEY#an-id"},
{PK: "LPA#0", SK: "#DONOR#an-id"},
{PK: "LPA#999", SK: "#DONOR#an-id"},
}, attributeValues, nil)

dashboardStore := &dashboardStore{dynamoClient: dynamoClient}
Expand Down

0 comments on commit b410a07

Please sign in to comment.