Skip to content

test: add coverage for livechat rooms delete endpoint - #41162

Merged
dionisio-bot[bot] merged 2 commits into
developfrom
test/livechat-rooms-delete-api
Jul 4, 2026
Merged

test: add coverage for livechat rooms delete endpoint#41162
dionisio-bot[bot] merged 2 commits into
developfrom
test/livechat-rooms-delete-api

Conversation

@jessicaschelly

@jessicaschelly jessicaschelly commented Jul 3, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

Adds API test coverage for POST /api/v1/livechat/rooms.delete.

  • Unauthenticated requests return 401.
  • Missing roomId validation returns 400.
  • Open livechat rooms cannot be deleted.
  • Closed livechat rooms can be deleted successfully.
  • Users without remove-closed-livechat-room permission receive 403.

Issue(s)

QA-118

Steps to test or reproduce

Further comments

Review in cubic

Summary by CodeRabbit

  • Tests
    • Expanded end-to-end coverage for live chat room deletion.
    • Verified expected responses for unauthenticated requests, missing parameters, open rooms, and successful deletion of closed rooms.
    • Added coverage for permission-based access, ensuring unauthorized users receive the correct error.

@dionisio-bot

dionisio-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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

@changeset-bot

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 05c78ec

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

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds end-to-end API tests for the POST livechat/rooms.delete endpoint, covering unauthenticated access, missing parameters, deletion of open vs closed rooms, post-deletion verification via channels.info, and permission-gated access control.

Changes

Livechat rooms.delete test coverage

Layer / File(s) Summary
Test setup and auth/validation checks
apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts
Adds a createRoomForDeletion helper plus tests asserting 401 when unauthenticated and 400 invalid-params when roomId is missing.
Room state, success path, and permission checks
apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts
Adds tests for 400 on open-room deletion, 200 success on closed-room deletion with channels.info post-deletion verification, and a permission-gated 403 test for missing remove-closed-livechat-room.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Test
  participant API
  participant Room

  Test->>API: POST livechat/rooms.delete (open room)
  API-->>Test: 400 invalid-state
  Test->>Room: close room
  Test->>API: POST livechat/rooms.delete (closed room)
  API-->>Test: 200 success
  Test->>API: GET channels.info(roomId)
  API-->>Test: error-room-not-found
  Test->>API: remove permission remove-closed-livechat-room
  Test->>API: POST livechat/rooms.delete
  API-->>Test: 403 unauthorized
Loading

Suggested labels: type: chore

Suggested reviewers: KevLehman

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: added test coverage for the livechat rooms delete endpoint.

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.

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.27%. Comparing base (ebd4a12) to head (05c78ec).
⚠️ Report is 32 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #41162      +/-   ##
===========================================
- Coverage    69.33%   69.27%   -0.06%     
===========================================
  Files         3539     3539              
  Lines       138832   138832              
  Branches     24707    24730      +23     
===========================================
- Hits         96264    96181      -83     
- Misses       38553    38629      +76     
- Partials      4015     4022       +7     
Flag Coverage Δ
e2e 59.33% <ø> (-0.06%) ⬇️
e2e-api 49.82% <ø> (-0.51%) ⬇️
unit 70.13% <ø> (-0.06%) ⬇️

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 July 3, 2026 16:39
@jessicaschelly
jessicaschelly requested a review from a team as a code owner July 3, 2026 16:39

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts (1)

1207-1249: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Cleanup skipped if assertions fail.

In both should fail if the livechat room is still open and should delete a closed livechat room, the closeOmnichannelRoom/deleteVisitor cleanup calls execute after the request...expect(...) chain as plain sequential statements. If any assertion inside .expect() throws, the test fails before reaching cleanup, leaking the visitor/room and risking test-isolation issues for later runs. The permission block below (Lines 1251-1258) avoids this by using before/after hooks that always run; consider the same pattern here (e.g., wrap cleanup in after/afterEach, or use try/finally).

♻️ Example fix using try/finally
 it('should fail if the livechat room is still open', async () => {
 	const { room, visitor } = await createRoomForDeletion();

-	await request
-		.post(api('livechat/rooms.delete'))
-		.set(credentials)
-		.send({ roomId: room._id })
-		.expect(400)
-		.expect((res: Response) => {
-			expect(res.body).to.have.property('success', false);
-		});
-
-	await closeOmnichannelRoom(room._id);
-	await deleteVisitor(visitor.token);
+	try {
+		await request
+			.post(api('livechat/rooms.delete'))
+			.set(credentials)
+			.send({ roomId: room._id })
+			.expect(400)
+			.expect((res: Response) => {
+				expect(res.body).to.have.property('success', false);
+			});
+	} finally {
+		await closeOmnichannelRoom(room._id);
+		await deleteVisitor(visitor.token);
+	}
 });
🤖 Prompt for 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.

In `@apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts` around lines 1207 -
1249, The cleanup in the livechat room deletion tests is run only after the
request assertions, so failures in the `request(...).expect(...)` chain skip
`closeOmnichannelRoom` and `deleteVisitor`. Update the `should fail if the
livechat room is still open` and `should delete a closed livechat room` cases in
`00-rooms.ts` to guarantee cleanup runs even when assertions throw, using the
same `before`/`after` or `try/finally` pattern already used in the nearby
permission block. Keep the cleanup tied to `createRoomForDeletion`,
`closeOmnichannelRoom`, and `deleteVisitor`.
🤖 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.

Nitpick comments:
In `@apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts`:
- Around line 1207-1249: The cleanup in the livechat room deletion tests is run
only after the request assertions, so failures in the `request(...).expect(...)`
chain skip `closeOmnichannelRoom` and `deleteVisitor`. Update the `should fail
if the livechat room is still open` and `should delete a closed livechat room`
cases in `00-rooms.ts` to guarantee cleanup runs even when assertions throw,
using the same `before`/`after` or `try/finally` pattern already used in the
nearby permission block. Keep the cleanup tied to `createRoomForDeletion`,
`closeOmnichannelRoom`, and `deleteVisitor`.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e8ea870a-503a-4299-b19d-4c88eb50d219

📥 Commits

Reviewing files that changed from the base of the PR and between ebd4a12 and 05c78ec.

📒 Files selected for processing (1)
  • apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (3)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (5/5)
🧰 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/livechat/00-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/livechat/00-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/livechat/00-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/livechat/00-rooms.ts
🔇 Additional comments (2)
apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts (2)

1175-1205: LGTM!


1251-1272: LGTM!

Good use of before/after hooks to guarantee permission restoration regardless of test outcome.

@jessicaschelly jessicaschelly added this to the 8.7.0 milestone Jul 3, 2026

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

Copy link
Copy Markdown
Contributor

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

@jessicaschelly jessicaschelly added the stat: QA assured Means it has been tested and approved by a company insider label Jul 3, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jul 3, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Jul 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 3, 2026
@jessicaschelly jessicaschelly removed the stat: QA assured Means it has been tested and approved by a company insider label Jul 3, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Jul 3, 2026
@jessicaschelly jessicaschelly added the stat: QA assured Means it has been tested and approved by a company insider label Jul 3, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jul 3, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Jul 3, 2026
Merged via the queue into develop with commit 7f39354 Jul 4, 2026
83 of 85 checks passed
@dionisio-bot
dionisio-bot Bot deleted the test/livechat-rooms-delete-api branch July 4, 2026 01:43
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