Repository navigation
test: cover when the mention-not-in-room warning is skipped - #44183
Jisukumarmishra wants to merge 1 commit into
Conversation
The mention-user-not-in-channel hook skips edited messages and messages older than 60 seconds, as the TODO asked to test. Add unit tests for the warning being sent for new messages and skipped for old or edited ones.
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/meteor/server/hooks/messages/mentionUserNotInChannel.test.ts">
<violation number="1" location="apps/meteor/server/hooks/messages/mentionUserNotInChannel.test.ts:67">
P3: This test only checks that a warning was broadcast to the author in the room. It doesn't check the payload, so a regression that lists the wrong users or drops the mention would still pass. Assert the 4th broadcast argument's `mentions` contains Bob.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| await afterSaveMessage(messageMentioningBob(), { room }); | ||
|
|
||
| expect(findByRoomIdAndUserIds.calledOnce).to.be.true; | ||
| expect(broadcast.calledOnceWith('notify.ephemeralMessage', 'alice', 'room1')).to.be.true; |
There was a problem hiding this comment.
P3: This test only checks that a warning was broadcast to the author in the room. It doesn't check the payload, so a regression that lists the wrong users or drops the mention would still pass. Assert the 4th broadcast argument's mentions contains Bob.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At apps/meteor/server/hooks/messages/mentionUserNotInChannel.test.ts, line 67:
<comment>This test only checks that a warning was broadcast to the author in the room. It doesn't check the payload, so a regression that lists the wrong users or drops the mention would still pass. Assert the 4th broadcast argument's `mentions` contains Bob.</comment>
<file context>
@@ -0,0 +1,95 @@
+ await afterSaveMessage(messageMentioningBob(), { room });
+
+ expect(findByRoomIdAndUserIds.calledOnce).to.be.true;
+ expect(broadcast.calledOnceWith('notify.ephemeralMessage', 'alice', 'room1')).to.be.true;
+ });
+
</file context>
|
No actionable comments were generated in the recent review. WalkthroughThe change adds tests for the ChangesMention callback tests
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Other Suggested labels: Suggested reviewers: Merge Risk:
|
Proposed changes : ---- >
Resolves // TODO: check if I need to test this 60 second rule. in apps/meteor/server/hooks/messages/mentionUserNotInChannel.ts.
The mention-user-not-in-channel afterSaveMessage hook warns the author when a message mentions people who aren't in the room. It skips edited messages and messages older than 60 seconds (e.g. imported), since notifications are skipped for those too. The hook had no unit test.
New mentionUserNotInChannel.test.ts loads the hook with its dependencies stubbed and covers:
a new message mentioning someone not in the room triggers the warning;
a message sent 30 seconds ago still does;
a message older than 60 seconds is skipped without querying subscriptions;
an edited message is skipped the same way.
The only source change is removing the TODO line.
Decisions and gaps
Test-only change; no changeset.
The tests check behaviour, not how the age is computed, so they keep passing after #40077 moves this line from moment to date-fns. #43710 changes what the warning says, not when it is sent, so it doesn't affect them either.
Checked that the tests catch regressions: removing the 60-second condition, or the edited-message condition, from the hook makes them fail.
Issue(s)
None.
Steps to test or reproduce
apps/meteor → yarn .testunit:server (server/hooks/messages/mentionUserNotInChannel.test.ts).
Summary by CodeRabbit