Skip to content

Fixed and re-enabled the batch-sending integration tests#28799

Merged
9larsons merged 3 commits into
mainfrom
reenable-batch-sending-tests
Jun 22, 2026
Merged

Fixed and re-enabled the batch-sending integration tests#28799
9larsons merged 3 commits into
mainfrom
reenable-batch-sending-tests

Conversation

@9larsons

@9larsons 9larsons commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Re-enables batch-sending.test.js (skipped since early 2025) and hardens it to pass on both engines.

Re-enable

Skipped for "intermittent" failures; it had since rotted into deterministic failure:

  • Snapshot rot — the email template was rewritten over the 15 months it sat skipped; regenerated.
  • Hardcoded port — two Replacements tests pinned 127.0.0.1:2369, but the migration derives a per-fork port. Matched with \d+.

Year scrub

The footer renders the year live (new Date().getFullYear()) and matchEmailSnapshot didn't scrub it — so the snapshots would rot every January. Added a year scrub to the shared matcher; cards.test.js.snap regenerated (year-only) as a result.

Member-leak cascade (the mysql failures)

The suite seeds members once and several tests add more, cleaning up inline. When a test threw before its inline cleanup — e.g. the timing-sensitive submitted assertion that fails on mysql — the leaked subscriber shifted every later test's recipient count, turning one failure into eleven (the CI red). Now beforeEach snapshots the seeded member ids and afterEach drops any extras, so a single failure can't poison the rest. Removed the stale // FLAKEY markers.

Verified 4× on mysql + 2× on sqlite, 42/42 each.

no ref

The suite was skipped in early 2025 for "intermittent" failures, but had since
rotted into deterministic failure: the email-renderer template was rewritten
(copyright year now 2026) so every snapshot was stale, and two Replacements
tests hardcoded the unsubscribe-link port 2369, which the Mocha to Vitest
migration made per-fork. Regenerated the snapshots and matched the port flexibly
(the snapshots already scrub it); 42/42 pass, stable across repeated runs. A
latent within-file ordering dependency remains (dormant, since CI preserves
declaration order) and is worth hardening separately.
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 05a38fc7-9e5c-4e20-8ddc-a61f9d026a05

📥 Commits

Reviewing files that changed from the base of the PR and between 80c246f and 2456635.

📒 Files selected for processing (1)
  • ghost/core/test/integration/services/email-service/batch-sending.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • ghost/core/test/integration/services/email-service/batch-sending.test.js

Walkthrough

The integration test suite for email batch sending in batch-sending.test.js is re-enabled by changing describe.skip to describe. A beforeEach hook captures a snapshot of initially seeded Member IDs, and an afterEach hook deletes any Member records created during test execution that are not in the seeded set, preventing cross-test subscriber count drift. Inline FLAKEY comments are removed. Two sets of unsubscribe-link assertions within the "Replacements" tests are updated: the previously hardcoded port 2369 in http://127.0.0.1:2369/... URLs is replaced with a :\d+ regex pattern in both "member without name" and "member with name" test cases, for both HTML and plaintext outputs. The matchEmailSnapshot() utility in batch-email-utils.js adds a normalization rule to replace the dynamically rendered copyright year with a fixed placeholder © YYYY, preventing snapshot mismatches when the calendar year changes.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main objective of the changeset: re-enabling and fixing the batch-sending integration tests.
Description check ✅ Passed The description is well-detailed and directly related to the changeset, explaining the root causes of failures and how they were fixed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch reenable-batch-sending-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud

nx-cloud Bot commented Jun 22, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 2456635

Command Status Duration Result
nx run ghost:test:ci:integration:no-coverage ✅ Succeeded 2m 29s View ↗
nx run ghost:test:ci:integration ✅ Succeeded 2m 18s View ↗
nx run ghost:test:ci:legacy ✅ Succeeded 2m 43s View ↗
nx run ghost:test:ci:e2e ✅ Succeeded 2m 34s View ↗
nx run ghost:test:ci:e2e:no-coverage ✅ Succeeded 2m 14s View ↗
nx run-many -t test:unit -p ghost ✅ Succeeded 27s View ↗
nx run-many -t lint -p ghost ✅ Succeeded 43s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-22 19:29:56 UTC

9larsons added 2 commits June 22, 2026 13:46
no ref

The email footer renders the copyright year live (email-renderer.js uses
new Date().getFullYear()), and matchEmailSnapshot scrubbed the unsubscribe URL,
redirect links, keys and uuids but not the year — so the regenerated snapshots
would fail on the next January 1. Added a year scrub to the shared matcher (the
current year, resolved from the same process clock the renderer uses, so it
always matches what was rendered) and regenerated the batch-sending and cards
snapshots. Fixed copyright years in content (e.g. 2024) are left intact.
no ref

The suite seeds members once in beforeAll and several tests add more, cleaning
up inline. When a test threw before its inline cleanup — e.g. the timing-
sensitive "submitted" assertion in the first member-creating test, which fails
on mysql — the leaked subscriber shifted every later test's recipient count,
turning one failure into eleven. Snapshot the seeded member ids in beforeEach
and drop any extras in afterEach so a single failure can't poison the rest, and
removed the now-stale FLAKEY markers. Verified 4x on mysql and 2x on sqlite,
42/42 each.
@9larsons 9larsons merged commit 3968ba2 into main Jun 22, 2026
32 checks passed
@9larsons 9larsons deleted the reenable-batch-sending-tests branch June 22, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant