Skip to content

test: add rooms.saveDraft API tests#40766

Merged
dionisio-bot[bot] merged 5 commits into
developfrom
test/room-draft
Jun 2, 2026
Merged

test: add rooms.saveDraft API tests#40766
dionisio-bot[bot] merged 5 commits into
developfrom
test/room-draft

Conversation

@jessicaschelly
Copy link
Copy Markdown
Member

@jessicaschelly jessicaschelly commented Jun 2, 2026

Proposed changes (including videos or screenshots)

Adds API integration test coverage for POST /api/v1/rooms.saveDraft in apps/meteor/tests/end-to-end/api/rooms.ts.

Scenario Coverage
Save draft Persists draft text on the user's subscription; verified via GET /api/v1/subscriptions.getOne
Clear draft Saves a draft, then clears it with an empty draft string; verifies the draft field is removed from the subscription
Invalid subscription Returns 400 with error-invalid-subscription when the user has no subscription for the room

Other changes:

  • Creates a dedicated test channel and a user with joinDefaultChannels: false for the negative case
  • Cleans up the test channel and user in after

Issue(s)

QA-117

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Tests
    • Added end-to-end tests for saving drafts: verifies writing and clearing draft state on room subscriptions, proper error when saving without a subscription, and enforcement of maximum message size (exact-limit accepted, oversized rejected). Tests include setup and teardown of temporary room and user and validate returned error responses.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Jun 2, 2026

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 2, 2026

⚠️ No Changeset found

Latest commit: 6ae772d

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
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0dfec1e6-e8ff-4cd2-9308-2a020078aee3

📥 Commits

Reviewing files that changed from the base of the PR and between 100c7e2 and 6ae772d.

📒 Files selected for processing (1)
  • apps/meteor/tests/end-to-end/api/rooms.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/tests/end-to-end/api/rooms.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check

Walkthrough

Adds an end-to-end Mocha test suite for /rooms.saveDraft that verifies draft persistence to subscriptions, clearing drafts, subscription-required validation, and message-size limit behavior.

Changes

rooms.saveDraft API Tests

Layer / File(s) Summary
rooms.saveDraft core behaviors
apps/meteor/tests/end-to-end/api/rooms.ts
Setup/teardown creating a test channel and unsubscribed user; tests that saving a non-empty draft writes subscription.draft, saving an empty draft removes the draft field, and saving without a subscription returns 400 error-invalid-subscription.
Message size limit validation
apps/meteor/tests/end-to-end/api/rooms.ts
Temporarily adjusts Message_MaxAllowedSize, verifies saving a draft at the limit succeeds, verifies oversized drafts fail with error-message-size-exceeded and do not leave a draft, and restores the original setting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

type: chore

🚥 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 'test: add rooms.saveDraft API tests' is a concise, specific description of the main change: adding API tests for the rooms.saveDraft endpoint.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • QA-117: Request failed with status code 401

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
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.73%. Comparing base (0ef1002) to head (6ae772d).
⚠️ Report is 4 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40766      +/-   ##
===========================================
- Coverage    69.76%   69.73%   -0.03%     
===========================================
  Files         3327     3327              
  Lines       123134   123134              
  Branches     21987    21980       -7     
===========================================
- Hits         85904    85870      -34     
- Misses       33869    33905      +36     
+ Partials      3361     3359       -2     
Flag Coverage Δ
e2e 59.33% <ø> (+0.01%) ⬆️
e2e-api 46.18% <ø> (-0.81%) ⬇️
unit 70.45% <ø> (-0.04%) ⬇️

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.

@jessicaschelly jessicaschelly marked this pull request as ready for review June 2, 2026 16:35
@jessicaschelly jessicaschelly requested a review from a team as a code owner June 2, 2026 16:35
Comment thread apps/meteor/tests/end-to-end/api/rooms.ts
Copy link
Copy Markdown
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 1 file

Re-trigger cubic

Copy link
Copy Markdown
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/meteor/tests/end-to-end/api/rooms.ts`:
- Around line 211-234: The failing test should also verify that a rejected
oversized draft does not mutate the stored draft: after the request to
api('rooms.saveDraft') that expects 400, call api('subscriptions.getOne') with
the same credentials and roomId (testChannel._id) and assert that
subscription.draft still equals the previously saved max-size draft (the
'a'.repeat(maxAllowedSize) value), or alternatively clear the draft before the
oversized test by calling subscriptions.getOne or a draft-clear endpoint and
asserting it's empty; ensure you reference the same variables used in the test
(maxAllowedSize, testChannel._id, credentials, and the rooms.saveDraft /
subscriptions.getOne endpoints) so the check runs immediately after the failing
request.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e0480b37-f608-44c2-9c10-47967c4407c3

📥 Commits

Reviewing files that changed from the base of the PR and between efb9235 and 100c7e2.

📒 Files selected for processing (1)
  • apps/meteor/tests/end-to-end/api/rooms.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

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

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/tests/end-to-end/api/rooms.ts
🧠 Learnings (3)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/tests/end-to-end/api/rooms.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/tests/end-to-end/api/rooms.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/tests/end-to-end/api/rooms.ts

Comment thread apps/meteor/tests/end-to-end/api/rooms.ts
@jessicaschelly jessicaschelly requested a review from KevLehman June 2, 2026 17:45
@jessicaschelly jessicaschelly added this to the 8.6.0 milestone Jun 2, 2026
@jessicaschelly jessicaschelly added the stat: QA assured Means it has been tested and approved by a company insider label Jun 2, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 2, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue Jun 2, 2026
@jessicaschelly jessicaschelly removed this pull request from the merge queue due to a manual request Jun 2, 2026
@jessicaschelly jessicaschelly removed the stat: QA assured Means it has been tested and approved by a company insider label Jun 2, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Jun 2, 2026
@jessicaschelly jessicaschelly added the stat: QA assured Means it has been tested and approved by a company insider label Jun 2, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 2, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue Jun 2, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 2, 2026
@jessicaschelly jessicaschelly removed the stat: QA assured Means it has been tested and approved by a company insider label Jun 2, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Jun 2, 2026
@jessicaschelly jessicaschelly added the stat: QA assured Means it has been tested and approved by a company insider label Jun 2, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 2, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue Jun 2, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 2, 2026
@jessicaschelly jessicaschelly removed the stat: QA assured Means it has been tested and approved by a company insider label Jun 2, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Jun 2, 2026
@jessicaschelly jessicaschelly added the stat: QA assured Means it has been tested and approved by a company insider label Jun 2, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 2, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue Jun 2, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 2, 2026
@jessicaschelly jessicaschelly removed the stat: QA assured Means it has been tested and approved by a company insider label Jun 2, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Jun 2, 2026
@jessicaschelly jessicaschelly added the stat: QA assured Means it has been tested and approved by a company insider label Jun 2, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 2, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue Jun 2, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 2, 2026
@jessicaschelly jessicaschelly removed the stat: QA assured Means it has been tested and approved by a company insider label Jun 2, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Jun 2, 2026
@jessicaschelly jessicaschelly added the stat: QA assured Means it has been tested and approved by a company insider label Jun 2, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 2, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue Jun 2, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 2, 2026
@jessicaschelly jessicaschelly removed the stat: QA assured Means it has been tested and approved by a company insider label Jun 2, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Jun 2, 2026
@jessicaschelly jessicaschelly added the stat: QA assured Means it has been tested and approved by a company insider label Jun 2, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 2, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue Jun 2, 2026
Merged via the queue into develop with commit b510eae Jun 2, 2026
48 checks passed
@dionisio-bot dionisio-bot Bot deleted the test/room-draft branch June 2, 2026 23:16
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 type: chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants