-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from icdocsoc/feat-test-email
feat: test email mode
- Loading branch information
Showing
6 changed files
with
157 additions
and
34 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
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 |
---|---|---|
|
@@ -123,6 +123,84 @@ describe("sendEmails", () => { | |
expect(mockMailer.sendMail).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it("should send to test email if given and not cc or bcc anyone in", async () => { | ||
const mergeResults: MergeResultWithMetadata<unknown>[] = [ | ||
{ | ||
record: { field1: "value1" }, | ||
/// @ts-expect-error: Mocking previews | ||
previews: ["preview"], | ||
engineInfo: { name: "testEngine", options: {} }, | ||
email: { | ||
to: ["[email protected]"], | ||
subject: "Test Subject", | ||
cc: ["[email protected]"], | ||
bcc: ["[email protected]"], | ||
}, | ||
attachmentPaths: [], | ||
}, | ||
]; | ||
(mockStorageBackend.loadMergeResults as jest.Mock).mockReturnValue(mergeResults); | ||
|
||
const enginesMap = { | ||
testEngine: mockEngineConstructor, | ||
}; | ||
|
||
await sendEmails( | ||
mockStorageBackend, | ||
mockMailer, | ||
'"From" <[email protected]>', | ||
enginesMap, | ||
true, | ||
{ | ||
onlySend: 1, | ||
testSendTo: "[email protected]", | ||
}, | ||
); | ||
|
||
expect(mockMailer.sendMail).toHaveBeenCalledWith( | ||
'"From" <[email protected]>', | ||
["[email protected]"], | ||
"(TEST) Test Subject", | ||
expect.any(String), | ||
[], | ||
{ | ||
cc: [], | ||
bcc: [], | ||
}, | ||
); | ||
}); | ||
|
||
it("should refuse test send if onlySend is not set", async () => { | ||
const mergeResults: MergeResultWithMetadata<unknown>[] = [ | ||
{ | ||
record: { field1: "value1" }, | ||
/// @ts-expect-error: Mocking previews | ||
previews: ["preview"], | ||
engineInfo: { name: "testEngine", options: {} }, | ||
email: { to: ["[email protected]"], subject: "Test Subject", cc: [], bcc: [] }, | ||
attachmentPaths: [], | ||
}, | ||
]; | ||
(mockStorageBackend.loadMergeResults as jest.Mock).mockReturnValue(mergeResults); | ||
|
||
const enginesMap = { | ||
testEngine: mockEngineConstructor, | ||
}; | ||
|
||
await expect( | ||
sendEmails( | ||
mockStorageBackend, | ||
mockMailer, | ||
'"From" <[email protected]>', | ||
enginesMap, | ||
true, | ||
{ | ||
testSendTo: "[email protected]", | ||
}, | ||
), | ||
).rejects.toThrow("You must set onlySend to a number to use test mode."); | ||
}); | ||
|
||
it("should send no emails if only send 0", async () => { | ||
const mergeResults: MergeResultWithMetadata<unknown>[] = [ | ||
{ | ||
|
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
name,to,subject,attachment1,attachment2,bcc,cc | ||
Kishan,[email protected] [email protected],DoCSoc x Kishan,./attachments/DoCSoc Sponsorship Proposal 24-25.pdf,./attachments/munch.jpg,[email protected],[email protected] [email protected] | ||
Kishan,[email protected],DoCSoc x Kishan,./attachments/DoCSoc Sponsorship Proposal 24-25.pdf,./attachments/munch.jpg,[email protected],[email protected] [email protected] | ||
NotKishan,[email protected]," DoCSoc x NotKishan",./attachments/DoCSoc Sponsorship Proposal 24-25.pdf,./attachments/munch.jpg,, |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
docsoc-mailmerge generate nunjucks ./data/names.csv -o ./output -n test -b -c | ||
docsoc-mailmerge regenerate ./output/test | ||
docsoc-mailmerge upload-drafts ./output/test -y -s 2 -n 1 | ||
docsoc-mailmerge send ./output/test -s 5 -n 1 | ||
# docsoc-mailmerge upload-drafts ./output/test -y -s 2 -n 1 | ||
docsoc-mailmerge send ./output/test -s 5 -n 2 -t "[email protected]" |