Skip to content

test: add tests for image upload with rotation and EXIF#39252

Open
jessicaschelly wants to merge 5 commits intodevelopfrom
test/image-rotation
Open

test: add tests for image upload with rotation and EXIF#39252
jessicaschelly wants to merge 5 commits intodevelopfrom
test/image-rotation

Conversation

@jessicaschelly
Copy link
Member

@jessicaschelly jessicaschelly commented Mar 2, 2026

Proposed changes

Add tests for image rotation on file upload to verify the FileUpload_RotateImages setting works correctly.

Test coverage:

  • Uploads image with EXIF orientation 6 (90° CW rotation metadata)
  • Verifies pixels are rotated when setting is enabled (719x479 → 479x719)
  • Verifies EXIF data is stripped
  • Verifies thumbnail maintains correct orientation
  • Verifies pixels are NOT rotated when setting is disabled

Test fixture:

  • Added exif-orientation-6.jpg (18KB) - lightweight test image with EXIF orientation metadata

Issue(s)

CORE-1563
QA-112

Steps to test or reproduce

Further comments

The test uses sharp to verify image metadata before and after upload, ensuring the server correctly handles EXIF orientation data.

Summary by CodeRabbit

  • Tests
    • Added end-to-end tests for image file uploads that validate automatic rotation, EXIF stripping, and thumbnail generation.
    • Covers both rotation-enabled and rotation-disabled scenarios, verifies original and post-upload image dimensions and orientation changes, and confirms thumbnail aspect behavior.
    • Tests manage relevant settings and perform setup/cleanup of test users and rooms.

@jessicaschelly jessicaschelly requested a review from a team as a code owner March 2, 2026 17:31
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Mar 2, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Mar 2, 2026

⚠️ No Changeset found

Latest commit: cdcbb13

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 Mar 2, 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

Walkthrough

Adds a new end-to-end API test that verifies image upload rotation, EXIF stripping, and thumbnail generation using an EXIF-orientation image; toggles related settings, validates image metadata before/after upload, tests both enabled/disabled rotation states, and restores settings / cleans up.

Changes

Cohort / File(s) Summary
Image Rotation E2E Tests
apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts
New E2E test that creates a test user and private room; toggles FileUpload_RotateImages, Message_Attachments_Strip_Exif, and Message_Attachments_Thumbnails_Enabled; verifies original image metadata with sharp; uploads exif-orientation-6.jpg; asserts attachment, file and thumbnail URLs; downloads and inspects original and thumbnail to confirm rotation and EXIF removal; includes negative case (rotation disabled); restores settings and cleans up created entities.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

community

🚥 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 clearly describes the main change: adding tests for image upload with rotation and EXIF handling, which is the primary focus of the changeset.
Linked Issues check ✅ Passed The pull request fully implements test coverage for both CORE-1563 and QA-112 requirements, validating FileUpload_RotateImages enabled/disabled states, EXIF stripping, thumbnail generation, and image dimension changes.
Out of Scope Changes check ✅ Passed All changes are directly related to adding E2E tests for image upload with rotation and EXIF handling as required by the linked issues; no unrelated modifications detected.
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.

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

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 2 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: 1

🧹 Nitpick comments (1)
apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts (1)

92-94: Restore per-test setting changes in a finally block.

This test mutates a global setting and relies on suite teardown to restore it. Restoring inside the test keeps cases more isolated and safer for future test additions.

♻️ Suggested isolation improvement
 it('should NOT rotate pixels when FileUpload_RotateImages is disabled', async () => {
-	await updateSetting('FileUpload_RotateImages', false);
-
-	const requestConfig: IRequestConfig = { request, credentials: userCredentials };
-	const { message } = await uploadFileToRC(testRoom._id, testImagePath, 'no-rotation-test', requestConfig);
-	const uploadMessage = message as IMessage;
-
-	expect(uploadMessage).to.have.property('attachments');
-	const attachment = uploadMessage.attachments?.find((item) => item.title === testImageName);
-	expect(attachment).to.be.an('object');
-
-	const fileUrl = (attachment as { title_link?: string }).title_link;
-	expect(fileUrl).to.be.a('string');
-
-	const originalBuffer = await downloadBuffer(fileUrl as string, userCredentials);
-	const originalMetadata = await sharp(originalBuffer).metadata();
-
-	expect(originalMetadata.width).to.equal(719);
-	expect(originalMetadata.height).to.equal(479);
+	await updateSetting('FileUpload_RotateImages', false);
+	try {
+		const requestConfig: IRequestConfig = { request, credentials: userCredentials };
+		const { message } = await uploadFileToRC(testRoom._id, testImagePath, 'no-rotation-test', requestConfig);
+		const uploadMessage = message as IMessage;
+
+		expect(uploadMessage).to.have.property('attachments');
+		const attachment = uploadMessage.attachments?.find((item) => item.title === testImageName);
+		expect(attachment).to.be.an('object');
+
+		const fileUrl = (attachment as { title_link?: string }).title_link;
+		expect(fileUrl).to.be.a('string');
+
+		const originalBuffer = await downloadBuffer(fileUrl as string, userCredentials);
+		const originalMetadata = await sharp(originalBuffer).metadata();
+
+		expect(originalMetadata.width).to.equal(719);
+		expect(originalMetadata.height).to.equal(479);
+	} finally {
+		await updateSetting('FileUpload_RotateImages', true);
+	}
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts` around lines
92 - 94, Save the current value of the FileUpload_RotateImages setting before
mutating it, perform the test with updateSetting('FileUpload_RotateImages',
false) inside a try block, and then restore the original value in a finally
block using updateSetting(...) so the global setting is always reverted;
reference the test "should NOT rotate pixels when FileUpload_RotateImages is
disabled" and the updateSetting call to locate where to add const original =
await getSetting('FileUpload_RotateImages') (or equivalent) and the try/finally
wrapper.
🤖 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/end-to-end/api/file-upload-image-rotation.ts`:
- Around line 49-56: The after() teardown should be made resilient to partial
failures: replace the Promise.all([...]) with Promise.allSettled([...]) and only
call deleteRoom({ type: 'p', roomId: testRoom._id }) if testRoom is defined and
deleteUser(user) if user is defined; keep the updateSetting(...) calls
unconditional but include them in the settled array so a rejected cleanup does
not short-circuit other teardowns and errors are reported without masking the
original failure.

---

Nitpick comments:
In `@apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts`:
- Around line 92-94: Save the current value of the FileUpload_RotateImages
setting before mutating it, perform the test with
updateSetting('FileUpload_RotateImages', false) inside a try block, and then
restore the original value in a finally block using updateSetting(...) so the
global setting is always reverted; reference the test "should NOT rotate pixels
when FileUpload_RotateImages is disabled" and the updateSetting call to locate
where to add const original = await getSetting('FileUpload_RotateImages') (or
equivalent) and the try/finally wrapper.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7807d0 and 8d10bb5.

⛔ Files ignored due to path filters (1)
  • apps/meteor/tests/mocks/files/exif-orientation-6.jpg is excluded by !**/*.jpg
📒 Files selected for processing (1)
  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.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). (4)
  • GitHub Check: 📦 Build Packages
  • 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/file-upload-image-rotation.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/**/*.spec.ts : All test files must be created in `apps/meteor/tests/e2e/` directory

Applied to files:

  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.ts
📚 Learning: 2026-02-12T15:39:28.416Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 32703
File: apps/meteor/client/lib/chats/flows/uploadFiles.ts:52-58
Timestamp: 2026-02-12T15:39:28.416Z
Learning: In `apps/meteor/client/lib/chats/flows/uploadFiles.ts`, when E2E encryption is required but not allowed (e.g., `E2E_Enable_Encrypt_Files` setting is disabled), the function intentionally abandons the entire upload queue and displays a toast error. This fail-fast behavior prevents partial uploads when encryption requirements cannot be met and is the expected behavior, not a bug.

Applied to files:

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

Applied to files:

  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.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/file-upload-image-rotation.ts
🧬 Code graph analysis (1)
apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts (3)
packages/core-typings/src/ISetting.ts (1)
  • SettingValue (11-20)
apps/meteor/tests/data/file.helper.ts (1)
  • uploadFileToRC (18-58)
packages/core-typings/src/IMessage/MessageAttachment/Files/ImageAttachmentProps.ts (1)
  • ImageAttachmentProps (5-15)
🪛 Biome (2.4.4)
apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts

[error] 35-47: Duplicate before hook found.

(lint/suspicious/noDuplicateTestHooks)

🔇 Additional comments (1)
apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts (1)

59-90: Strong coverage for the rotation + EXIF + thumbnail path.

The assertions validate source metadata, uploaded file transformation, EXIF removal, and thumbnail orientation in one flow. Nice end-to-end coverage.

@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.86%. Comparing base (92a3e47) to head (cdcbb13).
⚠️ Report is 23 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #39252      +/-   ##
===========================================
+ Coverage    70.73%   70.86%   +0.12%     
===========================================
  Files         3195     3207      +12     
  Lines       113108   113353     +245     
  Branches     20460    20549      +89     
===========================================
+ Hits         80009    80324     +315     
+ Misses       31056    30979      -77     
- Partials      2043     2050       +7     
Flag Coverage Δ
unit 71.55% <ø> (+0.18%) ⬆️

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.

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.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts">

<violation number="1" location="apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts:50">
P2: Using Promise.allSettled here hides cleanup failures, which can leave settings/rooms/users in a bad state and cause cross-test contamination. Prefer failing the test when cleanup fails, or explicitly handle failures.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

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.

♻️ Duplicate comments (1)
apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts (1)

49-56: ⚠️ Potential issue | 🟠 Major

Use Promise.allSettled in teardown to prevent cleanup errors from masking root failures.

At Line 50, Promise.all can fail fast when one cleanup promise rejects, which makes teardown less resilient and can hide the primary failure signal. Promise.allSettled is safer for teardown hooks.

💡 Proposed hardening
 after(async () => {
-	await Promise.all([
-		updateSetting('FileUpload_RotateImages', rotateImagesSetting),
-		updateSetting('Message_Attachments_Strip_Exif', stripExifSetting),
-		updateSetting('Message_Attachments_Thumbnails_Enabled', thumbnailsEnabledSetting),
-		testRoom ? deleteRoom({ type: 'p', roomId: testRoom._id }) : Promise.resolve(),
-		user ? deleteUser(user) : Promise.resolve(),
-	]);
+	const cleanup: Promise<unknown>[] = [
+		updateSetting('FileUpload_RotateImages', rotateImagesSetting),
+		updateSetting('Message_Attachments_Strip_Exif', stripExifSetting),
+		updateSetting('Message_Attachments_Thumbnails_Enabled', thumbnailsEnabledSetting),
+	];
+
+	if (testRoom?._id) {
+		cleanup.push(deleteRoom({ type: 'p', roomId: testRoom._id }));
+	}
+	if (user) {
+		cleanup.push(deleteUser(user));
+	}
+
+	await Promise.allSettled(cleanup);
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts` around lines
49 - 56, The teardown currently uses Promise.all which will reject-fast and can
let a single cleanup error mask the original test failure; replace the
Promise.all call in the after hook with Promise.allSettled so updateSetting,
deleteRoom, and deleteUser calls (and the conditional testRoom/user branches
referring to rotateImagesSetting, stripExifSetting, thumbnailsEnabledSetting,
testRoom, and user) all run to completion and you still await their settled
results, optionally logging or ignoring individual rejections rather than
throwing.
🤖 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/end-to-end/api/file-upload-image-rotation.ts`:
- Around line 49-56: The teardown currently uses Promise.all which will
reject-fast and can let a single cleanup error mask the original test failure;
replace the Promise.all call in the after hook with Promise.allSettled so
updateSetting, deleteRoom, and deleteUser calls (and the conditional
testRoom/user branches referring to rotateImagesSetting, stripExifSetting,
thumbnailsEnabledSetting, testRoom, and user) all run to completion and you
still await their settled results, optionally logging or ignoring individual
rejections rather than throwing.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bcabff3 and bff902d.

📒 Files selected for processing (1)
  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.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). (4)
  • GitHub Check: 📦 Build Packages
  • 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/file-upload-image-rotation.ts
🧠 Learnings (17)
📚 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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.ts
📚 Learning: 2026-02-12T15:39:28.416Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 32703
File: apps/meteor/client/lib/chats/flows/uploadFiles.ts:52-58
Timestamp: 2026-02-12T15:39:28.416Z
Learning: In `apps/meteor/client/lib/chats/flows/uploadFiles.ts`, when E2E encryption is required but not allowed (e.g., `E2E_Enable_Encrypt_Files` setting is disabled), the function intentionally abandons the entire upload queue and displays a toast error. This fail-fast behavior prevents partial uploads when encryption requirements cannot be met and is the expected behavior, not a bug.

Applied to files:

  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.ts
📚 Learning: 2026-03-02T16:31:30.612Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 39250
File: apps/meteor/tests/end-to-end/api/livechat/07-queue.ts:1084-1094
Timestamp: 2026-03-02T16:31:30.612Z
Learning: In E2E API tests at apps/meteor/tests/end-to-end/api/livechat/, using sleep(1000) after updateSetting() or updateEESetting() calls in test setup hooks is acceptable and intentional to allow omnichannel settings to propagate their side effects.

Applied to files:

  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.ts
📚 Learning: 2025-12-10T21:00:54.909Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:54.909Z
Learning: Rocket.Chat monorepo: Jest testMatch pattern '<rootDir>/src/**/*.spec.(ts|js|mjs)' is valid in this repo and used across multiple packages (e.g., packages/tools, ee/packages/omnichannel-services). Do not flag it as invalid in future reviews.

Applied to files:

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

Applied to files:

  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.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/file-upload-image-rotation.ts
🪛 Biome (2.4.4)
apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts

[error] 35-47: Duplicate before hook found.

(lint/suspicious/noDuplicateTestHooks)

🔇 Additional comments (1)
apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts (1)

59-111: Good coverage on rotation behavior and metadata expectations.

The assertions around fixture orientation, post-upload dimensions, EXIF stripping, thumbnail orientation, and disabled-rotation behavior are solid and aligned with the PR objective.

@jessicaschelly jessicaschelly added this to the 8.3.0 milestone Mar 4, 2026
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.

♻️ Duplicate comments (1)
apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts (1)

49-56: ⚠️ Potential issue | 🟠 Major

Use non-short-circuit teardown aggregation.

The teardown still uses Promise.all, so a single rejected cleanup promise fails the hook immediately and can mask subsequent cleanup outcomes. Switch to Promise.allSettled here.

Suggested fix
 	after(async () => {
-		await Promise.all([
+		await Promise.allSettled([
 			updateSetting('FileUpload_RotateImages', rotateImagesSetting),
 			updateSetting('Message_Attachments_Strip_Exif', stripExifSetting),
 			updateSetting('Message_Attachments_Thumbnails_Enabled', thumbnailsEnabledSetting),
 			testRoom ? deleteRoom({ type: 'p', roomId: testRoom._id }) : Promise.resolve(),
 			user ? deleteUser(user) : Promise.resolve(),
 		]);
 	});
#!/bin/bash
# Verify teardown uses non-short-circuit cleanup in this test file.
rg -n -C3 'after\(async \(\) =>|Promise\.all\(|Promise\.allSettled\(' apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts` around lines
49 - 56, The teardown uses Promise.all which short-circuits on the first
rejection; change the await Promise.all([...]) call in the after hook to await
Promise.allSettled([...]) so all cleanup actions (the updateSetting calls and
the conditional deleteRoom/deleteUser promises referencing testRoom and user and
functions updateSetting, deleteRoom, deleteUser) run to completion and their
results are collected without throwing on the first failure.
🤖 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/end-to-end/api/file-upload-image-rotation.ts`:
- Around line 49-56: The teardown uses Promise.all which short-circuits on the
first rejection; change the await Promise.all([...]) call in the after hook to
await Promise.allSettled([...]) so all cleanup actions (the updateSetting calls
and the conditional deleteRoom/deleteUser promises referencing testRoom and user
and functions updateSetting, deleteRoom, deleteUser) run to completion and their
results are collected without throwing on the first failure.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 70963c8a-f31d-4eaf-b707-64608506fde2

📥 Commits

Reviewing files that changed from the base of the PR and between bff902d and f632ee0.

📒 Files selected for processing (1)
  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.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). (4)
  • GitHub Check: 📦 Build Packages
  • 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/file-upload-image-rotation.ts
🧠 Learnings (17)
📚 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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.ts
📚 Learning: 2026-02-12T15:39:28.416Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 32703
File: apps/meteor/client/lib/chats/flows/uploadFiles.ts:52-58
Timestamp: 2026-02-12T15:39:28.416Z
Learning: In `apps/meteor/client/lib/chats/flows/uploadFiles.ts`, when E2E encryption is required but not allowed (e.g., `E2E_Enable_Encrypt_Files` setting is disabled), the function intentionally abandons the entire upload queue and displays a toast error. This fail-fast behavior prevents partial uploads when encryption requirements cannot be met and is the expected behavior, not a bug.

Applied to files:

  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.ts
📚 Learning: 2026-03-02T16:31:41.304Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 39250
File: apps/meteor/tests/end-to-end/api/livechat/07-queue.ts:1084-1094
Timestamp: 2026-03-02T16:31:41.304Z
Learning: In E2E API tests at apps/meteor/tests/end-to-end/api/livechat/, using sleep(1000) after updateSetting() or updateEESetting() calls in test setup hooks is acceptable and intentional to allow omnichannel settings to propagate their side effects.

Applied to files:

  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts
📚 Learning: 2025-12-10T21:00:54.909Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:54.909Z
Learning: Rocket.Chat monorepo: Jest testMatch pattern '<rootDir>/src/**/*.spec.(ts|js|mjs)' is valid in this repo and used across multiple packages (e.g., packages/tools, ee/packages/omnichannel-services). Do not flag it as invalid in future reviews.

Applied to files:

  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts
📚 Learning: 2025-11-05T20:53:57.761Z
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 37357
File: apps/meteor/ee/server/startup/federation.ts:39-74
Timestamp: 2025-11-05T20:53:57.761Z
Learning: In Rocket.Chat (apps/meteor/app/settings/server/CachedSettings.ts), the settings.watchMultiple() method immediately invokes its callback with current values if all requested settings exist in the store, then continues watching for subsequent changes. It does not wait for a setting to change before the first invocation.

Applied to files:

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

Applied to files:

  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.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/file-upload-image-rotation.ts
🪛 Biome (2.4.4)
apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts

[error] 35-47: Duplicate before hook found.

(lint/suspicious/noDuplicateTestHooks)

🔇 Additional comments (2)
apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts (2)

59-90: Solid end-to-end validation for rotated upload path.

This test correctly validates fixture EXIF orientation, post-upload physical rotation, EXIF stripping, and thumbnail orientation from the processed file.


92-111: Good negative coverage for rotation-disabled behavior.

The disabled-setting scenario is validated against original dimensions, which cleanly covers the expected non-rotation path.

@jessicaschelly jessicaschelly added the stat: QA assured Means it has been tested and approved by a company insider label Mar 4, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Mar 4, 2026
@dionisio-bot dionisio-bot bot enabled auto-merge March 4, 2026 17:45
@jessicaschelly jessicaschelly removed stat: ready to merge PR tested and approved waiting for merge stat: QA assured Means it has been tested and approved by a company insider labels Mar 4, 2026
const thumbBuffer = await downloadBuffer(thumbUrl as string, userCredentials);
const thumbMetadata = await sharp(thumbBuffer).metadata();

expect(thumbMetadata.width).to.be.lessThan(thumbMetadata.height as number);
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe here is more accurate if we assert that thumbMetadata.width and thumbMetadata.height are a specific number instead of 'height less than width'

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm, yeah, it makes sense.. I kept the orientation-based assertion because the test is more focused on rotation behavior, not thumbnail sizing config
if i assert exact thumbnail dimensions, the test gets tied to Message_Attachments_Thumbnails_Width/Height, so it could fail whenever those settings change even though rotation is still working correctly, but i can change the setting to a specific width/height, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

i'm with you then, ignore my comment. It'd be out of the scope of this task to verify whether the thumbnail sizing or config is correct, but if we don't have any test checking it I'd suggest creating a separate task for it

Copy link
Contributor

Choose a reason for hiding this comment

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

But as I see here: This has to be applied to both the original image being uploaded and the thumbnail generated in the server

Copy link
Member Author

@jessicaschelly jessicaschelly Mar 4, 2026

Choose a reason for hiding this comment

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

agreed! it mentions the orientation should be applied, so we have the assert for the orientation (height less than width = portrait), but not the sizing.. I could add here the size no problem, i was just worried about tying this test with another setting, wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

as you are validating both width and height instead of just orientation above, I thought it could be more accurate to validate in the same way the thumbnail (perhaps adding Message_Attachments_Thumbnails_Width settings on the before), not 100% sure maybe someone can help us with a 3rd pov 👀

@nazabucciarelli nazabucciarelli self-requested a review March 4, 2026 20:33
@jessicaschelly jessicaschelly requested a review from KevLehman March 5, 2026 14:22
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.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts">

<violation number="1" location="apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts:54">
P2: Teardown cleanup is now unsafe: unconditional `deleteRoom`/`deleteUser` can throw when setup fails before `user`/`testRoom` are initialized, making failures flaky and harder to diagnose.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

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.

♻️ Duplicate comments (1)
apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts (1)

49-56: ⚠️ Potential issue | 🟠 Major

Harden teardown to avoid masking the original failure.

On Line 50, Promise.all short-circuits on first rejection, and direct dereference on Line 54 (testRoom._id) can throw if setup partially failed. This can hide the real test failure cause.

Suggested hardening
 	after(async () => {
-		await Promise.all([
-			updateSetting('FileUpload_RotateImages', rotateImagesSetting),
-			updateSetting('Message_Attachments_Strip_Exif', stripExifSetting),
-			updateSetting('Message_Attachments_Thumbnails_Enabled', thumbnailsEnabledSetting),
-			deleteRoom({ type: 'p', roomId: testRoom._id }),
-			deleteUser(user),
-		]);
+		const cleanup: Promise<unknown>[] = [
+			updateSetting('FileUpload_RotateImages', rotateImagesSetting),
+			updateSetting('Message_Attachments_Strip_Exif', stripExifSetting),
+			updateSetting('Message_Attachments_Thumbnails_Enabled', thumbnailsEnabledSetting),
+		];
+
+		if (testRoom?._id) {
+			cleanup.push(deleteRoom({ type: 'p', roomId: testRoom._id }));
+		}
+		if (user) {
+			cleanup.push(deleteUser(user));
+		}
+
+		await Promise.allSettled(cleanup);
 	});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts` around lines
49 - 56, The teardown uses Promise.all which short-circuits on the first
rejection and directly dereferences testRoom._id, risking masking the original
test failure; change the after hook to use Promise.allSettled so all cleanup
tasks run even if one fails, and guard the room id dereference (e.g., use
optional chaining or a conditional) when calling deleteRoom to avoid thrown
errors if setup failed; ensure the cleanup calls referenced (updateSetting,
deleteRoom, deleteUser) remain included so every task is attempted and
handle/report individual failures instead of letting one rejection abort the
rest.
🤖 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/end-to-end/api/file-upload-image-rotation.ts`:
- Around line 49-56: The teardown uses Promise.all which short-circuits on the
first rejection and directly dereferences testRoom._id, risking masking the
original test failure; change the after hook to use Promise.allSettled so all
cleanup tasks run even if one fails, and guard the room id dereference (e.g.,
use optional chaining or a conditional) when calling deleteRoom to avoid thrown
errors if setup failed; ensure the cleanup calls referenced (updateSetting,
deleteRoom, deleteUser) remain included so every task is attempted and
handle/report individual failures instead of letting one rejection abort the
rest.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5db26f79-f93d-496c-b9ab-a06e25c40a7e

📥 Commits

Reviewing files that changed from the base of the PR and between f632ee0 and cdcbb13.

📒 Files selected for processing (1)
  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.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). (4)
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: 📦 Meteor Build (coverage)
🧰 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/file-upload-image-rotation.ts
🧠 Learnings (19)
📚 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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.ts
📚 Learning: 2026-02-12T15:39:28.416Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 32703
File: apps/meteor/client/lib/chats/flows/uploadFiles.ts:52-58
Timestamp: 2026-02-12T15:39:28.416Z
Learning: In `apps/meteor/client/lib/chats/flows/uploadFiles.ts`, when E2E encryption is required but not allowed (e.g., `E2E_Enable_Encrypt_Files` setting is disabled), the function intentionally abandons the entire upload queue and displays a toast error. This fail-fast behavior prevents partial uploads when encryption requirements cannot be met and is the expected behavior, not a bug.

Applied to files:

  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.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/end-to-end/api/file-upload-image-rotation.ts
📚 Learning: 2026-03-02T16:31:41.304Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 39250
File: apps/meteor/tests/end-to-end/api/livechat/07-queue.ts:1084-1094
Timestamp: 2026-03-02T16:31:41.304Z
Learning: In E2E API tests at apps/meteor/tests/end-to-end/api/livechat/, using sleep(1000) after updateSetting() or updateEESetting() calls in test setup hooks is acceptable and intentional to allow omnichannel settings to propagate their side effects.

Applied to files:

  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts
📚 Learning: 2025-12-10T21:00:54.909Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:54.909Z
Learning: Rocket.Chat monorepo: Jest testMatch pattern '<rootDir>/src/**/*.spec.(ts|js|mjs)' is valid in this repo and used across multiple packages (e.g., packages/tools, ee/packages/omnichannel-services). Do not flag it as invalid in future reviews.

Applied to files:

  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts
📚 Learning: 2025-11-05T20:53:57.761Z
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 37357
File: apps/meteor/ee/server/startup/federation.ts:39-74
Timestamp: 2025-11-05T20:53:57.761Z
Learning: In Rocket.Chat (apps/meteor/app/settings/server/CachedSettings.ts), the settings.watchMultiple() method immediately invokes its callback with current values if all requested settings exist in the store, then continues watching for subsequent changes. It does not wait for a setting to change before the first invocation.

Applied to files:

  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts
📚 Learning: 2025-09-30T13:00:05.465Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 36990
File: apps/meteor/ee/server/apps/storage/AppRealStorage.ts:55-58
Timestamp: 2025-09-30T13:00:05.465Z
Learning: In AppRealStorage (apps/meteor/ee/server/apps/storage/AppRealStorage.ts), the `remove` method is designed to be idempotent and returns `{ success: true }` unconditionally because the goal is to ensure the app is removed, not to distinguish whether this specific call performed the deletion. Database errors will throw exceptions.

Applied to files:

  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: UserBridge.doGetUserRoomIds in packages/apps-engine/src/server/bridges/UserBridge.ts has a bug where it implicitly returns undefined when the app lacks read permission (missing return statement in the else case of the permission check).

Applied to files:

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

Applied to files:

  • apps/meteor/tests/end-to-end/api/file-upload-image-rotation.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/file-upload-image-rotation.ts
🪛 Biome (2.4.4)
apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts

[error] 35-47: Duplicate before hook found.

(lint/suspicious/noDuplicateTestHooks)

🔇 Additional comments (1)
apps/meteor/tests/end-to-end/api/file-upload-image-rotation.ts (1)

59-84: Coverage and assertions look solid for rotation/EXIF scenarios.

These tests validate the intended behavior end-to-end: input EXIF orientation, rotated pixel dimensions when enabled, EXIF stripping, thumbnail orientation consistency, and no pixel rotation when disabled.

Also applies to: 86-104, 115-131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants