-
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-1596 Send attorney invite after certificate is provided (#902)
- Loading branch information
Showing
18 changed files
with
394 additions
and
257 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
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 |
---|---|---|
|
@@ -151,6 +151,7 @@ func App( | |
notFoundHandler, | ||
addressClient, | ||
notifyClient, | ||
shareCodeSender, | ||
) | ||
|
||
attorney.Register( | ||
|
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 |
---|---|---|
|
@@ -78,6 +78,59 @@ func TestEmailWhenError(t *testing.T) { | |
assert.Equal(`error sending message: This happened: Plus this`, err.Error()) | ||
} | ||
|
||
type testSendableEmail struct { | ||
A string | ||
} | ||
|
||
func (e testSendableEmail) emailID(bool) string { return "template-id" } | ||
|
||
func TestSendEmail(t *testing.T) { | ||
assert := assert.New(t) | ||
ctx := context.Background() | ||
|
||
doer := newMockDoer(t) | ||
doer. | ||
On("Do", mock.MatchedBy(func(req *http.Request) bool { | ||
var buf bytes.Buffer | ||
io.Copy(&buf, req.Body) | ||
req.Body = ioutil.NopCloser(&buf) | ||
|
||
var v map[string]any | ||
json.Unmarshal(buf.Bytes(), &v) | ||
|
||
return assert.Equal("[email protected]", v["email_address"].(string)) && | ||
assert.Equal("template-id", v["template_id"].(string)) && | ||
assert.Equal(map[string]any{"A": "value"}, v["personalisation"].(map[string]any)) | ||
})). | ||
Return(&http.Response{ | ||
Body: io.NopCloser(strings.NewReader(`{"id":"xyz"}`)), | ||
}, nil) | ||
|
||
client, _ := New(true, "", "my_client-f33517ff-2a88-4f6e-b855-c550268ce08a-740e5834-3a29-46b4-9a6f-16142fde533a", doer) | ||
client.now = func() time.Time { return time.Date(2020, time.January, 2, 3, 4, 5, 6, time.UTC) } | ||
|
||
id, err := client.SendEmail(ctx, "[email protected]", testSendableEmail{A: "value"}) | ||
assert.Nil(err) | ||
assert.Equal("xyz", id) | ||
} | ||
|
||
func TestSendEmailWhenError(t *testing.T) { | ||
assert := assert.New(t) | ||
ctx := context.Background() | ||
|
||
doer := newMockDoer(t) | ||
doer. | ||
On("Do", mock.Anything). | ||
Return(&http.Response{ | ||
Body: io.NopCloser(strings.NewReader(`{"errors":[{"error":"SomeError","message":"This happened"}, {"error":"AndError","message":"Plus this"}]}`)), | ||
}, nil) | ||
|
||
client, _ := New(true, "", "my_client-f33517ff-2a88-4f6e-b855-c550268ce08a-740e5834-3a29-46b4-9a6f-16142fde533a", doer) | ||
|
||
_, err := client.SendEmail(ctx, "[email protected]", testSendableEmail{}) | ||
assert.Equal(`error sending message: This happened: Plus this`, err.Error()) | ||
} | ||
|
||
func TestTemplateID(t *testing.T) { | ||
production, _ := New(true, "", "my_client-f33517ff-2a88-4f6e-b855-c550268ce08a-740e5834-3a29-46b4-9a6f-16142fde533a", nil) | ||
assert.Equal(t, "e39849c0-ecab-4e16-87ec-6b22afb9d535", production.TemplateID(WitnessCodeSMS)) | ||
|
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,19 @@ | ||
package notify | ||
|
||
type InitialOriginalAttorneyEmail struct { | ||
DonorFullName string | ||
LpaType string | ||
AttorneyFullName string | ||
DonorFirstNames string | ||
AttorneyStartPageURL string | ||
ShareCode string | ||
DonorFirstNamesPossessive string | ||
} | ||
|
||
func (e InitialOriginalAttorneyEmail) emailID(isProduction bool) string { | ||
if isProduction { | ||
return "080071dc-0434-4b13-adb7-c4e5612c4b47" | ||
} | ||
|
||
return "376d7ef2-7941-46c2-b372-bacca0e00c1d" | ||
} |
47 changes: 47 additions & 0 deletions
47
internal/page/certificateprovider/mock_ShareCodeSender_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.