Skip to content

Added snapshot tests for welcome emails#26965

Merged
cmraible merged 1 commit intomainfrom
evanhahn-ny-1178-add-snapshot-tests-for-welcome-emails
Mar 25, 2026
Merged

Added snapshot tests for welcome emails#26965
cmraible merged 1 commit intomainfrom
evanhahn-ny-1178-add-snapshot-tests-for-welcome-emails

Conversation

@EvanHahn
Copy link
Contributor

closes https://linear.app/ghost/issue/NY-1178
towards https://linear.app/ghost/issue/NY-1163

This was written almost entirely by Claude Opus 4.6 against the following prompt:

I want to create a snapshot test for member welcome emails. We currently have some tests for this, like in ghost/core/test/e2e-api/admin/automated-emails.test.js and ghost/core/test/integration/services/member-welcome-emails.test.js, but these don't assert on the final rendered output.

Build a (test-only) change that renders the full HTML of a member welcome email, and asserts on the snapshot. We have assertMatchSnapshot for this purpose, which I reckon you should use.

I reviewed the code thoroughly and made a couple of small tweaks.

closes https://linear.app/ghost/issue/NY-1178
towards https://linear.app/ghost/issue/NY-1163

This was written almost entirely by Claude Opus 4.6 against the
following prompt:

> I want to create a snapshot test for member welcome emails. We
> currently have _some_ tests for this, like in
> `ghost/core/test/e2e-api/admin/automated-emails.test.js` and
> `ghost/core/test/integration/services/member-welcome-emails.test.js`,
> but these don't assert on the final rendered output.
>
> Build a (test-only) change that renders the full HTML of a member
> welcome email, and asserts on the snapshot. We have
> `assertMatchSnapshot` for this purpose, which I reckon you should use.

I reviewed the code thoroughly and made a couple of small tweaks.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 25, 2026

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: 7b0a3f82-e8fe-46cb-9630-9bd9b366cbb6

📥 Commits

Reviewing files that changed from the base of the PR and between b08f266 and c6c8f05.

⛔ Files ignored due to path filters (1)
  • ghost/core/test/integration/services/__snapshots__/member-welcome-emails-snapshot.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • ghost/core/test/integration/services/member-welcome-emails-snapshot.test.js

Walkthrough

A new Jest integration snapshot test suite was added for MemberWelcomeEmailRenderer. The test file initializes the Ghost test environment through lifecycle hooks, stubs Date.prototype.getFullYear to return 2020 for consistent snapshots, and includes helper functions for constructing Lexical JSON structures. Test cases cover rendering welcome emails with simple paragraphs, performing template variable replacements in content and subject lines, substituting fallback values when member names are missing, and rendering with custom accent colors. Output assertions validate both HTML and plaintext formats via snapshot comparison.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Added snapshot tests for welcome emails' directly and clearly summarizes the main change: a new snapshot test suite for member welcome emails.
Description check ✅ Passed The description is related to the changeset, providing context about the issue references, test motivation, and implementation approach using Claude Opus with author review.

✏️ 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 evanhahn-ny-1178-add-snapshot-tests-for-welcome-emails

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.

@EvanHahn EvanHahn requested a review from cmraible March 25, 2026 18:10
Copy link
Collaborator

@cmraible cmraible left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for covering this!

@cmraible cmraible merged commit 27b35dc into main Mar 25, 2026
84 of 94 checks passed
@cmraible cmraible deleted the evanhahn-ny-1178-add-snapshot-tests-for-welcome-emails branch March 25, 2026 18:40
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.

2 participants