fix(test): wait for email HTML body in Email_settings spec#41893
fix(test): wait for email HTML body in Email_settings spec#41893wyattwalter wants to merge 5 commits into
Conversation
Email_settings_Spec flakes (~25-35% in CI) when it shares a shard with heavy specs. Under maildev/SMTP contention, waitForEmail returns an email whose .html is not yet populated; `const emailHtml = email.html` followed by `emailHtml.match(...)` then throws a TypeError synchronously inside the .then callback, which surfaces as an unhandled promise rejection and aborts the test. The wrapping try/catch is inert against async Cypress failures. Stack: Email_settings_Spec.ts:293 (test #4); the same email.html -> .match pattern is in tests #3, #5 and #6. Default email.html to an empty string so .match() returns null and the existing if-guards / else cy.log branches handle a missing body without throwing. Validated via an amplified /ci-test-limit run on appsmith-ee. Ref APP-15291 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
WalkthroughAdd an optional ChangesEmail wait/matching updates
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Supersedes the earlier `email.html || ""` guard, which only stopped the crash by silently skipping the invite-link verification when the body was missing — masking the flake rather than fixing it. Root cause: under maildev/SMTP contention waitForEmail matched an email by subject+recipient before its HTML part was populated, so `email.html` was undefined and `emailHtml.match(...)` threw inside the .then callback (unhandled rejection, abort). Stack: Email_settings_Spec.ts test #4; same pattern in #3/#5/#6. Fix at the source: add an opt-in `requireHtml` flag to waitForEmail so a matched-but-bodyless email is treated as not-yet-delivered and polling continues until the HTML body arrives (or the existing timeout). Tests #3-#6 opt in; the email-body assertions then run for real on a complete email. Reverted the `|| ""` guard since the body is now guaranteed present. Ref APP-15291 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…-keys) Ref APP-15291 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…merge) Ref APP-15291 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
/ci-test-limit |
|
Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/27428547269. |
|
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/27428547269. |
ci-test-limit validation is complete; restore limited-tests.txt to its default so the PR contains only the waitForEmail/Email_settings fix. Ref APP-15291 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
Email_settings_Specfails intermittently in CI (~25-35% of runs) when it shares a duration-balanced shard with heavy specs. It's a null-handling bug in the spec's email flow, exposed under maildev/SMTP contention.Root cause
waitForEmailmatches an email by subject + recipient, then hands it to the test. Under contention maildev can surface an email's metadata before its HTML part is parsed, so the matched email's.htmlisundefined. Tests #3–#6 then do:That throw is an unhandled promise rejection that aborts the test (the wrapping
try/catchis inert against async Cypress failures). Captured CI stack:Email_settings_Spec.tstest #4 (To verify invite workspace email); the sameemail.html→.matchpattern is in tests #3, #5 and #6.Fix
Fix it at the source rather than masking it. Add an opt-in
requireHtmlflag towaitForEmail: when set, a matched email whose HTML body isn't populated yet is treated as not yet delivered, so polling continues until the body arrives (or the existing timeout). Tests #3–#6 opt in; their email-body assertions then run for real on a complete email.(An earlier revision of this PR used
email.html || "", but that only stopped the crash by silently skipping the invite-link verification when the body was missing — masking the flake. Reverted in favor of the helper-level fix.)waitForEmailis identical in CE and EE, so this lands in CE and the hourly sync carries it to EE. The new flag is optional and defaults to current behavior, so other callers (including this spec's test #2, which readsemail.text) are unaffected.Validation
Attribution and the fix were verified on appsmith-ee via amplified
/ci-test-limitruns (multiple copies of the spec downstream of a heavy git spec in one shard): the unfixed baseline reproduced the failure at the exact line above.Ref APP-15291
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/27509234477
Commit: 56deaca
Cypress dashboard.
Tags:
@tag.EmailSpec:
Sun, 14 Jun 2026 19:36:07 UTC
Summary by CodeRabbit
Automation
/ok-to-test tags="@tag.Email"