test: Separate livechat API tests#39114
Conversation
|
Looks like this PR is ready to merge! 🎉 |
|
WalkthroughThis pull request adds end-to-end testing infrastructure for Livechat API functionality. It introduces new CI jobs for testing Livechat API in both CE and EE versions, creates a dedicated Mocha configuration file for Livechat API tests, adds an npm script to run these tests, and updates test methods to properly initialize and clean up Livechat test environments. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #39114 +/- ##
===========================================
- Coverage 70.77% 70.71% -0.06%
===========================================
Files 3195 3195
Lines 113096 113095 -1
Branches 20513 20510 -3
===========================================
- Hits 80044 79977 -67
- Misses 31015 31070 +55
- Partials 2037 2048 +11
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
/jira CORE |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/ci-test-e2e.yml (1)
214-228:⚠️ Potential issue | 🟠 MajorPre-existing bug: Undefined variable
$sin API test step.Note: The same undefined
$svariable issue exists in the original API test step on line 228. Consider fixing both steps for consistency.🐛 Proposed fix for the original API test step
run: | set -o xtrace - npm run testapi + npm run testapi; s=$? docker compose -f ../../docker-compose-ci.yml stop ls -la $COVERAGE_DIR exit $s🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/ci-test-e2e.yml around lines 214 - 228, The step currently uses an undefined variable "exit $s"; change the shell flow to capture and propagate the test command's exit status instead of referencing $s: run "npm run testapi" and save its exit code (e.g. EXIT_CODE=$? immediately after the command or use "npm run testapi || EXIT_CODE=$?"), then run the cleanup commands (docker compose ... stop and ls -la $COVERAGE_DIR) and finish with "exit $EXIT_CODE" (or simply enable "set -e" at the top and remove the explicit exit), replacing the buggy "exit $s" in this API test step (and mirror the same fix in the original API test step).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/ci-test-e2e.yml:
- Around line 230-244: The step currently ends with an undefined variable "exit
$s" which masks the real test result; capture the exit code after running "npm
run testapi:livechat" (e.g., run the command, then set TEST_EXIT=$?), use that
variable when exiting (exit $TEST_EXIT), and keep the docker compose stop / ls
-la $COVERAGE_DIR lines before exiting; update the same pattern for the other
API test step that also uses "exit $s".
---
Outside diff comments:
In @.github/workflows/ci-test-e2e.yml:
- Around line 214-228: The step currently uses an undefined variable "exit $s";
change the shell flow to capture and propagate the test command's exit status
instead of referencing $s: run "npm run testapi" and save its exit code (e.g.
EXIT_CODE=$? immediately after the command or use "npm run testapi ||
EXIT_CODE=$?"), then run the cleanup commands (docker compose ... stop and ls
-la $COVERAGE_DIR) and finish with "exit $EXIT_CODE" (or simply enable "set -e"
at the top and remove the explicit exit), replacing the buggy "exit $s" in this
API test step (and mirror the same fix in the original API test step).
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
.github/workflows/ci-test-e2e.yml.github/workflows/ci.ymlapps/meteor/.mocharc.api.jsapps/meteor/.mocharc.api.livechat.jsapps/meteor/package.jsonapps/meteor/tests/end-to-end/api/methods.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 (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/methods.ts
🧠 Learnings (24)
📓 Common learnings
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.
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:09.561Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs for apps/meteor/app/api/server/v1 endpoints, maintainers prefer to avoid any logic changes; style-only cleanups (like removing inline comments) may be deferred to follow-ups to keep scope tight.
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 0
File: :0-0
Timestamp: 2026-02-24T19:05:56.710Z
Learning: In Rocket.Chat PRs, keep feature PRs free of unrelated lockfile-only dependency bumps; prefer reverting lockfile drift or isolating such bumps into a separate "chore" commit/PR, and always use yarn install --immutable with the Yarn version pinned in package.json via Corepack.
📚 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:
apps/meteor/.mocharc.api.jsapps/meteor/tests/end-to-end/api/methods.tsapps/meteor/.mocharc.api.livechat.js.github/workflows/ci-test-e2e.ymlapps/meteor/package.json
📚 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:
apps/meteor/.mocharc.api.jsapps/meteor/tests/end-to-end/api/methods.tsapps/meteor/.mocharc.api.livechat.js.github/workflows/ci-test-e2e.ymlapps/meteor/package.json
📚 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/.mocharc.api.jsapps/meteor/tests/end-to-end/api/methods.tsapps/meteor/.mocharc.api.livechat.js
📚 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/page-objects/**/*.ts : Utilize existing page objects pattern from `apps/meteor/tests/e2e/page-objects/`
Applied to files:
apps/meteor/.mocharc.api.jsapps/meteor/tests/end-to-end/api/methods.tsapps/meteor/.mocharc.api.livechat.js
📚 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/.mocharc.api.jsapps/meteor/tests/end-to-end/api/methods.tsapps/meteor/.mocharc.api.livechat.jsapps/meteor/package.json
📚 Learning: 2026-02-24T19:09:09.561Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:09.561Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs for apps/meteor/app/api/server/v1 endpoints, maintainers prefer to avoid any logic changes; style-only cleanups (like removing inline comments) may be deferred to follow-ups to keep scope tight.
Applied to files:
apps/meteor/.mocharc.api.jsapps/meteor/package.json
📚 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:
apps/meteor/.mocharc.api.jsapps/meteor/tests/end-to-end/api/methods.tsapps/meteor/package.json
📚 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:
apps/meteor/.mocharc.api.jsapps/meteor/tests/end-to-end/api/methods.tsapps/meteor/.mocharc.api.livechat.jsapps/meteor/package.json
📚 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:
apps/meteor/.mocharc.api.jsapps/meteor/tests/end-to-end/api/methods.tsapps/meteor/.mocharc.api.livechat.jsapps/meteor/package.json
📚 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:
apps/meteor/.mocharc.api.js
📚 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:
apps/meteor/.mocharc.api.jsapps/meteor/tests/end-to-end/api/methods.tsapps/meteor/.mocharc.api.livechat.jsapps/meteor/package.json
📚 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:
apps/meteor/.mocharc.api.jsapps/meteor/.mocharc.api.livechat.jsapps/meteor/package.json
📚 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 `.spec.ts` extension for test files (e.g., `login.spec.ts`)
Applied to files:
apps/meteor/.mocharc.api.js
📚 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:
apps/meteor/.mocharc.api.jsapps/meteor/.mocharc.api.livechat.jsapps/meteor/package.json
📚 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} : Store commonly used locators in variables/constants for reuse
Applied to files:
apps/meteor/.mocharc.api.jsapps/meteor/.mocharc.api.livechat.js
📚 Learning: 2026-02-25T20:10:16.987Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38913
File: packages/ddp-client/src/legacy/types/SDKLegacy.ts:34-34
Timestamp: 2026-02-25T20:10:16.987Z
Learning: In the RocketChat/Rocket.Chat monorepo, packages/ddp-client and apps/meteor do not use TypeScript project references. Module augmentations in apps/meteor (e.g., declare module 'rocket.chat/rest-typings') are not visible when compiling packages/ddp-client in isolation, which is why legacy SDK methods that depend on OperationResult types for OpenAPI-migrated endpoints must remain commented out.
Applied to files:
apps/meteor/tests/end-to-end/api/methods.tsapps/meteor/.mocharc.api.livechat.jsapps/meteor/package.json
📚 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/methods.ts
📚 Learning: 2025-11-27T17:56:26.050Z
Learnt from: MartinSchoeler
Repo: RocketChat/Rocket.Chat PR: 37557
File: apps/meteor/client/views/admin/ABAC/AdminABACRooms.tsx:115-116
Timestamp: 2025-11-27T17:56:26.050Z
Learning: In Rocket.Chat, the GET /v1/abac/rooms endpoint (implemented in ee/packages/abac/src/index.ts) only returns rooms where abacAttributes exists and is not an empty array (query: { abacAttributes: { $exists: true, $ne: [] } }). Therefore, in components consuming this endpoint (like AdminABACRooms.tsx), room.abacAttributes is guaranteed to be defined for all returned rooms, and optional chaining before calling array methods like .join() is sufficient without additional null coalescing.
Applied to files:
apps/meteor/tests/end-to-end/api/methods.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:
apps/meteor/tests/end-to-end/api/methods.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:
apps/meteor/tests/end-to-end/api/methods.ts
📚 Learning: 2025-11-24T17:08:26.531Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/test-cases.mdc:0-0
Timestamp: 2025-11-24T17:08:26.531Z
Learning: Applies to **/*test-case*.md : Define test type classification (API, E2E, or Unit) as the most appropriate type for each test scenario
Applied to files:
.github/workflows/ci-test-e2e.yml
📚 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:
apps/meteor/package.json
📚 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:
apps/meteor/package.json
🧬 Code graph analysis (1)
apps/meteor/tests/end-to-end/api/methods.ts (1)
apps/meteor/tests/data/livechat/rooms.ts (2)
createAgent(254-268)makeAgentAvailable(294-310)
🔇 Additional comments (10)
apps/meteor/.mocharc.api.js (1)
13-13: LGTM!The spec pattern changes correctly narrow the API test scope by explicitly listing the non-livechat test paths, allowing the new
.mocharc.api.livechat.jsconfig to handle livechat tests separately.apps/meteor/.mocharc.api.livechat.js (1)
1-14: LGTM!The new Mocha configuration correctly extends the base config and targets the livechat test directory. The settings (timeout, bail, retries) are consistent with the main API test configuration.
apps/meteor/package.json (1)
58-58: LGTM!The new
testapi:livechatscript follows the established pattern from the existingtestapiscript and correctly references the new Mocha configuration file.apps/meteor/tests/end-to-end/api/methods.ts (2)
11-11: LGTM!The import correctly adds
makeAgentAvailablefrom the livechat rooms helper module.
3392-3405: LGTM!The test setup and teardown correctly initialize and clean up the Livechat environment for the
[@joinRoom]test. Enabling Livechat, creating an agent, and making the agent available ensures proper test isolation for testing livechat room behavior..github/workflows/ci.yml (5)
513-527: LGTM!The new
test-api-livechatjob for CE correctly follows the established pattern fromtest-api, using the same workflow withtype: api-livechat.
574-592: LGTM!The new
test-api-livechat-eejob for EE correctly mirrors thetest-api-eejob structure with appropriate transporter, enterprise license, MongoDB version, and coverage settings.
720-720: LGTM!Correctly adds
test-api-livechat-eeto thereport-coveragejob dependencies to ensure livechat test coverage is included in the report.
772-772: LGTM!The
tests-donejob now correctly depends on bothtest-api-livechatandtest-api-livechat-eeto ensure all test suites complete before marking tests as done.
801-807: LGTM!The result checks for the new livechat test jobs are correctly structured and follow the same pattern as the existing test job checks.
Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Further comments
Task: CORE-1892
Summary by CodeRabbit
Tests
Chores