-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MLPAB-1743: Create a new LPA as a supporter (#1017)
- Loading branch information
Showing
25 changed files
with
908 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
describe('Dashboard', () => { | ||
beforeEach(() => { | ||
cy.visit('/fixtures/supporter?redirect=/supporter-dashboard&organisation=1'); | ||
}); | ||
|
||
it('can create a new LPA', () => { | ||
cy.checkA11yApp(); | ||
cy.contains('button', 'Make a new LPA').click(); | ||
|
||
cy.url().should('contain', '/your-details'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,8 +33,15 @@ func TestOrganisationStoreCreate(t *testing.T) { | |
|
||
organisationStore := &organisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} | ||
|
||
err := organisationStore.Create(ctx, "A name") | ||
organisation, err := organisationStore.Create(ctx, "A name") | ||
assert.Nil(t, err) | ||
assert.Equal(t, &actor.Organisation{ | ||
PK: "ORGANISATION#a-uuid", | ||
SK: "ORGANISATION#a-uuid", | ||
ID: "a-uuid", | ||
CreatedAt: testNow, | ||
Name: "A name", | ||
}, organisation) | ||
} | ||
|
||
func TestOrganisationStoreCreateWithSessionMissing(t *testing.T) { | ||
|
@@ -47,8 +54,9 @@ func TestOrganisationStoreCreateWithSessionMissing(t *testing.T) { | |
t.Run(name, func(t *testing.T) { | ||
organisationStore := &organisationStore{} | ||
|
||
err := organisationStore.Create(ctx, "A name") | ||
organisation, err := organisationStore.Create(ctx, "A name") | ||
assert.Error(t, err) | ||
assert.Nil(t, organisation) | ||
}) | ||
} | ||
} | ||
|
@@ -84,8 +92,9 @@ func TestOrganisationStoreCreateWhenErrors(t *testing.T) { | |
dynamoClient := makeMockDynamoClient(t) | ||
organisationStore := &organisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} | ||
|
||
err := organisationStore.Create(ctx, "A name") | ||
organisation, err := organisationStore.Create(ctx, "A name") | ||
assert.ErrorIs(t, err, expectedError) | ||
assert.Nil(t, organisation) | ||
}) | ||
} | ||
} | ||
|
@@ -211,3 +220,62 @@ func TestOrganisationStoreCreateMemberInviteWhenErrors(t *testing.T) { | |
err := organisationStore.CreateMemberInvite(ctx, &actor.Organisation{}, "[email protected]", "abcde") | ||
assert.ErrorIs(t, err, expectedError) | ||
} | ||
|
||
func TestOrganisationStoreCreateLPA(t *testing.T) { | ||
ctx := page.ContextWithSessionData(context.Background(), &page.SessionData{SessionID: "an-id"}) | ||
expectedDonor := &actor.DonorProvidedDetails{ | ||
PK: "LPA#a-uuid", | ||
SK: "ORGANISATION#an-id", | ||
LpaID: "a-uuid", | ||
CreatedAt: testNow, | ||
Version: 1, | ||
} | ||
expectedDonor.Hash, _ = expectedDonor.GenerateHash() | ||
|
||
dynamoClient := newMockDynamoClient(t) | ||
dynamoClient.EXPECT(). | ||
Create(ctx, expectedDonor). | ||
Return(nil) | ||
|
||
organisationStore := &organisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} | ||
|
||
donor, err := organisationStore.CreateLPA(ctx, "an-id") | ||
|
||
assert.Nil(t, err) | ||
assert.Equal(t, expectedDonor, donor) | ||
} | ||
|
||
func TestOrganisationStoreCreateLPAWithSessionMissing(t *testing.T) { | ||
ctx := page.ContextWithSessionData(context.Background(), &page.SessionData{SessionID: ""}) | ||
|
||
organisationStore := &organisationStore{dynamoClient: nil, now: testNowFn, uuidString: func() string { return "a-uuid" }} | ||
|
||
_, err := organisationStore.CreateLPA(ctx, "an-id") | ||
|
||
assert.NotNil(t, err) | ||
} | ||
|
||
func TestOrganisationStoreCreateLPAMissingSessionID(t *testing.T) { | ||
ctx := context.Background() | ||
|
||
organisationStore := &organisationStore{dynamoClient: nil, now: testNowFn, uuidString: func() string { return "a-uuid" }} | ||
|
||
_, err := organisationStore.CreateLPA(ctx, "an-id") | ||
|
||
assert.Equal(t, page.SessionMissingError{}, err) | ||
} | ||
|
||
func TestOrganisationStoreCreateLPAWhenDynamoError(t *testing.T) { | ||
ctx := page.ContextWithSessionData(context.Background(), &page.SessionData{SessionID: "an-id"}) | ||
|
||
dynamoClient := newMockDynamoClient(t) | ||
dynamoClient.EXPECT(). | ||
Create(ctx, mock.Anything). | ||
Return(expectedError) | ||
|
||
organisationStore := &organisationStore{dynamoClient: dynamoClient, now: testNowFn, uuidString: func() string { return "a-uuid" }} | ||
|
||
_, err := organisationStore.CreateLPA(ctx, "an-id") | ||
|
||
assert.Equal(t, expectedError, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.