Skip to content

Added a few more E2E tests for automations#28697

Merged
EvanHahn merged 1 commit into
mainfrom
ny1327
Jun 18, 2026
Merged

Added a few more E2E tests for automations#28697
EvanHahn merged 1 commit into
mainfrom
ny1327

Conversation

@EvanHahn

Copy link
Copy Markdown
Contributor

closes https://linear.app/ghost/issue/NY-1327

This is a test-only change to give us some more confidence in automations.

@coderabbitai

coderabbitai Bot commented Jun 18, 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: 0790efad-761d-4d5d-a497-1c086de2d90f

📥 Commits

Reviewing files that changed from the base of the PR and between 7e8f868 and a7973ea.

📒 Files selected for processing (1)
  • ghost/core/test/e2e-api/members/automations.test.js

Walkthrough

The test file ghost/core/test/e2e-api/members/automations.test.js receives two new shared helpers: updateAutomation, which issues a PUT to the admin automations API with optional field overrides, and getMemberWelcomeEmailSends, which filters the mailer send stub's call arguments for member-welcome-email-tagged payloads. An existing inline assertion is refactored to use getMemberWelcomeEmailSends. Three new e2e test cases are added that assert zero welcome emails are sent when: the automation is inactive at run time, the automation is deactivated between the member creation step and the scheduler poll, or the member's status is changed to non-free (with DomainEvents.dispatch stubbed) before the poll runs.

Possibly related PRs

  • TryGhost/Ghost#27853: Adds the PUT endpoint for updating automations that the new updateAutomation helper uses to set automations inactive.
  • TryGhost/Ghost#28120: Adds the step-execution and poll logic for automation email sending that the new cancellation test cases directly exercise.
  • TryGhost/Ghost#28598: Refactors the same automations e2e test file to use real-DB/fixtures setup, establishing the foundation for the cancellation assertions added here.

Suggested reviewers

  • troyciesco
  • cmraible
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding more E2E tests for automations, which is confirmed by the file changes and test additions.
Description check ✅ Passed The description is related to the changeset, explaining it is a test-only change for automations and referencing the associated issue.
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 ny1327

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 18, 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 7e8f868

Command Status Duration Result
nx run ghost:test:ci:integration:no-coverage ✅ Succeeded 2m 10s View ↗
nx run ghost:test:ci:integration ✅ Succeeded 1m 19s View ↗
nx run ghost:test:ci:e2e:no-coverage ✅ Succeeded 4m 3s View ↗
nx run ghost:test:ci:e2e ✅ Succeeded 3m 41s View ↗
nx run ghost:test:ci:legacy ✅ Succeeded 2m 17s View ↗
nx run-many -t test:unit -p ghost ✅ Succeeded 33s 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-18 01:24:00 UTC

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ghost/core/test/e2e-api/members/automations.test.js`:
- Around line 284-304: The DomainEvents.dispatch stub is created at line 284 and
restored at line 293, which means the member creation that occurs between these
lines happens while dispatch is stubbed. This suppresses domain events that
should normally fire during member creation, invalidating the test scenario.
Move the sinon.stub(DomainEvents, 'dispatch') call to after the
membersService.api.members.create() call completes, so that the member creation
events are not suppressed and the automation enrollment can be properly
triggered before the scheduler poll at runSchedulerPoll().
- Around line 228-244: The test validates that inactive automations do nothing,
but it never calls runSchedulerPoll() before asserting zero email sends. Add a
call to runSchedulerPoll() after the DomainEvents.allSettled() call and before
the final assertion that checks getMemberWelcomeEmailSends().length equals zero.
This ensures the test actually verifies that the inactive status blocks email
sends, rather than just confirming that no poll was executed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d8efc952-3029-4d2f-84d0-61dc14883047

📥 Commits

Reviewing files that changed from the base of the PR and between e8358cd and 7e8f868.

📒 Files selected for processing (1)
  • ghost/core/test/e2e-api/members/automations.test.js

Comment thread ghost/core/test/e2e-api/members/automations.test.js
Comment thread ghost/core/test/e2e-api/members/automations.test.js Outdated
closes https://linear.app/ghost/issue/NY-1327

This is a test-only change to give us some more confidence in
automations.
@EvanHahn EvanHahn enabled auto-merge (squash) June 18, 2026 01:20
@EvanHahn EvanHahn merged commit 3aeba4a into main Jun 18, 2026
32 checks passed
@EvanHahn EvanHahn deleted the ny1327 branch June 18, 2026 01:24
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