-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MLPAB-1743: Create a new LPA as a supporter #1017
Merged
Merged
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5afcfe9
break out supporter handlers
acsauk f621409
Merge branch 'main' into MLPAB-1743
acsauk 48dbea7
Merge branch 'main' into MLPAB-1743
acsauk 26544f7
fix supporter routing
acsauk baf659f
fix handlers
acsauk cb00121
rely on SessionData for org ID
acsauk 74b02a6
updates mocks
acsauk 8f55518
Merge branch 'main' into MLPAB-1743
acsauk d32570e
prefer passing org ID
acsauk 937d100
tidy
acsauk e5c2676
tidy
acsauk 48d1303
template fix
acsauk 58df922
test fixes
acsauk 2991002
add e2e
acsauk 2d76db2
bump cov
acsauk 7e4a5dc
Merge branch 'main' into MLPAB-1743
acsauk e458088
make corp name black
acsauk fb43534
add org name to login session
acsauk ac2b0bf
Merge branch 'main' into MLPAB-1743
acsauk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) | ||
}) | ||
} | ||
} | ||
|
@@ -194,3 +203,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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm leaving this here for now. We could probably modify
donorStore.Create()
but I didn't want to have to think through theLpaLink
implications until we need it for the dashboard.