-
Notifications
You must be signed in to change notification settings - Fork 13k
chore: Adds deprecation warning on livechat:saveAgentInfo with new endpoint replacing it
#36975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: f3673f9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 40 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughIntroduces a new REST endpoint POST /v1/livechat/agents.saveInfo, updates client and tests to use it, adds request/response validators, and logs deprecation for the Meteor method livechat:saveAgentInfo. Includes dependency bumps and public typings exposure for the new route. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Client (UI/Tests)
participant API as REST API<br>/v1/livechat/agents.saveInfo
participant Auth as Auth/Permissions
participant LC as Livechat Service
participant DB as Data Store
rect rgba(227,242,253,0.6)
C->>API: POST agentId, agentData, agentDepartments
API->>Auth: Validate auth + manage-livechat-agents
Auth-->>API: OK / 401 / 403
alt Unauthorized/Forbidden
API-->>C: 401/403 error
else Authorized
API->>LC: hasRole(agentId, 'livechat-agent')
LC-->>API: true/false
alt Not agent
API-->>C: 400 error-user-is-not-agent
else Is agent
API->>DB: saveAgentInfo(agentId, data, departments)
DB-->>API: success
API-->>C: 200 { success: true }
end
end
end
note over C,API: Legacy Meteor method logs deprecation and points here
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #36975 +/- ##
===========================================
- Coverage 67.34% 66.27% -1.08%
===========================================
Files 3339 3393 +54
Lines 113205 115459 +2254
Branches 20532 21164 +632
===========================================
+ Hits 76234 76516 +282
- Misses 34361 36332 +1971
- Partials 2610 2611 +1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
…TZ-62 # Conflicts: # apps/meteor/app/livechat/server/api/v1/agent.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
.changeset/cuddly-dots-end.md (1)
1-7: Fix stray character and clarify endpoint path in changesetThere’s an orphan “7” at the end and the replacement endpoint should include the version prefix for clarity.
Apply this diff:
Adds deprecation warning on `livechat:saveAgentInfo` with new endpoint replacing it; `livechat/agents.saveInfo` +Adds deprecation warning for `livechat:saveAgentInfo`; replacement endpoint: `POST /v1/livechat/agents.saveInfo`. -7apps/meteor/client/views/omnichannel/agents/AgentEdit.tsx (1)
82-92: Send only mutable fields in agentData (avoid name/username/email), and precompute department IDsPrevents leaking read‑only fields and makes payload minimal/explicit.
- await saveAgentInfo({ - agentId: agentData._id, - agentData: data, - agentDepartments: departments.map((dep) => dep.value), - }); + const agentDepartmentsIds = departments.map((dep) => dep.value); + const { maxNumberSimultaneousChat, voipExtension } = data; + await saveAgentInfo({ + agentId: agentData._id, + agentData: { + ...(typeof maxNumberSimultaneousChat === 'number' ? { maxNumberSimultaneousChat } : {}), + ...(voipEnabled ? { voipExtension } : {}), + }, + agentDepartments: agentDepartmentsIds, + });packages/rest-typings/src/v1/omnichannel.ts (1)
1726-1767: Add route signature to OmnichannelEndpoints to avoid relying on server-side module augmentation for client typingYou defined validators but didn’t wire the endpoint into the OmnichannelEndpoints map. Adding it here ensures useEndpoint gets proper types in the client without depending on ambient augmentation declared in a server file.
export type OmnichannelEndpoints = { + '/v1/livechat/agents.saveInfo': { + POST: (params: POSTLivechatAgentSaveInfoParams) => void; + };Please confirm TS type inference for useEndpoint('POST', '/v1/livechat/agents.saveInfo') works in the client after this change. If you prefer keeping the server-side augmentation, ensure the ambient declaration is included in the client TS program.
apps/meteor/tests/data/livechat/users.ts (1)
101-116: Assert success:true in response to catch silent failuresCurrently only status and content-type are asserted.
await request .post(api('livechat/agents.saveInfo')) .set(credentials) .send({ agentId, agentData: livechatSettings, agentDepartments, }) .expect('Content-Type', 'application/json') - .expect(200); + .expect(200) + .expect((res) => { + if (res.body?.success !== true) throw new Error('Expected { success: true } from livechat/agents.saveInfo'); + });apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts (1)
118-118: Tighten waitForResponse filter (URL + method) to reduce flakinessUse a predicate to ensure it’s the POST to the exact endpoint.
- const response = page.waitForResponse('**/api/v1/livechat/agents.saveInfo'); + const response = page.waitForResponse((r) => r.url().endsWith('/api/v1/livechat/agents.saveInfo') && r.request().method() === 'POST');
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (7)
.changeset/cuddly-dots-end.md(1 hunks)apps/meteor/app/livechat/server/api/v1/agent.ts(2 hunks)apps/meteor/app/livechat/server/methods/saveAgentInfo.ts(2 hunks)apps/meteor/client/views/omnichannel/agents/AgentEdit.tsx(2 hunks)apps/meteor/tests/data/livechat/users.ts(2 hunks)apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts(1 hunks)packages/rest-typings/src/v1/omnichannel.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
apps/meteor/tests/e2e/**/*.spec.ts
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
apps/meteor/tests/e2e/**/*.spec.ts: All Playwright test files must be located under apps/meteor/tests/e2e/ and use the .spec.ts extension (e.g., login.spec.ts)
Use descriptive test names that clearly communicate expected behavior
Use test.beforeAll() and test.afterAll() for setup and teardown
Use test.step() to organize complex test scenarios
Group related tests in the same file
Utilize Playwright fixtures (test, page, expect) consistently
Prefer web-first assertions (e.g., toBeVisible, toHaveText)
Use expect matchers (toEqual, toContain, toBeTruthy, toHaveLength, etc.) instead of assert statements
Maintain test isolation between test cases
Ensure a clean state for each test execution
Ensure tests run reliably in parallel without shared state conflicts
Files:
apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts
apps/meteor/tests/e2e/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
apps/meteor/tests/e2e/**/*.{ts,tsx,js,jsx}: Write concise, technical TypeScript/JavaScript with accurate typing
Follow DRY by extracting reusable logic into helper functions or page objects
Avoid code comments in the implementation
Files:
apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts
apps/meteor/tests/e2e/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
apps/meteor/tests/e2e/**/*.{ts,tsx}: Avoid using page.locator(); prefer semantic locators like page.getByRole, page.getByLabel, page.getByText, and page.getByTitle
Store commonly used locators in variables/constants for reuse
Use page.waitFor() with specific conditions and avoid hardcoded timeouts
Implement proper wait strategies for dynamic content
Follow the Page Object Model pattern consistently
Files:
apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts
🧠 Learnings (7)
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
PR: RocketChat/Rocket.Chat#0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use descriptive test names that clearly communicate expected behavior
Applied to files:
apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
PR: RocketChat/Rocket.Chat#0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.{ts,tsx} : Implement proper wait strategies for dynamic content
Applied to files:
apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
PR: RocketChat/Rocket.Chat#0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.{ts,tsx} : Use page.waitFor() with specific conditions and avoid hardcoded timeouts
Applied to files:
apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
PR: RocketChat/Rocket.Chat#0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Utilize Playwright fixtures (test, page, expect) consistently
Applied to files:
apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
PR: RocketChat/Rocket.Chat#0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
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-agents.spec.ts
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
PR: RocketChat/Rocket.Chat#0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Prefer web-first assertions (e.g., toBeVisible, toHaveText)
Applied to files:
apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts
📚 Learning: 2025-09-16T22:08:51.490Z
Learnt from: CR
PR: RocketChat/Rocket.Chat#0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-09-16T22:08:51.490Z
Learning: Applies to apps/meteor/tests/e2e/**/*.{ts,tsx} : Avoid using page.locator(); prefer semantic locators like page.getByRole, page.getByLabel, page.getByText, and page.getByTitle
Applied to files:
apps/meteor/tests/e2e/omnichannel/omnichannel-agents.spec.ts
🧬 Code graph analysis (4)
apps/meteor/tests/data/livechat/users.ts (1)
apps/meteor/tests/data/api-data.ts (1)
credentials(39-42)
apps/meteor/app/livechat/server/api/v1/agent.ts (5)
packages/rest-typings/src/v1/omnichannel.ts (2)
POSTLivechatAgentSaveInfoSuccessResponse(1766-1766)isPOSTLivechatAgentSaveInfoParams(1753-1753)packages/rest-typings/src/v1/Ajv.ts (3)
validateBadRequestErrorResponse(46-46)validateUnauthorizedErrorResponse(69-69)validateForbiddenErrorResponse(92-92)apps/meteor/app/authorization/server/functions/hasRole.ts (1)
hasRoleAsync(23-29)apps/meteor/app/livechat/server/lib/omni-users.ts (1)
saveAgentInfo(84-114)apps/meteor/app/api/server/ApiClass.ts (1)
ExtractRoutesFromAPI(73-77)
apps/meteor/client/views/omnichannel/agents/AgentEdit.tsx (2)
apps/meteor/app/livechat/server/lib/omni-users.ts (1)
saveAgentInfo(84-114)packages/ui-contexts/src/index.ts (1)
useEndpoint(32-32)
packages/rest-typings/src/v1/omnichannel.ts (1)
packages/rest-typings/src/v1/Ajv.ts (1)
ajv(23-23)
🔇 Additional comments (2)
apps/meteor/app/livechat/server/methods/saveAgentInfo.ts (1)
16-19: Deprecation logger usage looks goodLogs the deprecation with removal target and replacement endpoint right at method entry.
Minor: please verify that
checkis imported (e.g.,import { check } from 'meteor/check') in this file; it’s referenced below.apps/meteor/app/livechat/server/api/v1/agent.ts (1)
139-163: New REST endpoint is correctly validated and permission-gatedAuth + manage-livechat-agents permission, AJV body/response validators, agent role check, and reuse of saveAgentInfo are all appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On behalf of frontend, LGTM!
Proposed changes (including videos or screenshots)
This PR adds a deprecation warning for
livechat:saveAgentInfometeor method, as well as it adds an endpoint (livechat/agents.saveInfo)to replace it.Issue(s)
CTZ-62
Steps to test or reproduce
Further comments
Tests will be implemented on this task
Summary by CodeRabbit