test(federation): add e2e test for self-join in federated rooms#38669
test(federation): add e2e test for self-join in federated rooms#38669Aryan-Verma-999 wants to merge 3 commits intoRocketChat:developfrom
Conversation
Adds a failing e2e test demonstrating that users who self-join a federated room via channels.join API are not registered on the Matrix homeserver, unlike users who are explicitly invited Ref: RocketChat#38239
|
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 |
|
WalkthroughA new end-to-end test suite for federation self-join scenarios. Tests verify local users self-joining federated rooms via the channels.join API, room membership visibility, and federation metadata across federated and local contexts, with conditional execution gated on IS_EE. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
🚥 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. Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@apps/meteor/tests/end-to-end/api/federation-self-join.ts`:
- Around line 14-23: Remove the top JSDoc block and all inline comments in this
test file so it follows the "avoid code comments" guideline: delete the JSDoc
header and the inline comment lines referenced around the test blocks (near the
federation self-join describe/it blocks and the assertions), leaving the
existing describe/it titles and assertion messages intact as the only
documentation, and then run the linter/formatter to ensure no trailing
whitespace or formatting issues remain; key locations to edit include the file's
Federation self-join test suite (the describe/it blocks and their assertions)
where the inline comments are present.
- Around line 153-172: The two end-to-end tests that assert self-join federation
behavior (the it block titled "should mark the self-joined user as federated in
the user record" and the other failing it at lines covering 257–271) are known
to fail and must be skipped to avoid breaking CI; update those test cases to use
it.skip(...) or it.todo(...) (preserving the test descriptions) and add a short
comment pointing to the related issue/PR so they can be re-enabled when the bug
is fixed.
🧹 Nitpick comments (2)
apps/meteor/tests/end-to-end/api/federation-self-join.ts (2)
54-61: Guard cleanup against undefined references from failed setup.If the
beforehook fails partway (e.g., room creation fails but user was created),federatedRoomisundefinedanddeleteRoomwill throw insidePromise.all, potentially masking the real failure and skipping remaining cleanup. A simple guard keeps things robust:Proposed fix (both after blocks)
after(async () => { - await Promise.all([ - deleteRoom({ type: 'c', roomId: federatedRoom._id }), - deleteUser(testUser), - updateSetting('Federation_Service_Enabled', false), - updatePermission('access-federation', ['admin']), - ]); + await Promise.all([ + federatedRoom && deleteRoom({ type: 'c', roomId: federatedRoom._id }), + testUser && deleteUser(testUser), + updateSetting('Federation_Service_Enabled', false), + updatePermission('access-federation', ['admin']), + ]); });Apply the same pattern to the second
afterblock (lines 219–227).Also applies to: 219-227
76-86: Tests depend on sequential execution order — fragile by design.The
itblocks in lines 76–151 are order-dependent: "self-join" must run before "subscription check," "send message" before "history check." While mocha runs serially by default, this is a common source of confusion. Consider documenting this coupling in thedescribetitle (e.g.,describe('sequential: …')) or consolidating tightly coupled assertions into feweritblocks. This is a minor observation — no action required if this pattern is standard in the repo.Also applies to: 88-99, 101-114, 116-134, 136-151
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/meteor/tests/end-to-end/api/federation-self-join.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
apps/meteor/tests/end-to-end/api/federation-self-join.ts
🧠 Learnings (8)
📓 Common learnings
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37377
File: apps/meteor/ee/server/hooks/federation/index.ts:86-88
Timestamp: 2025-11-04T16:49:19.107Z
Learning: In Rocket.Chat's federation system (apps/meteor/ee/server/hooks/federation/), permission checks follow two distinct patterns: (1) User-initiated federation actions (creating rooms, adding users to federated rooms, joining from invites) should throw MeteorError to inform users they lack 'access-federation' permission. (2) Remote server-initiated federation events should silently skip/ignore when users lack permission. The beforeAddUserToRoom hook only executes for local user-initiated actions, so throwing an error there is correct. Remote federation events are handled separately by the federation Matrix package with silent skipping logic.
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 37532
File: ee/packages/federation-matrix/src/FederationMatrix.ts:920-927
Timestamp: 2025-12-09T20:01:07.355Z
Learning: In Rocket.Chat's federation invite handling (ee/packages/federation-matrix/src/FederationMatrix.ts), when a user rejects an invite via federationSDK.rejectInvite(), the subscription cleanup happens automatically through an event-driven flow: Matrix emits a leave event back, which is processed by handleLeave() in ee/packages/federation-matrix/src/events/member.ts, and that function calls Room.performUserRemoval() to clean up the subscription. No explicit cleanup is needed in the reject branch of handleInvite() because the leave event handler takes care of it.
<!-- </add_learning>
📚 Learning: 2025-11-04T16:49:19.107Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37377
File: apps/meteor/ee/server/hooks/federation/index.ts:86-88
Timestamp: 2025-11-04T16:49:19.107Z
Learning: In Rocket.Chat's federation system (apps/meteor/ee/server/hooks/federation/), permission checks follow two distinct patterns: (1) User-initiated federation actions (creating rooms, adding users to federated rooms, joining from invites) should throw MeteorError to inform users they lack 'access-federation' permission. (2) Remote server-initiated federation events should silently skip/ignore when users lack permission. The beforeAddUserToRoom hook only executes for local user-initiated actions, so throwing an error there is correct. Remote federation events are handled separately by the federation Matrix package with silent skipping logic.
Applied to files:
apps/meteor/tests/end-to-end/api/federation-self-join.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts
Applied to files:
apps/meteor/tests/end-to-end/api/federation-self-join.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Group related tests in the same file
Applied to files:
apps/meteor/tests/end-to-end/api/federation-self-join.ts
📚 Learning: 2025-10-28T16:53:42.761Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.
Applied to files:
apps/meteor/tests/end-to-end/api/federation-self-join.ts
📚 Learning: 2025-11-05T21:04:35.787Z
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 37357
File: ee/packages/federation-matrix/src/setup.ts:103-120
Timestamp: 2025-11-05T21:04:35.787Z
Learning: In Rocket.Chat's federation-matrix setup (ee/packages/federation-matrix/src/setup.ts and apps/meteor/ee/server/startup/federation.ts), configureFederationMatrixSettings does not need to be called before setupFederationMatrix. The SDK's init() establishes infrastructure (database, event handlers, APIs) first, and the configuration can be applied later via settings watchers before actual federation events are processed. The config only matters when events actually occur, at which point all infrastructure is already configured.
Applied to files:
apps/meteor/tests/end-to-end/api/federation-self-join.ts
📚 Learning: 2025-12-09T20:01:07.355Z
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 37532
File: ee/packages/federation-matrix/src/FederationMatrix.ts:920-927
Timestamp: 2025-12-09T20:01:07.355Z
Learning: In Rocket.Chat's federation invite handling (ee/packages/federation-matrix/src/FederationMatrix.ts), when a user rejects an invite via federationSDK.rejectInvite(), the subscription cleanup happens automatically through an event-driven flow: Matrix emits a leave event back, which is processed by handleLeave() in ee/packages/federation-matrix/src/events/member.ts, and that function calls Room.performUserRemoval() to clean up the subscription. No explicit cleanup is needed in the reject branch of handleInvite() because the leave event handler takes care of it.
<!-- </add_learning>
Applied to files:
apps/meteor/tests/end-to-end/api/federation-self-join.ts
📚 Learning: 2025-09-19T15:15:04.642Z
Learnt from: rodrigok
Repo: RocketChat/Rocket.Chat PR: 36991
File: apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts:219-221
Timestamp: 2025-09-19T15:15:04.642Z
Learning: The Federation_Matrix_homeserver_domain setting in apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts is part of the old federation system and is being deprecated/removed, so configuration issues with this setting should not be flagged for improvement.
Applied to files:
apps/meteor/tests/end-to-end/api/federation-self-join.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: cubic · AI code reviewer
🔇 Additional comments (2)
apps/meteor/tests/end-to-end/api/federation-self-join.ts (2)
1-12: LGTM — imports are clean and well-scoped.Correct usage of type-only imports for
Credentials,IRoom,IUser, andTestUser. Helper imports are appropriate for the test patterns used.
24-25: LGTM — EE guard and credential setup.Properly gates the entire suite behind
IS_EEand initializes credentials inbefore.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
There was a problem hiding this comment.
2 issues found across 1 file
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="apps/meteor/tests/end-to-end/api/federation-self-join.ts">
<violation number="1" location="apps/meteor/tests/end-to-end/api/federation-self-join.ts:170">
P2: The new test contains assertions explicitly documented as "currently FAILS" but is not skipped. This will break CI unless the underlying bug fix is included; consider skipping the test until the behavior is fixed or include the fix in this PR.</violation>
<violation number="2" location="apps/meteor/tests/end-to-end/api/federation-self-join.ts:257">
P1: This test is documented to fail (demonstrating a known bug) and will break CI if merged. Use `it.skip()` or `it.todo()` to mark it as pending until the fix for issue #38239 lands.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #38669 +/- ##
===========================================
+ Coverage 70.46% 70.71% +0.24%
===========================================
Files 3175 3195 +20
Lines 111091 113106 +2015
Branches 20029 20610 +581
===========================================
+ Hits 78278 79978 +1700
- Misses 30763 31079 +316
+ Partials 2050 2049 -1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
ggazzo
left a comment
There was a problem hiding this comment.
I was expecting those tests under ./ee/packages/federation-matrix make sure lint and ts are ok... then we can work to provide a fix ;)
|
Done! Moved the test to |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts (2)
87-88: Consider guarding against undefined config properties.Non-null assertions on
request!andcredentials!will throw ifgetRequestConfigreturns an incomplete configuration. A type guard or early validation would provide a clearer error message.🔧 Optional: Add validation before using config
it('should allow a local user to self-join the federated room', async () => { - const requestInstance = selfJoinUserRequestConfig.request!; - const credentialsInstance = selfJoinUserRequestConfig.credentials!; + const { request: requestInstance, credentials: credentialsInstance } = selfJoinUserRequestConfig; + if (!requestInstance || !credentialsInstance) { + throw new Error('Self-join user request config is incomplete'); + } const response = await requestInstance.post('/api/v1/channels.join').set(credentialsInstance).send({ roomId: federatedChannel._id });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts` around lines 87 - 88, The test currently uses non-null assertions on selfJoinUserRequestConfig.request and .credentials (assigned to requestInstance and credentialsInstance) which will throw uninformative errors if getRequestConfig returns incomplete data; replace the assertions with an explicit guard/validation: check that selfJoinUserRequestConfig and its request and credentials properties are defined (or call getRequestConfig and validate its return), and if not, throw or fail the test with a clear message (e.g., "getRequestConfig returned missing request/credentials for self-join") before using requestInstance/credentialsInstance so later code can assume them safely.
42-42: Consider using a more specific type forfederatedChannel.Using
anytype loses type safety. Consider importing or defining a type for the room response body.🔧 Optional: Use IRoom or a partial type
+import type { IRoom } from '@rocket.chat/core-typings'; + +// In describe blocks: -let federatedChannel: any; +let federatedChannel: Pick<IRoom, '_id' | 'federated' | 'name'>;Also applies to: 125-125
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts` at line 42, Replace the loose any type for the test variable federatedChannel with a concrete Room/response type to restore type safety: import or declare the appropriate interface (e.g., IRoom or a Partial<IRoom> / RoomResponseBody) and annotate federatedChannel with that type instead of any; update the same variable usage elsewhere in this file (the other federatedChannel declaration) to use the same specific type so the test assertions and autocompletion work correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts`:
- Around line 87-88: The test currently uses non-null assertions on
selfJoinUserRequestConfig.request and .credentials (assigned to requestInstance
and credentialsInstance) which will throw uninformative errors if
getRequestConfig returns incomplete data; replace the assertions with an
explicit guard/validation: check that selfJoinUserRequestConfig and its request
and credentials properties are defined (or call getRequestConfig and validate
its return), and if not, throw or fail the test with a clear message (e.g.,
"getRequestConfig returned missing request/credentials for self-join") before
using requestInstance/credentialsInstance so later code can assume them safely.
- Line 42: Replace the loose any type for the test variable federatedChannel
with a concrete Room/response type to restore type safety: import or declare the
appropriate interface (e.g., IRoom or a Partial<IRoom> / RoomResponseBody) and
annotate federatedChannel with that type instead of any; update the same
variable usage elsewhere in this file (the other federatedChannel declaration)
to use the same specific type so the test assertions and autocompletion work
correctly.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
**/*.spec.ts
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use.spec.tsextension for test files (e.g.,login.spec.ts)
Files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
🧠 Learnings (15)
📓 Common learnings
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37377
File: apps/meteor/ee/server/hooks/federation/index.ts:86-88
Timestamp: 2025-11-04T16:49:19.107Z
Learning: In Rocket.Chat's federation system (apps/meteor/ee/server/hooks/federation/), permission checks follow two distinct patterns: (1) User-initiated federation actions (creating rooms, adding users to federated rooms, joining from invites) should throw MeteorError to inform users they lack 'access-federation' permission. (2) Remote server-initiated federation events should silently skip/ignore when users lack permission. The beforeAddUserToRoom hook only executes for local user-initiated actions, so throwing an error there is correct. Remote federation events are handled separately by the federation Matrix package with silent skipping logic.
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 37532
File: ee/packages/federation-matrix/src/FederationMatrix.ts:920-927
Timestamp: 2025-12-09T20:01:07.355Z
Learning: In Rocket.Chat's federation invite handling (ee/packages/federation-matrix/src/FederationMatrix.ts), when a user rejects an invite via federationSDK.rejectInvite(), the subscription cleanup happens automatically through an event-driven flow: Matrix emits a leave event back, which is processed by handleLeave() in ee/packages/federation-matrix/src/events/member.ts, and that function calls Room.performUserRemoval() to clean up the subscription. No explicit cleanup is needed in the reject branch of handleInvite() because the leave event handler takes care of it.
<!-- </add_learning>
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 35995
File: apps/meteor/app/api/server/v1/rooms.ts:1107-1112
Timestamp: 2026-02-23T17:53:18.785Z
Learning: In Rocket.Chat PR reviews, maintain strict scope boundaries—when a PR is focused on a specific endpoint (e.g., rooms.favorite), avoid reviewing or suggesting changes to other endpoints that were incidentally refactored (e.g., rooms.invite) unless explicitly requested by maintainers.
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts
Applied to files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Group related tests in the same file
Applied to files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Utilize Playwright fixtures (`test`, `page`, `expect`) for consistency in test files
Applied to files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use `test.step()` for complex test scenarios to improve organization in Playwright tests
Applied to files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Maintain test isolation between test cases in Playwright tests
Applied to files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
📚 Learning: 2025-12-10T21:00:54.909Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:54.909Z
Learning: Rocket.Chat monorepo: Jest testMatch pattern '<rootDir>/src/**/*.spec.(ts|js|mjs)' is valid in this repo and used across multiple packages (e.g., packages/tools, ee/packages/omnichannel-services). Do not flag it as invalid in future reviews.
Applied to files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : All test files must be created in `apps/meteor/tests/e2e/` directory
Applied to files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
📚 Learning: 2025-11-05T21:04:35.787Z
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 37357
File: ee/packages/federation-matrix/src/setup.ts:103-120
Timestamp: 2025-11-05T21:04:35.787Z
Learning: In Rocket.Chat's federation-matrix setup (ee/packages/federation-matrix/src/setup.ts and apps/meteor/ee/server/startup/federation.ts), configureFederationMatrixSettings does not need to be called before setupFederationMatrix. The SDK's init() establishes infrastructure (database, event handlers, APIs) first, and the configuration can be applied later via settings watchers before actual federation events are processed. The config only matters when events actually occur, at which point all infrastructure is already configured.
Applied to files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
📚 Learning: 2025-10-28T16:53:42.761Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.
Applied to files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
📚 Learning: 2025-11-04T16:49:19.107Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37377
File: apps/meteor/ee/server/hooks/federation/index.ts:86-88
Timestamp: 2025-11-04T16:49:19.107Z
Learning: In Rocket.Chat's federation system (apps/meteor/ee/server/hooks/federation/), permission checks follow two distinct patterns: (1) User-initiated federation actions (creating rooms, adding users to federated rooms, joining from invites) should throw MeteorError to inform users they lack 'access-federation' permission. (2) Remote server-initiated federation events should silently skip/ignore when users lack permission. The beforeAddUserToRoom hook only executes for local user-initiated actions, so throwing an error there is correct. Remote federation events are handled separately by the federation Matrix package with silent skipping logic.
Applied to files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
📚 Learning: 2025-12-09T20:01:00.324Z
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 37532
File: ee/packages/federation-matrix/src/FederationMatrix.ts:920-927
Timestamp: 2025-12-09T20:01:00.324Z
Learning: When reviewing federation invite handling in Rocket.Chat (specifically under ee/packages/federation-matrix), understand that rejecting an invite via federationSDK.rejectInvite() triggers an event-driven cleanup: a leave event is emitted and handled by handleLeave() in ee/packages/federation-matrix/src/events/member.ts, which calls Room.performUserRemoval() to remove the subscription. Do not add explicit cleanup in the reject branch of handleInvite(); rely on the existing leave-event flow for cleanup. If making changes, ensure this invariant remains and that any related paths still funnel cleanup through the leave event to avoid duplicate or missing removals.
Applied to files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.
Applied to files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.
Applied to files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.
Applied to files:
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts
🔇 Additional comments (6)
ee/packages/federation-matrix/tests/end-to-end/self-join.spec.ts (6)
1-7: LGTM!Imports are well-organized and include all necessary dependencies for the federation self-join test scenarios.
9-38: LGTM!The conditional execution pattern with
IS_EEand the setup/teardown for federation testing infrastructure is appropriate.
96-105: LGTM!The retry configuration for
findRoomMemberis appropriate for handling eventual consistency in federation scenarios.
107-120: LGTM!The skipped tests appropriately document the expected behavior that will pass once the federation self-join bug is fixed (per Issue
#38239).
179-215: LGTM!The comparison tests effectively demonstrate the discrepancy between invited and self-joined users, which aligns with the bug reproduction intent of this PR.
86-94: channels.join is the correct unified endpoint for joining both public and private rooms.There is no
groups.joinendpoint in Rocket.Chat's API. Thechannels.joinendpoint is the standard way to join all room types, including private federated rooms. ThefindChannelByIdOrNamefunction searches rooms by ID or name regardless of type, and the underlyingRoom.join()method handles both public and private rooms generically. The test design and explicit suite name confirm this is intentional.Likely an incorrect or invalid review comment.
|
CI results confirm the test reproduces the bug correctly |
Proposed Changes
Adds a failing e2e test that demonstrates users who self-join a federated room via channels.join API are not properly registered on the Matrix homeserver, unlike users who are explicitly invited via channels.invite.
Test Suite 1 — Self-join flow:
Test Suite 2 — Invited vs self-joined comparison:
Issue(s)
Closes #38239
Steps to test or reproduce
Or run the test:
npm run testapi -- --grep "federation - self-join"Further comments
This test was requested by @ggazzo in #38239 to reproduce the bug before fixing it. The root cause is in apps/meteor/ee/server/hooks/federation/index.ts, the beforeAddUserToRoom callback requires an inviter parameter, which is undefined during self-join, causing the federation registration to be skipped entirely.
Summary by CodeRabbit
Release Notes