Skip to content

Commit bf97bf1

Browse files
committed
fix: don't call post send hook in test mode
1 parent 4e7b514 commit bf97bf1

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

email/mailmerge/src/pipelines/send.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ describe("sendEmails", () => {
123123
expect(mockMailer.sendMail).toHaveBeenCalledTimes(1);
124124
});
125125

126-
it("should send to test email if given and not cc or bcc anyone in", async () => {
126+
it("should send to test email if given, not cc or bcc anyone in and not call post send hooks", async () => {
127127
const mergeResults: MergeResultWithMetadata<unknown>[] = [
128128
{
129129
record: { field1: "value1" },
@@ -168,6 +168,7 @@ describe("sendEmails", () => {
168168
bcc: [],
169169
},
170170
);
171+
expect(mockStorageBackend.postSendAction).not.toHaveBeenCalled();
171172
});
172173

173174
it("should refuse test send if onlySend is not set", async () => {

email/mailmerge/src/pipelines/send.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export async function sendEmails(
6666
}
6767
logger.warn("");
6868
logger.warn(`Will send ${options.onlySend} emails to ${options.testSendTo} as a test.`);
69+
logger.warn("Note that post send hooks will not be called in test mode.");
6970
logger.warn("");
7071
}
7172

@@ -167,7 +168,7 @@ You are about to send ${emailsNumberDisplay} emails. The esitmated time for this
167168
},
168169
);
169170

170-
if (storageBackend.postSendAction) {
171+
if (storageBackend.postSendAction && !options.testSendTo) {
171172
logger.debug("Calling post-send hook...");
172173
await storageBackend.postSendAction(originalResult, PostSendActionMode.SMTP_SEND);
173174
}

email/workspace/quick-run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
docsoc-mailmerge generate nunjucks ./data/names.csv -o ./output -n test -b -c
22
docsoc-mailmerge regenerate ./output/test
33
# docsoc-mailmerge upload-drafts ./output/test -y -s 2 -n 1
4-
docsoc-mailmerge send ./output/test -s 5 -n 2 -t "[email protected]"
4+
docsoc-mailmerge send ./output/test -s 5 -n 1 -t "[email protected]"

0 commit comments

Comments
 (0)