Repository navigation
test: cover Email Inbox message processing - #42999
ricardogarim wants to merge 2 commits into
Conversation
|
Looks like this PR is ready to merge! 🎉 |
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
WalkthroughAdded tests for email inbox configuration, incoming and outgoing email handling, and attachment behavior. Updated the room-history test to register mocked models in a suite-level hook. ChangesEmail inbox tests
Room history test setup
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Other Suggested labels: Merge Risk: ⚪ Minimal · up to
|
|
|
@cubic-dev-ai review |
@ricardogarim I have started the AI code review. It will take a few minutes to complete. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #42999 +/- ##
===========================================
+ Coverage 70.95% 71.00% +0.05%
===========================================
Files 5193 5193
Lines 222993 223034 +41
Branches 41294 41240 -54
===========================================
+ Hits 158221 158366 +145
+ Misses 59578 59456 -122
- Partials 5194 5212 +18 Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
a818995 to
a7ec206
Compare

Proposed changes (including videos or screenshots)
The Email Inbox feature reads email through IMAP and sends replies through SMTP. When an email arrives, the visitor's email shows as a livechat message in the room of its email thread, with its files. When an agent quotes that message, the visitor gets the reply by email in the same thread. Agents can also send message files by email, and admins can send a test email to check an inbox.
This PR adds node:test unit tests next to the three Email Inbox files. The tests cover the inbox setup, the incoming email flow, and the outgoing replies, files and test email. The model fakes use
registerModelinbefore().The first commit moves the
registerModelcalls ofcleanRoomHistory.test.tsintobefore(). All unit test files run in one process, and that file registered its fakes when it loaded. The new tests replaced itsIMessagesModelfake, and 4 of its tests failed.Coverage and mutation
EmailInbox.tsEmailInbox_Incoming.tsEmailInbox_Outgoing.tsBefore this PR, no unit test loaded these files, and Codecov does not list them. The "after" values come from nyc.
Mutation (by hand, 68 mutants): 67 killed. The mutant that stays changes
!match?.groupsto!match. It does not change the result, because every match of the regex includes its named groups.Issue(s)
Steps to test or reproduce
In
apps/meteor, runyarn .testunit:server.Further comments
EmailInbox.tscallsvoid onEmailReceived(...)in atry/catch, so thecatchdoes not get its errors. When the processing fails (for example, after an admin deletes the department of the inbox), only the global handler logs the error. The history record and the IMAP "seen" flag are already set, so the email is lost. This PR does not change this behavior.EmailInbox_Outgoing.ts, theafterSaveMessagecallback has a secondif (!inbox)check that never runs.Summary by CodeRabbit