Skip to content

Comments

test: Add automated tests for custom fields functionality.#38743

Open
Harmeet221 wants to merge 13 commits intodevelopfrom
custom-field-implementation
Open

test: Add automated tests for custom fields functionality.#38743
Harmeet221 wants to merge 13 commits intodevelopfrom
custom-field-implementation

Conversation

@Harmeet221
Copy link
Contributor

@Harmeet221 Harmeet221 commented Feb 17, 2026

JIRA TASK: https://rocketchat.atlassian.net/browse/QA-111

Description:

Added comprehensive end-to-end test coverage for omnichannel custom fields, including room and visitor-scoped field creation, updates, and validation.

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Tests
    • Added end-to-end Playwright tests for omnichannel custom fields (room- and visitor-scoped): API-driven setup/teardown and UI flows to view, edit, save, and verify persisted values in chat and contact info.
    • Extended test helpers and UI page-object utilities to support creating, setting, and asserting room and visitor custom field values.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Feb 17, 2026

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 Feb 17, 2026

⚠️ No Changeset found

Latest commit: 8e1e9b9

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 Feb 17, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d08b14a and 8e1e9b9.

📒 Files selected for processing (2)
  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.ts
  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.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). (4)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build

Walkthrough

Adds a new Playwright E2E test for omnichannel custom fields (room- and visitor-scoped), plus small page-object accessors and an API helper to set visitor custom field values; includes API-driven setup/teardown and UI verification flows.

Changes

Cohort / File(s) Summary
E2E Test Suite
apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
New serial Playwright test: API-driven setup (agent, manager, room & visitor custom fields, conversation, preload visitor value), UI flows to open conversation, edit/verify room custom field, open contact info, verify/update visitor custom field, and cleanup.
Page Object — Edit Room Flex Tab
apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
Added getRoomCustomField(customFieldId: string): Locator to locate room-scoped custom field inputs by dynamic id/name.
Page Object — Omnichannel Contact Info
apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.ts
Added dialogContactInfo(): Locator (dialog root) and getVisitorCustomField(customFieldId: string): Locator to locate visitor-scoped custom field inputs by dynamic id/name.
Omnichannel API Utils
apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts
Added setVisitorCustomFieldValue(api, { token, customFieldId, value, overwrite? }) to POST visitor custom field values to /livechat/custom.field, returning parsed response and throwing on non-OK.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Runner
    participant API as Server API
    participant Browser as Browser/UI
    participant DB as Database

    Test->>API: create agent & manager
    Test->>API: create room-scoped custom field
    Test->>API: create visitor-scoped custom field
    Test->>API: create conversation (visitor + room)
    Test->>API: setVisitorCustomFieldValue(token, fieldId, value) -- preload visitor value
    Note right of DB: Entities persisted

    Test->>Browser: open app, navigate to conversation
    Browser->>API: load conversation & room data
    Browser->>API: fetch room custom fields
    Browser->>Browser: edit room custom field (UI)
    Browser->>API: save room custom field update
    API->>DB: persist room field value
    Browser->>Browser: verify updated room field value

    Browser->>Browser: open contact info panel
    Browser->>API: fetch visitor custom fields
    Browser->>Browser: update visitor custom field (UI)
    Browser->>API: save visitor custom field update
    API->>DB: persist visitor field value
    Browser->>Browser: verify updated visitor field value

    Test->>API: cleanup created fields, users, conversation
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped into tests with eager delight,

Room fields and visitor tags snug and bright.
I clicked and I posted, then checked with a grin,
Values all settled — the assertions win.
Carrots for coverage, and nap time within. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary change: adding automated tests for custom fields functionality, which aligns with the PR's main objective.
Linked Issues check ✅ Passed The PR implements all E2E test requirements from QA-111: creates room and visitor-scoped custom fields, verifies their appearance in room/contact info, and validates updates are reflected correctly.
Out of Scope Changes check ✅ Passed All changes are within scope: test file additions and page-object/utility helper methods support the QA-111 E2E testing objectives with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.53%. Comparing base (968d73c) to head (8e1e9b9).
⚠️ Report is 6 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38743      +/-   ##
===========================================
+ Coverage    70.51%   70.53%   +0.01%     
===========================================
  Files         3182     3183       +1     
  Lines       112471   112485      +14     
  Branches     20392    20418      +26     
===========================================
+ Hits         79307    79337      +30     
+ Misses       31105    31092      -13     
+ Partials      2059     2056       -3     
Flag Coverage Δ
e2e 60.39% <ø> (+0.01%) ⬆️
e2e-api 47.78% <ø> (+0.03%) ⬆️
unit 71.48% <ø> (+0.01%) ⬆️

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.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2026

📦 Docker Image Size Report

📈 Changes

Service Current Baseline Change Percent
sum of all images 1.1GiB 1.1GiB +11MiB
rocketchat 360MiB 349MiB +11MiB
omnichannel-transcript-service 134MiB 134MiB -1.7KiB
queue-worker-service 134MiB 134MiB -1.1KiB
ddp-streamer-service 128MiB 128MiB -3.1KiB
account-service 115MiB 115MiB -333B
authorization-service 112MiB 112MiB +119B
presence-service 112MiB 112MiB -407B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["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 21:56", "12/12 22:45", "12/13 01:34", "12/15 22:31", "12/16 22:18", "12/17 21:04", "12/18 23:12", "12/19 23:27", "12/20 21:03", "12/22 18:54", "12/23 16:16", "12/24 19:38", "12/25 17:51", "12/26 13:18", "12/29 19:01", "12/30 20:52", "02/12 22:57", "02/13 22:38", "02/16 14:04", "02/18 23:15", "02/19 23:23", "02/20 04:42", "02/20 11:21 (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, 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, 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, 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.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, 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, 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, 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.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, 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, 0.13, 0.13, 0.13]
  line "rocketchat" [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.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.34, 0.34, 0.34, 0.34, 0.35]
Loading

Statistics (last 30 days):

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

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

  • Tag: pr-38743
  • Baseline: develop
  • Timestamp: 2026-02-20 11:21:28 UTC
  • Historical data points: 30

Updated: Fri, 20 Feb 2026 11:21:29 GMT

@Harmeet221 Harmeet221 marked this pull request as ready for review February 17, 2026 11:57
@Harmeet221 Harmeet221 requested a review from a team as a code owner February 17, 2026 11:57
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

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: 3

🧹 Nitpick comments (1)
apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts (1)

90-99: Reuse commonly used locators within the test.

The same room custom field locator is queried multiple times; keep it in a constant and reuse to align with locator reuse guidance.

♻️ Suggested refactor
 test('Should be allowed to set room custom field for a conversation', async () => {
+	const roomCustomFieldInput = poHomeChannel.editRoomInfo.getRoomCustomField(roomCustomFieldLabel);
+
 	await test.step('Agent opens the conversation', async () => {
 		await poHomeChannel.sidebar.getSidebarItemByName(visitor.name).click();
 	});
@@
 	await test.step('Agent fills room custom field and saves', async () => {
-		await poHomeChannel.editRoomInfo.getRoomCustomField(roomCustomFieldLabel).fill(roomCustomFieldValue);
+		await roomCustomFieldInput.fill(roomCustomFieldValue);
 		await poHomeChannel.editRoomInfo.btnSave.click();
 	});
@@
 	await test.step('Custom field should be updated successfully', async () => {
 		await poHomeChannel.roomInfo.btnEdit.click();
 		await poHomeChannel.editRoomInfo.waitForDisplay();
-		await expect(poHomeChannel.editRoomInfo.getRoomCustomField(roomCustomFieldLabel)).toHaveValue(roomCustomFieldValue);
+		await expect(roomCustomFieldInput).toHaveValue(roomCustomFieldValue);
 	});
 });

As per coding guidelines, "Store commonly used locators in variables/constants for reuse".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts`
around lines 90 - 99, The test repeatedly calls
poHomeChannel.editRoomInfo.getRoomCustomField(roomCustomFieldLabel); extract
that locator into a constant (e.g., const roomCustomField =
poHomeChannel.editRoomInfo.getRoomCustomField(roomCustomFieldLabel)) before the
steps and then use roomCustomField.fill(roomCustomFieldValue) and the same
roomCustomField in the assertion; keep other interactions (btnSave.click,
roomInfo.btnEdit.click, editRoomInfo.waitForDisplay) unchanged and reference the
new constant instead of repeated getRoomCustomField calls.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 508b4a1 and 2dc2534.

📒 Files selected for processing (3)
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{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/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.ts
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
apps/meteor/tests/e2e/page-objects/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

Utilize existing page objects pattern from apps/meteor/tests/e2e/page-objects/

Files:

  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.ts
apps/meteor/tests/e2e/**/*.{ts,spec.ts}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

apps/meteor/tests/e2e/**/*.{ts,spec.ts}: Store commonly used locators in variables/constants for reuse
Follow Page Object Model pattern consistently in Playwright tests

Files:

  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.ts
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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.ts extension for test files (e.g., login.spec.ts)

Files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
apps/meteor/tests/e2e/**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

apps/meteor/tests/e2e/**/*.spec.ts: All test files must be created in apps/meteor/tests/e2e/ directory
Avoid using page.locator() in Playwright tests - always prefer semantic locators such as page.getByRole(), page.getByLabel(), page.getByText(), or page.getByTitle()
Use test.beforeAll() and test.afterAll() for setup/teardown in Playwright tests
Use test.step() for complex test scenarios to improve organization in Playwright tests
Group related tests in the same file
Utilize Playwright fixtures (test, page, expect) for consistency in test files
Prefer web-first assertions (toBeVisible, toHaveText, etc.) in Playwright tests
Use expect matchers for assertions (toEqual, toContain, toBeTruthy, toHaveLength, etc.) instead of assert statements in Playwright tests
Use page.waitFor() with specific conditions instead of hardcoded timeouts in Playwright tests
Implement proper wait strategies for dynamic content in Playwright tests
Maintain test isolation between test cases in Playwright tests
Ensure clean state for each test execution in Playwright tests
Ensure tests run reliably in parallel without shared state conflicts

Files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
🧠 Learnings (13)
📚 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/tests/e2e/page-objects/fragments/edit-room-flextab.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/page-objects/**/*.ts : Utilize existing page objects pattern from `apps/meteor/tests/e2e/page-objects/`

Applied to files:

  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 : Avoid using `page.locator()` in Playwright tests - always prefer semantic locators such as `page.getByRole()`, `page.getByLabel()`, `page.getByText()`, or `page.getByTitle()`

Applied to files:

  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.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:

  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
📚 Learning: 2025-12-16T17:29:40.430Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37834
File: apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-emoji.ts:12-22
Timestamp: 2025-12-16T17:29:40.430Z
Learning: In all page-object files under apps/meteor/tests/e2e/page-objects/, import expect from ../../utils/test (Playwright's async expect) instead of from Jest. Jest's expect is synchronous and incompatible with web-first assertions like toBeVisible, which can cause TypeScript errors.

Applied to files:

  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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/**/*.{ts,spec.ts} : Follow Page Object Model pattern consistently in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 clean state for each test execution in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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.beforeAll()` and `test.afterAll()` for setup/teardown in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
🪛 Biome (2.3.14)
apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts

[error] 35-35: This callback passed to forEach() iterable method should not return a value.

Either remove this return or remove the returned value.

(lint/suspicious/useIterableCallbackReturn)


[error] 72-72: This callback passed to forEach() iterable method should not return a value.

Either remove this return or remove the returned value.

(lint/suspicious/useIterableCallbackReturn)

🔇 Additional comments (2)
apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts (1)

88-90: Nice addition: room custom field accessor.

Encapsulating the custom-field lookup behind the page object keeps test code clean and uses a semantic locator.

apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.ts (1)

42-48: Good accessors for contact info dialog and visitor fields.

These additions keep custom-field access consistent and aligned with the page-object pattern.

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts`:
- Around line 31-36: The test currently uses responses.forEach((res) =>
expect(res.status()).toBe(200)) which triggers the lint rule forbidding returns
from forEach callbacks; replace the forEach with an explicit loop (e.g., for
(const res of responses) { expect(res.status()).toBe(200); }) to make intent
clear and satisfy linting, and apply the same change to the other occurrence
around the responses/assertions at lines 70-72 (same responses variable created
from Promise.all of api.post calls).
- Around line 64-68: The test's beforeEach uses a non-semantic locator
page.locator('#main-content'); update the setup in test.beforeEach to use a
semantic Playwright locator instead (e.g., page.getByRole('main') or
page.getByTestId('main-content') or page.getByLabel(...) depending on the
markup) so the HomeOmnichannel initialization waits on an accessible element;
replace page.locator('#main-content').waitFor() with the appropriate semantic
call (keeping the await) to adhere to the locator guideline.
- Around line 14-77: The suite uses shared mutable state created in
test.beforeAll (roomCustomField, visitorCustomField, conversation) which breaks
parallel safety; move creation of createCustomField and createConversation into
test.beforeEach and corresponding deletion into test.afterEach (use
roomCustomField.delete(), visitorCustomField.delete(), conversation.delete()) so
each test gets isolated fixtures, or if sharing is unavoidable, convert the
suite to serial by using test.describe.serial instead of test.describe; update
references to test.beforeAll/test.afterAll accordingly.

---

Nitpick comments:
In `@apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts`:
- Around line 90-99: The test repeatedly calls
poHomeChannel.editRoomInfo.getRoomCustomField(roomCustomFieldLabel); extract
that locator into a constant (e.g., const roomCustomField =
poHomeChannel.editRoomInfo.getRoomCustomField(roomCustomFieldLabel)) before the
steps and then use roomCustomField.fill(roomCustomFieldValue) and the same
roomCustomField in the assertion; keep other interactions (btnSave.click,
roomInfo.btnEdit.click, editRoomInfo.waitForDisplay) unchanged and reference the
new constant instead of repeated getRoomCustomField calls.

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.

🧹 Nitpick comments (2)
apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts (1)

124-137: Assertion uses toContainText on the entire dialog — this is fragile.

toContainText(visitorCustomFieldValue) on the entire dialog root will match if the text appears anywhere in the dialog, which could produce false positives if the value happens to coincide with other dialog content. Consider asserting directly on the custom field element for a more precise check:

Suggested improvement
 		await test.step('Assert custom field is set successfully', async () => {
-			await expect(poHomeChannel.contacts.contactInfo.dialogContactInfo).toContainText(visitorCustomFieldValue);
+			await expect(poHomeChannel.contacts.contactInfo.getVisitorCustomField(visitorCustomFieldLabel)).toHaveValue(visitorCustomFieldValue);
 		});

Note: If the field is rendered as read-only text rather than an input, toContainText scoped to the field element would still be more precise than asserting on the whole dialog. Same concern applies to line 158.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts`
around lines 124 - 137, The test is asserting visitorCustomFieldValue against
the whole dialog (poHomeChannel.contacts.contactInfo.dialogContactInfo), which
is fragile; change the assertion to target the specific custom-field element
instead. Use the contact-info helper to get the field element (e.g.
poHomeChannel.contacts.contactInfo.getCustomFieldElement(customFieldName)) or
scope a locator off dialogContactInfo such as
dialogContactInfo.locator('selector-for-custom-field' or
`:has-text("${customFieldLabel}")`). Then replace
expect(...dialogContactInfo).toContainText(visitorCustomFieldValue) with
expect(fieldElement).toHaveText(visitorCustomFieldValue) (and apply the same
change for the other occurrence mentioned in the comment).
apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.ts (1)

42-48: dialogContactInfo is a trivial alias for this.root.

Consider whether exposing this.root directly under a new name adds clarity vs. just using this.root in the base class. That said, it does give test call-sites a more descriptive name, so this is acceptable as-is.

getVisitorCustomField follows the same pattern as the room counterpart — looks good.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.ts` around
lines 42 - 48, The property dialogContactInfo is a trivial alias of this.root;
either remove it and update all call sites to use this.root directly, or keep it
but add a short JSDoc on dialogContactInfo explaining it’s an intentional, more
descriptive alias for the root locator; leave getVisitorCustomField(label:
string) as-is. Ensure you update any tests referencing dialogContactInfo if you
choose removal, or add the JSDoc above the dialogContactInfo getter if you keep
it.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 508b4a1 and 2dc2534.

📒 Files selected for processing (3)
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{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/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.ts
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
apps/meteor/tests/e2e/page-objects/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

Utilize existing page objects pattern from apps/meteor/tests/e2e/page-objects/

Files:

  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.ts
apps/meteor/tests/e2e/**/*.{ts,spec.ts}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

apps/meteor/tests/e2e/**/*.{ts,spec.ts}: Store commonly used locators in variables/constants for reuse
Follow Page Object Model pattern consistently in Playwright tests

Files:

  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.ts
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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.ts extension for test files (e.g., login.spec.ts)

Files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
apps/meteor/tests/e2e/**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

apps/meteor/tests/e2e/**/*.spec.ts: All test files must be created in apps/meteor/tests/e2e/ directory
Avoid using page.locator() in Playwright tests - always prefer semantic locators such as page.getByRole(), page.getByLabel(), page.getByText(), or page.getByTitle()
Use test.beforeAll() and test.afterAll() for setup/teardown in Playwright tests
Use test.step() for complex test scenarios to improve organization in Playwright tests
Group related tests in the same file
Utilize Playwright fixtures (test, page, expect) for consistency in test files
Prefer web-first assertions (toBeVisible, toHaveText, etc.) in Playwright tests
Use expect matchers for assertions (toEqual, toContain, toBeTruthy, toHaveLength, etc.) instead of assert statements in Playwright tests
Use page.waitFor() with specific conditions instead of hardcoded timeouts in Playwright tests
Implement proper wait strategies for dynamic content in Playwright tests
Maintain test isolation between test cases in Playwright tests
Ensure clean state for each test execution in Playwright tests
Ensure tests run reliably in parallel without shared state conflicts

Files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
🧠 Learnings (21)
📓 Common learnings
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: Focus on comprehensive feature coverage and edge case validation in test design
📚 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/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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/**/*.{ts,spec.ts} : Store commonly used locators in variables/constants for reuse

Applied to files:

  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 : Avoid using `page.locator()` in Playwright tests - always prefer semantic locators such as `page.getByRole()`, `page.getByLabel()`, `page.getByText()`, or `page.getByTitle()`

Applied to files:

  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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/**/*.{ts,spec.ts} : Follow Page Object Model pattern consistently in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
📚 Learning: 2025-12-16T17:29:40.430Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37834
File: apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-emoji.ts:12-22
Timestamp: 2025-12-16T17:29:40.430Z
Learning: In all page-object files under apps/meteor/tests/e2e/page-objects/, import expect from ../../utils/test (Playwright's async expect) instead of from Jest. Jest's expect is synchronous and incompatible with web-first assertions like toBeVisible, which can cause TypeScript errors.

Applied to files:

  • apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts
  • apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 clean state for each test execution in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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.beforeAll()` and `test.afterAll()` for setup/teardown in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 **/*.spec.ts : Use descriptive test names that clearly communicate expected behavior in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 : Implement proper wait strategies for dynamic content in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 `expect` matchers for assertions (`toEqual`, `toContain`, `toBeTruthy`, `toHaveLength`, etc.) instead of `assert` statements in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 : Prefer web-first assertions (`toBeVisible`, `toHaveText`, etc.) in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
📚 Learning: 2025-09-23T19:22:59.217Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 36987
File: apps/meteor/tests/e2e/page-objects/fragments/room-toolbar.ts:10-20
Timestamp: 2025-09-23T19:22:59.217Z
Learning: In Playwright e2e tests, prefer stable selectors like data-qa-id attributes over localized text in getByRole() or getByText() calls to prevent test failures when UI language changes. Test translations separately by validating actual text content after ensuring UI interactions work with stable selectors.

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 `page.waitFor()` with specific conditions instead of hardcoded timeouts in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
📚 Learning: 2025-12-16T17:29:45.163Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37834
File: apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-emoji.ts:12-22
Timestamp: 2025-12-16T17:29:45.163Z
Learning: In page object files under `apps/meteor/tests/e2e/page-objects/`, always import `expect` from `../../utils/test` (Playwright's async expect), not from Jest. Jest's `expect` has a synchronous signature and will cause TypeScript errors when used with web-first assertions like `toBeVisible()`.

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
🧬 Code graph analysis (1)
apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts (3)
apps/meteor/tests/mocks/data.ts (1)
  • createFakeVisitor (346-351)
apps/meteor/tests/e2e/page-objects/home-omnichannel.ts (1)
  • HomeOmnichannel (14-52)
apps/meteor/tests/data/livechat/custom-fields.ts (1)
  • createCustomField (8-33)
🪛 Biome (2.3.14)
apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts

[error] 35-35: This callback passed to forEach() iterable method should not return a value.

Either remove this return or remove the returned value.

(lint/suspicious/useIterableCallbackReturn)


[error] 72-72: This callback passed to forEach() iterable method should not return a value.

Either remove this return or remove the returned value.

(lint/suspicious/useIterableCallbackReturn)

🔇 Additional comments (4)
apps/meteor/tests/e2e/page-objects/fragments/edit-room-flextab.ts (1)

87-90: LGTM!

Clean addition following the existing page object pattern and using a semantic locator (getByLabel).

apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts (3)

79-100: Good use of test.step() for organizing the room custom field flow.

The steps are clearly named and the assertion uses web-first toHaveValue. Follows the page object model correctly.


139-160: Remove this comment — btnSave is properly scoped and available.

The btnSave locator is inherited from FlexTab and scoped to this.root, which is initialized in OmnichannelContactInfo as the persistent dialog { name: 'Contact' }. Both btnEdit and btnSave remain scoped to the same root element throughout the operation, so the locator chain will resolve correctly without transitioning to a different dialog.

Likely an incorrect or invalid review comment.


49-53: The concern about agentId: 'user1' is not valid. The API endpoint (GET /livechat/room) accepts agentId as a string and passes it to normalizeAgent(), which calls Users.getAgentInfo(agentId). This function accepts both user IDs and usernames, successfully resolving 'user1' to the corresponding user. If the agent is not found, the room is created without agent assignment by design—this is intentional behavior, not a silent failure. The widespread use of this pattern across 15+ e2e test files confirms it is the standard, tested approach.

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts`:
- Around line 64-68: Replace the non-semantic locator used in the test setup:
inside test.beforeEach where page.locator('#main-content').waitFor() is called,
switch to a semantic Playwright locator such as page.getByRole('main').waitFor()
(or another appropriate getByRole/getByTestId used by HomeOmnichannel) to adhere
to the guideline of preferring semantic locators; update the wait call in the
same test.beforeEach block so HomeOmnichannel initialization and subsequent
actions rely on the semantic locator.
- Line 14: The test suite declared with test.describe('OC - Custom fields usage,
scope : room and visitor') has sequential dependencies between tests (1→2 and
3→4); change the suite declaration to use test.describe.serial so the tests run
sequentially rather than in parallel; update the suite definition (the
test.describe call) to test.describe.serial(...) to ensure deterministic order
for the tests in this file.
- Line 35: Replace the Array.forEach callback that calls expect on each response
with a for...of loop to avoid implicit-return lint errors: iterate over the
responses array using "for (const res of responses)" and call
expect(res.status()).toBe(200) inside the loop; apply the same change to the
similar occurrence around line 72 that also iterates over responses and calls
expect. Ensure you update both spots that reference responses and res.status()
so the lint rule no longer flags the implicit return from the forEach callback.

---

Nitpick comments:
In `@apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts`:
- Around line 124-137: The test is asserting visitorCustomFieldValue against the
whole dialog (poHomeChannel.contacts.contactInfo.dialogContactInfo), which is
fragile; change the assertion to target the specific custom-field element
instead. Use the contact-info helper to get the field element (e.g.
poHomeChannel.contacts.contactInfo.getCustomFieldElement(customFieldName)) or
scope a locator off dialogContactInfo such as
dialogContactInfo.locator('selector-for-custom-field' or
`:has-text("${customFieldLabel}")`). Then replace
expect(...dialogContactInfo).toContainText(visitorCustomFieldValue) with
expect(fieldElement).toHaveText(visitorCustomFieldValue) (and apply the same
change for the other occurrence mentioned in the comment).

In `@apps/meteor/tests/e2e/page-objects/omnichannel/omnichannel-info.ts`:
- Around line 42-48: The property dialogContactInfo is a trivial alias of
this.root; either remove it and update all call sites to use this.root directly,
or keep it but add a short JSDoc on dialogContactInfo explaining it’s an
intentional, more descriptive alias for the root locator; leave
getVisitorCustomField(label: string) as-is. Ensure you update any tests
referencing dialogContactInfo if you choose removal, or add the JSDoc above the
dialogContactInfo getter if you keep it.

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.

🧹 Nitpick comments (3)
apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts (3)

134-136: Consider using the field-specific locator for a more precise assertion.

toContainText on the entire dialog is a broad check. You already have getVisitorCustomField(visitorCustomFieldLabel) available — using it here (e.g., checking toHaveText or toContainText on the specific field element) would make the assertion more targeted and less prone to false positives.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts`
around lines 134 - 136, The assertion is too broad: replace the generic check on
poHomeChannel.contacts.contactInfo.dialogContactInfo with a targeted assertion
against the specific custom-field locator returned by
getVisitorCustomField(visitorCustomFieldLabel); call
getVisitorCustomField(visitorCustomFieldLabel) and assert its text
equals/contains visitorCustomFieldValue (e.g., toHaveText or toContainText)
inside the same test.step 'Assert custom field is set successfully' to make the
check precise and avoid false positives.

157-159: Same broad assertion pattern — prefer field-specific locator.

Same as the previous test: asserting toContainText on the entire dialog. Consider using getVisitorCustomField(visitorCustomFieldLabel) for a targeted assertion on the updated value.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts`
around lines 157 - 159, The test currently asserts the whole dialog
(`poHomeChannel.contacts.contactInfo.dialogContactInfo`) contains the updated
value which is broad; replace that with a targeted assertion using the
`getVisitorCustomField(visitorCustomFieldLabel)` locator: call
`poHomeChannel.contacts.contactInfo.getVisitorCustomField(visitorCustomFieldLabel)`
and assert it contains/equals `updatedVisitorCustomFieldValue` so the check is
specific to the updated custom field.

17-23: Redundant variable aliases add confusion.

roomCustomFieldName is identical to roomCustomFieldLabel, and likewise for visitorCustomFieldName/visitorCustomFieldLabel. Using two names for the same value obscures the intent — readers have to verify they're equal. Consider using a single variable per custom field (e.g., just roomCustomFieldLabel) and passing it to both field and label parameters directly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts`
around lines 17 - 23, The test defines redundant aliases roomCustomFieldName and
visitorCustomFieldName that are identical to roomCustomFieldLabel and
visitorCustomFieldLabel; remove the duplicate variables and use the single label
variables (roomCustomFieldLabel and visitorCustomFieldLabel) when passing values
to both the label and field parameters in the test flow (search for usages of
roomCustomFieldName and visitorCustomFieldName and replace them with
roomCustomFieldLabel/visitorCustomFieldLabel, keeping roomCustomFieldValue and
visitorCustomFieldValue unchanged).
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2dc2534 and a540ac8.

📒 Files selected for processing (1)
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{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/e2e/omnichannel/omnichannel-custom-field-usage.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.ts extension for test files (e.g., login.spec.ts)

Files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
apps/meteor/tests/e2e/**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

apps/meteor/tests/e2e/**/*.spec.ts: All test files must be created in apps/meteor/tests/e2e/ directory
Avoid using page.locator() in Playwright tests - always prefer semantic locators such as page.getByRole(), page.getByLabel(), page.getByText(), or page.getByTitle()
Use test.beforeAll() and test.afterAll() for setup/teardown in Playwright tests
Use test.step() for complex test scenarios to improve organization in Playwright tests
Group related tests in the same file
Utilize Playwright fixtures (test, page, expect) for consistency in test files
Prefer web-first assertions (toBeVisible, toHaveText, etc.) in Playwright tests
Use expect matchers for assertions (toEqual, toContain, toBeTruthy, toHaveLength, etc.) instead of assert statements in Playwright tests
Use page.waitFor() with specific conditions instead of hardcoded timeouts in Playwright tests
Implement proper wait strategies for dynamic content in Playwright tests
Maintain test isolation between test cases in Playwright tests
Ensure clean state for each test execution in Playwright tests
Ensure tests run reliably in parallel without shared state conflicts

Files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
apps/meteor/tests/e2e/**/*.{ts,spec.ts}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

apps/meteor/tests/e2e/**/*.{ts,spec.ts}: Store commonly used locators in variables/constants for reuse
Follow Page Object Model pattern consistently in Playwright tests

Files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
🧠 Learnings (19)
📓 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/**/*.{ts,spec.ts} : Follow Page Object Model pattern consistently in Playwright tests
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: 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/`
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 36987
File: apps/meteor/tests/e2e/page-objects/fragments/room-toolbar.ts:10-20
Timestamp: 2025-09-23T19:22:59.217Z
Learning: In Playwright e2e tests, prefer stable selectors like data-qa-id attributes over localized text in getByRole() or getByText() calls to prevent test failures when UI language changes. Test translations separately by validating actual text content after ensuring UI interactions work with stable selectors.
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 : Implement proper wait strategies for dynamic content in Playwright tests
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
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
📚 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/tests/e2e/omnichannel/omnichannel-custom-field-usage.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/**/*.{ts,spec.ts} : Follow Page Object Model pattern consistently in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 clean state for each test execution in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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.beforeAll()` and `test.afterAll()` for setup/teardown in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 : Implement proper wait strategies for dynamic content in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 **/*.spec.ts : Use descriptive test names that clearly communicate expected behavior in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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/page-objects/**/*.ts : Utilize existing page objects pattern from `apps/meteor/tests/e2e/page-objects/`

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 `expect` matchers for assertions (`toEqual`, `toContain`, `toBeTruthy`, `toHaveLength`, etc.) instead of `assert` statements in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 : Prefer web-first assertions (`toBeVisible`, `toHaveText`, etc.) in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 : Avoid using `page.locator()` in Playwright tests - always prefer semantic locators such as `page.getByRole()`, `page.getByLabel()`, `page.getByText()`, or `page.getByTitle()`

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
📚 Learning: 2025-09-23T19:22:59.217Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 36987
File: apps/meteor/tests/e2e/page-objects/fragments/room-toolbar.ts:10-20
Timestamp: 2025-09-23T19:22:59.217Z
Learning: In Playwright e2e tests, prefer stable selectors like data-qa-id attributes over localized text in getByRole() or getByText() calls to prevent test failures when UI language changes. Test translations separately by validating actual text content after ensuring UI interactions work with stable selectors.

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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/**/*.{ts,spec.ts} : Store commonly used locators in variables/constants for reuse

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 `page.waitFor()` with specific conditions instead of hardcoded timeouts in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
📚 Learning: 2025-12-16T17:29:45.163Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37834
File: apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-emoji.ts:12-22
Timestamp: 2025-12-16T17:29:45.163Z
Learning: In page object files under `apps/meteor/tests/e2e/page-objects/`, always import `expect` from `../../utils/test` (Playwright's async expect), not from Jest. Jest's `expect` has a synchronous signature and will cause TypeScript errors when used with web-first assertions like `toBeVisible()`.

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
🪛 Biome (2.3.14)
apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts

[error] 35-35: This callback passed to forEach() iterable method should not return a value.

Either remove this return or remove the returned value.

(lint/suspicious/useIterableCallbackReturn)


[error] 72-72: This callback passed to forEach() iterable method should not return a value.

Either remove this return or remove the returned value.

(lint/suspicious/useIterableCallbackReturn)

⏰ 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 (2)
apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts (2)

14-14: Good use of test.describe.serial and proper setup/teardown pattern.

The serial execution mode correctly addresses the shared state between tests. The beforeEach properly reinitializes the page object per test, and beforeAll/afterAll handle resource lifecycle cleanly.

Also applies to: 64-68


84-88: The code at lines 84-88 is correct. Room info automatically displays when selecting an omnichannel conversation, and waitForDisplay() is the appropriate way to wait for it. This pattern is consistent across multiple omnichannel test files (omnichannel-sla-policies-sidebar.spec.ts, omnichannel-assign-room-tags.spec.ts, etc.), all of which follow the same approach of clicking a sidebar item and then interacting with the now-visible room info panel without additional setup steps.

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts`:
- Line 35: Replace the responses.forEach callback (which causes the
useIterableCallbackReturn lint error) with an explicit for...of loop: iterate
using "for (const res of responses)" and call expect(res.status()).toBe(200)
inside the loop body; do the same replacement for the second occurrence around
the earlier mentioned Line 72 so both instances use for...of instead of
Array.prototype.forEach.

---

Nitpick comments:
In `@apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts`:
- Around line 134-136: The assertion is too broad: replace the generic check on
poHomeChannel.contacts.contactInfo.dialogContactInfo with a targeted assertion
against the specific custom-field locator returned by
getVisitorCustomField(visitorCustomFieldLabel); call
getVisitorCustomField(visitorCustomFieldLabel) and assert its text
equals/contains visitorCustomFieldValue (e.g., toHaveText or toContainText)
inside the same test.step 'Assert custom field is set successfully' to make the
check precise and avoid false positives.
- Around line 157-159: The test currently asserts the whole dialog
(`poHomeChannel.contacts.contactInfo.dialogContactInfo`) contains the updated
value which is broad; replace that with a targeted assertion using the
`getVisitorCustomField(visitorCustomFieldLabel)` locator: call
`poHomeChannel.contacts.contactInfo.getVisitorCustomField(visitorCustomFieldLabel)`
and assert it contains/equals `updatedVisitorCustomFieldValue` so the check is
specific to the updated custom field.
- Around line 17-23: The test defines redundant aliases roomCustomFieldName and
visitorCustomFieldName that are identical to roomCustomFieldLabel and
visitorCustomFieldLabel; remove the duplicate variables and use the single label
variables (roomCustomFieldLabel and visitorCustomFieldLabel) when passing values
to both the label and field parameters in the test flow (search for usages of
roomCustomFieldName and visitorCustomFieldName and replace them with
roomCustomFieldLabel/visitorCustomFieldLabel, keeping roomCustomFieldValue and
visitorCustomFieldValue unchanged).

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.

🧹 Nitpick comments (3)
apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts (1)

13-17: Optional: rename customFieldId to customFieldKey to match the API body field.

The parameter name customFieldId suggests a MongoDB ObjectId, but the /livechat/custom.field endpoint expects the field name as key (e.g. "key": "address"). Rocket.Chat stores a custom field's name as its _id, so passing customField._id is functionally correct — but renaming the parameter to customFieldKey would make the intent explicit and prevent future callers from accidentally passing an unrelated _id.

♻️ Proposed rename
 export const setVisitorCustomFieldValue = async (
 	api: BaseTest['api'],
-	params: { token: string; customFieldId: string; value: string; overwrite?: boolean },
+	params: { token: string; customFieldKey: string; value: string; overwrite?: boolean },
 ) => {
 	const response = await api.post('/livechat/custom.field', {
 		token: params.token,
-		key: params.customFieldId,
+		key: params.customFieldKey,
 		value: params.value,
 		overwrite: params.overwrite ?? true,
 	});

Update the call site in omnichannel-custom-field-usage.spec.ts:

-		customFieldId: visitorCustomField.customField._id,
+		customFieldKey: visitorCustomField.customField._id,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts` around lines 13 -
17, Rename the parameter customFieldId to customFieldKey in the
setVisitorCustomFieldValue function signature and its internal usage so it
clearly represents the API's expected "key" (string field name) rather than
suggesting a DB ObjectId; also update all call sites (e.g., the test
omnichannel-custom-field-usage.spec.ts) to pass and reference customFieldKey
accordingly and ensure the POST body still sends the value as key:
customFieldKey.
apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts (2)

19-25: Redundant *Name variables — they're always identical to their *Label counterparts.

roomCustomFieldName = roomCustomFieldLabel and visitorCustomFieldName = visitorCustomFieldLabel are immediately aliased and never diverge. This creates the false impression they can differ.

♻️ Proposed simplification
 	const roomCustomFieldLabel = `room_cf_${faker.string.alpha(8)}`;
-	const roomCustomFieldName = roomCustomFieldLabel;
 	const roomCustomFieldValue = faker.lorem.words(3);
 
 	const visitorCustomFieldLabel = `visitor_cf_${faker.string.alpha(8)}`;
-	const visitorCustomFieldName = visitorCustomFieldLabel;
 	const visitorCustomFieldValue = faker.lorem.words(3);

Then at the createCustomField call sites, pass the label directly:

 			createCustomField(api, {
 				field: roomCustomFieldLabel,
-				label: roomCustomFieldName,
+				label: roomCustomFieldLabel,
 				scope: 'room',
 			}),
 			createCustomField(api, {
 				field: visitorCustomFieldLabel,
-				label: visitorCustomFieldName,
+				label: visitorCustomFieldLabel,
 				scope: 'visitor',
 			}),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts`
around lines 19 - 25, The variables roomCustomFieldName and
visitorCustomFieldName are redundant aliases of roomCustomFieldLabel and
visitorCustomFieldLabel; remove roomCustomFieldName and visitorCustomFieldName
and update any call sites (e.g., createCustomField invocations in this test) to
pass roomCustomFieldLabel and visitorCustomFieldLabel directly (and replace uses
of the removed symbols throughout the spec) so there’s a single source of truth
for each custom field label/name.

127-129: Tighten visitor-field assertions — toContainText on the dialog root confirms the value appears anywhere in the dialog.

Both Tests 3 and 4 use toContainText on dialogContactInfo (the full dialog container). Since getVisitorCustomField(label) is already available (used on line 146 for editing) and scoped to the specific field element, it's better to use it for assertions too. This narrows the check to the correct element and improves failure diagnostics.

♻️ Proposed fix (Test 3)
 		await test.step('Assert custom field is set successfully', async () => {
-			await expect(poHomeChannel.contacts.contactInfo.dialogContactInfo).toContainText(visitorCustomFieldValue);
+			await expect(poHomeChannel.contacts.contactInfo.getVisitorCustomField(visitorCustomFieldLabel)).toContainText(visitorCustomFieldValue);
 		});
♻️ Proposed fix (Test 4)
 		await test.step('Assert custom field is updated successfully', async () => {
-			await expect(poHomeChannel.contacts.contactInfo.dialogContactInfo).toContainText(updatedVisitorCustomFieldValue);
+			await expect(poHomeChannel.contacts.contactInfo.getVisitorCustomField(visitorCustomFieldLabel)).toContainText(updatedVisitorCustomFieldValue);
 		});

Note: if getVisitorCustomField returns an <input> in both view and edit modes, prefer toHaveValue over toContainText for the view-mode steps.

Also applies to: 150-152

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts`
around lines 127 - 129, The assertion currently uses
dialogContactInfo.toContainText which only checks the whole dialog; change both
Test 3 and Test 4 to assert against the specific field element returned by
getVisitorCustomField(label) instead of dialogContactInfo, and if that helper
returns an input element in view mode use toHaveValue(visitorCustomFieldValue)
otherwise use toContainText on the element returned by getVisitorCustomField;
update the expectations that reference dialogContactInfo (the assertions around
visitorCustomFieldValue) to call getVisitorCustomField(label) and perform the
more specific assertion.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a540ac8 and 2649557.

📒 Files selected for processing (2)
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
  • apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{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/e2e/utils/omnichannel/custom-field.ts
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
apps/meteor/tests/e2e/**/*.{ts,spec.ts}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

apps/meteor/tests/e2e/**/*.{ts,spec.ts}: Store commonly used locators in variables/constants for reuse
Follow Page Object Model pattern consistently in Playwright tests

Files:

  • apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts
  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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.ts extension for test files (e.g., login.spec.ts)

Files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
apps/meteor/tests/e2e/**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

apps/meteor/tests/e2e/**/*.spec.ts: All test files must be created in apps/meteor/tests/e2e/ directory
Avoid using page.locator() in Playwright tests - always prefer semantic locators such as page.getByRole(), page.getByLabel(), page.getByText(), or page.getByTitle()
Use test.beforeAll() and test.afterAll() for setup/teardown in Playwright tests
Use test.step() for complex test scenarios to improve organization in Playwright tests
Group related tests in the same file
Utilize Playwright fixtures (test, page, expect) for consistency in test files
Prefer web-first assertions (toBeVisible, toHaveText, etc.) in Playwright tests
Use expect matchers for assertions (toEqual, toContain, toBeTruthy, toHaveLength, etc.) instead of assert statements in Playwright tests
Use page.waitFor() with specific conditions instead of hardcoded timeouts in Playwright tests
Implement proper wait strategies for dynamic content in Playwright tests
Maintain test isolation between test cases in Playwright tests
Ensure clean state for each test execution in Playwright tests
Ensure tests run reliably in parallel without shared state conflicts

Files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
🧠 Learnings (20)
📓 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/**/*.{ts,spec.ts} : Follow Page Object Model pattern consistently in Playwright tests
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: 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
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
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 36987
File: apps/meteor/tests/e2e/page-objects/fragments/room-toolbar.ts:10-20
Timestamp: 2025-09-23T19:22:59.217Z
Learning: In Playwright e2e tests, prefer stable selectors like data-qa-id attributes over localized text in getByRole() or getByText() calls to prevent test failures when UI language changes. Test translations separately by validating actual text content after ensuring UI interactions work with stable selectors.
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/`
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 : Implement proper wait strategies for dynamic content in Playwright tests
📚 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/tests/e2e/omnichannel/omnichannel-custom-field-usage.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/**/*.{ts,spec.ts} : Follow Page Object Model pattern consistently in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 clean state for each test execution in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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.beforeAll()` and `test.afterAll()` for setup/teardown in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 **/*.spec.ts : Use descriptive test names that clearly communicate expected behavior in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 : Implement proper wait strategies for dynamic content in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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/page-objects/**/*.ts : Utilize existing page objects pattern from `apps/meteor/tests/e2e/page-objects/`

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 `expect` matchers for assertions (`toEqual`, `toContain`, `toBeTruthy`, `toHaveLength`, etc.) instead of `assert` statements in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 : Prefer web-first assertions (`toBeVisible`, `toHaveText`, etc.) in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 : Avoid using `page.locator()` in Playwright tests - always prefer semantic locators such as `page.getByRole()`, `page.getByLabel()`, `page.getByText()`, or `page.getByTitle()`

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
📚 Learning: 2025-09-23T19:22:59.217Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 36987
File: apps/meteor/tests/e2e/page-objects/fragments/room-toolbar.ts:10-20
Timestamp: 2025-09-23T19:22:59.217Z
Learning: In Playwright e2e tests, prefer stable selectors like data-qa-id attributes over localized text in getByRole() or getByText() calls to prevent test failures when UI language changes. Test translations separately by validating actual text content after ensuring UI interactions work with stable selectors.

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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/**/*.{ts,spec.ts} : Store commonly used locators in variables/constants for reuse

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.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 `page.waitFor()` with specific conditions instead of hardcoded timeouts in Playwright tests

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
📚 Learning: 2025-12-16T17:29:45.163Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37834
File: apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-emoji.ts:12-22
Timestamp: 2025-12-16T17:29:45.163Z
Learning: In page object files under `apps/meteor/tests/e2e/page-objects/`, always import `expect` from `../../utils/test` (Playwright's async expect), not from Jest. Jest's `expect` has a synchronous signature and will cause TypeScript errors when used with web-first assertions like `toBeVisible()`.

Applied to files:

  • apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts
🧬 Code graph analysis (2)
apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts (1)
apps/meteor/tests/e2e/utils/test.ts (1)
  • BaseTest (17-27)
apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts (4)
apps/meteor/tests/mocks/data.ts (1)
  • createFakeVisitor (346-351)
apps/meteor/tests/e2e/page-objects/home-omnichannel.ts (1)
  • HomeOmnichannel (14-52)
apps/meteor/tests/data/livechat/rooms.ts (2)
  • createAgent (254-268)
  • createManager (270-284)
apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts (2)
  • createCustomField (29-59)
  • setVisitorCustomFieldValue (13-27)
⏰ 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)
apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts (1)

34-70: LGTM — well-structured lifecycle hooks.

The beforeAll/afterAll pair correctly batches all API setup and teardown. afterAll not needing { api } is intentional — all delete() closures capture the api from the beforeAll fixture scope, consistent with the pattern in other E2E suites.

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/meteor/tests/e2e/omnichannel/omnichannel-custom-field-usage.spec.ts`:
- Around line 19-25: The variables roomCustomFieldName and
visitorCustomFieldName are redundant aliases of roomCustomFieldLabel and
visitorCustomFieldLabel; remove roomCustomFieldName and visitorCustomFieldName
and update any call sites (e.g., createCustomField invocations in this test) to
pass roomCustomFieldLabel and visitorCustomFieldLabel directly (and replace uses
of the removed symbols throughout the spec) so there’s a single source of truth
for each custom field label/name.
- Around line 127-129: The assertion currently uses
dialogContactInfo.toContainText which only checks the whole dialog; change both
Test 3 and Test 4 to assert against the specific field element returned by
getVisitorCustomField(label) instead of dialogContactInfo, and if that helper
returns an input element in view mode use toHaveValue(visitorCustomFieldValue)
otherwise use toContainText on the element returned by getVisitorCustomField;
update the expectations that reference dialogContactInfo (the assertions around
visitorCustomFieldValue) to call getVisitorCustomField(label) and perform the
more specific assertion.

In `@apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts`:
- Around line 13-17: Rename the parameter customFieldId to customFieldKey in the
setVisitorCustomFieldValue function signature and its internal usage so it
clearly represents the API's expected "key" (string field name) rather than
suggesting a DB ObjectId; also update all call sites (e.g., the test
omnichannel-custom-field-usage.spec.ts) to pass and reference customFieldKey
accordingly and ensure the POST body still sends the value as key:
customFieldKey.

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.

🧹 Nitpick comments (2)
apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts (2)

26-27: field is implicitly any — add an explicit type annotation.

response.json() resolves to any, so field is untyped. The Livechat POST /livechat/custom.field endpoint returns a { field: { key, value, label } } shape that differs from ILivechatCustomField (the field definition type). Declaring an inline type or a local interface makes the return contract explicit and aligns with the "accurate typing" coding guideline.

✏️ Proposed refactor
+type VisitorCustomFieldResult = { key: string; value: string; label: string };
+
 export const setVisitorCustomFieldValue = async (
 	api: BaseTest['api'],
 	params: { token: string; customFieldId: string; value: string; overwrite?: boolean },
-) => {
+): Promise<{ response: Awaited<ReturnType<BaseTest['api']['post']>>; field: VisitorCustomFieldResult }> => {

As per coding guidelines: "Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts` around lines 26 -
27, The variable field is implicitly any because response.json() is untyped;
update the destructuring to use an explicit type for the JSON payload (e.g., an
inline type or local interface describing { field: { key: string; value: string;
label: string } }) so the returned object shape is explicit; specifically,
annotate the result of await response.json() (the destructured const { field })
with that type and return the typed field alongside response from this helper in
custom-field.ts.

26-27: field is implicitly any — narrow it to the documented response shape.

The official Rocket.Chat docs confirm the POST /api/v1/livechat/custom.field response is { "field": { "key": "...", "value": "...", "overwrite": true }, "success": true }, so the type of field is fully known at compile time. Leaving it as any misses the "accurate typing" guideline.

✏️ Proposed refactor
+type VisitorCustomFieldResult = { key: string; value: string; overwrite: boolean };
+
 export const setVisitorCustomFieldValue = async (
 	api: BaseTest['api'],
 	params: { token: string; customFieldId: string; value: string; overwrite?: boolean },
 ) => {
 	const response = await api.post('/livechat/custom.field', {
 		token: params.token,
 		key: params.customFieldId,
 		value: params.value,
 		overwrite: params.overwrite ?? true,
 	});
 	if (!response.ok()) {
 		throw new Error(`Failed to set visitor custom field [http status: ${response.status()}]`);
 	}
-	const { field } = await response.json();
+	const { field } = (await response.json()) as { field: VisitorCustomFieldResult };
 	return { response, field };
 };

As per coding guidelines: "Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts` around lines 26 -
27, The destructured field from await response.json() is implicitly any; define
a typed interface (e.g., CustomField { key: string; value: string; overwrite:
boolean }) and use it when parsing the response (either by typing the JSON
result or casting the destructured payload) so that the local variable field has
the concrete type instead of any; update the return signature to reflect the
typed field so callers get accurate types (refer to the destructuring of
response.json() and the returned field variable).
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2649557 and d08b14a.

📒 Files selected for processing (1)
  • apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts
🧰 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:

  • apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts
apps/meteor/tests/e2e/**/*.{ts,spec.ts}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

apps/meteor/tests/e2e/**/*.{ts,spec.ts}: Store commonly used locators in variables/constants for reuse
Follow Page Object Model pattern consistently in Playwright tests

Files:

  • apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts
🧠 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/**/*.{ts,spec.ts} : Follow Page Object Model pattern consistently in Playwright tests
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: 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
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
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
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/`
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
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 : Implement proper wait strategies for dynamic content in Playwright tests
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 36987
File: apps/meteor/tests/e2e/page-objects/fragments/room-toolbar.ts:10-20
Timestamp: 2025-09-23T19:22:59.217Z
Learning: In Playwright e2e tests, prefer stable selectors like data-qa-id attributes over localized text in getByRole() or getByText() calls to prevent test failures when UI language changes. Test translations separately by validating actual text content after ensuring UI interactions work with stable selectors.
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 `page.waitFor()` with specific conditions instead of hardcoded timeouts in Playwright tests
🧬 Code graph analysis (1)
apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts (1)
apps/meteor/tests/e2e/utils/test.ts (1)
  • BaseTest (17-27)
⏰ 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). (6)
  • GitHub Check: 🔨 Test Storybook / Test Storybook
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: 📦 Meteor Build (coverage)
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: CodeQL-Build
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/meteor/tests/e2e/utils/omnichannel/custom-field.ts`:
- Around line 26-27: The variable field is implicitly any because
response.json() is untyped; update the destructuring to use an explicit type for
the JSON payload (e.g., an inline type or local interface describing { field: {
key: string; value: string; label: string } }) so the returned object shape is
explicit; specifically, annotate the result of await response.json() (the
destructured const { field }) with that type and return the typed field
alongside response from this helper in custom-field.ts.
- Around line 26-27: The destructured field from await response.json() is
implicitly any; define a typed interface (e.g., CustomField { key: string;
value: string; overwrite: boolean }) and use it when parsing the response
(either by typing the JSON result or casting the destructured payload) so that
the local variable field has the concrete type instead of any; update the return
signature to reflect the typed field so callers get accurate types (refer to the
destructuring of response.json() and the returned field variable).

@aleksandernsilva aleksandernsilva added the stat: QA assured Means it has been tested and approved by a company insider label Feb 19, 2026
@aleksandernsilva aleksandernsilva added this to the 8.2.0 milestone Feb 19, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Feb 19, 2026
}

getVisitorCustomField(label: string): Locator {
return this.root.getByLabel(label);
Copy link
Member

@ggazzo ggazzo Feb 19, 2026

Choose a reason for hiding this comment

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

how about add an extra selector here to make sure we are selecting a custom field, not only by the label (this could prevent conflicts)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated it.

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