Skip to content

test(federation): improve and slim down config and scripts#37769

Merged
sampaiodiego merged 6 commits intodevelopfrom
federation-tests-improve-scripts
Dec 11, 2025
Merged

test(federation): improve and slim down config and scripts#37769
sampaiodiego merged 6 commits intodevelopfrom
federation-tests-improve-scripts

Conversation

@sampaiodiego
Copy link
Member

@sampaiodiego sampaiodiego commented Dec 10, 2025

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Tests
    • Restructured federation test configuration and environment handling, replaced endpoint field usage in test setups, added richer test-wrapping helpers (skip/only/todo), and improved test-run metadata for clearer reporting (dynamic run titles).
  • Chores
    • Renamed test script to test:federation, updated integration test invocation to use the new command and environment setup, and exposed PR number to test runs.

✏️ Tip: You can customize this high-level summary in your review settings.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Dec 10, 2025

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Dec 10, 2025

⚠️ No Changeset found

Latest commit: 34826d1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 10, 2025

Walkthrough

Consolidates federation test configuration: introduces a typed FederationServerConfig and renames per-server field apiUrlurl across tests, adds a federation-specific Jest config with dynamic Qase run title, replaces testend-to-end with test:federation, and updates the integration test runner to use the new command and env vars.

Changes

Cohort / File(s) Summary
Package & Runner
ee/packages/federation-matrix/package.json, ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh
Removed testend-to-end script; added test:federation (jest --config jest.config.federation.ts); updated shell script to invoke federation tests with IS_EE=true NODE_EXTRA_CA_CERTS=$(pwd)/.../rootCA.crt yarn test:federation.
Config Type & Env Handling
ee/packages/federation-matrix/tests/helper/config.ts
Added FederationServerConfig type; replaced per-server apiUrl/flat env vars with url, domain, derived matrix IDs and consolidated environment parsing/validation.
End-to-end Tests
ee/packages/federation-matrix/tests/end-to-end/messaging.spec.ts, ee/packages/federation-matrix/tests/end-to-end/room.spec.ts
Replaced all usages of federationConfig.rc1.apiUrl with federationConfig.rc1.url when building request configs, DDP listeners, and user/admin request setups.
Jest & Qase Setup
ee/packages/federation-matrix/jest.config.federation.ts, ee/packages/federation-matrix/tests/setup-qase.ts
Added jest.config.federation.ts with dynamic Qase run title logic; augmented global.it/global.test via Object.assign to expose .skip, .only, .todo helpers and added suitePathStack handling plus describe-eval error logging.
CI Workflow
.github/workflows/ci.yml
Added PR_NUMBER env var to federation test steps (${{ github.event.number }}) so tests can access the PR number at runtime.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay extra attention to tests/helper/config.ts (type additions, env parsing, derived IDs).
  • Verify Qase run title behavior in jest.config.federation.ts (env-dependent logic).
  • Confirm tests/setup-qase.ts augmentation preserves existing test timing/semantics.

Possibly related PRs

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • ggazzo
  • rodrigok

Poem

🐰 I hopped through configs, tidy and quick,
apiUrl became url — a neat little trick.
Tests renamed, Qase gets a fancy title,
I wiggled my nose and munched a small bridle.
Hooray for clean runs and a carrot-filled sprint! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: refactoring federation test configuration and scripts for improvement and reduction in complexity across multiple files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch federation-tests-improve-scripts

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between dbad394 and 34826d1.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
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
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.
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
⏰ 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). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (1)
.github/workflows/ci.yml (1)

659-659: No action required—PR_NUMBER is already handled gracefully.

github.event.number is only defined during pull_request events, but the jest configuration in jest.config.federation.ts already uses a conditional check (if (process.env.PR_NUMBER)) to safely handle cases where it's undefined. The test script does not require this variable. The job running on all triggers (release, pull_request, and push to develop) is not a problem since PR_NUMBER is optional.


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.

@sampaiodiego sampaiodiego force-pushed the federation-tests-improve-scripts branch from 64edfad to e2ec1f0 Compare December 10, 2025 20:33
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh (1)

327-346: Update NO_TEST instructions to use test:federation

The main path now runs IS_EE=true NODE_EXTRA_CA_CERTS=… yarn test:federation, but the NO_TEST branch still tells users to run yarn testend-to-end. This is misleading with the new script name.

Consider updating the hint to something like:

-    log_info "To run tests manually, execute: yarn testend-to-end"
+    log_info "To run tests manually, execute: IS_EE=true NODE_EXTRA_CA_CERTS=\$(pwd)/docker-compose/traefik/certs/ca/rootCA.crt yarn test:federation"

so manual runs match what the script does.

🧹 Nitpick comments (2)
ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh (1)

27-29: Redundant removal of freshly created BUILD_DIR

BUILD_DIR is created via mktemp -d and then immediately removed with rm -rf "$BUILD_DIR" before the Meteor build recreates it. That works in practice but is a bit confusing; you could drop the cleanup or switch to rm -rf "$BUILD_DIR"/* to keep the directory while clearing contents.

Also applies to: 191-193

ee/packages/federation-matrix/tests/helper/config.ts (1)

38-96: Centralized env handling is good; consider optional explicit URL overrides

validateEnvVar plus getFederationConfig nicely de-duplicate env parsing and enforce non‑empty values, while deriving:

  • url as https://${domain}
  • Matrix IDs as @user:${domain}

for both RC1 and HS1.

If you ever need to run federation tests against endpoints that don’t follow this pattern (e.g., different scheme/port or a nontrivial path), you might want to add optional FEDERATION_RC1_URL / FEDERATION_SYNAPSE_URL envs that, when set, override the derived https://${domain} value, falling back to the current derivation otherwise. That keeps today’s behavior but restores flexibility for more exotic setups.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ddf6717 and e2ec1f0.

📒 Files selected for processing (5)
  • ee/packages/federation-matrix/package.json (1 hunks)
  • ee/packages/federation-matrix/tests/end-to-end/messaging.spec.ts (1 hunks)
  • ee/packages/federation-matrix/tests/end-to-end/room.spec.ts (4 hunks)
  • ee/packages/federation-matrix/tests/helper/config.ts (3 hunks)
  • ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh (7 hunks)
🧰 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/messaging.spec.ts
  • ee/packages/federation-matrix/tests/end-to-end/room.spec.ts
  • ee/packages/federation-matrix/tests/helper/config.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.ts extension for test files (e.g., login.spec.ts)

Files:

  • ee/packages/federation-matrix/tests/end-to-end/messaging.spec.ts
  • ee/packages/federation-matrix/tests/end-to-end/room.spec.ts
🧠 Learnings (7)
📚 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/package.json
  • ee/packages/federation-matrix/tests/end-to-end/messaging.spec.ts
  • ee/packages/federation-matrix/tests/end-to-end/room.spec.ts
  • ee/packages/federation-matrix/tests/helper/config.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:

  • ee/packages/federation-matrix/package.json
  • ee/packages/federation-matrix/tests/end-to-end/messaging.spec.ts
  • ee/packages/federation-matrix/tests/end-to-end/room.spec.ts
  • ee/packages/federation-matrix/tests/helper/config.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/package.json
  • ee/packages/federation-matrix/tests/end-to-end/room.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 : Ensure tests run reliably in parallel without shared state conflicts

Applied to files:

  • ee/packages/federation-matrix/tests/end-to-end/messaging.spec.ts
  • ee/packages/federation-matrix/tests/end-to-end/room.spec.ts
  • ee/packages/federation-matrix/tests/helper/config.ts
  • ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh
📚 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/messaging.spec.ts
  • ee/packages/federation-matrix/tests/end-to-end/room.spec.ts
  • ee/packages/federation-matrix/tests/helper/config.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/room.spec.ts
  • ee/packages/federation-matrix/tests/helper/config.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/room.spec.ts
  • ee/packages/federation-matrix/tests/helper/config.ts
🧬 Code graph analysis (2)
ee/packages/federation-matrix/tests/end-to-end/messaging.spec.ts (1)
ee/packages/federation-matrix/tests/helper/config.ts (1)
  • federationConfig (113-113)
ee/packages/federation-matrix/tests/end-to-end/room.spec.ts (2)
apps/meteor/tests/data/users.helper.ts (1)
  • getRequestConfig (35-43)
ee/packages/federation-matrix/tests/helper/ddp-listener.ts (1)
  • createDDPListener (166-168)
🔇 Additional comments (6)
ee/packages/federation-matrix/package.json (1)

17-17: New test:federation script wiring looks correct

Hooking Jest via jest.config.federation.ts matches the updated integration runner and cleanly scopes federation tests; no issues here.

ee/packages/federation-matrix/tests/end-to-end/messaging.spec.ts (1)

22-28: Switch to federationConfig.rc1.url is consistent with new config helper

Using federationConfig.rc1.url as the base URL for getRequestConfig matches the new FederationServerConfig shape and still provides a full origin to supertest; behavior stays the same.

ee/packages/federation-matrix/tests/end-to-end/room.spec.ts (1)

32-36: Consistent use of federationConfig.rc1.url for HTTP and DDP clients

Updating all RC1 request/connection points (getRequestConfig and createDDPListener) to use federationConfig.rc1.url makes the origin a single source of truth under FederationServerConfig. The change is type‑safe and should be behavior‑preserving as long as your new url (https://${FEDERATION_RC1_DOMAIN}) matches what apiUrl used to be, including any port differences.

Please confirm that any environments which previously relied on a custom RC1 API URL (e.g., non‑443 port or extra path) are still correctly covered by the new domain‑based URL derivation; if not, you may need an explicit FEDERATION_RC1_URL override in the helper config.

Also applies to: 50-54, 85-88, 258-261

ee/packages/federation-matrix/tests/scripts/run-integration-tests.sh (1)

262-302: Capturing curl output in wait_for_service improves diagnosability

Storing curl_output / curl_exit_code and logging the error when services are not yet ready is a solid debugging aid for federation test flakiness; scope is limited to local rc1/hs1 health checks, so no concern from a security/noise standpoint.

ee/packages/federation-matrix/tests/helper/config.ts (2)

9-24: FederationServerConfig shape is clear and symmetric

Defining FederationServerConfig and using it for both rc1 and hs1 gives a clean, consistent contract (URL, domain, admin, additional user) that matches how the tests consume the config. No issues here.


105-111: Fail-fast federation config initialization is appropriate

Initializing federationConfig at module load and exiting the process on configuration errors makes misconfigured environments fail immediately instead of producing confusing test failures later; that’s a good trade‑off for this test helper.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 10, 2025

📦 Docker Image Size Report

📈 Changes

Service Current Baseline Change Percent
sum of all images 1.2GiB 1.2GiB +9.7MiB
rocketchat 358MiB 349MiB +9.7MiB
omnichannel-transcript-service 132MiB 132MiB -843B
queue-worker-service 132MiB 132MiB +1.2KiB
ddp-streamer-service 126MiB 126MiB -947B
account-service 113MiB 113MiB -366B
stream-hub-service 111MiB 111MiB -30B
presence-service 111MiB 111MiB -196B
authorization-service 111MiB 111MiB +232B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/15 22:28", "11/16 01:28", "11/17 23:50", "11/18 22:53", "11/19 23:02", "11/21 16:49", "11/24 17:34", "11/27 22:32", "11/28 19:05", "12/01 23:01", "12/02 21:57", "12/03 21:00", "12/04 18:17", "12/05 21:56", "12/08 20:15", "12/09 22:17", "12/10 23:26", "12/11 17:41", "12/11 19:29 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "queue-worker-service" [0.14, 0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "rocketchat" [0.36, 0.36, 0.35, 0.35, 0.35, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.35]
  line "stream-hub-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
Loading

Statistics (last 18 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.2GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 1.2GiB
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-37769
  • Baseline: develop
  • Timestamp: 2025-12-11 19:29:40 UTC
  • Historical data points: 18

Updated: Thu, 11 Dec 2025 19:29:40 GMT

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.79%. Comparing base (ddf6717) to head (34826d1).
⚠️ Report is 10 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #37769      +/-   ##
===========================================
+ Coverage    67.70%   67.79%   +0.08%     
===========================================
  Files         3452     3452              
  Lines       113975   113985      +10     
  Branches     20940    20943       +3     
===========================================
+ Hits         77168    77274     +106     
+ Misses       34678    34580      -98     
- Partials      2129     2131       +2     
Flag Coverage Δ
e2e 57.31% <ø> (+0.04%) ⬆️
e2e-api 43.27% <ø> (+0.94%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
ee/packages/federation-matrix/tests/setup-qase.ts (1)

101-143: Apply the same fix to global.test wrapper.

The global.test wrapper has the same suitePathStack manipulation issue as global.it. Apply the same simplification here.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e2ec1f0 and dbad394.

📒 Files selected for processing (2)
  • ee/packages/federation-matrix/jest.config.federation.ts (2 hunks)
  • ee/packages/federation-matrix/tests/setup-qase.ts (1 hunks)
🧰 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:

  • ee/packages/federation-matrix/jest.config.federation.ts
  • ee/packages/federation-matrix/tests/setup-qase.ts
🧠 Learnings (14)
📓 Common learnings
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
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.
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
📚 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/jest.config.federation.ts
  • ee/packages/federation-matrix/tests/setup-qase.ts
📚 Learning: 2025-12-10T21:00:43.645Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:43.645Z
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/jest.config.federation.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/jest.config.federation.ts
  • ee/packages/federation-matrix/tests/setup-qase.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/jest.config.federation.ts
  • ee/packages/federation-matrix/tests/setup-qase.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 clean state for each test execution in Playwright tests

Applied to files:

  • ee/packages/federation-matrix/jest.config.federation.ts
  • ee/packages/federation-matrix/tests/setup-qase.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 **/*.spec.ts : Use descriptive test names that clearly communicate expected behavior in Playwright tests

Applied to files:

  • ee/packages/federation-matrix/jest.config.federation.ts
  • ee/packages/federation-matrix/tests/setup-qase.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/jest.config.federation.ts
  • ee/packages/federation-matrix/tests/setup-qase.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/setup-qase.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.beforeAll()` and `test.afterAll()` for setup/teardown in Playwright tests

Applied to files:

  • ee/packages/federation-matrix/tests/setup-qase.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/setup-qase.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 `expect` matchers for assertions (`toEqual`, `toContain`, `toBeTruthy`, `toHaveLength`, etc.) instead of `assert` statements in Playwright tests

Applied to files:

  • ee/packages/federation-matrix/tests/setup-qase.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/**/*.{ts,spec.ts} : Follow Page Object Model pattern consistently in Playwright tests

Applied to files:

  • ee/packages/federation-matrix/tests/setup-qase.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 **/*.{ts,tsx,js} : Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests

Applied to files:

  • ee/packages/federation-matrix/tests/setup-qase.ts
🔇 Additional comments (2)
ee/packages/federation-matrix/jest.config.federation.ts (2)

11-25: LGTM! Clean dynamic title generation.

The function correctly builds a descriptive Qase run title by incorporating optional CI metadata (PR number, GitHub run ID) and a timestamp for unique identification.


55-58: LGTM! Dynamic title integration works correctly.

The Qase run configuration now uses the dynamically generated title, providing better traceability for federation test runs in CI.

Comment on lines +54 to +98
global.it = Object.assign(
(testName: any, fn?: any, timeout?: number) => {
// Handle qase-wrapped test names (qase returns a string)
if (typeof testName === 'string' && fn) {
return currentIt(
testName,
async () => {
// Set suite immediately at the start of the test
qase.suite(currentPath);
// Call the original test function and return the result
return fn();
},
timeout,
);
}
// Handle cases where testName might be a number or other type
return currentIt(testName, fn, timeout);
},
{
skip: (name: string, fn: () => void) => {
suitePathStack.push(name);
try {
currentIt.skip(name, fn);
} finally {
suitePathStack.pop();
}
},
only: (name: string, fn: () => void) => {
suitePathStack.push(name);
try {
currentIt.only(name, fn);
} finally {
suitePathStack.pop();
}
},
todo: (name: string) => {
suitePathStack.push(name);
try {
currentIt.todo(name);
} finally {
suitePathStack.pop();
}
},
},
) as typeof global.it;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove suitePathStack manipulation from skip/only/todo methods.

The skip/only/todo implementations incorrectly push test names onto suitePathStack, which is designed to track suite (describe block) hierarchy, not individual test names. While the immediate push/pop minimizes runtime impact, this corrupts the conceptual model and adds confusing, unnecessary operations.

These methods should simply delegate to the original implementation without stack manipulation:

 global.it = Object.assign(
 	(testName: any, fn?: any, timeout?: number) => {
 		if (typeof testName === 'string' && fn) {
 			return currentIt(
 				testName,
 				async () => {
 					qase.suite(currentPath);
 					return fn();
 				},
 				timeout,
 			);
 		}
 		return currentIt(testName, fn, timeout);
 	},
 	{
-		skip: (name: string, fn: () => void) => {
-			suitePathStack.push(name);
-			try {
-				currentIt.skip(name, fn);
-			} finally {
-				suitePathStack.pop();
-			}
-		},
+		skip: currentIt.skip.bind(currentIt),
-		only: (name: string, fn: () => void) => {
-			suitePathStack.push(name);
-			try {
-				currentIt.only(name, fn);
-			} finally {
-				suitePathStack.pop();
-			}
-		},
+		only: currentIt.only.bind(currentIt),
-		todo: (name: string) => {
-			suitePathStack.push(name);
-			try {
-				currentIt.todo(name);
-			} finally {
-				suitePathStack.pop();
-			}
-		},
+		todo: currentIt.todo.bind(currentIt),
 	},
 ) as typeof global.it;
🤖 Prompt for AI Agents
In ee/packages/federation-matrix/tests/setup-qase.ts around lines 54 to 98, the
skip/only/todo methods currently push and pop test names on suitePathStack
(which tracks suite/describe hierarchy) — remove that manipulation and have
these methods simply delegate directly to the original currentIt
implementations; replace the bodies so skip calls currentIt.skip(name, fn), only
calls currentIt.only(name, fn), and todo calls currentIt.todo(name) with no
push/pop or try/finally around them.

Comment on lines +146 to +150
try {
fn();
} catch (error) {
console.error('Error in describe block:', error);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Re-throw errors after logging to avoid swallowing exceptions.

The try-catch block logs errors from the describe block but doesn't re-throw them, which swallows exceptions and could hide real problems during test setup. Jest needs to see these errors to properly fail the test suite.

 try {
 	fn();
 } catch (error) {
 	console.error('Error in describe block:', error);
+	throw error;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
try {
fn();
} catch (error) {
console.error('Error in describe block:', error);
}
try {
fn();
} catch (error) {
console.error('Error in describe block:', error);
throw error;
}
🤖 Prompt for AI Agents
In ee/packages/federation-matrix/tests/setup-qase.ts around lines 146-150 the
try-catch around fn() logs errors but does not re-throw them, which swallows
exceptions; update the catch block to re-throw the caught error after logging
(e.g., console.error(...); throw error;) so Jest receives the failure and the
test suite can fail appropriately.

ggazzo
ggazzo previously approved these changes Dec 11, 2025
@ggazzo ggazzo added this to the 7.14.0 milestone Dec 11, 2025
@sampaiodiego sampaiodiego requested a review from a team as a code owner December 11, 2025 19:12
@sampaiodiego sampaiodiego added the stat: QA assured Means it has been tested and approved by a company insider label Dec 11, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Dec 11, 2025
@sampaiodiego sampaiodiego merged commit 2527c47 into develop Dec 11, 2025
75 of 77 checks passed
@sampaiodiego sampaiodiego deleted the federation-tests-improve-scripts branch December 11, 2025 19:44
@dougfabris dougfabris modified the milestones: 7.14.0, 8.0.0 Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants