diff --git a/email/mailmerge/src/pipelines/send.spec.ts b/email/mailmerge/src/pipelines/send.spec.ts index 8d23e32..c6894d2 100644 --- a/email/mailmerge/src/pipelines/send.spec.ts +++ b/email/mailmerge/src/pipelines/send.spec.ts @@ -123,7 +123,7 @@ describe("sendEmails", () => { expect(mockMailer.sendMail).toHaveBeenCalledTimes(1); }); - it("should send to test email if given and not cc or bcc anyone in", async () => { + it("should send to test email if given, not cc or bcc anyone in and not call post send hooks", async () => { const mergeResults: MergeResultWithMetadata[] = [ { record: { field1: "value1" }, @@ -168,6 +168,7 @@ describe("sendEmails", () => { bcc: [], }, ); + expect(mockStorageBackend.postSendAction).not.toHaveBeenCalled(); }); it("should refuse test send if onlySend is not set", async () => { diff --git a/email/mailmerge/src/pipelines/send.ts b/email/mailmerge/src/pipelines/send.ts index 62af176..254a783 100644 --- a/email/mailmerge/src/pipelines/send.ts +++ b/email/mailmerge/src/pipelines/send.ts @@ -66,6 +66,7 @@ export async function sendEmails( } logger.warn(""); logger.warn(`Will send ${options.onlySend} emails to ${options.testSendTo} as a test.`); + logger.warn("Note that post send hooks will not be called in test mode."); logger.warn(""); } @@ -167,7 +168,7 @@ You are about to send ${emailsNumberDisplay} emails. The esitmated time for this }, ); - if (storageBackend.postSendAction) { + if (storageBackend.postSendAction && !options.testSendTo) { logger.debug("Calling post-send hook..."); await storageBackend.postSendAction(originalResult, PostSendActionMode.SMTP_SEND); } diff --git a/email/workspace/quick-run.sh b/email/workspace/quick-run.sh index 3d5e072..c6d57fb 100755 --- a/email/workspace/quick-run.sh +++ b/email/workspace/quick-run.sh @@ -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 2 -t "kss22@ic.ac.uk" \ No newline at end of file +docsoc-mailmerge send ./output/test -s 5 -n 1 -t "kss22@ic.ac.uk" \ No newline at end of file