Skip to content

Commit 3148b38

Browse files
committed
Fixed batch-sending retry test after #27822 split the guard log
no ref - #27822 (a1ba8ea, on main after this branch was first pushed) split the single "Tried sending email batch that is not pending or failed" error into two paths: already-submitted batches now log info ("already submitted on a prior run; skipping"), only stuck submitting orphans still error - the retry test for "One failed batch marks the email as failed" still stubbed logging.error and asserted the old message, so the assertion failed on the GHA merge commit even though the branch passed locally - repoint the stub at logging.info with the new message text; same scoped pattern (stub for the retry call only, restore before assert)
1 parent d233eaf commit 3148b38

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

ghost/core/test/integration/services/email-service/batch-sending.test.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -490,21 +490,19 @@ describe('Batch sending tests', function () {
490490
let memberIds = emailRecipients.map(recipient => recipient.get('member_id'));
491491
assert.equal(memberIds.length, _.uniq(memberIds).length);
492492

493-
// On retry, the 3 already-submitted batches hit the "not pending or
494-
// failed" guard and log an expected error; only the previously-failed
495-
// batch is re-sent. Stub the logger to assert that guard instead of
496-
// spamming stdout. Scoped to the retry so the genuine failure error
497-
// logged by the initial send above stays visible.
498-
const errorLog = sinon.stub(logging, 'error');
493+
// On retry, the 3 already-submitted batches hit the "already submitted
494+
// on a prior run" branch in #sendBatch and log info; only the
495+
// previously-failed batch is re-sent. Stub logging.info just for the
496+
// retry so the genuine failure error logged by the initial send above
497+
// stays visible, then assert at least one of those skip logs fired.
498+
const infoLog = sinon.stub(logging, 'info');
499499

500500
await retryEmail(agent, emailModel.id);
501501
await jobManager.allSettled();
502502

503-
sinon.assert.called(errorLog);
504-
for (const call of errorLog.getCalls()) {
505-
assert.match(call.args[0], /Tried sending email batch that is not pending or failed/);
506-
}
507-
errorLog.restore();
503+
const skipLogs = infoLog.getCalls().filter(call => /already submitted on a prior run; skipping/.test(call.args[0]));
504+
infoLog.restore();
505+
assert.ok(skipLogs.length > 0, 'expected at least one "already submitted on a prior run; skipping" info log');
508506

509507
await emailModel.refresh();
510508
batches = await models.EmailBatch.findAll({filter: `email_id:'${emailModel.id}'`});

0 commit comments

Comments
 (0)